Paste: Record-Record-cast

Author: bender
Mode: java
Date: Sat, 11 Sep 2010 16:46:30
Plain Text |
				client.model.parser.dom.Record rec = (client.model.parser.dom.Record) e;
				Map<String,List<CommonValue>> map = new HashMap<String,List<CommonValue>>();
				for(String key: rec){
					List<CommonValue> newVal= new LinkedList<CommonValue>();
					Value val = rec.get(key);
					//TODO  Multiple Values
					if(val instanceof BibTeXString){
						BibTeXString bib = (BibTeXString) val;
						newVal.clear();
						newVal.add(new common.data.StringValue(bib.toString()));
						map.put(key, newVal);
					}
					else if(val instanceof MultipleValues){
						MultipleValues mult = (MultipleValues) val;
						newVal.clear();
						for(Value multVal:mult){
							if(multVal instanceof BibTeXString){
								newVal.add(new common.data.StringValue(((BibTeXString) multVal).toString()));
							
							}
						}
						map.put(key, newVal);
					}
		

Annotation: nachmal record kram

Author: bender
Mode: java
Date: Sat, 11 Sep 2010 16:49:20
Plain Text |
				
		for(Entry e: file){
			if(e instanceof client.model.parser.dom.Record){
				client.model.parser.dom.Record rec = (client.model.parser.dom.Record) e;
				Map<String,List<CommonValue>> map = new HashMap<String,List<CommonValue>>();
				for(String key: rec){
					List<CommonValue> newVal= new LinkedList<CommonValue>();
					Value val = rec.get(key);
					//TODO  Multiple Values
					if(val instanceof BibTeXString){
						BibTeXString bib = (BibTeXString) val;
						newVal.clear();
						newVal.add(new common.data.StringValue(bib.toString()));
						map.put(key, newVal);
					}
					else if(val instanceof MultipleValues){
						MultipleValues mult = (MultipleValues) val;
						newVal.clear();
						for(Value multVal:mult){
							if(multVal instanceof BibTeXString){
								newVal.add(new common.data.StringValue(((BibTeXString) multVal).toString()));
							
							}
						}
						map.put(key, newVal);
					}
					else{
						
					}
				}
//				CommonRecord newRec = new CommonRecord(rec.getType(),null,map);
				CommonRecord newRec = new CommonRecord(rec.getType(), "key", map);
//				setRec.add(newRec);
				recList.add(newRec);
			}
			
		}

Annotation: readable

Author: Crest
Mode: java
Date: Sat, 11 Sep 2010 17:07:04
Plain Text |
	public static CommonValue convert(client.model.parser.dom.Value value) {
		if (value instanceof client.model.parser.dom.BibTeXString) {
			client.model.parser.dom.BibTeXString stringValue = (client.model.parser.dom.BibTeXString) value;
			
			if ( stringValue.isInteger() ) {
				return new IntegerValue(Long.parseLong(stringValue.getContent()));
			} else {
				return new StringValue(stringValue.getContent());
			}
		} else {
			return null;
		}
	}
	
	public static CommonRecord convert(client.model.parser.dom.Record record) {
		CommonRecord result = new CommonRecord(record.getType(), record.getKey());
		
		for ( String name : record ) {
			client.model.parser.dom.Value value = record.get(name);
			if ( value instanceof client.model.parser.dom.MultipleValues ) {
				client.model.parser.dom.MultipleValues multiValue = (client.model.parser.dom.MultipleValues) value;
				for ( client.model.parser.dom.Value singleValue : multiValue ) {
					CommonValue converted = convert(singleValue);
					if ( converted == null ) continue;
					result.add(name, converted);
				}
			} else {
				CommonValue converted = convert(value);
				if ( converted == null ) continue;
				result.add(name, converted);
			}
			
		}
		
		return result;
	}

Annotation: removeSpace

Author: bender
Mode: java
Date: Sat, 11 Sep 2010 19:07:24
Plain Text |
	public String removeSpace(String oldString){
		String newString = oldString.replaceAll("  ", " ");
		while(!oldString.equals(newString)){
			oldString = newString;
			newString = newString.replaceAll("  ", " ");
		}
		return newString;
	}

New Annotation

Summary:
Author:
Mode:
Body: