From b1193b90511a77cdb007bcbeb520c01ecdcb17e5 Mon Sep 17 00:00:00 2001 From: Willem Cazander Date: Sat, 24 Aug 2013 18:35:53 +0200 Subject: [PATCH] Renamed ElementNamespaceContext to ElementNamespace. --- .../org/x4o/xml/eld/EldModuleLoaderCore.java | 24 ++++----- .../eld/lang/ElementModuleBindingHandler.java | 48 ++++++++--------- ...va => ElementNamespaceBindingHandler.java} | 12 ++--- .../x4o/xml/eld/xsd/EldXsdXmlGenerator.java | 10 ++-- .../org/x4o/xml/eld/xsd/EldXsdXmlWriter.java | 22 ++++---- ...ext.java => AbstractElementNamespace.java} | 17 +++--- ...text.java => DefaultElementNamespace.java} | 4 +- ...faultElementNamespaceInstanceProvider.java | 16 +++--- ...paceContext.java => ElementNamespace.java} | 4 +- .../ElementNamespaceInstanceProvider.java | 4 +- .../java/org/x4o/xml/io/DefaultX4OWriter.java | 8 +-- .../org/x4o/xml/io/sax/X4OContentHandler.java | 10 ++-- .../org/x4o/xml/io/sax/X4ODebugWriter.java | 12 ++--- .../org/x4o/xml/io/sax/X4OEntityResolver.java | 4 +- .../AbstractX4OLanguageConfiguration.java | 52 +++++++------------ .../xml/lang/AbstractX4OLanguageModule.java | 34 ++++++------ .../org/x4o/xml/lang/DefaultX4OLanguage.java | 12 ++--- .../lang/DefaultX4OLanguageConfiguration.java | 4 +- .../java/org/x4o/xml/lang/X4OLanguage.java | 6 +-- .../xml/lang/X4OLanguageConfiguration.java | 2 +- .../lang/X4OLanguageConfigurationLocal.java | 2 +- .../org/x4o/xml/lang/X4OLanguageModule.java | 12 ++--- .../xml/lang/phase/X4OPhaseLanguageRead.java | 6 +-- .../xml/lang/phase/X4OPhaseLanguageWrite.java | 6 +-- .../main/resources/META-INF/eld/eld-lang.eld | 4 +- .../java/org/x4o/xml/core/EmptyXmlTest.java | 2 +- .../java/org/x4o/xml/eld/EldParserTest.java | 2 +- .../test/resources/META-INF/x4o-drivers.xml | 2 +- .../org/x4o/xml/eld/doc/EldDocWriter.java | 10 ++-- .../xml/eld/doc/EldDocWriterElementClass.java | 6 +-- .../eld/doc/EldDocWriterElementNamespace.java | 10 ++-- .../x4o/xml/eld/doc/EldDocWriterLanguage.java | 6 +-- .../eld/doc/EldDocWriterLanguageModule.java | 6 +-- .../xml/eld/doc/EldDocXTreePageWriter.java | 14 ++--- 34 files changed, 189 insertions(+), 204 deletions(-) rename x4o-driver/src/main/java/org/x4o/xml/eld/lang/{ElementNamespaceContextBindingHandler.java => ElementNamespaceBindingHandler.java} (85%) rename x4o-driver/src/main/java/org/x4o/xml/element/{AbstractElementNamespaceContext.java => AbstractElementNamespace.java} (87%) rename x4o-driver/src/main/java/org/x4o/xml/element/{DefaultElementNamespaceContext.java => DefaultElementNamespace.java} (90%) rename x4o-driver/src/main/java/org/x4o/xml/element/{ElementNamespaceContext.java => ElementNamespace.java} (96%) diff --git a/x4o-driver/src/main/java/org/x4o/xml/eld/EldModuleLoaderCore.java b/x4o-driver/src/main/java/org/x4o/xml/eld/EldModuleLoaderCore.java index 1ef57e2..11512e7 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/eld/EldModuleLoaderCore.java +++ b/x4o-driver/src/main/java/org/x4o/xml/eld/EldModuleLoaderCore.java @@ -35,13 +35,13 @@ import org.x4o.xml.eld.lang.ElementClassAttributeBindingHandler; import org.x4o.xml.eld.lang.ElementClassBindingHandler; import org.x4o.xml.eld.lang.ElementInterfaceBindingHandler; import org.x4o.xml.eld.lang.ElementModuleBindingHandler; -import org.x4o.xml.eld.lang.ElementNamespaceContextBindingHandler; +import org.x4o.xml.eld.lang.ElementNamespaceBindingHandler; import org.x4o.xml.eld.lang.ModuleElement; import org.x4o.xml.element.ElementBindingHandler; import org.x4o.xml.element.ElementClass; import org.x4o.xml.element.ElementClassAttribute; -import org.x4o.xml.element.ElementNamespaceContext; +import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.element.ElementNamespaceInstanceProvider; import org.x4o.xml.element.ElementNamespaceInstanceProviderException; @@ -96,15 +96,15 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader { addBindingHandler(languageModule,new ElementModuleBindingHandler(),"cel-module-bind","Binds the LanguageModule childeren."); addBindingHandler(languageModule,new ElementClassAttributeBindingHandler(),"cel-class-attr-bind","Binds the ElementClassAttribute childeren."); addBindingHandler(languageModule,new ElementInterfaceBindingHandler(),"cel-interface-bind","Binds the ElementInterface childeren."); - addBindingHandler(languageModule,new ElementNamespaceContextBindingHandler(),"cel-namespace-bind","Binds the Namespace childeren."); + addBindingHandler(languageModule,new ElementNamespaceBindingHandler(),"cel-namespace-bind","Binds the Namespace childeren."); // Create cel-lang namespace in language - ElementNamespaceContext namespace = createNamespaceContext(language,CEL_CORE,CEL_CORE_URI,CEL_CORE_XSD_URI,CEL_CORE_XSD_FILE,CEL_CORE); + ElementNamespace namespace = createNamespaceContext(language,CEL_CORE,CEL_CORE_URI,CEL_CORE_XSD_URI,CEL_CORE_XSD_FILE,CEL_CORE); configElementClasses(language,namespace); startAndAddNamespace(language,languageModule,namespace); // Create cel-root namespace in language for schema support - ElementNamespaceContext namespaceRoot = createNamespaceContext(language,CEL_ROOT,CEL_ROOT_URI,CEL_ROOT_XSD_URI,CEL_ROOT_XSD_FILE,CEL_ROOT); + ElementNamespace namespaceRoot = createNamespaceContext(language,CEL_ROOT,CEL_ROOT_URI,CEL_ROOT_XSD_URI,CEL_ROOT_XSD_FILE,CEL_ROOT); namespaceRoot.setLanguageRoot(true); // Only define single language root so xsd is (mostly) not cicle import. ElementClass rootElement = createElementClass(language,"module",language.getLanguageConfiguration().getDefaultElementLanguageModule(),ModuleElement.class,"The module tag is the root xml element for ELD language."); rootElement.addElementClassAttribute(createElementClassAttribute(language,"id",true,null)); @@ -119,7 +119,7 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader { * @param language The language to config for. * @throws X4OLanguageModuleLoaderException */ - private void configElementClasses(X4OLanguage language,ElementNamespaceContext namespace) throws X4OLanguageModuleLoaderException { + private void configElementClasses(X4OLanguage language,ElementNamespace namespace) throws X4OLanguageModuleLoaderException { ElementClass ec = null; namespace.addElementClass(createElementClass(language,"attribute",language.getLanguageConfiguration().getDefaultElementClassAttribute(),null,"Defines xml element attribute.")); @@ -131,7 +131,7 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader { namespace.addElementClass(createElementClass(language,"classConverter",ClassConverter.class,null,"Converts string attribute to java class instance.")); - ec = createElementClass(language,"namespace",language.getLanguageConfiguration().getDefaultElementNamespaceContext(),null,"Defines an xml namespace."); + ec = createElementClass(language,"namespace",language.getLanguageConfiguration().getDefaultElementNamespace(),null,"Defines an xml namespace."); ec.addElementClassAttribute(createElementClassAttribute(language,"uri",true,null)); namespace.addElementClass(ec); @@ -197,20 +197,20 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader { languageModule.setSourceResource(this.getClass().getSimpleName()); //TODO: check if oke. } - private void startAndAddNamespace(X4OLanguageLocal language,X4OLanguageModule languageModule,ElementNamespaceContext namespace) throws X4OLanguageModuleLoaderException { + private void startAndAddNamespace(X4OLanguageLocal language,X4OLanguageModule languageModule,ElementNamespace namespace) throws X4OLanguageModuleLoaderException { try { namespace.getElementNamespaceInstanceProvider().start(language, namespace); } catch (ElementNamespaceInstanceProviderException e) { throw new X4OLanguageModuleLoaderException(this,"Error starting instance provider: "+e.getMessage(),e); } - languageModule.addElementNamespaceContext(namespace); + languageModule.addElementNamespace(namespace); } - private ElementNamespaceContext createNamespaceContext(X4OLanguageLocal language,String id,String uri,String schemaUri,String schemaResource,String schemaPrefix) throws X4OLanguageModuleLoaderException { + private ElementNamespace createNamespaceContext(X4OLanguageLocal language,String id,String uri,String schemaUri,String schemaResource,String schemaPrefix) throws X4OLanguageModuleLoaderException { logger.finer("Creating "+language.getLanguageName()+" namespace."); - ElementNamespaceContext namespace; + ElementNamespace namespace; try { - namespace = (ElementNamespaceContext)X4OLanguageClassLoader.newInstance(language.getLanguageConfiguration().getDefaultElementNamespaceContext()); + namespace = (ElementNamespace)X4OLanguageClassLoader.newInstance(language.getLanguageConfiguration().getDefaultElementNamespace()); } catch (InstantiationException e) { throw new X4OLanguageModuleLoaderException(this,e.getMessage(),e); } catch (IllegalAccessException e) { diff --git a/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementModuleBindingHandler.java b/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementModuleBindingHandler.java index 67a37c2..d7b840e 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementModuleBindingHandler.java +++ b/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementModuleBindingHandler.java @@ -30,7 +30,7 @@ import org.x4o.xml.element.ElementBindingHandler; import org.x4o.xml.element.ElementBindingHandlerException; import org.x4o.xml.element.ElementConfiguratorGlobal; import org.x4o.xml.element.ElementInterface; -import org.x4o.xml.element.ElementNamespaceContext; +import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.element.ElementNamespaceInstanceProvider; import org.x4o.xml.element.ElementNamespaceInstanceProviderException; import org.x4o.xml.lang.X4OLanguageModule; @@ -49,7 +49,7 @@ public class ElementModuleBindingHandler extends AbstractElementBindingHandler< private final static Class[] CLASSES_CHILD = new Class[] { ElementInterface.class, - ElementNamespaceContext.class, + ElementNamespace.class, ElementBindingHandler.class, ElementAttributeHandler.class, ElementConfiguratorGlobal.class, @@ -88,62 +88,62 @@ public class ElementModuleBindingHandler extends AbstractElementBindingHandler< languageModule.addElementInterface(elementInterface); return; } - if (childObject instanceof ElementNamespaceContext) { - ElementNamespaceContext elementNamespaceContext = (ElementNamespaceContext)childObject; + if (childObject instanceof ElementNamespace) { + ElementNamespace elementNamespace = (ElementNamespace)childObject; - if (elementNamespaceContext.getId()==null) { - throw new NullPointerException("Can add ElementNamespaceContext without id."); + if (elementNamespace.getId()==null) { + throw new NullPointerException("Can add elementNamespace without id."); } // TODO: no language here so move to EL default on eld attribute tag - if (elementNamespaceContext.getId()!=null) { + if (elementNamespace.getId()!=null) { StringBuffer buf = new StringBuffer(30); - for (char c:elementNamespaceContext.getId().toLowerCase().toCharArray()) { + for (char c:elementNamespace.getId().toLowerCase().toCharArray()) { if (Character.isLetter(c)) {buf.append(c);} if (Character.isDigit(c)) {buf.append(c);} if ('-'==c) {buf.append(c);} } String id = buf.toString(); - elementNamespaceContext.setId(id); + elementNamespace.setId(id); } - if (elementNamespaceContext.getUri()==null) { - elementNamespaceContext.setUri( + if (elementNamespace.getUri()==null) { + elementNamespace.setUri( "http://"+languageModule.getProviderHost()+ "/xml/ns/"+x4oParsingContext.getLanguageName()+ - "-"+elementNamespaceContext.getId()); + "-"+elementNamespace.getId()); } - if (elementNamespaceContext.getSchemaUri()==null) { - elementNamespaceContext.setSchemaUri( + if (elementNamespace.getSchemaUri()==null) { + elementNamespace.setSchemaUri( "http://"+languageModule.getProviderHost()+ "/xml/ns/"+x4oParsingContext.getLanguageName()+ - "-"+elementNamespaceContext.getId()+ + "-"+elementNamespace.getId()+ "-"+x4oParsingContext.getLanguageVersion()+ ".xsd" ); } - if (elementNamespaceContext.getSchemaResource()==null) { - elementNamespaceContext.setSchemaResource( + if (elementNamespace.getSchemaResource()==null) { + elementNamespace.setSchemaResource( x4oParsingContext.getLanguageName()+ - "-"+elementNamespaceContext.getId()+ + "-"+elementNamespace.getId()+ "-"+x4oParsingContext.getLanguageVersion()+ ".xsd" ); } - if (elementNamespaceContext.getSchemaPrefix()==null) { - elementNamespaceContext.setSchemaPrefix(elementNamespaceContext.getId()); + if (elementNamespace.getSchemaPrefix()==null) { + elementNamespace.setSchemaPrefix(elementNamespace.getId()); } try { - elementNamespaceContext.setElementNamespaceInstanceProvider((ElementNamespaceInstanceProvider)X4OLanguageClassLoader.newInstance(childElement.getLanguageContext().getLanguage().getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider())); + elementNamespace.setElementNamespaceInstanceProvider((ElementNamespaceInstanceProvider)X4OLanguageClassLoader.newInstance(childElement.getLanguageContext().getLanguage().getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider())); } catch (Exception e) { throw new ElementBindingHandlerException("Error loading: "+e.getMessage(),e); } try { - elementNamespaceContext.getElementNamespaceInstanceProvider().start(x4oParsingContext, elementNamespaceContext); + elementNamespace.getElementNamespaceInstanceProvider().start(x4oParsingContext, elementNamespace); } catch (ElementNamespaceInstanceProviderException e) { throw new ElementBindingHandlerException("Error starting: "+e.getMessage(),e); } - languageModule.addElementNamespaceContext(elementNamespaceContext); + languageModule.addElementNamespace(elementNamespace); return; } if (childObject instanceof ElementBindingHandler) { @@ -170,7 +170,7 @@ public class ElementModuleBindingHandler extends AbstractElementBindingHandler< for (ElementInterface child:parent.getElementInterfaces()) { createChild(parentElement, child); } - for (ElementNamespaceContext child:parent.getElementNamespaceContexts()) { + for (ElementNamespace child:parent.getElementNamespaces()) { createChild(parentElement, child); } for (ElementBindingHandler child:parent.getElementBindingHandlers()) { diff --git a/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementNamespaceContextBindingHandler.java b/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementNamespaceBindingHandler.java similarity index 85% rename from x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementNamespaceContextBindingHandler.java rename to x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementNamespaceBindingHandler.java index 8709ee8..7015c31 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementNamespaceContextBindingHandler.java +++ b/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementNamespaceBindingHandler.java @@ -26,15 +26,15 @@ import org.x4o.xml.element.AbstractElementBindingHandler; import org.x4o.xml.element.Element; import org.x4o.xml.element.ElementBindingHandlerException; import org.x4o.xml.element.ElementClass; -import org.x4o.xml.element.ElementNamespaceContext; +import org.x4o.xml.element.ElementNamespace; /** - * ElementNamespaceContextBindingHandler binds ElementClass into namespace. + * ElementNamespaceBindingHandler binds ElementClass into namespace. * * @author Willem Cazander * @version 1.0 Aug 21, 2012 */ -public class ElementNamespaceContextBindingHandler extends AbstractElementBindingHandler { +public class ElementNamespaceBindingHandler extends AbstractElementBindingHandler { private final static Class[] CLASSES_CHILD = new Class[] { ElementClass.class @@ -44,7 +44,7 @@ public class ElementNamespaceContextBindingHandler extends AbstractElementBindin * @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass() */ public Class getBindParentClass() { - return ElementNamespaceContext.class; + return ElementNamespace.class; } /** @@ -57,7 +57,7 @@ public class ElementNamespaceContextBindingHandler extends AbstractElementBindin /** * @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object) */ - public void bindChild(Element childElement,ElementNamespaceContext parent, Object childObject) throws ElementBindingHandlerException { + public void bindChild(Element childElement,ElementNamespace parent, Object childObject) throws ElementBindingHandlerException { if (childObject instanceof ElementClass) { ElementClass elementClass = (ElementClass)childObject; if (elementClass.getId()==null && elementClass.getObjectClass()!=null) { @@ -70,7 +70,7 @@ public class ElementNamespaceContextBindingHandler extends AbstractElementBindin /** * @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object) */ - public void createChilderen(Element parentElement,ElementNamespaceContext parent) throws ElementBindingHandlerException { + public void createChilderen(Element parentElement,ElementNamespace parent) throws ElementBindingHandlerException { for (ElementClass child:parent.getElementClasses()) { createChild(parentElement, child); } diff --git a/x4o-driver/src/main/java/org/x4o/xml/eld/xsd/EldXsdXmlGenerator.java b/x4o-driver/src/main/java/org/x4o/xml/eld/xsd/EldXsdXmlGenerator.java index 7d13e45..efe68df 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/eld/xsd/EldXsdXmlGenerator.java +++ b/x4o-driver/src/main/java/org/x4o/xml/eld/xsd/EldXsdXmlGenerator.java @@ -29,7 +29,7 @@ import java.io.Writer; import org.x4o.xml.element.ElementClass; import org.x4o.xml.element.ElementException; -import org.x4o.xml.element.ElementNamespaceContext; +import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.io.DefaultX4OSchemaWriter; import org.x4o.xml.io.sax.ext.ContentWriterXml; import org.x4o.xml.io.sax.ext.ContentWriterXsd; @@ -54,7 +54,7 @@ public class EldXsdXmlGenerator { this.propertyConfig=propertyConfig; } - private void checkNamespace(ElementNamespaceContext ns) { + private void checkNamespace(ElementNamespace ns) { if (ns.getSchemaResource()==null) { throw new NullPointerException("Can't generate xsd for namespace without schemaResource uri: "+ns.getUri()); } @@ -73,7 +73,7 @@ public class EldXsdXmlGenerator { if (namespace!=null) { - ElementNamespaceContext ns = language.findElementNamespaceContext(namespace); + ElementNamespace ns = language.findElementNamespace(namespace); if (ns==null) { throw new NullPointerException("Could not find namespace: "+namespace); } @@ -90,7 +90,7 @@ public class EldXsdXmlGenerator { return; } for (X4OLanguageModule mod:language.getLanguageModules()) { - for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) { + for (ElementNamespace ns:mod.getElementNamespaces()) { checkNamespace(ns); File outputFile = new File(basePath.getAbsolutePath()+File.separatorChar+ns.getSchemaResource()); Writer wr = new OutputStreamWriter(new FileOutputStream(outputFile), encoding); @@ -111,7 +111,7 @@ public class EldXsdXmlGenerator { public void generateSchema(String namespaceUri,ContentWriterXsd xmlWriter) throws SAXException { - ElementNamespaceContext ns = language.findElementNamespaceContext(namespaceUri); + ElementNamespace ns = language.findElementNamespace(namespaceUri); if (ns==null) { throw new NullPointerException("Could not find namespace: "+namespaceUri); } diff --git a/x4o-driver/src/main/java/org/x4o/xml/eld/xsd/EldXsdXmlWriter.java b/x4o-driver/src/main/java/org/x4o/xml/eld/xsd/EldXsdXmlWriter.java index 469f35a..0fb73cf 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/eld/xsd/EldXsdXmlWriter.java +++ b/x4o-driver/src/main/java/org/x4o/xml/eld/xsd/EldXsdXmlWriter.java @@ -38,7 +38,7 @@ import org.x4o.xml.element.ElementClass; import org.x4o.xml.element.ElementClassAttribute; import org.x4o.xml.element.ElementInterface; import org.x4o.xml.element.ElementMetaBase; -import org.x4o.xml.element.ElementNamespaceContext; +import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.io.XMLConstants; import org.x4o.xml.io.sax.ext.ContentWriterXsd; import org.x4o.xml.lang.X4OLanguageModule; @@ -112,13 +112,13 @@ public class EldXsdXmlWriter { // redo this mess, add nice find for binding handlers for (X4OLanguageModule modContext:language.getLanguageModules()) { - for (ElementNamespaceContext nsContext:modContext.getElementNamespaceContexts()) { + for (ElementNamespace nsContext:modContext.getElementNamespaces()) { for (ElementClass ec:nsContext.getElementClasses()) { Class objectClass = null; if (ec.getObjectClass()!=null) { objectClass = ec.getObjectClass(); for (X4OLanguageModule mod:language.getLanguageModules()) { - for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) { + for (ElementNamespace ns:mod.getElementNamespaces()) { for (ElementClass checkClass:ns.getElementClasses()) { if (checkClass.getObjectClass()==null) { continue; @@ -147,7 +147,7 @@ public class EldXsdXmlWriter { private static final String COMMENT_SEPERATOR = " ==================================================================== "; private static final String COMMENT_TEXT = "====="; - public void startSchema(ElementNamespaceContext ns) throws SAXException { + public void startSchema(ElementNamespace ns) throws SAXException { xmlWriter.startDocument(); xmlWriter.ignorableWhitespace(XMLConstants.CHAR_NEWLINE); @@ -174,7 +174,7 @@ public class EldXsdXmlWriter { X4OLanguageModule module = null; for (X4OLanguageModule elm:language.getLanguageModules()) { - ElementNamespaceContext s = elm.getElementNamespaceContext(ns.getUri()); + ElementNamespace s = elm.getElementNamespace(ns.getUri()); if (s!=null) { module = elm; break; @@ -185,7 +185,7 @@ public class EldXsdXmlWriter { b.append("\n\tID:\t\t"); b.append(module.getId()); b.append("\n\tProviderName:\t"); b.append(module.getProviderName()); b.append("\n\tProviderHost:\t"); b.append(module.getProviderHost()); - b.append("\n\tNamespaces:\t\t"); b.append(module.getElementNamespaceContexts().size()); + b.append("\n\tNamespaces:\t\t"); b.append(module.getElementNamespaces().size()); b.append("\n\tUri:\t\t\t"); b.append(ns.getUri()); b.append("\n\tUri schema:\t"); b.append(ns.getSchemaUri()); b.append("\n\tCreated on:\t\t"); b.append(new Date()); @@ -211,7 +211,7 @@ public class EldXsdXmlWriter { if (ns.getUri().equals(uri)) { continue; } - ElementNamespaceContext nsContext = language.findElementNamespaceContext(uri); + ElementNamespace nsContext = language.findElementNamespace(uri); atts = new AttributesImpl(); atts.addAttribute ("", "namespace", "", "", nsContext.getUri()); atts.addAttribute ("", "schemaLocation", "", "", nsContext.getSchemaResource()); @@ -226,7 +226,7 @@ public class EldXsdXmlWriter { xmlWriter.endDocument(); } - public void writeElementClass(ElementClass ec,ElementNamespaceContext nsWrite) throws SAXException { + public void writeElementClass(ElementClass ec,ElementNamespace nsWrite) throws SAXException { AttributesImpl atts = new AttributesImpl(); if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) { @@ -262,7 +262,7 @@ public class EldXsdXmlWriter { xmlWriter.startElement (SCHEMA_URI, "choice", "", atts); for (X4OLanguageModule mod:language.getLanguageModules()) { - for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) { + for (ElementNamespace ns:mod.getElementNamespaces()) { writeElementClassNamespaces(ec,nsWrite,ns); } } @@ -362,7 +362,7 @@ public class EldXsdXmlWriter { } } - private void writeElementClassNamespaces(ElementClass ecWrite,ElementNamespaceContext nsWrite,ElementNamespaceContext ns) throws SAXException { + private void writeElementClassNamespaces(ElementClass ecWrite,ElementNamespace nsWrite,ElementNamespace ns) throws SAXException { AttributesImpl atts = new AttributesImpl(); List refElements = new ArrayList(20); for (ElementClass checkClass:ns.getElementClasses()) { @@ -417,7 +417,7 @@ public class EldXsdXmlWriter { } - public void writeElement(ElementClass ec,ElementNamespaceContext nsWrite) throws SAXException { + public void writeElement(ElementClass ec,ElementNamespace nsWrite) throws SAXException { if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) { return; // is done in writeElementClass } diff --git a/x4o-driver/src/main/java/org/x4o/xml/element/AbstractElementNamespaceContext.java b/x4o-driver/src/main/java/org/x4o/xml/element/AbstractElementNamespace.java similarity index 87% rename from x4o-driver/src/main/java/org/x4o/xml/element/AbstractElementNamespaceContext.java rename to x4o-driver/src/main/java/org/x4o/xml/element/AbstractElementNamespace.java index d743a19..ed91320 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/element/AbstractElementNamespaceContext.java +++ b/x4o-driver/src/main/java/org/x4o/xml/element/AbstractElementNamespace.java @@ -28,11 +28,12 @@ import java.util.List; import java.util.Map; /** - * The abstract verion of ElementNamespaceContext + * AbstractElementNamespace is the abstract version of an ElementNamespace. + * * @author Willem Cazander * @version 1.0 Oct 28, 2009 */ -public abstract class AbstractElementNamespaceContext extends AbstractElementMetaBase implements ElementNamespaceContext { +public abstract class AbstractElementNamespace extends AbstractElementMetaBase implements ElementNamespace { private ElementNamespaceInstanceProvider elementNamespaceInstanceProvider = null; private String prefixMapping = null; @@ -44,12 +45,12 @@ public abstract class AbstractElementNamespaceContext extends AbstractElementMet private String schemaPrefix = null; private Boolean languageRoot = null; - public AbstractElementNamespaceContext() { + public AbstractElementNamespace() { elementClasses = new HashMap(100); } /** - * @see org.x4o.xml.element.ElementNamespaceContext#getPrefixMapping() + * @see org.x4o.xml.element.ElementNamespace#getPrefixMapping() */ public String getPrefixMapping() { return prefixMapping; @@ -70,14 +71,14 @@ public abstract class AbstractElementNamespaceContext extends AbstractElementMet } /** - * @see org.x4o.xml.element.ElementNamespaceContext#setPrefixMapping(java.lang.String) + * @see org.x4o.xml.element.ElementNamespace#setPrefixMapping(java.lang.String) */ public void setPrefixMapping(String prefixMapping) { this.prefixMapping=prefixMapping; } /** - * @see org.x4o.xml.element.ElementNamespaceContext#addElementClass(org.x4o.xml.element.ElementClass) + * @see org.x4o.xml.element.ElementNamespace#addElementClass(org.x4o.xml.element.ElementClass) */ public void addElementClass(ElementClass elementClass) { if (elementClass.getId()==null) { @@ -87,14 +88,14 @@ public abstract class AbstractElementNamespaceContext extends AbstractElementMet } /** - * @see org.x4o.xml.element.ElementNamespaceContext#getElementClass(java.lang.String) + * @see org.x4o.xml.element.ElementNamespace#getElementClass(java.lang.String) */ public ElementClass getElementClass(String tag) { return elementClasses.get(tag); } /** - * @see org.x4o.xml.element.ElementNamespaceContext#getElementClasses() + * @see org.x4o.xml.element.ElementNamespace#getElementClasses() */ public List getElementClasses() { return new ArrayList(elementClasses.values()); diff --git a/x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementNamespaceContext.java b/x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementNamespace.java similarity index 90% rename from x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementNamespaceContext.java rename to x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementNamespace.java index fd3a4ab..c48a67f 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementNamespaceContext.java +++ b/x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementNamespace.java @@ -24,11 +24,11 @@ package org.x4o.xml.element; /** - * The default namespace context. + * DefaultElementNamespace is the default element namespace implementation. * * @author Willem Cazander * @version 1.0 Oct 28, 2009 */ -public class DefaultElementNamespaceContext extends AbstractElementNamespaceContext { +public class DefaultElementNamespace extends AbstractElementNamespace { } diff --git a/x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementNamespaceInstanceProvider.java b/x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementNamespaceInstanceProvider.java index 77b60a5..3faaf17 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementNamespaceInstanceProvider.java +++ b/x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementNamespaceInstanceProvider.java @@ -37,7 +37,7 @@ import org.x4o.xml.lang.X4OLanguageClassLoader; public class DefaultElementNamespaceInstanceProvider implements ElementNamespaceInstanceProvider { private Logger logger = null; - private ElementNamespaceContext elementNamespaceContext = null; + private ElementNamespace elementNamespace = null; /** * Creates new DefaultElementNamespaceInstanceProvider. @@ -48,12 +48,12 @@ public class DefaultElementNamespaceInstanceProvider implements ElementNamespace /** * @param language The elementLanguage of this provider. - * @param elementNamespaceContext The elementNamespaceContext for this provider. - * @see org.x4o.xml.element.ElementNamespaceInstanceProvider#start(org.x4o.xml.lang.X4OLanguage, org.x4o.xml.element.ElementNamespaceContext) + * @param elementNamespace The elementNamespace for this provider. + * @see org.x4o.xml.element.ElementNamespaceInstanceProvider#start(org.x4o.xml.lang.X4OLanguage, org.x4o.xml.element.ElementNamespace) */ - public void start(X4OLanguage language,ElementNamespaceContext elementNamespaceContext) { - this.elementNamespaceContext=elementNamespaceContext; - logger.finer("Starting DefaultElementNamespaceInstanceProvider for: "+elementNamespaceContext.getUri()); + public void start(X4OLanguage language,ElementNamespace elementNamespace) { + this.elementNamespace=elementNamespace; + logger.finer("Starting DefaultElementNamespaceInstanceProvider for: "+elementNamespace.getUri()); } /** @@ -64,11 +64,11 @@ public class DefaultElementNamespaceInstanceProvider implements ElementNamespace * @see org.x4o.xml.element.ElementNamespaceInstanceProvider#createElementInstance(org.x4o.xml.lang.X4OLanguageContext,java.lang.String) */ public Element createElementInstance(X4OLanguageContext languageContext,String tag) throws ElementNamespaceInstanceProviderException { - ElementClass elementClass = elementNamespaceContext.getElementClass(tag); + ElementClass elementClass = elementNamespace.getElementClass(tag); Element element = null; if (elementClass==null) { - throw new ElementNamespaceInstanceProviderException(this,"Tag: " + tag + " unknown in: " + elementNamespaceContext.getUri()); + throw new ElementNamespaceInstanceProviderException(this,"Tag: " + tag + " unknown in: " + elementNamespace.getUri()); } try { diff --git a/x4o-driver/src/main/java/org/x4o/xml/element/ElementNamespaceContext.java b/x4o-driver/src/main/java/org/x4o/xml/element/ElementNamespace.java similarity index 96% rename from x4o-driver/src/main/java/org/x4o/xml/element/ElementNamespaceContext.java rename to x4o-driver/src/main/java/org/x4o/xml/element/ElementNamespace.java index 283a29b..cef03a1 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/element/ElementNamespaceContext.java +++ b/x4o-driver/src/main/java/org/x4o/xml/element/ElementNamespace.java @@ -25,12 +25,12 @@ package org.x4o.xml.element; import java.util.List; /** - * ElementNamespaceContext stores all element tag classes for the namespace. + * ElementNamespace stores all element tag classes for the namespace. * * @author Willem Cazander * @version 1.0 Oct 28, 2009 */ -public interface ElementNamespaceContext extends ElementMetaBase { +public interface ElementNamespace extends ElementMetaBase { /** * Sets the prefix mapping. diff --git a/x4o-driver/src/main/java/org/x4o/xml/element/ElementNamespaceInstanceProvider.java b/x4o-driver/src/main/java/org/x4o/xml/element/ElementNamespaceInstanceProvider.java index 025b143..12b7fcb 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/element/ElementNamespaceInstanceProvider.java +++ b/x4o-driver/src/main/java/org/x4o/xml/element/ElementNamespaceInstanceProvider.java @@ -36,10 +36,10 @@ public interface ElementNamespaceInstanceProvider { /** * Starts the ElementProvider. * @param language The X4OLanguage to start in. - * @param elementNamespaceContext The ElementNamespaceContext to start for. + * @param elementNamespace The elementNamespace to start for. * @throws ElementNamespaceInstanceProviderException Thrown when error happened in language. */ - void start(X4OLanguage language,ElementNamespaceContext elementNamespaceContext) throws ElementNamespaceInstanceProviderException; + void start(X4OLanguage language,ElementNamespace elementNamespace) throws ElementNamespaceInstanceProviderException; /** * Provide an Element for an xml tag. diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OWriter.java b/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OWriter.java index ca037ce..9185135 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OWriter.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OWriter.java @@ -37,7 +37,7 @@ import org.x4o.xml.element.Element; import org.x4o.xml.element.ElementClass; import org.x4o.xml.element.ElementClassAttribute; import org.x4o.xml.element.ElementInterface; -import org.x4o.xml.element.ElementNamespaceContext; +import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.element.ElementObjectPropertyValueException; import org.x4o.xml.io.sax.ext.PropertyConfig; import org.x4o.xml.io.sax.ext.ContentWriterXml; @@ -128,7 +128,7 @@ public class DefaultX4OWriter extends AbstractX4OWriter { Element root = languageContext.getRootElement(); if (schemaUriRoot==null) { String rootUri = findElementUri(root); - ElementNamespaceContext ns = languageContext.getLanguage().findElementNamespaceContext(rootUri); + ElementNamespace ns = languageContext.getLanguage().findElementNamespace(rootUri); if (ns!=null) { schemaUriRoot = ns.getSchemaUri(); } @@ -316,7 +316,7 @@ public class DefaultX4OWriter extends AbstractX4OWriter { private String findElementUri(Element e) { for (X4OLanguageModule mod:e.getLanguageContext().getLanguage().getLanguageModules()) { - for (ElementNamespaceContext c:mod.getElementNamespaceContexts()) { + for (ElementNamespace c:mod.getElementNamespaces()) { ElementClass ec = c.getElementClass(e.getElementClass().getId()); if (ec!=null) { return c.getUri(); @@ -327,7 +327,7 @@ public class DefaultX4OWriter extends AbstractX4OWriter { } private String findNamespacePrefix(Element e,String uri) { - ElementNamespaceContext ns = e.getLanguageContext().getLanguage().findElementNamespaceContext(uri); + ElementNamespace ns = e.getLanguageContext().getLanguage().findElementNamespace(uri); if (ns.getPrefixMapping()!=null) { return ns.getPrefixMapping(); } diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OContentHandler.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OContentHandler.java index 7e36b34..b9da3dd 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OContentHandler.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OContentHandler.java @@ -25,7 +25,7 @@ package org.x4o.xml.io.sax; import org.x4o.xml.element.Element; import org.x4o.xml.element.Element.ElementType; import org.x4o.xml.element.ElementException; -import org.x4o.xml.element.ElementNamespaceContext; +import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.element.ElementNamespaceInstanceProvider; import org.x4o.xml.io.DefaultX4OReader; import org.x4o.xml.io.sax.ext.AttributeMap; @@ -106,7 +106,7 @@ public class X4OContentHandler extends DefaultHandler2 { if ("http://www.w3.org/2001/XInclude".equals(namespaceUri)) { return; // skip xinclude ns. } - ElementNamespaceContext enc = elementLanguage.getLanguage().findElementNamespaceContext(namespaceUri); + ElementNamespace enc = elementLanguage.getLanguage().findElementNamespace(namespaceUri); if (enc==null) { throw new SAXException("Can't find namespace uri: "+namespaceUri+" in language: "+elementLanguage.getLanguage().getLanguageName()); } @@ -125,16 +125,16 @@ public class X4OContentHandler extends DefaultHandler2 { overrideSaxHandler.startElement(namespaceUri, tag, qName, attributes); return; } - ElementNamespaceContext enc = elementLanguage.getLanguage().findElementNamespaceContext(namespaceUri); + ElementNamespace enc = elementLanguage.getLanguage().findElementNamespace(namespaceUri); if (enc==null) { if ("".equals(namespaceUri)) { String configEmptryUri = propertyConfig.getPropertyString(DefaultX4OReader.DOC_EMPTY_NAMESPACE_URI); if (configEmptryUri!=null) { namespaceUri = configEmptryUri; - enc = elementLanguage.getLanguage().findElementNamespaceContext(namespaceUri); + enc = elementLanguage.getLanguage().findElementNamespace(namespaceUri); } if (enc==null) { - throw new SAXParseException("No ElementNamespaceContext found for empty namespace.",locator); + throw new SAXParseException("No ElementNamespace found for empty namespace.",locator); } enc.setPrefixMapping(""); } diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4ODebugWriter.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4ODebugWriter.java index baab8a2..58764b2 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4ODebugWriter.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4ODebugWriter.java @@ -38,7 +38,7 @@ import org.x4o.xml.element.ElementConfigurator; import org.x4o.xml.element.ElementConfiguratorGlobal; import org.x4o.xml.element.ElementException; import org.x4o.xml.element.ElementInterface; -import org.x4o.xml.element.ElementNamespaceContext; +import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.element.ElementNamespaceInstanceProvider; import org.x4o.xml.io.sax.ext.ContentWriter; import org.x4o.xml.lang.X4OLanguageModule; @@ -142,7 +142,7 @@ public class X4ODebugWriter { contentWriter.startElement (DEBUG_URI, "X4OLanguageDefaultClasses", "", atts); X4OLanguageConfiguration conf = ec.getLanguage().getLanguageConfiguration(); - debugLanguageDefaultClass("getDefaultElementNamespaceContext",conf.getDefaultElementNamespaceContext()); + debugLanguageDefaultClass("getDefaultElementNamespace",conf.getDefaultElementNamespace()); debugLanguageDefaultClass("getDefaultElementInterface",conf.getDefaultElementInterface()); debugLanguageDefaultClass("getDefaultElement",conf.getDefaultElement()); debugLanguageDefaultClass("getDefaultElementClass",conf.getDefaultElementClass()); @@ -234,7 +234,7 @@ public class X4ODebugWriter { //module.getElementBindingHandlers(); //module.getGlobalElementConfigurators(); //module.getElementInterfaces(); - //module.getElementNamespaceContexts(); + //module.getElementNamespace(); debugElementConfiguratorGlobal(module.getElementConfiguratorGlobals()); debugElementBindingHandler(module.getElementBindingHandlers()); @@ -265,7 +265,7 @@ public class X4ODebugWriter { contentWriter.endElement(DEBUG_URI, "elementInterface", ""); } - for (ElementNamespaceContext enc:module.getElementNamespaceContexts()) { + for (ElementNamespace enc:module.getElementNamespaces()) { atts = new AttributesImpl(); atts.addAttribute ("", "uri", "", "", enc.getUri()); atts.addAttribute ("", "description", "", "", enc.getDescription()); @@ -273,7 +273,7 @@ public class X4ODebugWriter { atts.addAttribute ("", "schemaResource", "", "", enc.getSchemaResource()); atts.addAttribute ("", "className", "", "", enc.getClass().getName()); - contentWriter.startElement (DEBUG_URI, ElementNamespaceContext.class.getSimpleName(), "", atts); + contentWriter.startElement (DEBUG_URI, ElementNamespace.class.getSimpleName(), "", atts); for (ElementClass ec:enc.getElementClasses()) { debugElementClass(ec); } @@ -284,7 +284,7 @@ public class X4ODebugWriter { contentWriter.startElement (DEBUG_URI, ElementNamespaceInstanceProvider.class.getSimpleName(), "", atts); contentWriter.endElement(DEBUG_URI, ElementNamespaceInstanceProvider.class.getSimpleName(), ""); - contentWriter.endElement(DEBUG_URI, ElementNamespaceContext.class.getSimpleName(), ""); + contentWriter.endElement(DEBUG_URI, ElementNamespace.class.getSimpleName(), ""); } contentWriter.endElement(DEBUG_URI, "ElementLanguageModule", ""); diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OEntityResolver.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OEntityResolver.java index e8ffc37..a4ed56f 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OEntityResolver.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OEntityResolver.java @@ -30,7 +30,7 @@ import java.util.HashMap; import java.util.Map; import java.util.logging.Logger; -import org.x4o.xml.element.ElementNamespaceContext; +import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.io.DefaultX4OReader; import org.x4o.xml.io.sax.ext.PropertyConfig; import org.x4o.xml.lang.X4OLanguageModule; @@ -74,7 +74,7 @@ public class X4OEntityResolver implements EntityResolver { this.schemaResources=new HashMap(20); this.schemaPathResources=new HashMap(20); for (X4OLanguageModule mod:elementContext.getLanguage().getLanguageModules()) { - for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) { + for (ElementNamespace ns:mod.getElementNamespaces()) { if (ns.getSchemaUri()==null) { continue; } diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageConfiguration.java b/x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageConfiguration.java index ecb7f01..a6f3ae3 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageConfiguration.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageConfiguration.java @@ -22,10 +22,6 @@ */ package org.x4o.xml.lang; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - /** * AbstractX4OLanguageConfiguration. * @@ -37,7 +33,7 @@ public abstract class AbstractX4OLanguageConfiguration implements X4OLanguageCon private String languageResourcePathPrefix = null; private String languageResourceModulesFileName = null; - private Class defaultElementNamespaceContext = null; + private Class defaultElementNamespace = null; private Class defaultElementInterface = null; private Class defaultElement = null; private Class defaultElementClass = null; @@ -86,24 +82,22 @@ public abstract class AbstractX4OLanguageConfiguration implements X4OLanguageCon /** * @param languageResourceModulesFileName the languageResourceModulesFileName to set */ - public void setLanguageResourceModulesFileName( - String languageResourceModulesFileName) { + public void setLanguageResourceModulesFileName(String languageResourceModulesFileName) { this.languageResourceModulesFileName = languageResourceModulesFileName; } /** - * @return the defaultElementNamespaceContext + * @return the defaultElementNamespace */ - public Class getDefaultElementNamespaceContext() { - return defaultElementNamespaceContext; + public Class getDefaultElementNamespace() { + return defaultElementNamespace; } /** - * @param defaultElementNamespaceContext the defaultElementNamespaceContext to set + * @param defaultElementNamespace the defaultElementNamespace to set */ - public void setDefaultElementNamespaceContext( - Class defaultElementNamespaceContext) { - this.defaultElementNamespaceContext = defaultElementNamespaceContext; + public void setDefaultElementNamespace(Class defaultElementNamespace) { + this.defaultElementNamespace = defaultElementNamespace; } /** @@ -158,8 +152,7 @@ public abstract class AbstractX4OLanguageConfiguration implements X4OLanguageCon /** * @param defaultElementClassAttribute the defaultElementClassAttribute to set */ - public void setDefaultElementClassAttribute( - Class defaultElementClassAttribute) { + public void setDefaultElementClassAttribute(Class defaultElementClassAttribute) { this.defaultElementClassAttribute = defaultElementClassAttribute; } @@ -173,8 +166,7 @@ public abstract class AbstractX4OLanguageConfiguration implements X4OLanguageCon /** * @param defaultElementLanguageModule the defaultElementLanguageModule to set */ - public void setDefaultElementLanguageModule( - Class defaultElementLanguageModule) { + public void setDefaultElementLanguageModule(Class defaultElementLanguageModule) { this.defaultElementLanguageModule = defaultElementLanguageModule; } @@ -202,8 +194,7 @@ public abstract class AbstractX4OLanguageConfiguration implements X4OLanguageCon /** * @param defaultElementBodyCharacters the defaultElementBodyCharacters to set */ - public void setDefaultElementBodyCharacters( - Class defaultElementBodyCharacters) { + public void setDefaultElementBodyCharacters(Class defaultElementBodyCharacters) { this.defaultElementBodyCharacters = defaultElementBodyCharacters; } @@ -217,8 +208,7 @@ public abstract class AbstractX4OLanguageConfiguration implements X4OLanguageCon /** * @param defaultElementBodyWhitespace the defaultElementBodyWhitespace to set */ - public void setDefaultElementBodyWhitespace( - Class defaultElementBodyWhitespace) { + public void setDefaultElementBodyWhitespace(Class defaultElementBodyWhitespace) { this.defaultElementBodyWhitespace = defaultElementBodyWhitespace; } @@ -232,8 +222,7 @@ public abstract class AbstractX4OLanguageConfiguration implements X4OLanguageCon /** * @param defaultElementNamespaceInstanceProvider the defaultElementNamespaceInstanceProvider to set */ - public void setDefaultElementNamespaceInstanceProvider( - Class defaultElementNamespaceInstanceProvider) { + public void setDefaultElementNamespaceInstanceProvider(Class defaultElementNamespaceInstanceProvider) { this.defaultElementNamespaceInstanceProvider = defaultElementNamespaceInstanceProvider; } @@ -247,8 +236,7 @@ public abstract class AbstractX4OLanguageConfiguration implements X4OLanguageCon /** * @param defaultElementAttributeValueParser the defaultElementAttributeValueParser to set */ - public void setDefaultElementAttributeValueParser( - Class defaultElementAttributeValueParser) { + public void setDefaultElementAttributeValueParser(Class defaultElementAttributeValueParser) { this.defaultElementAttributeValueParser = defaultElementAttributeValueParser; } @@ -262,8 +250,7 @@ public abstract class AbstractX4OLanguageConfiguration implements X4OLanguageCon /** * @param defaultElementObjectPropertyValue the defaultElementObjectPropertyValue to set */ - public void setDefaultElementObjectPropertyValue( - Class defaultElementObjectPropertyValue) { + public void setDefaultElementObjectPropertyValue(Class defaultElementObjectPropertyValue) { this.defaultElementObjectPropertyValue = defaultElementObjectPropertyValue; } @@ -277,8 +264,7 @@ public abstract class AbstractX4OLanguageConfiguration implements X4OLanguageCon /** * @param defaultElementAttributeHandlerComparator the defaultElementAttributeHandlerComparator to set */ - public void setDefaultElementAttributeHandlerComparator( - Class defaultElementAttributeHandlerComparator) { + public void setDefaultElementAttributeHandlerComparator(Class defaultElementAttributeHandlerComparator) { this.defaultElementAttributeHandlerComparator = defaultElementAttributeHandlerComparator; } @@ -292,8 +278,7 @@ public abstract class AbstractX4OLanguageConfiguration implements X4OLanguageCon /** * @param defaultLanguageVersionFilter the defaultLanguageVersionFilter to set */ - public void setDefaultLanguageVersionFilter( - Class defaultLanguageVersionFilter) { + public void setDefaultLanguageVersionFilter(Class defaultLanguageVersionFilter) { this.defaultLanguageVersionFilter = defaultLanguageVersionFilter; } @@ -321,8 +306,7 @@ public abstract class AbstractX4OLanguageConfiguration implements X4OLanguageCon /** * @param defaultExpressionLanguageContext the defaultExpressionLanguageContext to set */ - public void setDefaultExpressionLanguageContext( - Class defaultExpressionLanguageContext) { + public void setDefaultExpressionLanguageContext(Class defaultExpressionLanguageContext) { this.defaultExpressionLanguageContext = defaultExpressionLanguageContext; } } diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageModule.java b/x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageModule.java index 7e52430..93e916f 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageModule.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageModule.java @@ -33,7 +33,7 @@ import org.x4o.xml.element.ElementAttributeHandler; import org.x4o.xml.element.ElementBindingHandler; import org.x4o.xml.element.ElementConfiguratorGlobal; import org.x4o.xml.element.ElementInterface; -import org.x4o.xml.element.ElementNamespaceContext; +import org.x4o.xml.element.ElementNamespace; /** * An AbstractElementLanguageModule. @@ -52,7 +52,7 @@ public abstract class AbstractX4OLanguageModule extends AbstractElementMetaBase private List elementBindingHandlers = null; private List elementConfiguratorGlobals = null; private List elementInterfaces = null; - private Map elementNamespaceContexts = null; + private Map elementNamespaces = null; private X4OLanguageModuleLoader elementLanguageModuleLoader = null; /** @@ -65,7 +65,7 @@ public abstract class AbstractX4OLanguageModule extends AbstractElementMetaBase elementBindingHandlers = new ArrayList(4); elementConfiguratorGlobals = new ArrayList(4); elementInterfaces = new ArrayList(20); - elementNamespaceContexts = new HashMap(10); + elementNamespaces = new HashMap(10); } /** @@ -190,31 +190,31 @@ public abstract class AbstractX4OLanguageModule extends AbstractElementMetaBase } /** - * @see org.x4o.xml.lang.X4OLanguageModule#addElementNamespaceContext(org.x4o.xml.element.ElementNamespaceContext) + * @see org.x4o.xml.lang.X4OLanguageModule#addElementNamespace(org.x4o.xml.element.ElementNamespace) */ - public void addElementNamespaceContext(ElementNamespaceContext elementNamespaceContext) { - if (elementNamespaceContext==null) { + public void addElementNamespace(ElementNamespace elementNamespace) { + if (elementNamespace==null) { throw new NullPointerException("Can't add null."); } - if (elementNamespaceContext.getUri()==null) { - throw new NullPointerException("Can add ElementNamespaceContext without uri."); + if (elementNamespace.getUri()==null) { + throw new NullPointerException("Can add ElementNamespace without uri."); } - logger.fine("Adding namespaceUri: "+elementNamespaceContext.getUri()); - elementNamespaceContexts.put(elementNamespaceContext.getUri(), elementNamespaceContext); + logger.fine("Adding namespaceUri: "+elementNamespace.getUri()); + elementNamespaces.put(elementNamespace.getUri(), elementNamespace); } /** - * @see org.x4o.xml.lang.X4OLanguageModule#getElementNamespaceContext(java.lang.String) + * @see org.x4o.xml.lang.X4OLanguageModule#getElementNamespace(java.lang.String) */ - public ElementNamespaceContext getElementNamespaceContext(String namespaceUri) { - return elementNamespaceContexts.get(namespaceUri); + public ElementNamespace getElementNamespace(String namespaceUri) { + return elementNamespaces.get(namespaceUri); } /** - * @see org.x4o.xml.lang.X4OLanguageModule#getElementNamespaceContexts() + * @see org.x4o.xml.lang.X4OLanguageModule#getElementNamespaces() */ - public List getElementNamespaceContexts() { - return new ArrayList(elementNamespaceContexts.values()); + public List getElementNamespaces() { + return new ArrayList(elementNamespaces.values()); } /** @@ -252,7 +252,7 @@ public abstract class AbstractX4OLanguageModule extends AbstractElementMetaBase elementAttributeHandlers.clear(); elementBindingHandlers.clear(); elementInterfaces.clear(); - elementNamespaceContexts.clear(); + elementNamespaces.clear(); getLanguageModuleLoader().loadLanguageModule(elementLanguage, elementLanguageModule); } diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/DefaultX4OLanguage.java b/x4o-driver/src/main/java/org/x4o/xml/lang/DefaultX4OLanguage.java index c606c2b..8da8225 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/DefaultX4OLanguage.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/DefaultX4OLanguage.java @@ -32,7 +32,7 @@ import org.x4o.xml.element.ElementAttributeValueParser; import org.x4o.xml.element.ElementBindingHandler; import org.x4o.xml.element.ElementClass; import org.x4o.xml.element.ElementInterface; -import org.x4o.xml.element.ElementNamespaceContext; +import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.element.ElementNamespaceInstanceProviderException; import org.x4o.xml.element.ElementObjectPropertyValue; import org.x4o.xml.lang.phase.X4OPhaseException; @@ -157,7 +157,7 @@ public class DefaultX4OLanguage implements X4OLanguageLocal { */ public Element createElementInstance(X4OLanguageContext context,Class objectClass) { for (X4OLanguageModule modContext:getLanguageModules()) { - for (ElementNamespaceContext nsContext:modContext.getElementNamespaceContexts()) { + for (ElementNamespace nsContext:modContext.getElementNamespaces()) { for (ElementClass ec:nsContext.getElementClasses()) { if (ec.getObjectClass()!=null && ec.getObjectClass().equals(objectClass)) { try { @@ -253,15 +253,15 @@ public class DefaultX4OLanguage implements X4OLanguageLocal { } /** - * @see org.x4o.xml.lang.X4OLanguage#findElementNamespaceContext(java.lang.String) + * @see org.x4o.xml.lang.X4OLanguage#findElementNamespace(java.lang.String) */ - public ElementNamespaceContext findElementNamespaceContext(String namespaceUri) { + public ElementNamespace findElementNamespace(String namespaceUri) { // TODO: refactor so no search for every tag !! - ElementNamespaceContext result = null; + ElementNamespace result = null; for (int i=0;i getDefaultElementNamespaceContext(); + Class getDefaultElementNamespace(); Class getDefaultElementInterface(); Class getDefaultElement(); Class getDefaultElementClass(); diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageConfigurationLocal.java b/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageConfigurationLocal.java index c276990..af113e1 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageConfigurationLocal.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageConfigurationLocal.java @@ -35,7 +35,7 @@ public interface X4OLanguageConfigurationLocal extends X4OLanguageConfiguration void setLanguageResourcePathPrefix(String value); void setLanguageResourceModulesFileName(String value); - void setDefaultElementNamespaceContext(Class value); + void setDefaultElementNamespace(Class value); void setDefaultElementInterface(Class value); void setDefaultElement(Class value); void setDefaultElementClass(Class value); diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageModule.java b/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageModule.java index c14da93..149a042 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageModule.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageModule.java @@ -29,7 +29,7 @@ import org.x4o.xml.element.ElementBindingHandler; import org.x4o.xml.element.ElementConfiguratorGlobal; import org.x4o.xml.element.ElementInterface; import org.x4o.xml.element.ElementMetaBase; -import org.x4o.xml.element.ElementNamespaceContext; +import org.x4o.xml.element.ElementNamespace; /** * The ElementLanguageModule.
@@ -110,21 +110,21 @@ public interface X4OLanguageModule extends ElementMetaBase { /** * Adds an namespace to this langauge module. - * @param elementNamespaceContext Adds an ElementNamespaceContext to this langauge module. + * @param elementNamespace Adds an ElementNamespace to this langauge module. */ - void addElementNamespaceContext(ElementNamespaceContext elementNamespaceContext); + void addElementNamespace(ElementNamespace elementNamespace); /** * Returns the namespace context for an namespace uri. * @param namespaceUri the namespace uri. - * @return The ElementNamespaceContext. + * @return The ElementNamespace. */ - ElementNamespaceContext getElementNamespaceContext(String namespaceUri); + ElementNamespace getElementNamespace(String namespaceUri); /** * @return Returns a list of all namespaces defined in this language. */ - List getElementNamespaceContexts(); + List getElementNamespaces(); /** * @param elementLanguageModuleLoader Sets the loader of this module. diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageRead.java b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageRead.java index 182f6bd..cdf5bd6 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageRead.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageRead.java @@ -40,7 +40,7 @@ import org.x4o.xml.element.ElementConfigurator; import org.x4o.xml.element.ElementConfiguratorGlobal; import org.x4o.xml.element.ElementException; import org.x4o.xml.element.ElementInterface; -import org.x4o.xml.element.ElementNamespaceContext; +import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.io.sax.X4ODebugWriter; import org.x4o.xml.io.sax.ext.ContentWriter; import org.x4o.xml.lang.X4OLanguageModule; @@ -767,7 +767,7 @@ public class X4OPhaseLanguageRead { // note: slow version private String getNamespaceForElement(Element e) { for (X4OLanguageModule mod:e.getLanguageContext().getLanguage().getLanguageModules()) { - for (ElementNamespaceContext enc:mod.getElementNamespaceContexts()) { + for (ElementNamespace enc:mod.getElementNamespaces()) { List l = enc.getElementClasses(); if (l.contains(e.getElementClass())) { return enc.getUri(); @@ -802,7 +802,7 @@ public class X4OPhaseLanguageRead { } String nameSpace = getNamespaceForElement(element); - String prefix = element.getLanguageContext().getLanguage().findElementNamespaceContext(nameSpace).getPrefixMapping(); + String prefix = element.getLanguageContext().getLanguage().findElementNamespace(nameSpace).getPrefixMapping(); if (startedPrefix.contains(prefix)==false) { handler.startPrefixMapping(prefix, nameSpace); diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageWrite.java b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageWrite.java index 1d08d0b..dfbbafc 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageWrite.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageWrite.java @@ -29,7 +29,7 @@ import org.x4o.xml.element.ElementBindingHandler; import org.x4o.xml.element.ElementBindingHandlerException; import org.x4o.xml.element.ElementClass; import org.x4o.xml.element.ElementException; -import org.x4o.xml.element.ElementNamespaceContext; +import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.element.ElementNamespaceInstanceProviderException; import org.x4o.xml.lang.X4OLanguageModule; import org.x4o.xml.lang.X4OLanguageContext; @@ -133,7 +133,7 @@ public class X4OPhaseLanguageWrite { private Element findRootElement(X4OLanguageContext languageContext,Class objectClass) throws ElementNamespaceInstanceProviderException { // redo this mess, add nice find for root for (X4OLanguageModule modContext:languageContext.getLanguage().getLanguageModules()) { - for (ElementNamespaceContext nsContext:modContext.getElementNamespaceContexts()) { + for (ElementNamespace nsContext:modContext.getElementNamespaces()) { if (nsContext.getLanguageRoot()!=null && nsContext.getLanguageRoot()) { for (ElementClass ec:nsContext.getElementClasses()) { if (ec.getObjectClass()!=null && ec.getObjectClass().equals(objectClass)) { @@ -144,7 +144,7 @@ public class X4OPhaseLanguageWrite { } } for (X4OLanguageModule modContext:languageContext.getLanguage().getLanguageModules()) { - for (ElementNamespaceContext nsContext:modContext.getElementNamespaceContexts()) { + for (ElementNamespace nsContext:modContext.getElementNamespaces()) { for (ElementClass ec:nsContext.getElementClasses()) { if (ec.getObjectClass()!=null && ec.getObjectClass().equals(objectClass)) { return nsContext.getElementNamespaceInstanceProvider().createElementInstance(languageContext, ec.getId()); diff --git a/x4o-driver/src/main/resources/META-INF/eld/eld-lang.eld b/x4o-driver/src/main/resources/META-INF/eld/eld-lang.eld index 5df4b33..067ce5c 100644 --- a/x4o-driver/src/main/resources/META-INF/eld/eld-lang.eld +++ b/x4o-driver/src/main/resources/META-INF/eld/eld-lang.eld @@ -38,7 +38,7 @@ - + @@ -77,7 +77,7 @@ Some basic language definitions and some helper tags. - + Defines an namespace for the language. The namespace id. diff --git a/x4o-driver/src/test/java/org/x4o/xml/core/EmptyXmlTest.java b/x4o-driver/src/test/java/org/x4o/xml/core/EmptyXmlTest.java index 4ef9db4..05a398a 100644 --- a/x4o-driver/src/test/java/org/x4o/xml/core/EmptyXmlTest.java +++ b/x4o-driver/src/test/java/org/x4o/xml/core/EmptyXmlTest.java @@ -70,7 +70,7 @@ public class EmptyXmlTest extends TestCase { try { reader.readResource("tests/empty-xml/empty-test.xml"); } catch (SAXException e) { - assertEquals("No ElementNamespaceContext found for empty namespace.", e.getMessage()); + assertEquals("No ElementNamespace found for empty namespace.", e.getMessage()); return; } assertEquals(true,false); diff --git a/x4o-driver/src/test/java/org/x4o/xml/eld/EldParserTest.java b/x4o-driver/src/test/java/org/x4o/xml/eld/EldParserTest.java index 9ab661f..01c9ee4 100644 --- a/x4o-driver/src/test/java/org/x4o/xml/eld/EldParserTest.java +++ b/x4o-driver/src/test/java/org/x4o/xml/eld/EldParserTest.java @@ -76,7 +76,7 @@ public class EldParserTest extends TestCase { try { //X4OLanguageModule module = reader.readResource("META-INF/eld/eld-lang.eld"); //List resultTags = new ArrayList(50); - //for (ElementNamespaceContext ns:module.getElementNamespaceContexts()) { + //for (ElementNamespace ns:module.getElementNamespaces()) { // //} /* diff --git a/x4o-driver/src/test/resources/META-INF/x4o-drivers.xml b/x4o-driver/src/test/resources/META-INF/x4o-drivers.xml index 8d65a7f..72b54f1 100644 --- a/x4o-driver/src/test/resources/META-INF/x4o-drivers.xml +++ b/x4o-driver/src/test/resources/META-INF/x4o-drivers.xml @@ -32,7 +32,7 @@