Revision 28543 branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteClient/wfs/schema/XMLSchemaParser.java

View differences:

XMLSchemaParser.java
3 3
import java.io.File;
4 4
import java.io.FileReader;
5 5
import java.io.IOException;
6
import java.util.Hashtable;
7
import java.util.Iterator;
8
import java.util.Set;
9
import java.util.Vector;
10 6

  
11 7
import org.gvsig.remoteClient.utils.CapabilitiesTags;
12 8
import org.gvsig.remoteClient.utils.EncodingXMLParser;
......
99 95
	private String schema = "";
100 96
	private String encoding = "UTF-8";	
101 97
	private String nameSpace = "";
102
	private Hashtable attributes = null;
103 98
	private String version = null;
104 99
	
105 100
	
106 101
	public XMLSchemaParser(){
107
		super();
108
		//initializes a new hash table for many namespace to store the defined types
109
		attributes = new Hashtable();
102
		super();		
110 103
	}
111 104
	
112 105
	public XMLSchemaParser(String schema){
113 106
		super();
114 107
		//schema instace is named with the string in "schema"
115
		this.schema = schema;
116
		attributes = new Hashtable();
108
		this.schema = schema;		
117 109
	}
118 110
	
119 111
	/**
......
304 296
							if (getAttributeName(i).compareTo(GMLTags.GML_NAME) == 0){
305 297
								// inserts a new complex type inside the namespace
306 298
								XMLComplexType complexType = XMLTypesFactory.addComplexType(nameSpace,getAttributeValue(i));
307
				    			parseComplexType(complexType);	
308
				    			attributes.put(complexType.getName(),complexType);
299
				    			parseComplexType(complexType);					    			
309 300
				    		}
310 301
				    		
311 302
						}
......
321 312
					 * Etiqueta <element>	*
322 313
					 ************************/
323 314
					else if (getName().compareTo(CapabilitiesTags.ELEMENT)==0){							
324
						XMLElement entity = XMLElementsFactory.addType(this);
325
						try{
326
							//Sets the name and type of one element
327
							attributes.put(entity.getName(),entity.getEntityType());
328
						}catch(NullPointerException e){
329
							//Type not defined yet, do nothing here because the type will be declared later
330
						}
315
						XMLElement entity = XMLElementsFactory.addType(this);						
331 316
					}
332 317
					break;
333 318
					case KXmlParser.END_TAG:                            
......
500 485
			String attName = getAttributeName(i);
501 486
			String attValue = getAttributeValue(i);
502 487
			if (CapabilitiesTags.BASE.equals(attName)){
503
				attributes.put(complexType.getName(),attValue);
488
				complexType.setBaseType(attValue);				
504 489
			}
505 490
		}
506 491
		
......
581 566
				if (getName().compareTo(CapabilitiesTags.ELEMENT)==0){
582 567
					XMLElement element = new XMLElement(this);
583 568
					if (element != null){
584
						complexType.addSubtypes(element);
569
						complexType.addElements(element);
585 570
					}
586 571
					elemento_previo=element;
587 572
				}
......
634 619
				if (getName().compareTo(CapabilitiesTags.ELEMENT)==0){
635 620
					XMLElement element = new XMLElement(this);
636 621
					if (element != null){
637
						complexType.addSubtypes(element);
622
						complexType.addElements(element);
638 623
					}					
639 624
				}				
640 625
				break;
......
651 636
		}		
652 637
	}
653 638

  
654
	/**
655
	 * @return Returns the attributes.
656
	 */
657
	public Hashtable getAttributes() {
658
		return attributes;
659
	}
660
	
661
	public Vector getAttributesList(){
662
		Vector vector = new Vector();
663
		Set keys = attributes.keySet();
664
		Iterator it = keys.iterator();
665
		while(it.hasNext()){
666
			vector.add(attributes.get((String)it.next()));
667
		}
668
		return vector;
669
	}
670

  
671 639
	public String getversion() {
672 640
		if (version == null){
673 641
			//return the default GML version

Also available in: Unified diff