1 57 package com.sun.org.apache.xerces.internal.util; 58 59 import java.util.Hashtable ; 60 61 import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; 62 import org.w3c.dom.TypeInfo ; 63 64 73 public class TypeInfoImpl implements TypeInfo { 74 75 private final String typeNamespace; 76 private final String typeName; 77 private final static String dtdNamespaceURI = "http://www.w3.org/TR/REC-xml"; 78 public TypeInfoImpl(){ 79 typeNamespace = null; 80 typeName = null; 81 } 82 public TypeInfoImpl(String typeNamespace, String typeName) { 83 this.typeNamespace = typeNamespace; 84 this.typeName = typeName; 85 } 86 87 public TypeInfoImpl(XSTypeDefinition t) { 88 this( t.getNamespace(), t.getName() ); 89 } 90 91 public String getTypeName() { 92 return typeName; 93 } 94 95 public String getTypeNamespace() { 96 return typeNamespace; 97 } 98 99 102 public boolean isDerivedFrom(String typeNamespaceArg, String typeNameArg, int derivationMethod) { 103 return false; 104 } 105 106 109 private static final Hashtable dtdCache = new Hashtable (); 110 111 117 public static TypeInfo getDTDTypeInfo( String name ) { 118 TypeInfo t = (TypeInfo )dtdCache.get(name); 119 if(t==null) throw new IllegalArgumentException ("Unknown DTD datatype "+name); 120 return t; 121 } 122 123 static { 124 String [] typeNames = new String []{ 125 "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", 126 "ENTITY", "ENTITIES", "NOTATION"}; 127 for( int i=0; i<typeNames.length; i++ ) 128 dtdCache.put(typeNames[i],new TypeInfoImpl(dtdNamespaceURI,typeNames[i])); 129 } 130 } 131 | Popular Tags |