Upped pom version and fixed pmd warnings in code.

This commit is contained in:
Willem Cazander 2012-09-12 16:10:30 +02:00
parent 787b1174b0
commit c38c283fe9
55 changed files with 285 additions and 239 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>x4o</name> <name>x4o</name>
<comment>x4o-base, Eclipse with Maven build project.</comment> <comment>X4O Project build with Eclipse and Maven.</comment>
<projects> <projects>
</projects> </projects>
<buildSpec> <buildSpec>

View file

@ -4,7 +4,7 @@
<groupId>org.x4o</groupId> <groupId>org.x4o</groupId>
<artifactId>x4o</artifactId> <artifactId>x4o</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>0.8.2-SNAPSHOT</version> <version>0.8.5-SNAPSHOT</version>
<name>x4o</name> <name>x4o</name>
<description>Creates an easy xml layer for objects and creating your own xml language implementations.</description> <description>Creates an easy xml layer for objects and creating your own xml language implementations.</description>
<url>http://www.x4o.org</url> <url>http://www.x4o.org</url>
@ -38,6 +38,10 @@
<developerConnection>scm:git:ssh://git.sv.gnu.org:/srv/git/x4o.git</developerConnection> <developerConnection>scm:git:ssh://git.sv.gnu.org:/srv/git/x4o.git</developerConnection>
<url>http://git.savannah.gnu.org/cgit/x4o.git</url> <url>http://git.savannah.gnu.org/cgit/x4o.git</url>
</scm> </scm>
<issueManagement>
<system>savannah</system>
<url>https://savannah.nongnu.org/bugs/?group=x4o</url>
</issueManagement>
<prerequisites> <prerequisites>
<maven>3.0.1</maven> <maven>3.0.1</maven>
</prerequisites> </prerequisites>

View file

@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>x4o</artifactId> <artifactId>x4o</artifactId>
<groupId>org.x4o</groupId> <groupId>org.x4o</groupId>
<version>0.8.2-SNAPSHOT</version> <version>0.8.5-SNAPSHOT</version>
</parent> </parent>
<artifactId>x4o-core</artifactId> <artifactId>x4o-core</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>

View file

@ -45,7 +45,7 @@ public class BooleanConverter extends AbstractStringObjectConverter {
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException { public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
// WARNING: this alway returns a boolean :''( // WARNING: this alway returns a boolean :''(
return new Boolean(str); return Boolean.valueOf(str);
} }
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException { public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {

View file

@ -36,7 +36,7 @@ import org.x4o.xml.element.ElementLanguage;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Dec 31, 2008 * @version 1.0 Dec 31, 2008
*/ */
abstract public class AbstractX4OPhaseHandler implements X4OPhaseHandler { public abstract class AbstractX4OPhaseHandler implements X4OPhaseHandler {
protected X4OPhase phase = null; protected X4OPhase phase = null;
protected List<X4OPhaseListener> X4OPhaseListeners = null; protected List<X4OPhaseListener> X4OPhaseListeners = null;

View file

@ -147,17 +147,15 @@ public class X4OEntityResolver implements EntityResolver {
} }
} }
if (basePath!=null && systemId!=null) { if (basePath!=null && systemId!=null && systemId.startsWith(basePath.toExternalForm())) {
if (systemId.startsWith(basePath.toExternalForm())) { logger.finer("Base reference basePath: "+basePath+" systemId: "+systemId);
logger.finer("Base reference basePath: "+basePath+" systemId: "+systemId); try {
try { InputSource in = new InputSource(new URL(systemId).openStream());
InputSource in = new InputSource(new URL(systemId).openStream()); in.setPublicId(publicId);
in.setPublicId(publicId); in.setSystemId(systemId);
in.setSystemId(systemId); return in;
return in; } catch (IOException e) {
} catch (IOException e) { throw new IOException("Could not open: "+systemId+" error: "+e.getMessage(),e);
throw new IOException("Could not open: "+systemId+" error: "+e.getMessage(),e);
}
} }
} }

View file

@ -37,7 +37,7 @@ public interface X4OParserSupport {
* Loads the language ElementLanguage to provide support. * Loads the language ElementLanguage to provide support.
* *
* @return Returns the ElementLanguage. * @return Returns the ElementLanguage.
* @throws X4OParserSupportException * @throws X4OParserSupportException Is thrown when supporting language could not be loaded.
*/ */
ElementLanguage loadElementLanguageSupport() throws X4OParserSupportException; ElementLanguage loadElementLanguageSupport() throws X4OParserSupportException;
} }

View file

@ -31,7 +31,7 @@ package org.x4o.xml.core;
*/ */
public enum X4OPhase { public enum X4OPhase {
/** Defines this meta startup phase */ /** Defines this meta startup phase. */
startupX4OPhase(true), startupX4OPhase(true),
/** Load all meta info of the language we are creating. */ /** Load all meta info of the language we are creating. */
@ -46,10 +46,10 @@ public enum X4OPhase {
/** Optional extra config phase for injecting bean instances into the EL context. */ /** Optional extra config phase for injecting bean instances into the EL context. */
configGlobalElBeansPhase(true), configGlobalElBeansPhase(true),
/** emty meta phase to refer to that sax is ready and element s are waiting for processing */ /** emty meta phase to refer to that sax is ready and element s are waiting for processing. */
startX4OPhase(true), startX4OPhase(true),
/** re runnable phases which config xml to beans and binds them together */ /** re runnable phases which config xml to beans and binds them together. */
configElementPhase, configElementPhase,
configElementInterfacePhase, configElementInterfacePhase,
configGlobalElementPhase, configGlobalElementPhase,
@ -76,10 +76,10 @@ public enum X4OPhase {
/** Rerun all needed phases for all element that requested it. */ /** Rerun all needed phases for all element that requested it. */
runDirtyElementLastPhase, runDirtyElementLastPhase,
/** Releases all Elements, which clears attributes and childeren etc.. */ /** Releases all Elements, which clears attributes and childeren etc. */
releasePhase(true), releasePhase(true),
/** write all phases and stuff to debug sax stream */ /** write all phases and stuff to debug sax stream. */
debugPhase; debugPhase;
/** Defines which phase we start, when context is created. */ /** Defines which phase we start, when context is created. */
@ -101,7 +101,7 @@ public enum X4OPhase {
private boolean runOnce = false; private boolean runOnce = false;
/** /**
* Creates an X4O Phase * Creates an X4O Phase.
*/ */
private X4OPhase() { private X4OPhase() {
} }

View file

@ -32,7 +32,7 @@ package org.x4o.xml.core;
public class X4OPhaseException extends Exception { public class X4OPhaseException extends Exception {
/** The serial version uid */ /** The serial version uid */
static final long serialVersionUID = 10l; static final long serialVersionUID = 10L;
private X4OPhaseHandler exceptionPhase = null; private X4OPhaseHandler exceptionPhase = null;
@ -68,7 +68,7 @@ public class X4OPhaseException extends Exception {
} }
/** /**
* Returns the X4OPhaseHandler which created this Exception * Returns the X4OPhaseHandler which created this Exception.
* @return An X4OPhaseHandler * @return An X4OPhaseHandler
*/ */
public X4OPhaseHandler getX4OPhaseHandler() { public X4OPhaseHandler getX4OPhaseHandler() {

View file

@ -561,10 +561,8 @@ public class X4OPhaseHandlerFactory {
Object value = valueString; Object value = valueString;
ElementClassAttribute attrClass = element.getElementClass().getElementClassAttributeByName(name); ElementClassAttribute attrClass = element.getElementClass().getElementClassAttributeByName(name);
if (attrClass!=null) { if (attrClass!=null) {
if (attrClass.getRunResolveEL()==null || attrClass.getRunResolveEL()) { if (attrClass.getRunResolveEL()==null || attrClass.getRunResolveEL() && attrParser.isELParameter(name, valueString, element)) {
if (attrParser.isELParameter(name, valueString, element)) { value = attrParser.getELParameterValue(valueString, element);
value = attrParser.getELParameterValue(valueString, element);
}
} }
if (attrClass.getRunConverters()==null || attrClass.getRunConverters()) { if (attrClass.getRunConverters()==null || attrClass.getRunConverters()) {
value = attrParser.getConvertedParameterValue(name, value, element); value = attrParser.getConvertedParameterValue(name, value, element);

View file

@ -39,10 +39,10 @@ import org.x4o.xml.element.ElementLanguage;
public interface X4OLanguageConfiguration { public interface X4OLanguageConfiguration {
/** Prefix where we load all language definitions from. */ /** Prefix where we load all language definitions from. */
public final static String DEFAULT_LANG_PATH_PREFIX = "META-INF"; public static final String DEFAULT_LANG_PATH_PREFIX = "META-INF";
/** The modules file to startup the language definition process. */ /** The modules file to startup the language definition process. */
public final static String DEFAULT_LANG_MODULES_FILE = "-modules.xml"; public static final String DEFAULT_LANG_MODULES_FILE = "-modules.xml";
/** /**
* Returns the language for which this ElementLanguage is created. * Returns the language for which this ElementLanguage is created.
@ -73,75 +73,75 @@ public interface X4OLanguageConfiguration {
// Core interfaces are also in class for text reference without instance // Core interfaces are also in class for text reference without instance
public Class<?> getDefaultElementNamespaceContext(); Class<?> getDefaultElementNamespaceContext();
public Class<?> getDefaultElementInterface(); Class<?> getDefaultElementInterface();
public Class<?> getDefaultElement(); Class<?> getDefaultElement();
public Class<?> getDefaultElementClass(); Class<?> getDefaultElementClass();
public Class<?> getDefaultElementClassAttribute(); Class<?> getDefaultElementClassAttribute();
// Other needed interfaces in class form also // Other needed interfaces in class form also
public Class<?> getDefaultElementLanguageModule(); Class<?> getDefaultElementLanguageModule();
public Class<?> getDefaultElementBodyComment(); Class<?> getDefaultElementBodyComment();
public Class<?> getDefaultElementBodyCharacters(); Class<?> getDefaultElementBodyCharacters();
public Class<?> getDefaultElementBodyWhitespace(); Class<?> getDefaultElementBodyWhitespace();
public Class<?> getDefaultElementNamespaceInstanceProvider(); Class<?> getDefaultElementNamespaceInstanceProvider();
public Class<?> getDefaultElementAttributeValueParser(); Class<?> getDefaultElementAttributeValueParser();
public Class<?> getDefaultElementObjectPropertyValue(); Class<?> getDefaultElementObjectPropertyValue();
public Class<?> getDefaultElementAttributeHandlerComparator(); Class<?> getDefaultElementAttributeHandlerComparator();
/** /**
* @return Returns the X4OLanguageVersionFilter which filters the best version to use. * @return Returns the X4OLanguageVersionFilter which filters the best version to use.
*/ */
public Class<?> getDefaultX4OLanguageVersionFilter(); Class<?> getDefaultX4OLanguageVersionFilter();
/** /**
* @return Returns the X4OLanguageLoader which loads languages into the element context. * @return Returns the X4OLanguageLoader which loads languages into the element context.
*/ */
public Class<?> getDefaultX4OLanguageLoader(); Class<?> getDefaultX4OLanguageLoader();
/** /**
* Creates and filles the inital element language used to store the language. * Creates and filles the inital element language used to store the language.
* @return The newly created ElementLanguage. * @return The newly created ElementLanguage.
*/ */
public ElementLanguage createElementLanguage(); ElementLanguage createElementLanguage();
/** /**
* @return Returns Map of SAX properties which are set. * @return Returns Map of SAX properties which are set.
*/ */
public Map<String,Object> getSAXParserProperties(); Map<String,Object> getSAXParserProperties();
/** /**
* @return Returns Map of SAX properties which are optional set. * @return Returns Map of SAX properties which are optional set.
*/ */
public Map<String,Object> getSAXParserPropertiesOptional(); Map<String,Object> getSAXParserPropertiesOptional();
/** /**
* @return Returns Map of SAX features which are set on the xml parser. * @return Returns Map of SAX features which are set on the xml parser.
*/ */
public Map<String,Boolean> getSAXParserFeatures(); Map<String,Boolean> getSAXParserFeatures();
/** /**
* @return Returns Map of SAX features which are optional set. * @return Returns Map of SAX features which are optional set.
*/ */
public Map<String, Boolean> getSAXParserFeaturesOptional(); Map<String, Boolean> getSAXParserFeaturesOptional();
/** /**
* @return Returns List of SAX features which are required for xml parsing. * @return Returns List of SAX features which are required for xml parsing.
*/ */
public List<String> getSAXParserFeaturesRequired(); List<String> getSAXParserFeaturesRequired();
/** /**
* @return Returns null or an X4ODebugWriter to write parsing steps and debug data to. * @return Returns null or an X4ODebugWriter to write parsing steps and debug data to.
*/ */
public X4ODebugWriter getX4ODebugWriter(); X4ODebugWriter getX4ODebugWriter();
/** /**
* @return Returns true if this config has a debug writer. * @return Returns true if this config has a debug writer.
*/ */
public boolean hasX4ODebugWriter(); boolean hasX4ODebugWriter();
/** /**
* @param debugWriter The debug writer to set * @param debugWriter The debug writer to set
*/ */
public void setX4ODebugWriter(X4ODebugWriter debugWriter); void setX4ODebugWriter(X4ODebugWriter debugWriter);
} }

View file

@ -31,36 +31,36 @@ package org.x4o.xml.core.config;
*/ */
public class X4OLanguagePropertyKeys { public class X4OLanguagePropertyKeys {
public final static String LANGUAGE_NAME = X4OLanguageProperty.LANGUAGE_NAME.toUri(); public static final String LANGUAGE_NAME = X4OLanguageProperty.LANGUAGE_NAME.toUri();
public final static String LANGUAGE_VERSION = X4OLanguageProperty.LANGUAGE_VERSION.toUri(); public static final String LANGUAGE_VERSION = X4OLanguageProperty.LANGUAGE_VERSION.toUri();
public final static String DEBUG_OUTPUT_STREAM = X4OLanguageProperty.DEBUG_OUTPUT_STREAM.toUri(); public static final String DEBUG_OUTPUT_STREAM = X4OLanguageProperty.DEBUG_OUTPUT_STREAM.toUri();
public final static String DEBUG_OUTPUT_HANDLER = X4OLanguageProperty.DEBUG_OUTPUT_HANDLER.toUri(); public static final String DEBUG_OUTPUT_HANDLER = X4OLanguageProperty.DEBUG_OUTPUT_HANDLER.toUri();
public final static String DEBUG_OUTPUT_ELD_PARSER = X4OLanguageProperty.DEBUG_OUTPUT_ELD_PARSER.toUri(); public static final String DEBUG_OUTPUT_ELD_PARSER = X4OLanguageProperty.DEBUG_OUTPUT_ELD_PARSER.toUri();
public final static String INPUT_BUFFER_SIZE = X4OLanguageProperty.INPUT_BUFFER_SIZE.toUri(); public static final String INPUT_BUFFER_SIZE = X4OLanguageProperty.INPUT_BUFFER_SIZE.toUri();
public final static String INPUT_EMPTY_NAMESPACE_URI = X4OLanguageProperty.INPUT_EMPTY_NAMESPACE_URI.toUri(); public static final String INPUT_EMPTY_NAMESPACE_URI = X4OLanguageProperty.INPUT_EMPTY_NAMESPACE_URI.toUri();
public final static String INPUT_SOURCE_STREAM = X4OLanguageProperty.INPUT_SOURCE_STREAM.toUri(); public static final String INPUT_SOURCE_STREAM = X4OLanguageProperty.INPUT_SOURCE_STREAM.toUri();
public final static String INPUT_SOURCE_ENCODING = X4OLanguageProperty.INPUT_SOURCE_ENCODING.toUri(); public static final String INPUT_SOURCE_ENCODING = X4OLanguageProperty.INPUT_SOURCE_ENCODING.toUri();
public final static String INPUT_SOURCE_OBJECT = X4OLanguageProperty.INPUT_SOURCE_OBJECT.toUri(); public static final String INPUT_SOURCE_OBJECT = X4OLanguageProperty.INPUT_SOURCE_OBJECT.toUri();
public final static String INPUT_SOURCE_SYSTEM_ID = X4OLanguageProperty.INPUT_SOURCE_SYSTEM_ID.toUri(); public static final String INPUT_SOURCE_SYSTEM_ID = X4OLanguageProperty.INPUT_SOURCE_SYSTEM_ID.toUri();
public final static String INPUT_SOURCE_BASE_PATH = X4OLanguageProperty.INPUT_SOURCE_BASE_PATH.toUri(); public static final String INPUT_SOURCE_BASE_PATH = X4OLanguageProperty.INPUT_SOURCE_BASE_PATH.toUri();
public final static String CONFIG_ERROR_HANDLER = X4OLanguageProperty.CONFIG_ERROR_HANDLER.toUri(); public static final String CONFIG_ERROR_HANDLER = X4OLanguageProperty.CONFIG_ERROR_HANDLER.toUri();
public final static String CONFIG_ENTITY_RESOLVER = X4OLanguageProperty.CONFIG_ENTITY_RESOLVER.toUri(); public static final String CONFIG_ENTITY_RESOLVER = X4OLanguageProperty.CONFIG_ENTITY_RESOLVER.toUri();
public final static String EL_BEAN_INSTANCE_MAP = X4OLanguageProperty.EL_BEAN_INSTANCE_MAP.toUri(); public static final String EL_BEAN_INSTANCE_MAP = X4OLanguageProperty.EL_BEAN_INSTANCE_MAP.toUri();
public final static String EL_FACTORY_INSTANCE = X4OLanguageProperty.EL_FACTORY_INSTANCE.toUri(); public static final String EL_FACTORY_INSTANCE = X4OLanguageProperty.EL_FACTORY_INSTANCE.toUri();
public final static String PHASE_STOP_AFTER = X4OLanguageProperty.PHASE_STOP_AFTER.toUri(); public static final String PHASE_STOP_AFTER = X4OLanguageProperty.PHASE_STOP_AFTER.toUri();
public final static String PHASE_SKIP_RELEASE = X4OLanguageProperty.PHASE_SKIP_RELEASE.toUri(); public static final String PHASE_SKIP_RELEASE = X4OLanguageProperty.PHASE_SKIP_RELEASE.toUri();
public final static String PHASE_SKIP_RUN = X4OLanguageProperty.PHASE_SKIP_RUN.toUri(); public static final String PHASE_SKIP_RUN = X4OLanguageProperty.PHASE_SKIP_RUN.toUri();
public final static String PHASE_SKIP_SIBLINGS = X4OLanguageProperty.PHASE_SKIP_SIBLINGS.toUri(); public static final String PHASE_SKIP_SIBLINGS = X4OLanguageProperty.PHASE_SKIP_SIBLINGS.toUri();
public final static String VALIDATION_SCHEMA_PATH = X4OLanguageProperty.VALIDATION_SCHEMA_PATH.toUri(); public static final String VALIDATION_SCHEMA_PATH = X4OLanguageProperty.VALIDATION_SCHEMA_PATH.toUri();
public final static String VALIDATION_INPUT = X4OLanguageProperty.VALIDATION_INPUT.toUri(); public static final String VALIDATION_INPUT = X4OLanguageProperty.VALIDATION_INPUT.toUri();
public final static String VALIDATION_INPUT_XSD = X4OLanguageProperty.VALIDATION_INPUT_XSD.toUri(); public static final String VALIDATION_INPUT_XSD = X4OLanguageProperty.VALIDATION_INPUT_XSD.toUri();
public final static String VALIDATION_ELD = X4OLanguageProperty.VALIDATION_ELD.toUri(); public static final String VALIDATION_ELD = X4OLanguageProperty.VALIDATION_ELD.toUri();
public final static String VALIDATION_ELD_XSD = X4OLanguageProperty.VALIDATION_ELD_XSD.toUri(); public static final String VALIDATION_ELD_XSD = X4OLanguageProperty.VALIDATION_ELD_XSD.toUri();
} }

View file

@ -42,6 +42,11 @@ public class EldModuleLoader implements ElementLanguageModuleLoader {
private String eldResource = null; private String eldResource = null;
private boolean isEldCore = false; private boolean isEldCore = false;
/**
* Creates an ELD/CEL module loader.
* @param eldResource The resource to load.
* @param isEldCore If true then load CEL else load ELD.
*/
public EldModuleLoader(String eldResource,boolean isEldCore) { public EldModuleLoader(String eldResource,boolean isEldCore) {
if (eldResource==null) { if (eldResource==null) {
throw new NullPointerException("Can't load null eld resource."); throw new NullPointerException("Can't load null eld resource.");
@ -52,6 +57,9 @@ public class EldModuleLoader implements ElementLanguageModuleLoader {
} }
/** /**
* Loads the ELD language into the module.
* @param elementLanguage The langauge to load for.
* @param elementLanguageModule The module to load it in.
* @see org.x4o.xml.element.ElementLanguageModuleLoader#loadLanguageModule(org.x4o.xml.element.ElementLanguage, org.x4o.xml.element.ElementLanguageModule) * @see org.x4o.xml.element.ElementLanguageModuleLoader#loadLanguageModule(org.x4o.xml.element.ElementLanguage, org.x4o.xml.element.ElementLanguageModule)
*/ */
public void loadLanguageModule(ElementLanguage elementLanguage,ElementLanguageModule elementLanguageModule) throws ElementLanguageModuleLoaderException { public void loadLanguageModule(ElementLanguage elementLanguage,ElementLanguageModule elementLanguageModule) throws ElementLanguageModuleLoaderException {

View file

@ -59,22 +59,28 @@ import org.x4o.xml.impl.DefaultElementClass;
public class EldModuleLoaderCore implements ElementLanguageModuleLoader { public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
private Logger logger = null; private Logger logger = null;
private static final String _CEL_XMLNS = "http://cel.x4o.org/xml/ns/"; private static final String PP_CEL_XMLNS = "http://cel.x4o.org/xml/ns/";
private static final String _CEL_CORE = "cel-core"; private static final String PP_CEL_XSD_FILE = "-1.0.xsd";
private static final String _CEL_ROOT = "cel-root"; private static final String CEL_CORE = "cel-core";
private static final String _CEL_XSD_FILE = "-1.0.xsd"; private static final String CEL_ROOT = "cel-root";
private static final String CEL_CORE_URI = _CEL_XMLNS+_CEL_CORE; private static final String CEL_CORE_URI = PP_CEL_XMLNS+CEL_CORE;
private static final String CEL_ROOT_URI = _CEL_XMLNS+_CEL_ROOT; private static final String CEL_ROOT_URI = PP_CEL_XMLNS+CEL_ROOT;
private static final String CEL_CORE_XSD_URI = CEL_CORE_URI+_CEL_XSD_FILE; private static final String CEL_CORE_XSD_URI = CEL_CORE_URI+PP_CEL_XSD_FILE;
private static final String CEL_ROOT_XSD_URI = CEL_ROOT_URI+_CEL_XSD_FILE; private static final String CEL_ROOT_XSD_URI = CEL_ROOT_URI+PP_CEL_XSD_FILE;
private static final String CEL_CORE_XSD_FILE = _CEL_CORE+_CEL_XSD_FILE; private static final String CEL_CORE_XSD_FILE = CEL_CORE+PP_CEL_XSD_FILE;
private static final String CEL_ROOT_XSD_FILE = _CEL_ROOT+_CEL_XSD_FILE; private static final String CEL_ROOT_XSD_FILE = CEL_ROOT+PP_CEL_XSD_FILE;
/**
* Creates the CEL module loader.
*/
public EldModuleLoaderCore() { public EldModuleLoaderCore() {
logger = Logger.getLogger(EldModuleLoaderCore.class.getName()); logger = Logger.getLogger(EldModuleLoaderCore.class.getName());
} }
/** /**
* Loads the CEL language into the module.
* @param elementLanguage The langauge to load for.
* @param elementLanguageModule The module to load it in.
* @see org.x4o.xml.element.ElementLanguageModuleLoader#loadLanguageModule(org.x4o.xml.element.ElementLanguage, org.x4o.xml.element.ElementLanguageModule) * @see org.x4o.xml.element.ElementLanguageModuleLoader#loadLanguageModule(org.x4o.xml.element.ElementLanguage, org.x4o.xml.element.ElementLanguageModule)
*/ */
public void loadLanguageModule(ElementLanguage elementLanguage,ElementLanguageModule elementLanguageModule) throws ElementLanguageModuleLoaderException { public void loadLanguageModule(ElementLanguage elementLanguage,ElementLanguageModule elementLanguageModule) throws ElementLanguageModuleLoaderException {
@ -137,7 +143,9 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e); throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
} }
try { try {
namespace.setElementNamespaceInstanceProvider((ElementNamespaceInstanceProvider)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider())); namespace.setElementNamespaceInstanceProvider((ElementNamespaceInstanceProvider)
X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider())
);
} catch (Exception e) { } catch (Exception e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e); throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
} }
@ -145,7 +153,7 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
namespace.setUri(CEL_CORE_URI); namespace.setUri(CEL_CORE_URI);
namespace.setSchemaUri(CEL_CORE_XSD_URI); namespace.setSchemaUri(CEL_CORE_XSD_URI);
namespace.setSchemaResource(CEL_CORE_XSD_FILE); namespace.setSchemaResource(CEL_CORE_XSD_FILE);
namespace.setSchemaPrefix(_CEL_CORE); namespace.setSchemaPrefix(CEL_CORE);
logger.finer("Loading elementClassList size: "+elementClassList.size()); logger.finer("Loading elementClassList size: "+elementClassList.size());
for (ElementClass ecL:elementClassList) { for (ElementClass ecL:elementClassList) {
@ -174,7 +182,9 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e); throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
} }
try { try {
namespace.setElementNamespaceInstanceProvider((ElementNamespaceInstanceProvider)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider())); namespace.setElementNamespaceInstanceProvider((ElementNamespaceInstanceProvider)
X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider())
);
} catch (Exception e) { } catch (Exception e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e); throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
} }
@ -182,7 +192,7 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
namespace.setUri(CEL_ROOT_URI); namespace.setUri(CEL_ROOT_URI);
namespace.setSchemaUri(CEL_ROOT_XSD_URI); namespace.setSchemaUri(CEL_ROOT_XSD_URI);
namespace.setSchemaResource(CEL_ROOT_XSD_FILE); namespace.setSchemaResource(CEL_ROOT_XSD_FILE);
namespace.setSchemaPrefix(_CEL_ROOT); namespace.setSchemaPrefix(CEL_ROOT);
namespace.addElementClass(new DefaultElementClass("module",elementLanguage.getLanguageConfiguration().getDefaultElementLanguageModule(),ModuleElement.class)); namespace.addElementClass(new DefaultElementClass("module",elementLanguage.getLanguageConfiguration().getDefaultElementLanguageModule(),ModuleElement.class));
namespace.setLanguageRoot(true); // Only define single language root so xsd is (mostly) not cicle import. namespace.setLanguageRoot(true); // Only define single language root so xsd is (mostly) not cicle import.
try { try {

View file

@ -26,6 +26,7 @@ package org.x4o.xml.eld;
import org.x4o.xml.core.X4ODriver; import org.x4o.xml.core.X4ODriver;
import org.x4o.xml.core.X4OParser; import org.x4o.xml.core.X4OParser;
import org.x4o.xml.core.config.X4OLanguageProperty; import org.x4o.xml.core.config.X4OLanguageProperty;
import org.x4o.xml.core.config.X4OLanguagePropertyKeys;
import org.x4o.xml.element.ElementLanguage; import org.x4o.xml.element.ElementLanguage;
import org.x4o.xml.element.ElementLanguageModule; import org.x4o.xml.element.ElementLanguageModule;
@ -48,47 +49,57 @@ public class EldParser extends X4OParser {
/** Defines the identifier of the 'Core Element Language' language. */ /** Defines the identifier of the 'Core Element Language' language. */
public static final String CEL_LANGUAGE = "cel"; public static final String CEL_LANGUAGE = "cel";
protected EldParser() { /** The EL key to access the parent language configuration. */
this(false); public static final String EL_PARENT_LANGUAGE_CONFIGURATION = "parentLanguageConfiguration";
}
/** The EL key to access the parent language module. */
public static final String EL_PARENT_ELEMENT_LANGUAGE_MODULE = "parentElementLanguageModule";
/** The EL key to access the parent language element langauge. */
public static final String EL_PARENT_LANGUAGE_ELEMENT_LANGUAGE = "parentLanguageElementLanguage";
/**
* Creates an Eld language parser for the language support.
* @param isEldCore If true then langauge is not eld but cel.
*/
protected EldParser(boolean isEldCore) { protected EldParser(boolean isEldCore) {
super(isEldCore?CEL_LANGUAGE:ELD_LANGUAGE,ELD_VERSION); super(isEldCore?CEL_LANGUAGE:ELD_LANGUAGE,ELD_VERSION);
} }
/** /**
* getDriver for unit tests * Returns the X4ODriver object.
* @return The X4ODriver.
*/ */
protected X4ODriver getDriver() { protected X4ODriver getDriver() {
return super.getDriver(); X4ODriver driver = super.getDriver();
// FAKE operation to make PMD happy as it does not see that "Overriding method merely calls super"
// this method is here only for visibility for unit tests of this package.
driver.getProperty(X4OLanguagePropertyKeys.LANGUAGE_NAME);
return driver;
} }
/** /**
* Start the second x4o parsing for eld files. * Creates the ELD x4o language parser.
* @param elementLanguage The elementLanguage to fill. * @param elementLanguage The elementLanguage to fill.
* @param elementLanguageModule The elementLanguageModule from to fill. * @param elementLanguageModule The elementLanguageModule from to fill.
*/ */
public EldParser(ElementLanguage elementLanguage,ElementLanguageModule elementLanguageModule) { public EldParser(ElementLanguage elementLanguage,ElementLanguageModule elementLanguageModule) {
this(false); this(elementLanguage,elementLanguageModule,false);
if (elementLanguage.getLanguageConfiguration().getLanguagePropertyBoolean(X4OLanguageProperty.DEBUG_OUTPUT_ELD_PARSER)) {
getDriver().getElementLanguage().getLanguageConfiguration().setX4ODebugWriter(elementLanguage.getLanguageConfiguration().getX4ODebugWriter()); // move to ..
}
addELBeanInstance(PARENT_LANGUAGE_CONFIGURATION, elementLanguage.getLanguageConfiguration());
addELBeanInstance(PARENT_LANGUAGE_ELEMENT_LANGUAGE, elementLanguage);
addELBeanInstance(PARENT_ELEMENT_LANGUAGE_MODULE, elementLanguageModule);
} }
/**
* Creates the ELD or CEL x4o language parser.
* @param elementLanguage The elementLanguage to fill.
* @param elementLanguageModule The elementLanguageModule from to fill.
* @param isEldCore If true then langauge is not eld but cel.
*/
public EldParser(ElementLanguage elementLanguage,ElementLanguageModule elementLanguageModule,boolean isEldCore) { public EldParser(ElementLanguage elementLanguage,ElementLanguageModule elementLanguageModule,boolean isEldCore) {
this(isEldCore); this(isEldCore);
if (elementLanguage.getLanguageConfiguration().getLanguagePropertyBoolean(X4OLanguageProperty.DEBUG_OUTPUT_ELD_PARSER)) { if (elementLanguage.getLanguageConfiguration().getLanguagePropertyBoolean(X4OLanguageProperty.DEBUG_OUTPUT_ELD_PARSER)) {
getDriver().getElementLanguage().getLanguageConfiguration().setX4ODebugWriter(elementLanguage.getLanguageConfiguration().getX4ODebugWriter()); getDriver().getElementLanguage().getLanguageConfiguration().setX4ODebugWriter(elementLanguage.getLanguageConfiguration().getX4ODebugWriter());
} }
addELBeanInstance(PARENT_LANGUAGE_CONFIGURATION, elementLanguage.getLanguageConfiguration()); addELBeanInstance(EL_PARENT_LANGUAGE_CONFIGURATION, elementLanguage.getLanguageConfiguration());
addELBeanInstance(PARENT_LANGUAGE_ELEMENT_LANGUAGE, elementLanguage); addELBeanInstance(EL_PARENT_LANGUAGE_ELEMENT_LANGUAGE, elementLanguage);
addELBeanInstance(PARENT_ELEMENT_LANGUAGE_MODULE, elementLanguageModule); addELBeanInstance(EL_PARENT_ELEMENT_LANGUAGE_MODULE, elementLanguageModule);
} }
public final static String PARENT_LANGUAGE_CONFIGURATION = "parentLanguageConfiguration";
public final static String PARENT_ELEMENT_LANGUAGE_MODULE = "parentElementLanguageModule";
public final static String PARENT_LANGUAGE_ELEMENT_LANGUAGE = "parentLanguageElementLanguage";
} }

View file

@ -38,6 +38,7 @@ public class EldParserSupport implements X4OParserSupport {
/** /**
* Loads the ElementLanguage of this language parser for support. * Loads the ElementLanguage of this language parser for support.
* @return The loaded ElementLanguage. * @return The loaded ElementLanguage.
* @throws X4OParserSupportException When support language could not be loaded.
* @see org.x4o.xml.core.X4OParserSupport#loadElementLanguageSupport() * @see org.x4o.xml.core.X4OParserSupport#loadElementLanguageSupport()
*/ */
public ElementLanguage loadElementLanguageSupport() throws X4OParserSupportException { public ElementLanguage loadElementLanguageSupport() throws X4OParserSupportException {

View file

@ -38,6 +38,7 @@ public class EldParserSupportCore implements X4OParserSupport {
/** /**
* Loads the ElementLanguage of this language parser for support. * Loads the ElementLanguage of this language parser for support.
* @return The loaded ElementLanguage. * @return The loaded ElementLanguage.
* @throws X4OParserSupportException When support language could not be loaded.
* @see org.x4o.xml.core.X4OParserSupport#loadElementLanguageSupport() * @see org.x4o.xml.core.X4OParserSupport#loadElementLanguageSupport()
*/ */
public ElementLanguage loadElementLanguageSupport() throws X4OParserSupportException { public ElementLanguage loadElementLanguageSupport() throws X4OParserSupportException {

View file

@ -84,7 +84,7 @@ public class ElementModuleBindingHandler extends AbstractElementBindingHandler
if (m==null) { if (m==null) {
return; return;
} }
ElementLanguage x4oParsingContext = (ElementLanguage)m.get(EldParser.PARENT_LANGUAGE_ELEMENT_LANGUAGE); ElementLanguage x4oParsingContext = (ElementLanguage)m.get(EldParser.EL_PARENT_LANGUAGE_ELEMENT_LANGUAGE);
//ElementLanguageModule elementLanguageModule = (ElementLanguageModule)m.get(EldParser.PARENT_ELEMENT_LANGUAGE_MODULE); //ElementLanguageModule elementLanguageModule = (ElementLanguageModule)m.get(EldParser.PARENT_ELEMENT_LANGUAGE_MODULE);
ElementLanguageModule elementLanguageModule = (ElementLanguageModule)parentObject; ElementLanguageModule elementLanguageModule = (ElementLanguageModule)parentObject;
if (x4oParsingContext==null) { if (x4oParsingContext==null) {

View file

@ -63,6 +63,5 @@ public class ElementNamespaceContextBindingHandler extends AbstractElementBindin
if (childObject instanceof ElementClass) { if (childObject instanceof ElementClass) {
parent.addElementClass((ElementClass)childObject); parent.addElementClass((ElementClass)childObject);
} }
return;
} }
} }

View file

@ -42,6 +42,7 @@ public class ModuleElement extends AbstractElement {
/** /**
* @see org.x4o.xml.element.AbstractElement#doElementStart() * @see org.x4o.xml.element.AbstractElement#doElementStart()
* @throws ElementException When module element is used and non-root element.
*/ */
@Override @Override
public void doElementStart() throws ElementException { public void doElementStart() throws ElementException {
@ -53,7 +54,7 @@ public class ModuleElement extends AbstractElement {
if (m==null) { if (m==null) {
return; return;
} }
ElementLanguageModule elementLanguageModule = (ElementLanguageModule)m.get(EldParser.PARENT_ELEMENT_LANGUAGE_MODULE); ElementLanguageModule elementLanguageModule = (ElementLanguageModule)m.get(EldParser.EL_PARENT_ELEMENT_LANGUAGE_MODULE);
setElementObject(elementLanguageModule); setElementObject(elementLanguageModule);
} }
} }

View file

@ -37,6 +37,7 @@ public class SkipPhaseElement extends AbstractElement {
/** /**
* @see org.x4o.xml.element.AbstractElement#doElementEnd() * @see org.x4o.xml.element.AbstractElement#doElementEnd()
* @throws ElementException Gets thrown when name is not set or element object is not an element class instance.
*/ */
@Override @Override
public void doElementEnd() throws ElementException { public void doElementEnd() throws ElementException {

View file

@ -297,7 +297,11 @@ public class EldXsdXmlWriter {
} }
if (ec.getAutoAttributes()!=null && ec.getAutoAttributes()==false) { if (ec.getAutoAttributes()!=null && ec.getAutoAttributes()==false) {
// oke // oke, reverse this if and rm whitespace.
char[] msg;
msg = " ".toCharArray();
xmlWriter.ignorableWhitespace(msg,0,msg.length);
} else { } else {
if (ec.getObjectClass()!=null) { if (ec.getObjectClass()!=null) {
@ -362,19 +366,13 @@ public class EldXsdXmlWriter {
List<String> refElements = new ArrayList<String>(20); List<String> refElements = new ArrayList<String>(20);
for (ElementClass checkClass:ns.getElementClasses()) { for (ElementClass checkClass:ns.getElementClasses()) {
List<String> parents = checkClass.getElementParents(nsWrite.getUri()); List<String> parents = checkClass.getElementParents(nsWrite.getUri());
if (parents!=null) { if (parents!=null && parents.contains(ec.getTag())) {
if (parents!=null) { refElements.add(checkClass.getTag());
if (parents.contains(ec.getTag())) {
refElements.add(checkClass.getTag());
}
}
} }
if (nsWrite.getUri().equals(ns.getUri())) { if (nsWrite.getUri().equals(ns.getUri())) {
parents = checkClass.getElementParents(""); parents = checkClass.getElementParents("");
if (parents!=null) { if (parents!=null && parents.contains(ec.getTag())) {
if (parents.contains(ec.getTag())) { refElements.add(checkClass.getTag());
refElements.add(checkClass.getTag());
}
} }
} }
if (ec.getObjectClass()==null) { if (ec.getObjectClass()==null) {

View file

@ -36,7 +36,7 @@ import org.x4o.xml.core.config.X4OLanguageClassLoader;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Aug 8, 2005 * @version 1.0 Aug 8, 2005
*/ */
abstract public class AbstractElement implements Element { public abstract class AbstractElement implements Element {
/** The parent Element */ /** The parent Element */
private Element parent = null; private Element parent = null;

View file

@ -32,7 +32,7 @@ import java.util.List;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Aug 10, 2006 * @version 1.0 Aug 10, 2006
*/ */
abstract public class AbstractElementAttributeHandler extends AbstractElementConfigurator implements ElementAttributeHandler { public abstract class AbstractElementAttributeHandler extends AbstractElementConfigurator implements ElementAttributeHandler {
private String attributeName = null; private String attributeName = null;
private List<String> nextAttributes = new ArrayList<String>(2); private List<String> nextAttributes = new ArrayList<String>(2);

View file

@ -30,6 +30,6 @@ package org.x4o.xml.element;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Apr 16, 2006 * @version 1.0 Apr 16, 2006
*/ */
abstract public class AbstractElementBindingHandler extends AbstractElementMetaBase implements ElementBindingHandler { public abstract class AbstractElementBindingHandler extends AbstractElementMetaBase implements ElementBindingHandler {
} }

View file

@ -34,7 +34,7 @@ import java.util.Map;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Aug 11, 2005 * @version 1.0 Aug 11, 2005
*/ */
abstract public class AbstractElementClass extends AbstractElementClassBase implements ElementClass { public abstract class AbstractElementClass extends AbstractElementClassBase implements ElementClass {
private String tag = null; private String tag = null;
private Class<?> objectClass = null; private Class<?> objectClass = null;

View file

@ -34,7 +34,7 @@ import org.x4o.xml.conv.ObjectConverter;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Jan 19, 2012 * @version 1.0 Jan 19, 2012
*/ */
abstract public class AbstractElementClassAttribute extends AbstractElementMetaBase implements ElementClassAttribute { public abstract class AbstractElementClassAttribute extends AbstractElementMetaBase implements ElementClassAttribute {
private String name = null; private String name = null;
private ObjectConverter objectConverter = null; private ObjectConverter objectConverter = null;

View file

@ -35,7 +35,7 @@ import java.util.Map;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Jan 19, 2012 * @version 1.0 Jan 19, 2012
*/ */
abstract public class AbstractElementClassBase extends AbstractElementMetaBase implements ElementClassBase { public abstract class AbstractElementClassBase extends AbstractElementMetaBase implements ElementClassBase {
private Map<String,ElementClassAttribute> elementClassAttributes = null; private Map<String,ElementClassAttribute> elementClassAttributes = null;
private List<ElementConfigurator> elementConfigurators = null; private List<ElementConfigurator> elementConfigurators = null;

View file

@ -30,7 +30,7 @@ package org.x4o.xml.element;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Jan 18, 2007 * @version 1.0 Jan 18, 2007
*/ */
abstract public class AbstractElementConfigurator extends AbstractElementMetaBase implements ElementConfigurator { public abstract class AbstractElementConfigurator extends AbstractElementMetaBase implements ElementConfigurator {
/** Flag indicating that this is an config action and should run in runPhase */ /** Flag indicating that this is an config action and should run in runPhase */
private boolean configAction = false; private boolean configAction = false;

View file

@ -32,7 +32,7 @@ import java.util.List;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Apr 15, 2008 * @version 1.0 Apr 15, 2008
*/ */
abstract public class AbstractElementInterface extends AbstractElementClassBase implements ElementInterface { public abstract class AbstractElementInterface extends AbstractElementClassBase implements ElementInterface {
private Class<?> interfaceClass = null; private Class<?> interfaceClass = null;
private List<ElementBindingHandler> elementBindingHandlers = null; private List<ElementBindingHandler> elementBindingHandlers = null;

View file

@ -34,7 +34,6 @@ import javax.el.ExpressionFactory;
import org.x4o.xml.core.X4OPhase; import org.x4o.xml.core.X4OPhase;
import org.x4o.xml.core.config.X4OLanguageConfiguration; import org.x4o.xml.core.config.X4OLanguageConfiguration;
import org.x4o.xml.element.ElementBindingHandler;
/** /**
* An AbstractElementLanguage. * An AbstractElementLanguage.
@ -42,7 +41,7 @@ import org.x4o.xml.element.ElementBindingHandler;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Aug 20, 2005 * @version 1.0 Aug 20, 2005
*/ */
abstract public class AbstractElementLanguage implements ElementLanguageLocal { public abstract class AbstractElementLanguage implements ElementLanguageLocal {
private Logger logger = null; private Logger logger = null;
private ExpressionFactory expressionFactory = null; private ExpressionFactory expressionFactory = null;

View file

@ -29,18 +29,13 @@ import java.util.HashMap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.x4o.xml.element.ElementAttributeHandler;
import org.x4o.xml.element.ElementBindingHandler;
import org.x4o.xml.element.ElementConfigurator;
import org.x4o.xml.element.ElementLanguage;
/** /**
* An AbstractElementLanguageModule. * An AbstractElementLanguageModule.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Aug 2, 2012 * @version 1.0 Aug 2, 2012
*/ */
abstract public class AbstractElementLanguageModule extends AbstractElementMetaBase implements ElementLanguageModule { public abstract class AbstractElementLanguageModule extends AbstractElementMetaBase implements ElementLanguageModule {
private Logger logger = null; private Logger logger = null;

View file

@ -30,7 +30,7 @@ package org.x4o.xml.element;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Jan 18, 2009 * @version 1.0 Jan 18, 2009
*/ */
abstract public class AbstractElementMetaBase implements ElementMetaBase { public abstract class AbstractElementMetaBase implements ElementMetaBase {
/** The description */ /** The description */
private String id = null; private String id = null;

View file

@ -33,7 +33,7 @@ import java.util.Map;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Oct 28, 2009 * @version 1.0 Oct 28, 2009
*/ */
abstract public class AbstractElementNamespaceContext extends AbstractElementMetaBase implements ElementNamespaceContext { public abstract class AbstractElementNamespaceContext extends AbstractElementMetaBase implements ElementNamespaceContext {
private ElementNamespaceInstanceProvider elementNamespaceInstanceProvider = null; private ElementNamespaceInstanceProvider elementNamespaceInstanceProvider = null;
private String prefixMapping = null; private String prefixMapping = null;

View file

@ -24,7 +24,6 @@
package org.x4o.xml.element; package org.x4o.xml.element;
import org.x4o.xml.conv.ObjectConverterException; import org.x4o.xml.conv.ObjectConverterException;
import org.x4o.xml.element.Element;
/** /**
* Helper interface for setting properties. * Helper interface for setting properties.

View file

@ -23,8 +23,6 @@
package org.x4o.xml.element; package org.x4o.xml.element;
import org.x4o.xml.element.Element;
/** /**
* Bind ElementObjects together. * Bind ElementObjects together.
* *

View file

@ -33,6 +33,8 @@ package org.x4o.xml.element;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class ElementConfiguratorException extends ElementException { public class ElementConfiguratorException extends ElementException {
private ElementConfigurator elementConfigurator = null;
/** /**
* Creates an configurator exception. * Creates an configurator exception.
* @param config The ElementConfigurator. * @param config The ElementConfigurator.
@ -40,6 +42,7 @@ public class ElementConfiguratorException extends ElementException {
*/ */
public ElementConfiguratorException(ElementConfigurator config,String message) { public ElementConfiguratorException(ElementConfigurator config,String message) {
super(message); super(message);
this.elementConfigurator=config;
} }
/** /**
@ -50,6 +53,7 @@ public class ElementConfiguratorException extends ElementException {
*/ */
public ElementConfiguratorException(ElementConfigurator config,String message,Exception exception) { public ElementConfiguratorException(ElementConfigurator config,String message,Exception exception) {
super(message,exception); super(message,exception);
this.elementConfigurator=config;
} }
/** /**
@ -60,5 +64,14 @@ public class ElementConfiguratorException extends ElementException {
*/ */
public ElementConfiguratorException(ElementConfigurator config,String message,ElementException exception) { public ElementConfiguratorException(ElementConfigurator config,String message,ElementException exception) {
super(message,exception); super(message,exception);
this.elementConfigurator=config;
}
/**
* Gets the ElementConfigurator which has thrown this exception.
* @return The ElementConfigurator.
*/
public ElementConfigurator getElementConfigurator() {
return elementConfigurator;
} }
} }

View file

@ -91,7 +91,7 @@ public interface ElementLanguageModule extends ElementMetaBase {
List<ElementConfigurator> getGlobalElementConfigurators(); List<ElementConfigurator> getGlobalElementConfigurators();
/** /**
* Adds an ElementInterface * Adds an ElementInterface.
* @param elementInterface The elementInterface to add. * @param elementInterface The elementInterface to add.
*/ */
void addElementInterface(ElementInterface elementInterface); void addElementInterface(ElementInterface elementInterface);
@ -103,8 +103,8 @@ public interface ElementLanguageModule extends ElementMetaBase {
List<ElementInterface> getElementInterfaces(); List<ElementInterface> getElementInterfaces();
/** /**
* * Adds an namespace to this langauge module.
* @param elementNamespaceContext * @param elementNamespaceContext Adds an ElementNamespaceContext to this langauge module.
*/ */
void addElementNamespaceContext(ElementNamespaceContext elementNamespaceContext); void addElementNamespaceContext(ElementNamespaceContext elementNamespaceContext);

View file

@ -35,8 +35,10 @@ package org.x4o.xml.element;
public interface ElementLanguageModuleLoader { public interface ElementLanguageModuleLoader {
/** /**
* Starts the ElementProvider * Starts the ElementProvider.
* @throws ElementLanguageModuleLoaderException * @param elementLanguage The ElementLanguage to load for.
* @param elementLanguageModule The ElementLanguageModule to load it into.
* @throws ElementLanguageModuleLoaderException Gets thrown when modules could not be correctly loaded.
*/ */
void loadLanguageModule(ElementLanguage elementLanguage,ElementLanguageModule elementLanguageModule) throws ElementLanguageModuleLoaderException; void loadLanguageModule(ElementLanguage elementLanguage,ElementLanguageModule elementLanguageModule) throws ElementLanguageModuleLoaderException;
} }

View file

@ -38,7 +38,9 @@ public interface ElementLanguageModuleLoaderSibling extends ElementLanguageModul
/** /**
* Loads in the sibling language. * Loads in the sibling language.
* @throws ElementLanguageModuleLoaderException * @param elementLanguage The ElementLanguage for which we load an sibling.
* @param loader The loader to use to load the x4o languages.
* @throws X4OLanguageLoaderException Gets thrown when there is an error loading the sibling language.
*/ */
void loadLanguageSibling(ElementLanguage elementLanguage,X4OLanguageLoader loader) throws X4OLanguageLoaderException; void loadLanguageSibling(ElementLanguage elementLanguage,X4OLanguageLoader loader) throws X4OLanguageLoaderException;
} }

View file

@ -39,9 +39,22 @@ public interface ElementNamespaceContext extends ElementMetaBase {
//String getNamespaceResourceFile(); //String getNamespaceResourceFile();
//String getNamespaceLanguage(); //String getNamespaceLanguage();
/**
* Sets the prefix mapping.
* @param prefixMapping The prefix mapping to set.
*/
void setPrefixMapping(String prefixMapping); void setPrefixMapping(String prefixMapping);
/**
* Gets the set prefix mapping of this namespace.
* @return Returns the prefix mapping.
*/
String getPrefixMapping(); String getPrefixMapping();
/**
* Sets the elememen instance provider which creates the elements objects.
* @param elementNamespaceInstanceProvider The ElementNamespaceInstanceProvider to set.
*/
void setElementNamespaceInstanceProvider(ElementNamespaceInstanceProvider elementNamespaceInstanceProvider); void setElementNamespaceInstanceProvider(ElementNamespaceInstanceProvider elementNamespaceInstanceProvider);
/** /**
@ -132,7 +145,7 @@ public interface ElementNamespaceContext extends ElementMetaBase {
/** /**
* @return the schemaPrefix * @return the schemaPrefix
*/ */
public String getSchemaPrefix(); String getSchemaPrefix();
/** /**
* @param schemaPrefix the schemaPrefix to set * @param schemaPrefix the schemaPrefix to set

View file

@ -23,9 +23,6 @@
package org.x4o.xml.element; package org.x4o.xml.element;
import org.x4o.xml.element.Element;
/** /**
* Provides elements from tag.<br> * Provides elements from tag.<br>
* And ElementClass from a tag.<br> * And ElementClass from a tag.<br>

View file

@ -130,22 +130,18 @@ public class DefaultElementAttributeValueParser implements ElementAttributeValue
return true; // null element disables checks return true; // null element disables checks
} }
ElementClassAttribute attr = element.getElementClass().getElementClassAttributeByName(name); ElementClassAttribute attr = element.getElementClass().getElementClassAttributeByName(name);
if (attr!=null) { if (attr!=null && attr.getRunResolveEL()!=null && attr.getRunResolveEL()==false) {
if (attr.getRunResolveEL()!=null && attr.getRunResolveEL()==false) { logger.finest("Skipping EL parsing for: "+name);
logger.finest("Skipping EL parsing for: "+name); return false;
return false;
}
} }
for (ElementInterface ei:element.getElementLanguage().findElementInterfaces(element.getElementObject())) { for (ElementInterface ei:element.getElementLanguage().findElementInterfaces(element.getElementObject())) {
logger.finest("Found interface match checking disables el parameters."); logger.finest("Found interface match checking disables el parameters.");
attr = ei.getElementClassAttributeByName(name); attr = ei.getElementClassAttributeByName(name);
if (attr!=null) { if (attr!=null && attr.getRunResolveEL()!=null && attr.getRunResolveEL()==false) {
if (attr.getRunResolveEL()!=null && attr.getRunResolveEL()==false) { logger.finest("Skipping EL parsing for: "+name+" in interface element.");
logger.finest("Skipping EL parsing for: "+name+" in interface element."); return false;
return false;
}
} }
} }
return true; return true;

View file

@ -275,7 +275,7 @@ public class DefaultX4OLanguageConfiguration implements X4OLanguageConfiguration
contextInit.setExpressionFactory(configExpressionFactory()); contextInit.setExpressionFactory(configExpressionFactory());
} }
if (contextInit.getELContext()==null) { if (contextInit.getELContext()==null) {
contextInit.setELContext(new X4OELContext(this)); contextInit.setELContext(new X4OELContext());
} }
try { try {
if (contextInit.getElementAttributeValueParser()==null) { if (contextInit.getElementAttributeValueParser()==null) {
@ -300,14 +300,14 @@ public class DefaultX4OLanguageConfiguration implements X4OLanguageConfiguration
ExpressionFactory expressionFactory = (ExpressionFactory) expressionFactoryClass.newInstance(); ExpressionFactory expressionFactory = (ExpressionFactory) expressionFactoryClass.newInstance();
return expressionFactory; return expressionFactory;
} catch (Exception e) { } catch (Exception e) {
try {
Class<?> expressionFactoryClass = X4OLanguageClassLoader.loadClass("de.odysseus.el.ExpressionFactoryImpl");
ExpressionFactory expressionFactory = (ExpressionFactory) expressionFactoryClass.newInstance();
return expressionFactory;
} catch (Exception ee) {
throw new RuntimeException("Could not load ExpressionFactory tried: org.apache.el.ExpressionFactoryImpl and de.odysseus.el.ExpressionFactoryImpl but could not load one of them.");
}
} }
try {
Class<?> expressionFactoryClass = X4OLanguageClassLoader.loadClass("de.odysseus.el.ExpressionFactoryImpl");
ExpressionFactory expressionFactory = (ExpressionFactory) expressionFactoryClass.newInstance();
return expressionFactory;
} catch (Exception ee) {
}
throw new RuntimeException("Could not load ExpressionFactory tried: org.apache.el.ExpressionFactoryImpl and de.odysseus.el.ExpressionFactoryImpl but could not load one of them.");
} }
/** /**

View file

@ -126,6 +126,7 @@ public class DefaultX4OLanguageLoader implements X4OLanguageLoader {
} else if ("elb-resource".equals(key)) { } else if ("elb-resource".equals(key)) {
// todo // todo
logger.finer("elb-resources are not done yet.");
} else if ("sibling-loader".equals(key)) { } else if ("sibling-loader".equals(key)) {
try { try {
@ -169,25 +170,24 @@ public class DefaultX4OLanguageLoader implements X4OLanguageLoader {
while(e.hasMoreElements()) { while(e.hasMoreElements()) {
URL u = e.nextElement(); URL u = e.nextElement();
logMessage(elementLanguage,"Loading relative modules: "+u+" for: "+language); logMessage(elementLanguage,"Loading relative modules: "+u+" for: "+language);
loadModuleXml(u.openStream(),u.toString()); loadModuleXml(u.openStream());
} }
e = Thread.currentThread().getContextClassLoader().getResources("/"+buf.toString()); e = Thread.currentThread().getContextClassLoader().getResources("/"+buf.toString());
while(e.hasMoreElements()) { while(e.hasMoreElements()) {
URL u = e.nextElement(); URL u = e.nextElement();
logMessage(elementLanguage,"Loading root modules: "+u+" for: "+language); logMessage(elementLanguage,"Loading root modules: "+u+" for: "+language);
loadModuleXml(u.openStream(),u.toString()); loadModuleXml(u.openStream());
} }
} }
/** /**
* Parser xml inputstream to languge modules * Parser xml inputstream to languge modules
* @param in * @param in The inputstream to parser.
* @param resourceFile
* @throws IOException * @throws IOException
* @throws SAXException * @throws SAXException
*/ */
private void loadModuleXml(InputStream in,String resourceFile) throws IOException, SAXException { private void loadModuleXml(InputStream in) throws IOException, SAXException {
if (in==null) { if (in==null) {
throw new NullPointerException("Can't parse null input stream"); throw new NullPointerException("Can't parse null input stream");
} }

View file

@ -35,8 +35,6 @@ import javax.el.ListELResolver;
import javax.el.MapELResolver; import javax.el.MapELResolver;
import javax.el.VariableMapper; import javax.el.VariableMapper;
import org.x4o.xml.core.config.X4OLanguageConfiguration;
/** /**
* X4OELFunctionMapper simple EL context. * X4OELFunctionMapper simple EL context.
* *
@ -49,7 +47,7 @@ public class X4OELContext extends ELContext {
private FunctionMapper functionMapper = null; private FunctionMapper functionMapper = null;
private VariableMapper variableMapper = null; private VariableMapper variableMapper = null;
public X4OELContext(X4OLanguageConfiguration x4oParserConfig) { public X4OELContext(/* X4OLanguageConfiguration x4oParserConfig */) {
CompositeELResolver compositeELResolver = new CompositeELResolver(); CompositeELResolver compositeELResolver = new CompositeELResolver();
compositeELResolver.add(new X4OELResolver(new HashMap<Object, Object>(100))); compositeELResolver.add(new X4OELResolver(new HashMap<Object, Object>(100)));

View file

@ -130,49 +130,47 @@ public class XMLWriter extends DefaultHandler2 {
} }
if (uri!=null & "".equals(uri)==false) { if ((uri!=null & "".equals(uri)==false) && printedMappings.contains(uri)==false) {
if (printedMappings.contains(uri)==false) { String prefix = prefixMapping.get(uri);
String prefix = prefixMapping.get(uri); if (prefix==null) {
if (prefix==null) { throw new SAXException("preFixUri: "+uri+" is not started.");
throw new SAXException("preFixUri: "+uri+" is not started."); }
} printedMappings.add(uri);
printedMappings.add(uri);
startElement.append(' '); startElement.append(' ');
startElement.append("xmlns"); startElement.append("xmlns");
if ("".equals(prefix)==false) { if ("".equals(prefix)==false) {
startElement.append(':'); startElement.append(':');
startElement.append(prefix); startElement.append(prefix);
} }
startElement.append("=\""); startElement.append("=\"");
startElement.append(uri); startElement.append(uri);
startElement.append('"'); startElement.append('"');
boolean first = true; boolean first = true;
for (String uri2:prefixMapping.keySet()) { for (String uri2:prefixMapping.keySet()) {
if (printedMappings.contains(uri2)==false) { if (printedMappings.contains(uri2)==false) {
prefix = prefixMapping.get(uri2); prefix = prefixMapping.get(uri2);
if (prefix==null) { if (prefix==null) {
throw new SAXException("preFixUri: "+uri+" is not started."); throw new SAXException("preFixUri: "+uri+" is not started.");
}
printedMappings.add(uri2);
if (first) {
startElement.append('\n');
first = false;
}
startElement.append(' ');
startElement.append("xmlns");
if ("".equals(prefix)==false) {
startElement.append(':');
startElement.append(prefix);
}
startElement.append("=\"");
startElement.append(uri2);
startElement.append('"');
startElement.append('\n');
} }
printedMappings.add(uri2);
if (first) {
startElement.append('\n');
first = false;
}
startElement.append(' ');
startElement.append("xmlns");
if ("".equals(prefix)==false) {
startElement.append(':');
startElement.append(prefix);
}
startElement.append("=\"");
startElement.append(uri2);
startElement.append('"');
startElement.append('\n');
} }
} }
} }

View file

@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>x4o</artifactId> <artifactId>x4o</artifactId>
<groupId>org.x4o</groupId> <groupId>org.x4o</groupId>
<version>0.8.2-SNAPSHOT</version> <version>0.8.5-SNAPSHOT</version>
</parent> </parent>
<artifactId>x4o-elddoc</artifactId> <artifactId>x4o-elddoc</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>

View file

@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>x4o</artifactId> <artifactId>x4o</artifactId>
<groupId>org.x4o</groupId> <groupId>org.x4o</groupId>
<version>0.8.2-SNAPSHOT</version> <version>0.8.5-SNAPSHOT</version>
<relativePath>..</relativePath> <relativePath>..</relativePath>
</parent> </parent>
<artifactId>x4o-meta</artifactId> <artifactId>x4o-meta</artifactId>

View file

@ -39,12 +39,15 @@ import org.x4o.xml.element.ElementLanguageModuleLoaderSibling;
public class MetaLanguageSiblingLoader implements ElementLanguageModuleLoaderSibling { public class MetaLanguageSiblingLoader implements ElementLanguageModuleLoaderSibling {
/** Defines the identifier of the meta x4o language. */ /** Defines the identifier of the meta x4o language. */
public final static String META_LANGUAGE = "meta"; public static final String META_LANGUAGE = "meta";
/** Defines the version of the meta x4o language. */ /** Defines the version of the meta x4o language. */
public final static String META_LANGUAGE_VERSION = "1.0"; public static final String META_LANGUAGE_VERSION = "1.0";
/** /**
* Loads an ElementLanguageModule.
* @param elementLanguage The ElementLanguage to load for.
* @param elementLanguageModule The ElementLanguageModule to load into.
* @see org.x4o.xml.element.ElementLanguageModuleLoader#loadLanguageModule(org.x4o.xml.element.ElementLanguage, org.x4o.xml.element.ElementLanguageModule) * @see org.x4o.xml.element.ElementLanguageModuleLoader#loadLanguageModule(org.x4o.xml.element.ElementLanguage, org.x4o.xml.element.ElementLanguageModule)
*/ */
public void loadLanguageModule(ElementLanguage elementLanguage,ElementLanguageModule elementLanguageModule) throws ElementLanguageModuleLoaderException { public void loadLanguageModule(ElementLanguage elementLanguage,ElementLanguageModule elementLanguageModule) throws ElementLanguageModuleLoaderException {
@ -55,6 +58,9 @@ public class MetaLanguageSiblingLoader implements ElementLanguageModuleLoaderSib
} }
/** /**
* Loads an sibling language.
* @param elementLanguage The ElementLanguage to load for.
* @param loader The x4o language loader.
* @throws X4OLanguageLoaderException * @throws X4OLanguageLoaderException
* @see org.x4o.xml.element.ElementLanguageModuleLoaderSibling#loadLanguageSibling(org.x4o.xml.element.ElementLanguage, org.x4o.xml.core.config.X4OLanguageLoader) * @see org.x4o.xml.element.ElementLanguageModuleLoaderSibling#loadLanguageSibling(org.x4o.xml.element.ElementLanguage, org.x4o.xml.core.config.X4OLanguageLoader)
*/ */

View file

@ -23,7 +23,6 @@
package org.x4o.xml.meta.lang; package org.x4o.xml.meta.lang;
import java.lang.Comparable;
import java.util.Comparator; import java.util.Comparator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;

View file

@ -95,6 +95,7 @@ public class PropertyElement extends AbstractElement {
method.invoke(getParent().getElementObject(),new Object[]{name,value}); method.invoke(getParent().getElementObject(),new Object[]{name,value});
return; return;
} catch (Exception e) { } catch (Exception e) {
throw new ElementException("Could not invoke setproperty of "+method.getName()+" on: "+getParent().getElementObject(),e);
} }
} }
} }
@ -104,7 +105,7 @@ public class PropertyElement extends AbstractElement {
getElementLanguage().getElementObjectPropertyValue().setProperty(getParent().getElementObject(), name, value); getElementLanguage().getElementObjectPropertyValue().setProperty(getParent().getElementObject(), name, value);
return; return;
} catch (Exception e) { } catch (Exception e) {
throw new ElementException("could not set property on parent element object: "+name,e); throw new ElementException("Could not set property on parent element object: "+name,e);
} }
} }
} }

View file

@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>x4o</artifactId> <artifactId>x4o</artifactId>
<groupId>org.x4o</groupId> <groupId>org.x4o</groupId>
<version>0.8.2-SNAPSHOT</version> <version>0.8.5-SNAPSHOT</version>
<relativePath>..</relativePath> <relativePath>..</relativePath>
</parent> </parent>
<artifactId>x4o-plugin</artifactId> <artifactId>x4o-plugin</artifactId>
@ -12,8 +12,8 @@
<name>x4o-plugin</name> <name>x4o-plugin</name>
<description>x4o plugins for other applications</description> <description>x4o plugins for other applications</description>
<modules> <modules>
<module>x4o-plugin-ant-schema</module> <module>x4o-plugin-ant-schema</module>
<module>x4o-plugin-ant-elddoc</module> <module>x4o-plugin-ant-elddoc</module>
</modules> </modules>
<build> <build>
<pluginManagement> <pluginManagement>

View file

@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>x4o-plugin</artifactId> <artifactId>x4o-plugin</artifactId>
<groupId>org.x4o.plugin</groupId> <groupId>org.x4o.plugin</groupId>
<version>0.8.2-SNAPSHOT</version> <version>0.8.5-SNAPSHOT</version>
<relativePath>..</relativePath> <relativePath>..</relativePath>
</parent> </parent>
<artifactId>x4o-plugin-ant-elddoc</artifactId> <artifactId>x4o-plugin-ant-elddoc</artifactId>

View file

@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>x4o-plugin</artifactId> <artifactId>x4o-plugin</artifactId>
<groupId>org.x4o.plugin</groupId> <groupId>org.x4o.plugin</groupId>
<version>0.8.2-SNAPSHOT</version> <version>0.8.5-SNAPSHOT</version>
<relativePath>..</relativePath> <relativePath>..</relativePath>
</parent> </parent>
<artifactId>x4o-plugin-ant-schema</artifactId> <artifactId>x4o-plugin-ant-schema</artifactId>