X4O Formatted x4o driver tests cases
This commit is contained in:
parent
bd4a04a813
commit
ed096a1427
74 changed files with 1640 additions and 1453 deletions
|
|
@ -105,11 +105,9 @@ public abstract class AbstractX4OLanguageModule extends AbstractElementMetaBase
|
|||
}
|
||||
// Check so doc tree does not loop; see EldDocHtmlWriter.findChilderen()
|
||||
/*
|
||||
for (Class<?> cl:elementBindingHandler.getBindChildClasses()) {
|
||||
if (elementBindingHandler.getBindParentClass().equals(cl)) {
|
||||
throw new IllegalStateException("Can't add binding handler: "+elementBindingHandler.getId()+" with same parent as child class.");
|
||||
}
|
||||
}*/
|
||||
* for (Class<?> cl:elementBindingHandler.getBindChildClasses()) { if (elementBindingHandler.getBindParentClass().equals(cl)) { throw new
|
||||
* IllegalStateException("Can't add binding handler: "+elementBindingHandler.getId()+" with same parent as child class."); } }
|
||||
*/
|
||||
logger.finer("Adding ElementBindingHandler: " + elementBindingHandler);
|
||||
elementBindingHandlers.add(elementBindingHandler);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -246,6 +246,7 @@ public abstract class AbstractX4OLanguageSession implements X4OLanguageSessionLo
|
|||
|
||||
/**
|
||||
* Gets the phase listeners for a phase.
|
||||
*
|
||||
* @param phaseId The phaseId of for the listeners.
|
||||
* @return The x4o phase listeners.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -151,13 +151,16 @@ public class DefaultX4OLanguage implements X4OLanguageLocal {
|
|||
languageSession.setExpressionLanguageFactory(X4OExpressionFactory.createExpressionFactory());
|
||||
}
|
||||
if (languageSession.getExpressionLanguageContext() == null) {
|
||||
languageSession.setExpressionLanguageContext(X4OExpressionFactory.createELContext(languageSession.getLanguage().getLanguageConfiguration().getDefaultExpressionLanguageContext()));
|
||||
languageSession.setExpressionLanguageContext(
|
||||
X4OExpressionFactory.createELContext(languageSession.getLanguage().getLanguageConfiguration().getDefaultExpressionLanguageContext()));
|
||||
}
|
||||
if (languageSession.getElementAttributeValueParser() == null) {
|
||||
languageSession.setElementAttributeValueParser(X4OLanguageClassLoader.newInstance(ElementAttributeValueParser.class, getLanguageConfiguration().getDefaultElementAttributeValueParser()));
|
||||
languageSession.setElementAttributeValueParser(X4OLanguageClassLoader.newInstance(ElementAttributeValueParser.class,
|
||||
getLanguageConfiguration().getDefaultElementAttributeValueParser()));
|
||||
}
|
||||
if (languageSession.getElementObjectPropertyValue() == null) {
|
||||
languageSession.setElementObjectPropertyValue(X4OLanguageClassLoader.newInstance(ElementObjectPropertyValue.class, getLanguageConfiguration().getDefaultElementObjectPropertyValue()));
|
||||
languageSession.setElementObjectPropertyValue(X4OLanguageClassLoader.newInstance(ElementObjectPropertyValue.class,
|
||||
getLanguageConfiguration().getDefaultElementObjectPropertyValue()));
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ public class DefaultX4OLanguageConfiguration extends AbstractX4OLanguageConfigur
|
|||
public DefaultX4OLanguageConfiguration() {
|
||||
}
|
||||
|
||||
//@formatter:off
|
||||
public void fillDefaults() {
|
||||
if (getLanguageResourcePathPrefix()==null) { setLanguageResourcePathPrefix( X4OLanguageConfiguration.DEFAULT_LANG_PATH_PREFIX); }
|
||||
if (getLanguageResourceModulesFileName()==null) { setLanguageResourceModulesFileName( X4OLanguageConfiguration.DEFAULT_LANG_MODULES_FILE);}
|
||||
|
|
@ -74,6 +75,7 @@ public class DefaultX4OLanguageConfiguration extends AbstractX4OLanguageConfigur
|
|||
if (getDefaultLanguageLoader()==null) { setDefaultLanguageLoader( DefaultX4OLanguageLoader.class); }
|
||||
if (getDefaultExpressionLanguageContext()==null) { setDefaultExpressionLanguageContext( X4OELContext.class); }
|
||||
}
|
||||
//@formatter:on
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.lang.X4OLanguageConfigurationLocal#createProxy()
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ public class DefaultX4OLanguageLoader implements X4OLanguageLoader {
|
|||
|
||||
/**
|
||||
* Write log message to debug writer.
|
||||
*
|
||||
* @param language The X4O language we are loading.
|
||||
* @param message The message to log to the debug output.
|
||||
*/
|
||||
|
|
@ -80,7 +81,8 @@ public class DefaultX4OLanguageLoader implements X4OLanguageLoader {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void loadLanguage(X4OLanguageSession session, X4OLanguageLocal languageLocal, String language, String languageVersion) throws X4OLanguageLoaderException {
|
||||
public void loadLanguage(X4OLanguageSession session, X4OLanguageLocal languageLocal, String language, String languageVersion)
|
||||
throws X4OLanguageLoaderException {
|
||||
logger.finer("Loading all modules for language: " + language);
|
||||
List<VersionedResources> modulesAll = loadLanguageModules(session, languageLocal, language);
|
||||
modulesAll = filterVersionModules(modulesAll, languageLocal, languageVersion);
|
||||
|
|
@ -116,7 +118,8 @@ public class DefaultX4OLanguageLoader implements X4OLanguageLoader {
|
|||
loadModule(session, languageLocal, loader, value, versionedResources);
|
||||
if (loader instanceof X4OLanguageModuleLoaderSibling) {
|
||||
// mmm
|
||||
X4OPhaseInitLanguageSiblings sibPhase = (X4OPhaseInitLanguageSiblings)languageLocal.getPhaseManager().getPhase(X4OPhaseLanguageInit.INIT_LANG_SIB);
|
||||
X4OPhaseInitLanguageSiblings sibPhase = (X4OPhaseInitLanguageSiblings) languageLocal.getPhaseManager()
|
||||
.getPhase(X4OPhaseLanguageInit.INIT_LANG_SIB);
|
||||
sibPhase.addLanguageModuleLoaderSibling((X4OLanguageModuleLoaderSibling) loader);
|
||||
}
|
||||
}
|
||||
|
|
@ -131,11 +134,13 @@ public class DefaultX4OLanguageLoader implements X4OLanguageLoader {
|
|||
}
|
||||
}
|
||||
|
||||
private List<VersionedResources> filterVersionModules(List<VersionedResources> resources, X4OLanguageLocal languageLocal, String languageVersion) throws X4OLanguageLoaderException {
|
||||
private List<VersionedResources> filterVersionModules(List<VersionedResources> resources, X4OLanguageLocal languageLocal, String languageVersion)
|
||||
throws X4OLanguageLoaderException {
|
||||
List<VersionedResources> result = new ArrayList<VersionedResources>(resources.size());
|
||||
X4OLanguageVersionFilter lvf;
|
||||
try {
|
||||
lvf = X4OLanguageClassLoader.newInstance(X4OLanguageVersionFilter.class, languageLocal.getLanguageConfiguration().getDefaultLanguageVersionFilter());
|
||||
lvf = X4OLanguageClassLoader.newInstance(X4OLanguageVersionFilter.class,
|
||||
languageLocal.getLanguageConfiguration().getDefaultLanguageVersionFilter());
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new X4OLanguageLoaderException(e);
|
||||
}
|
||||
|
|
@ -173,10 +178,12 @@ public class DefaultX4OLanguageLoader implements X4OLanguageLoader {
|
|||
}
|
||||
}
|
||||
|
||||
private void loadModule(X4OLanguageSession session, X4OLanguageLocal languageLocal, X4OLanguageModuleLoader loader, String resource, VersionedResources versionedResources) throws X4OLanguageLoaderException {
|
||||
private void loadModule(X4OLanguageSession session, X4OLanguageLocal languageLocal, X4OLanguageModuleLoader loader, String resource,
|
||||
VersionedResources versionedResources) throws X4OLanguageLoaderException {
|
||||
X4OLanguageModuleLocal module;
|
||||
try {
|
||||
module = X4OLanguageClassLoader.newInstance(X4OLanguageModuleLocal.class, languageLocal.getLanguageConfiguration().getDefaultElementLanguageModule());
|
||||
module = X4OLanguageClassLoader.newInstance(X4OLanguageModuleLocal.class,
|
||||
languageLocal.getLanguageConfiguration().getDefaultElementLanguageModule());
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new X4OLanguageLoaderException(e);
|
||||
}
|
||||
|
|
@ -203,10 +210,12 @@ public class DefaultX4OLanguageLoader implements X4OLanguageLoader {
|
|||
|
||||
/**
|
||||
* Loads all modules of an language.
|
||||
*
|
||||
* @param languageLocal The ElementLanguage to load for.
|
||||
* @param language The language to load.
|
||||
*/
|
||||
protected List<VersionedResources> loadLanguageModules(X4OLanguageSession session, X4OLanguageLocal languageLocal, String language) throws X4OLanguageLoaderException {
|
||||
protected List<VersionedResources> loadLanguageModules(X4OLanguageSession session, X4OLanguageLocal languageLocal, String language)
|
||||
throws X4OLanguageLoaderException {
|
||||
List<VersionedResources> result = new ArrayList<VersionedResources>(15);
|
||||
StringBuilder buf = new StringBuilder(150);
|
||||
buf.append(languageLocal.getLanguageConfiguration().getLanguageResourcePathPrefix());
|
||||
|
|
@ -239,12 +248,14 @@ public class DefaultX4OLanguageLoader implements X4OLanguageLoader {
|
|||
|
||||
/**
|
||||
* Parser xml inputstream to languge modules.
|
||||
*
|
||||
* @param in The inputstream to parser.
|
||||
* @throws IOException
|
||||
* @throws SAXException
|
||||
* @throws ParserConfigurationException
|
||||
*/
|
||||
protected List<VersionedResources> loadLanguageModulesXml(InputStream in, String loadedFrom) throws IOException, SAXException, ParserConfigurationException {
|
||||
protected List<VersionedResources> loadLanguageModulesXml(InputStream in, String loadedFrom)
|
||||
throws IOException, SAXException, ParserConfigurationException {
|
||||
if (in == null) {
|
||||
throw new NullPointerException("Can't parse null input stream");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
*/
|
||||
package org.x4o.xml.lang;
|
||||
|
||||
|
||||
/**
|
||||
* An DefaultElementLanguageModule.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ package org.x4o.xml.lang;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* DefaultX4OLanguageVersionFilter makes best filter match attempt.
|
||||
*
|
||||
|
|
@ -35,6 +34,7 @@ public class DefaultX4OLanguageVersionFilter implements X4OLanguageVersionFilter
|
|||
|
||||
/**
|
||||
* Filters to the best version.
|
||||
*
|
||||
* @see org.x4o.xml.lang.X4OLanguageVersionFilter#filterVersion(java.lang.String, java.util.List)
|
||||
* @return The perfect or best match or null if no match for requested language.
|
||||
* @param requestVersion The language version to search for.
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ public interface X4OLanguage {
|
|||
|
||||
/**
|
||||
* Returns the language name of this x4o xml language.
|
||||
*
|
||||
* @return Returns the language name.
|
||||
*/
|
||||
String getLanguageName();
|
||||
|
|
@ -52,6 +53,7 @@ public interface X4OLanguage {
|
|||
|
||||
/**
|
||||
* Returns the phase manager which runs the phases
|
||||
*
|
||||
* @return Returns the phase manager.
|
||||
*/
|
||||
X4OPhaseManager getPhaseManager();
|
||||
|
|
@ -63,12 +65,14 @@ public interface X4OLanguage {
|
|||
|
||||
/**
|
||||
* Creates and fills the initial element language used to store the language.
|
||||
*
|
||||
* @return The newly created X4OLanguageSession.
|
||||
*/
|
||||
X4OLanguageSession createLanguageSession();
|
||||
|
||||
/**
|
||||
* Search language for object and create element for it.
|
||||
*
|
||||
* @param context The X4O language context to create for.
|
||||
* @param objectClass The object to search for.
|
||||
* @return Returns an new Element instance for the object.
|
||||
|
|
@ -77,6 +81,7 @@ public interface X4OLanguage {
|
|||
|
||||
/**
|
||||
* Gets all ElementBindingHandlers which are possible for parent.
|
||||
*
|
||||
* @param parent The parent element object or class to search for.
|
||||
* @return Returns an List with all ElementBindingHandler for the search.
|
||||
*/
|
||||
|
|
@ -84,6 +89,7 @@ public interface X4OLanguage {
|
|||
|
||||
/**
|
||||
* Gets all ElementBindingHandlers for parent and child combination.
|
||||
*
|
||||
* @param parent The parent element object or class to search for.
|
||||
* @param child The parent element object or class to search for.
|
||||
* @return Returns an List with all ElementBindingHandler for the search pair.
|
||||
|
|
@ -92,6 +98,7 @@ public interface X4OLanguage {
|
|||
|
||||
/**
|
||||
* Returns list of ElementInterfaces for an element.
|
||||
*
|
||||
* @param object The element object or class to search for.
|
||||
* @return The list of elementInterfaces.
|
||||
*/
|
||||
|
|
@ -99,6 +106,7 @@ public interface X4OLanguage {
|
|||
|
||||
/**
|
||||
* Returns the namespace context for an namespace uri.
|
||||
*
|
||||
* @param namespaceUri the namespace uri.
|
||||
* @return The ElementNamespace.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public final class X4OLanguageClassLoader {
|
|||
|
||||
/**
|
||||
* Gets the thread classloader or the normal classloader.
|
||||
*
|
||||
* @return Returns the ClassLoader.
|
||||
*/
|
||||
public static ClassLoader getClassLoader() {
|
||||
|
|
@ -53,8 +54,7 @@ public final class X4OLanguageClassLoader {
|
|||
}
|
||||
|
||||
/**
|
||||
* Loads a Class from the ContextClassLoader and if that is not set, then
|
||||
* uses the class of the String className instance.
|
||||
* Loads a Class from the ContextClassLoader and if that is not set, then uses the class of the String className instance.
|
||||
*
|
||||
* @param className The class name to load
|
||||
* @return The loaded class
|
||||
|
|
@ -66,6 +66,7 @@ public final class X4OLanguageClassLoader {
|
|||
|
||||
/**
|
||||
* Creates new instance of clazz.
|
||||
*
|
||||
* @param resultType The result type to cast to..
|
||||
* @param clazz The class to make object from.
|
||||
* @return The object of the clazz.
|
||||
|
|
@ -78,6 +79,7 @@ public final class X4OLanguageClassLoader {
|
|||
|
||||
/**
|
||||
* Creates new instance of clazz.
|
||||
*
|
||||
* @param clazz The class to make object from.
|
||||
* @return The object of the clazz.
|
||||
* @throws ClassNotFoundException On any construct access or invoke error.
|
||||
|
|
@ -85,13 +87,15 @@ public final class X4OLanguageClassLoader {
|
|||
public static Object newInstance(Class<?> clazz) throws ClassNotFoundException {
|
||||
try {
|
||||
return clazz.getConstructor().newInstance();
|
||||
} catch (IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException e) {
|
||||
} catch (IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | InstantiationException
|
||||
| IllegalAccessException e) {
|
||||
throw new ClassNotFoundException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new instance of className.
|
||||
*
|
||||
* @param className The className to create object from.
|
||||
* @return The object of the className.
|
||||
* @throws ClassNotFoundException When className is not found or can't be created.
|
||||
|
|
@ -102,6 +106,7 @@ public final class X4OLanguageClassLoader {
|
|||
|
||||
/**
|
||||
* Gets a resource from the classloader to an url.
|
||||
*
|
||||
* @param resourceName The resource to get from the classloader.
|
||||
* @return The url to the resource or null if not found.
|
||||
* @see java.lang.ClassLoader#getResource(String)
|
||||
|
|
@ -112,6 +117,7 @@ public final class X4OLanguageClassLoader {
|
|||
|
||||
/**
|
||||
* Gets a resource from the classloader to an inputstream.
|
||||
*
|
||||
* @param resourceName The resource to get from the classloader.
|
||||
* @return The inputstream to the resource or null if not found.
|
||||
* @see java.lang.ClassLoader#getResourceAsStream(String)
|
||||
|
|
|
|||
|
|
@ -48,19 +48,30 @@ public interface X4OLanguageConfiguration {
|
|||
|
||||
// Core interfaces are also in class for text reference without instance
|
||||
Class<?> getDefaultElementNamespace();
|
||||
|
||||
Class<?> getDefaultElementInterface();
|
||||
|
||||
Class<?> getDefaultElement();
|
||||
|
||||
Class<?> getDefaultElementClass();
|
||||
|
||||
Class<?> getDefaultElementClassAttribute();
|
||||
|
||||
// Other needed interfaces in class form also
|
||||
Class<?> getDefaultElementLanguageModule();
|
||||
|
||||
Class<?> getDefaultElementBodyComment();
|
||||
|
||||
Class<?> getDefaultElementBodyCharacters();
|
||||
|
||||
Class<?> getDefaultElementBodyWhitespace();
|
||||
|
||||
Class<?> getDefaultElementNamespaceInstanceProvider();
|
||||
|
||||
Class<?> getDefaultElementAttributeValueParser();
|
||||
|
||||
Class<?> getDefaultElementObjectPropertyValue();
|
||||
|
||||
Class<?> getDefaultElementNamespaceAttributeComparator();
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -33,24 +33,38 @@ public interface X4OLanguageConfigurationLocal extends X4OLanguageConfiguration
|
|||
X4OLanguageConfiguration createProxy();
|
||||
|
||||
void setLanguageResourcePathPrefix(String value);
|
||||
|
||||
void setLanguageResourceModulesFileName(String value);
|
||||
|
||||
void setDefaultElementNamespace(Class<?> value);
|
||||
|
||||
void setDefaultElementInterface(Class<?> value);
|
||||
|
||||
void setDefaultElement(Class<?> value);
|
||||
|
||||
void setDefaultElementClass(Class<?> value);
|
||||
|
||||
void setDefaultElementClassAttribute(Class<?> value);
|
||||
|
||||
void setDefaultElementLanguageModule(Class<?> value);
|
||||
|
||||
void setDefaultElementBodyComment(Class<?> value);
|
||||
|
||||
void setDefaultElementBodyCharacters(Class<?> value);
|
||||
|
||||
void setDefaultElementBodyWhitespace(Class<?> value);
|
||||
|
||||
void setDefaultElementNamespaceInstanceProvider(Class<?> value);
|
||||
|
||||
void setDefaultElementAttributeValueParser(Class<?> value);
|
||||
|
||||
void setDefaultElementObjectPropertyValue(Class<?> value);
|
||||
|
||||
void setDefaultElementNamespaceAttributeComparator(Class<?> value);
|
||||
|
||||
void setDefaultLanguageVersionFilter(Class<?> value);
|
||||
|
||||
void setDefaultLanguageLoader(Class<?> value);
|
||||
|
||||
void setDefaultExpressionLanguageContext(Class<?> value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ public interface X4OLanguageLoader {
|
|||
|
||||
/**
|
||||
* Loads the language modules.
|
||||
*
|
||||
* @param session The session we run in.
|
||||
* @param language The local Language to load for.
|
||||
* @param languageName The language name to load.
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public class X4OLanguageLoaderException extends Exception {
|
|||
|
||||
/**
|
||||
* Constructs an X4OLanguageLoaderException with a detail message.
|
||||
*
|
||||
* @param message The message of this Exception
|
||||
*/
|
||||
public X4OLanguageLoaderException(String message) {
|
||||
|
|
@ -50,6 +51,7 @@ public class X4OLanguageLoaderException extends Exception {
|
|||
|
||||
/**
|
||||
* Creates an X4OLanguageLoaderException from a parent exception.
|
||||
*
|
||||
* @param e The exception.
|
||||
*/
|
||||
public X4OLanguageLoaderException(Exception e) {
|
||||
|
|
@ -58,6 +60,7 @@ public class X4OLanguageLoaderException extends Exception {
|
|||
|
||||
/**
|
||||
* Constructs an X4OLanguageLoaderException with a detail message.
|
||||
*
|
||||
* @param message The message of this Exception
|
||||
* @param e The exception.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ public interface X4OLanguageLocal extends X4OLanguage {
|
|||
|
||||
/**
|
||||
* Adds an X4OLanguageModule to this language.
|
||||
*
|
||||
* @param languageModule The element language module to add.
|
||||
*/
|
||||
void addLanguageModule(X4OLanguageModule languageModule);
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ public interface X4OLanguageModule /* extends ElementMetaBase TODO add local lay
|
|||
|
||||
// temp here see local
|
||||
String getId();
|
||||
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
|
|
@ -54,24 +55,28 @@ public interface X4OLanguageModule /* extends ElementMetaBase TODO add local lay
|
|||
|
||||
/**
|
||||
* Gets all ElementBindingHandlers.
|
||||
*
|
||||
* @return Returns an List with all ElementBindingHandlers.
|
||||
*/
|
||||
List<ElementBindingHandler> getElementBindingHandlers();
|
||||
|
||||
/**
|
||||
* Gets all ElementConfiguratorGlobals.
|
||||
*
|
||||
* @return All gloval ElementConfigurators.
|
||||
*/
|
||||
List<ElementConfiguratorGlobal> getElementConfiguratorGlobals();
|
||||
|
||||
/**
|
||||
* Returns list of ElementInterfaces in this context.
|
||||
*
|
||||
* @return The list of elementInterfaces.
|
||||
*/
|
||||
List<ElementInterface> getElementInterfaces();
|
||||
|
||||
/**
|
||||
* Returns the namespace context for an namespace uri.
|
||||
*
|
||||
* @param namespaceUri the namespace uri.
|
||||
* @return The ElementNamespace.
|
||||
*/
|
||||
|
|
@ -84,6 +89,7 @@ public interface X4OLanguageModule /* extends ElementMetaBase TODO add local lay
|
|||
|
||||
/**
|
||||
* Gets module loader meta result info.
|
||||
*
|
||||
* @param key The key to get info of.
|
||||
* @return The value of the info.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -23,8 +23,7 @@
|
|||
package org.x4o.xml.lang;
|
||||
|
||||
/**
|
||||
* X4OLanguageModuleLoader Loads all elements and other options
|
||||
* into the X4OLanguageModule for the X4OLanguageLocal language.
|
||||
* X4OLanguageModuleLoader Loads all elements and other options into the X4OLanguageModule for the X4OLanguageLocal language.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jul 8, 2006
|
||||
|
|
@ -33,6 +32,7 @@ public interface X4OLanguageModuleLoader {
|
|||
|
||||
/**
|
||||
* Starts the ElementProvider.
|
||||
*
|
||||
* @param session The session we run in.
|
||||
* @param language The local Language to load for.
|
||||
* @param module The language module to load it into.
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ public class X4OLanguageModuleLoaderException extends ElementException {
|
|||
|
||||
/**
|
||||
* Creates module loader exception.
|
||||
*
|
||||
* @param elementLanguageModuleLoader The loader module which creates this exception.
|
||||
* @param message The message of the exception.
|
||||
*/
|
||||
|
|
@ -47,6 +48,7 @@ public class X4OLanguageModuleLoaderException extends ElementException {
|
|||
|
||||
/**
|
||||
* Creates module loader exception.
|
||||
*
|
||||
* @param elementLanguageModuleLoader The loader module which creates this exception.
|
||||
* @param message The message of the exception.
|
||||
* @param exception The root cause of the exception.
|
||||
|
|
@ -58,6 +60,7 @@ public class X4OLanguageModuleLoaderException extends ElementException {
|
|||
|
||||
/**
|
||||
* Returns the module loader which created the exception.
|
||||
*
|
||||
* @return Returns the module loader.
|
||||
*/
|
||||
public X4OLanguageModuleLoader getElementProvider() {
|
||||
|
|
|
|||
|
|
@ -30,10 +30,12 @@ package org.x4o.xml.lang;
|
|||
*/
|
||||
public enum X4OLanguageModuleLoaderResult {
|
||||
|
||||
//@formatter:off
|
||||
LOAD_MODULE_RESOURCE,
|
||||
LOAD_FROM_RESOURCE,
|
||||
LOAD_VERSION,
|
||||
LOAD_CLASS,
|
||||
LOAD_TIME,
|
||||
LOAD_DATE;
|
||||
//@formatter:on
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@
|
|||
*/
|
||||
package org.x4o.xml.lang;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* ElementLanguageModuleLoaderSibling provides sibling language loading support.
|
||||
*
|
||||
|
|
@ -35,6 +33,7 @@ public interface X4OLanguageModuleLoaderSibling extends X4OLanguageModuleLoader
|
|||
|
||||
/**
|
||||
* Loads in the sibling language.
|
||||
*
|
||||
* @param session The session we run in.
|
||||
* @param language The local Language to load for.
|
||||
* @param loader The loader to use to load the x4o languages.
|
||||
|
|
|
|||
|
|
@ -48,30 +48,35 @@ public interface X4OLanguageModuleLocal extends X4OLanguageModule,ElementMetaBas
|
|||
|
||||
/**
|
||||
* Adds an ElementBindingHanlder.
|
||||
*
|
||||
* @param elementBindingHandler The ElementBindingHandler to add.
|
||||
*/
|
||||
void addElementBindingHandler(ElementBindingHandler elementBindingHandler);
|
||||
|
||||
/**
|
||||
* Adds an ElementConfiguratorGlobal.
|
||||
*
|
||||
* @param elementConfigurator The ElementConfigurtor to add.
|
||||
*/
|
||||
void addElementConfiguratorGlobal(ElementConfiguratorGlobal elementConfigurator);
|
||||
|
||||
/**
|
||||
* Adds an ElementInterface.
|
||||
*
|
||||
* @param elementInterface The elementInterface to add.
|
||||
*/
|
||||
void addElementInterface(ElementInterface elementInterface);
|
||||
|
||||
/**
|
||||
* Adds an namespace to this langauge module.
|
||||
*
|
||||
* @param elementNamespace Adds an ElementNamespace to this langauge module.
|
||||
*/
|
||||
void addElementNamespace(ElementNamespace elementNamespace);
|
||||
|
||||
/**
|
||||
* Sets module loader meta result info.
|
||||
*
|
||||
* @param key The key of the info.
|
||||
* @param value The value of the info.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -49,12 +49,14 @@ public interface X4OLanguageSession extends AutoCloseable {
|
|||
|
||||
/**
|
||||
* Gets the EL Context.
|
||||
*
|
||||
* @return Returns the ELContext.
|
||||
*/
|
||||
ELContext getExpressionLanguageContext();
|
||||
|
||||
/**
|
||||
* Gets the ExpressionFactory.
|
||||
*
|
||||
* @return Returns the ExpressionFactory.
|
||||
*/
|
||||
ExpressionFactory getExpressionLanguageFactory();
|
||||
|
|
@ -78,18 +80,21 @@ public interface X4OLanguageSession extends AutoCloseable {
|
|||
|
||||
/**
|
||||
* Get all Dirty Elements.
|
||||
*
|
||||
* @return Returns List with dirty elements.
|
||||
*/
|
||||
List<Element> getDirtyElements();
|
||||
|
||||
/**
|
||||
* Returns the root Element which starts the xml tree.
|
||||
*
|
||||
* @return Returns the root element of the document instance we parse.
|
||||
*/
|
||||
Element getRootElement();
|
||||
|
||||
/**
|
||||
* Sets the root element.
|
||||
*
|
||||
* @param element The root element to set.
|
||||
*/
|
||||
void setRootElement(Element element);
|
||||
|
|
@ -106,6 +111,7 @@ public interface X4OLanguageSession extends AutoCloseable {
|
|||
|
||||
/**
|
||||
* Returns the current X4OPhase of the parser.
|
||||
*
|
||||
* @return Returns the current phase.
|
||||
*/
|
||||
X4OPhase getPhaseCurrent();
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ import org.x4o.xml.lang.phase.X4OPhaseListener;
|
|||
public interface X4OLanguageSessionLocal extends X4OLanguageSession {
|
||||
|
||||
/**
|
||||
* Returns list of phase listeners which where added to it.
|
||||
* TODO: bad api here
|
||||
* Returns list of phase listeners which where added to it. TODO: bad api here
|
||||
*
|
||||
* @param phaseId The phaseId of for the listeners.
|
||||
* @return All X4OPhaseListeners.
|
||||
*/
|
||||
|
|
@ -51,12 +51,14 @@ public interface X4OLanguageSessionLocal extends X4OLanguageSession {
|
|||
|
||||
/**
|
||||
* Sets the EL Context.
|
||||
*
|
||||
* @param context The ELContext to set.
|
||||
*/
|
||||
void setExpressionLanguageContext(ELContext context);
|
||||
|
||||
/**
|
||||
* Sets the ExpressionFactory.
|
||||
*
|
||||
* @param expressionFactory The ExpressionFactory to set.
|
||||
*/
|
||||
void setExpressionLanguageFactory(ExpressionFactory expressionFactory);
|
||||
|
|
@ -78,6 +80,7 @@ public interface X4OLanguageSessionLocal extends X4OLanguageSession {
|
|||
|
||||
/**
|
||||
* Sets the phase of the context.
|
||||
*
|
||||
* @param phase The current phase to set.
|
||||
*/
|
||||
void setPhaseCurrent(X4OPhase phase);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import org.x4o.xml.element.AbstractElementNamespaceAttribute;
|
|||
import org.x4o.xml.element.Element;
|
||||
import org.x4o.xml.element.ElementConfiguratorException;
|
||||
|
||||
|
||||
/**
|
||||
* Stores an ElementObject into the EL context.
|
||||
*
|
||||
|
|
@ -44,7 +43,9 @@ public class ELIDAttributeHandler extends AbstractElementNamespaceAttribute {
|
|||
*/
|
||||
public void doConfigElement(Element element) throws ElementConfiguratorException {
|
||||
String attributeValue = element.getAttributes().get(getAttributeName());
|
||||
if(attributeValue==null) { return; }
|
||||
if (attributeValue == null) {
|
||||
return;
|
||||
}
|
||||
if (element.getElementObject() == null) {
|
||||
if (this.isConfigAction()) {
|
||||
throw new NullPointerException("Can't bind null object to el context");
|
||||
|
|
@ -52,9 +53,13 @@ public class ELIDAttributeHandler extends AbstractElementNamespaceAttribute {
|
|||
this.setConfigAction(true);
|
||||
return;
|
||||
}
|
||||
if(element.getElementObject()==null) { throw new NullPointerException("Can't bind null object to el context"); }
|
||||
ValueExpression ee = element.getLanguageSession().getExpressionLanguageFactory().createValueExpression(element.getLanguageSession().getExpressionLanguageContext(),"${"+attributeValue+"}", element.getElementObject().getClass());
|
||||
Logger.getLogger(ELIDAttributeHandler.class.getName()).finer("Set Variable in ELContext: "+"${"+attributeValue+"}"+" object SET: "+element.getElementObject());
|
||||
if (element.getElementObject() == null) {
|
||||
throw new NullPointerException("Can't bind null object to el context");
|
||||
}
|
||||
ValueExpression ee = element.getLanguageSession().getExpressionLanguageFactory().createValueExpression(
|
||||
element.getLanguageSession().getExpressionLanguageContext(), "${" + attributeValue + "}", element.getElementObject().getClass());
|
||||
Logger.getLogger(ELIDAttributeHandler.class.getName())
|
||||
.finer("Set Variable in ELContext: " + "${" + attributeValue + "}" + " object SET: " + element.getElementObject());
|
||||
ee.setValue(element.getLanguageSession().getExpressionLanguageContext(), element.getElementObject());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import javax.el.ValueExpression;
|
|||
import org.x4o.xml.element.AbstractElement;
|
||||
import org.x4o.xml.element.ElementException;
|
||||
|
||||
|
||||
/**
|
||||
* An ELReferenceElement.<br>
|
||||
* Fills the ElementObject with an object from el.
|
||||
|
|
@ -42,8 +41,11 @@ public class ELReferenceElement extends AbstractElement {
|
|||
@Override
|
||||
public void doElementRun() throws ElementException {
|
||||
String attributeValue = getAttributes().get("el.ref");
|
||||
if("".equals(attributeValue) | attributeValue==null) { throw new ElementException("Set the el.ref attribute"); }
|
||||
ValueExpression ee = getLanguageSession().getExpressionLanguageFactory().createValueExpression(getLanguageSession().getExpressionLanguageContext(),"${"+attributeValue+"}",Object.class);
|
||||
if ("".equals(attributeValue) | attributeValue == null) {
|
||||
throw new ElementException("Set the el.ref attribute");
|
||||
}
|
||||
ValueExpression ee = getLanguageSession().getExpressionLanguageFactory().createValueExpression(getLanguageSession().getExpressionLanguageContext(),
|
||||
"${" + attributeValue + "}", Object.class);
|
||||
Logger.getLogger(ELReferenceElement.class.getName()).finer("Get Variable in ELContext: ${" + attributeValue + "}");
|
||||
setElementObject(ee.getValue(getLanguageSession().getExpressionLanguageContext()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,8 @@ public class MetaLanguageSiblingLoader implements X4OLanguageModuleLoaderSibling
|
|||
public static final String META_LANGUAGE_DESCRIPTION = "X4O Meta XML Language Module.";
|
||||
|
||||
@Override
|
||||
public void loadLanguageModule(X4OLanguageSession session, X4OLanguageLocal language, X4OLanguageModuleLocal module) throws X4OLanguageModuleLoaderException {
|
||||
public void loadLanguageModule(X4OLanguageSession session, X4OLanguageLocal language, X4OLanguageModuleLocal module)
|
||||
throws X4OLanguageModuleLoaderException {
|
||||
module.setId(META_LANGUAGE);
|
||||
module.setProviderHost(META_LANGUAGE_HOST);
|
||||
module.setProviderName(MetaLanguageSiblingLoader.class.getSimpleName());
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import java.lang.reflect.Method;
|
|||
import org.x4o.xml.element.AbstractElement;
|
||||
import org.x4o.xml.element.ElementException;
|
||||
|
||||
|
||||
/**
|
||||
* MethodElement invokes an method on a element object.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import org.x4o.xml.eld.lang.BeanElement;
|
|||
import org.x4o.xml.element.AbstractElement;
|
||||
import org.x4o.xml.element.ElementException;
|
||||
|
||||
|
||||
/**
|
||||
* An PropertyElement.<br>
|
||||
*
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import org.x4o.xml.element.Element;
|
|||
import org.x4o.xml.element.ElementException;
|
||||
import org.x4o.xml.lang.X4OLanguageSession;
|
||||
|
||||
|
||||
/**
|
||||
* AbstractX4OPhaseHandler a base class for creating a phase handler.
|
||||
*
|
||||
|
|
@ -50,6 +49,7 @@ public abstract class AbstractX4OPhase implements X4OPhase {
|
|||
|
||||
/**
|
||||
* If returns true then this handler will run on all elements.
|
||||
*
|
||||
* @return defaults to true.
|
||||
*/
|
||||
public boolean isElementPhase() {
|
||||
|
|
@ -58,6 +58,7 @@ public abstract class AbstractX4OPhase implements X4OPhase {
|
|||
|
||||
/**
|
||||
* Abstract method.
|
||||
*
|
||||
* @param element The element to run phase for.
|
||||
* @throws X4OPhaseException when phase has error.
|
||||
*/
|
||||
|
|
@ -65,6 +66,7 @@ public abstract class AbstractX4OPhase implements X4OPhase {
|
|||
|
||||
/**
|
||||
* Empty method.
|
||||
*
|
||||
* @param elementLanguage The language to run phase for.
|
||||
* @throws X4OPhaseException when phase has error.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -32,8 +32,7 @@ import org.x4o.xml.lang.X4OLanguageSession;
|
|||
import org.x4o.xml.lang.X4OLanguageSessionLocal;
|
||||
|
||||
/**
|
||||
* X4OPhaseManager stores the X4OPhaseHandler and puts them in the right order.
|
||||
* And will execute the phases when runPhases is called.
|
||||
* X4OPhaseManager stores the X4OPhaseHandler and puts them in the right order. And will execute the phases when runPhases is called.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 6, 2008
|
||||
|
|
@ -50,7 +49,7 @@ public class DefaultX4OPhaseManager implements X4OPhaseManagerLocal {
|
|||
x4oPhases = new ArrayList<X4OPhase>(25);
|
||||
}
|
||||
/*
|
||||
|
||||
//@formatter:off
|
||||
PHASE_ORDER = { *startupX4OPhase,
|
||||
*createLanguagePhase,
|
||||
*createLanguageSiblingsPhase,
|
||||
|
|
@ -64,7 +63,7 @@ PHASE_ORDER = { *startupX4OPhase,
|
|||
*releasePhase
|
||||
};
|
||||
* = runOnce
|
||||
|
||||
//@formatter:on
|
||||
*/
|
||||
|
||||
public X4OPhase getPhase(String phaseName) {
|
||||
|
|
@ -86,6 +85,7 @@ PHASE_ORDER = { *startupX4OPhase,
|
|||
|
||||
/**
|
||||
* Adds an X4OPhaseHandler.
|
||||
*
|
||||
* @param phase The X4OPhaseHandler to add.
|
||||
*/
|
||||
public void addX4OPhase(X4OPhase phase) {
|
||||
|
|
@ -101,6 +101,7 @@ PHASE_ORDER = { *startupX4OPhase,
|
|||
|
||||
/**
|
||||
* Returns all the X4OPhaseHandlers.
|
||||
*
|
||||
* @return Returns all X4OPhaseHandlers.
|
||||
*/
|
||||
public List<X4OPhase> getAllPhases() {
|
||||
|
|
@ -109,6 +110,7 @@ PHASE_ORDER = { *startupX4OPhase,
|
|||
|
||||
/**
|
||||
* Returns all the X4OPhaseHandlers in ordered list.
|
||||
*
|
||||
* @return Returns all X4OPhaseHandler is order.
|
||||
*/
|
||||
public List<X4OPhase> getOrderedPhases(X4OPhaseType type) {
|
||||
|
|
@ -124,6 +126,7 @@ PHASE_ORDER = { *startupX4OPhase,
|
|||
|
||||
/**
|
||||
* Runs all the phases in the right order.
|
||||
*
|
||||
* @throws X4OPhaseException When a running handlers throws one.
|
||||
*/
|
||||
public void runPhases(X4OLanguageSession languageSession, X4OPhaseType type) throws X4OPhaseException {
|
||||
|
|
@ -178,6 +181,7 @@ PHASE_ORDER = { *startupX4OPhase,
|
|||
|
||||
/**
|
||||
* Runs phase on single element.
|
||||
*
|
||||
* @param e The Element to process.
|
||||
* @param p The phase to run.
|
||||
* @throws X4OPhaseException When a running handlers throws one.
|
||||
|
|
@ -214,6 +218,7 @@ PHASE_ORDER = { *startupX4OPhase,
|
|||
|
||||
/**
|
||||
* Run release phase manual if auto release is disabled by config.
|
||||
*
|
||||
* @throws X4OPhaseException When a running handlers throws one.
|
||||
*/
|
||||
public void doReleasePhaseManual(X4OLanguageSession languageSession) throws X4OPhaseException {
|
||||
|
|
@ -273,46 +278,12 @@ PHASE_ORDER = { *startupX4OPhase,
|
|||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
/*
|
||||
if (p1==p2) {
|
||||
return 0;
|
||||
}
|
||||
if (p1==X4OPhase.debugPhase) {
|
||||
return 0;
|
||||
}
|
||||
if (p2==X4OPhase.debugPhase) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int i1 = phaseOrder(p1);
|
||||
int i2 = phaseOrder(p2);
|
||||
|
||||
if (i1>i2) {
|
||||
return 1;
|
||||
}
|
||||
if (i1<i2) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
*/
|
||||
}
|
||||
/*
|
||||
private int phaseOrder(X4OPhase check) {
|
||||
int result=0;
|
||||
for (X4OPhase p:X4OPhase.PHASE_ORDER) {
|
||||
if (p==check) {
|
||||
return result;
|
||||
}
|
||||
result++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute element phase handler on full tree.
|
||||
*
|
||||
* @param phase The phase to run.
|
||||
* @throws X4OPhaseException When a running handlers throws one.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ public interface X4OPhase {
|
|||
|
||||
/**
|
||||
* Returns the X4OPhase for which this handler was written.
|
||||
*
|
||||
* @return Returns the phase for which this handler works.
|
||||
*/
|
||||
String getId();
|
||||
|
|
@ -45,27 +46,30 @@ public interface X4OPhase {
|
|||
|
||||
/**
|
||||
* Returns a flag indicating that this phase is runnable multiple times.
|
||||
*
|
||||
* @return True if phase is restricted to run once.
|
||||
*/
|
||||
boolean isRunOnce();
|
||||
|
||||
/**
|
||||
* Runs this phase.
|
||||
*
|
||||
* @param elementLanguage The elementLanguage running this phase.
|
||||
* @throws X4OPhaseException When error has happend.
|
||||
*/
|
||||
void runPhase(X4OLanguageSession elementLanguage) throws X4OPhaseException;
|
||||
|
||||
/**
|
||||
* runPhase is called but should do nothig.
|
||||
* When elementPhase is enables x4o tries to merge all element phases so
|
||||
* we don't need to loop element tree to often.
|
||||
* runPhase is called but should do nothig. When elementPhase is enables x4o tries to merge all element phases so we don't need to loop element tree to
|
||||
* often.
|
||||
*
|
||||
* @return True if to run in config.
|
||||
*/
|
||||
boolean isElementPhase();
|
||||
|
||||
/**
|
||||
* Run this phase for this Element.
|
||||
*
|
||||
* @param element The element to run this phase for.
|
||||
* @throws X4OPhaseException Is thrown when error has happen.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ public class X4OPhaseException extends Exception {
|
|||
|
||||
/**
|
||||
* Creates an ElementException from a parent exception.
|
||||
*
|
||||
* @param exceptionPhase The handler which throwed.
|
||||
* @param e The Exception.
|
||||
*/
|
||||
|
|
@ -47,6 +48,7 @@ public class X4OPhaseException extends Exception {
|
|||
|
||||
/**
|
||||
* Creates an ElementException from a parent exception.
|
||||
*
|
||||
* @param exceptionPhase The handler which throwed.
|
||||
* @param message The message of the error.
|
||||
*/
|
||||
|
|
@ -57,6 +59,7 @@ public class X4OPhaseException extends Exception {
|
|||
|
||||
/**
|
||||
* Creates an ElementException from a parent exception.
|
||||
*
|
||||
* @param exceptionPhase The handler which throwed.
|
||||
* @param message The message of the error.
|
||||
* @param e The Exception.
|
||||
|
|
@ -68,6 +71,7 @@ public class X4OPhaseException extends Exception {
|
|||
|
||||
/**
|
||||
* Returns the X4OPhaseHandler which created this Exception.
|
||||
*
|
||||
* @return An X4OPhaseHandler
|
||||
*/
|
||||
public X4OPhase getX4OPhaseHandler() {
|
||||
|
|
|
|||
|
|
@ -65,45 +65,55 @@ public class X4OPhaseLanguageInit {
|
|||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.INIT;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return INIT_START;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] {};
|
||||
}
|
||||
|
||||
public boolean isElementPhase() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
}
|
||||
|
||||
public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException {
|
||||
logger.finest("Run init start phase");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Loads all the modules a language.
|
||||
* Then creates the ElementProviders
|
||||
* Loads all the modules a language. Then creates the ElementProviders
|
||||
*/
|
||||
class X4OPhaseInitLanguage extends AbstractX4OPhase {
|
||||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.INIT;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return INIT_LANG;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] { INIT_START };
|
||||
}
|
||||
|
||||
public boolean isElementPhase() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
}
|
||||
|
||||
public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException {
|
||||
try {
|
||||
debugPhaseMessage(languageSession, "Load main language: " + languageSession.getLanguage().getLanguageName());
|
||||
X4OLanguageLoader loader = X4OLanguageClassLoader.newInstance(X4OLanguageLoader.class, languageSession.getLanguage().getLanguageConfiguration().getDefaultLanguageLoader());
|
||||
X4OLanguageLoader loader = X4OLanguageClassLoader.newInstance(X4OLanguageLoader.class,
|
||||
languageSession.getLanguage().getLanguageConfiguration().getDefaultLanguageLoader());
|
||||
X4OLanguageLocal language = (X4OLanguageLocal) languageSession.getLanguage();
|
||||
loader.loadLanguage(languageSession, language, language.getLanguageName(), language.getLanguageVersion());
|
||||
|
||||
|
|
@ -121,28 +131,36 @@ public class X4OPhaseLanguageInit {
|
|||
*/
|
||||
public class X4OPhaseInitLanguageSiblings extends AbstractX4OPhase {
|
||||
private List<X4OLanguageModuleLoaderSibling> siblingLoaders = new ArrayList<X4OLanguageModuleLoaderSibling>(2);
|
||||
|
||||
// mmmm think of better then cast
|
||||
public void addLanguageModuleLoaderSibling(X4OLanguageModuleLoaderSibling loader) {
|
||||
siblingLoaders.add(loader);
|
||||
}
|
||||
|
||||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.INIT;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return INIT_LANG_SIB;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] { INIT_LANG };
|
||||
}
|
||||
|
||||
public boolean isElementPhase() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
}
|
||||
|
||||
public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException {
|
||||
try {
|
||||
if (siblingLoaders.isEmpty() == false) {
|
||||
X4OLanguageLoader loader = X4OLanguageClassLoader.newInstance(X4OLanguageLoader.class, languageSession.getLanguage().getLanguageConfiguration().getDefaultLanguageLoader());
|
||||
X4OLanguageLoader loader = X4OLanguageClassLoader.newInstance(X4OLanguageLoader.class,
|
||||
languageSession.getLanguage().getLanguageConfiguration().getDefaultLanguageLoader());
|
||||
X4OLanguageLocal language = (X4OLanguageLocal) languageSession.getLanguage();
|
||||
for (X4OLanguageModuleLoaderSibling siblingLoader : siblingLoaders) {
|
||||
debugPhaseMessage(languageSession, "Loading sibling langauge loader: " + siblingLoader);
|
||||
|
|
@ -166,17 +184,22 @@ public class X4OPhaseLanguageInit {
|
|||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.INIT;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return INIT_END;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] { INIT_LANG_SIB };
|
||||
}
|
||||
|
||||
public boolean isElementPhase() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
}
|
||||
|
||||
public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException {
|
||||
logger.finest("Run init end phase");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,18 +117,23 @@ public class X4OPhaseLanguageRead {
|
|||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.XML_READ;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return READ_BEGIN;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] {};
|
||||
}
|
||||
|
||||
public boolean isElementPhase() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
// not used.
|
||||
}
|
||||
|
||||
public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException {
|
||||
// print the properties and classes for this language/config
|
||||
if (languageSession.hasX4ODebugWriter()) {
|
||||
|
|
@ -147,18 +152,23 @@ public class X4OPhaseLanguageRead {
|
|||
*/
|
||||
class X4OPhaseReadConfigElement extends AbstractX4OPhase {
|
||||
private X4OPhaseReadRunConfigurator runConf = null;
|
||||
|
||||
public X4OPhaseReadConfigElement(X4OPhaseReadRunConfigurator runConf) {
|
||||
this.runConf = runConf;
|
||||
}
|
||||
|
||||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.XML_READ;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return READ_CONFIG_ELEMENT;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] { READ_BEGIN };
|
||||
}
|
||||
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
|
||||
// First phase is to rename attributes, maybe move so sax phase
|
||||
|
|
@ -188,18 +198,23 @@ public class X4OPhaseLanguageRead {
|
|||
*/
|
||||
class X4OPhaseReadConfigElementInterface extends AbstractX4OPhase {
|
||||
private X4OPhaseReadRunConfigurator runConf = null;
|
||||
|
||||
public X4OPhaseReadConfigElementInterface(X4OPhaseReadRunConfigurator runConf) {
|
||||
this.runConf = runConf;
|
||||
}
|
||||
|
||||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.XML_READ;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return READ_CONFIG_ELEMENT_INTERFACE;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] { READ_CONFIG_ELEMENT };
|
||||
}
|
||||
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
if (element.getElementObject() == null) {
|
||||
logger.finest("Null elementObject skipping, interfaces");
|
||||
|
|
@ -219,18 +234,23 @@ public class X4OPhaseLanguageRead {
|
|||
*/
|
||||
class X4OPhaseReadConfigGlobalElement extends AbstractX4OPhase {
|
||||
private X4OPhaseReadRunConfigurator runConf = null;
|
||||
|
||||
public X4OPhaseReadConfigGlobalElement(X4OPhaseReadRunConfigurator runConf) {
|
||||
this.runConf = runConf;
|
||||
}
|
||||
|
||||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.XML_READ;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return READ_CONFIG_GLOBAL_ELEMENT;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] { READ_CONFIG_ELEMENT, READ_CONFIG_ELEMENT_INTERFACE };
|
||||
}
|
||||
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
for (X4OLanguageModule mod : element.getLanguageSession().getLanguage().getLanguageModules()) {
|
||||
logger.finest("Do Element Config Global Configurators: " + mod.getElementConfiguratorGlobals().size());
|
||||
|
|
@ -247,23 +267,29 @@ public class X4OPhaseLanguageRead {
|
|||
class X4OPhaseReadConfigGlobalAttribute extends AbstractX4OPhase {
|
||||
Comparator<ElementNamespaceAttribute> elementNamespaceAttributeComparator = null;
|
||||
private X4OPhaseReadRunConfigurator runConf = null;
|
||||
|
||||
public X4OPhaseReadConfigGlobalAttribute(X4OPhaseReadRunConfigurator runConf) {
|
||||
this.runConf = runConf;
|
||||
}
|
||||
|
||||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.XML_READ;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return READ_CONFIG_GLOBAL_ATTRIBUTE;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] { READ_CONFIG_GLOBAL_ELEMENT };
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
if (elementNamespaceAttributeComparator == null) {
|
||||
try {
|
||||
elementNamespaceAttributeComparator = (Comparator<ElementNamespaceAttribute>)X4OLanguageClassLoader.newInstance(element.getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementNamespaceAttributeComparator());
|
||||
elementNamespaceAttributeComparator = (Comparator<ElementNamespaceAttribute>) X4OLanguageClassLoader
|
||||
.newInstance(element.getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementNamespaceAttributeComparator());
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new X4OPhaseException(this, e);
|
||||
}
|
||||
|
|
@ -298,12 +324,15 @@ public class X4OPhaseLanguageRead {
|
|||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.XML_READ;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return READ_RUN_ATTRIBUTE;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] { READ_CONFIG_GLOBAL_ATTRIBUTE };
|
||||
}
|
||||
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
// we only can config ElementObjects
|
||||
if (element.getElementObject() == null) {
|
||||
|
|
@ -374,12 +403,15 @@ public class X4OPhaseLanguageRead {
|
|||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.XML_READ;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return READ_FILL_TEMPLATE;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] { READ_RUN_ATTRIBUTE };
|
||||
}
|
||||
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
}
|
||||
};
|
||||
|
|
@ -391,12 +423,15 @@ public class X4OPhaseLanguageRead {
|
|||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.XML_READ;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return READ_TRANSFORM;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] { READ_FILL_TEMPLATE };
|
||||
}
|
||||
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
if (element.isTransformingTree() == false) {
|
||||
return;
|
||||
|
|
@ -417,18 +452,23 @@ public class X4OPhaseLanguageRead {
|
|||
*/
|
||||
class X4OPhaseReadRunDirty extends AbstractX4OPhase {
|
||||
private X4OPhaseManager phaseManager = null;
|
||||
|
||||
public X4OPhaseReadRunDirty(X4OPhaseManager phaseManager) {
|
||||
this.phaseManager = phaseManager;
|
||||
}
|
||||
|
||||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.XML_READ;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return READ_RUN_DIRTY;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] { READ_TRANSFORM };
|
||||
}
|
||||
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
List<Element> dirtyElements = element.getLanguageSession().getDirtyElements();
|
||||
if (dirtyElements.isEmpty()) {
|
||||
|
|
@ -448,18 +488,23 @@ public class X4OPhaseLanguageRead {
|
|||
*/
|
||||
class X4OPhaseReadRunDirtyLast extends AbstractX4OPhase {
|
||||
private X4OPhaseManager phaseManager = null;
|
||||
|
||||
public X4OPhaseReadRunDirtyLast(X4OPhaseManager phaseManager) {
|
||||
this.phaseManager = phaseManager;
|
||||
}
|
||||
|
||||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.XML_READ;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return READ_RUN_DIRTY_LAST;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] { READ_RUN };
|
||||
}
|
||||
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
List<Element> dirtyElements = element.getLanguageSession().getDirtyElements();
|
||||
if (dirtyElements.isEmpty()) {
|
||||
|
|
@ -481,12 +526,15 @@ public class X4OPhaseLanguageRead {
|
|||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.XML_READ;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return READ_BIND_ELEMENT;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] { READ_RUN_DIRTY };
|
||||
}
|
||||
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
Element parentElement = element.getParent();
|
||||
if (parentElement == null) {
|
||||
|
|
@ -526,12 +574,15 @@ public class X4OPhaseLanguageRead {
|
|||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.XML_READ;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return READ_RUN;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] { READ_BIND_ELEMENT };
|
||||
}
|
||||
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
if (element.isTransformingTree()) {
|
||||
return; // has already runned.
|
||||
|
|
@ -549,21 +600,27 @@ public class X4OPhaseLanguageRead {
|
|||
|
||||
class X4OPhaseReadRunConfigurator extends AbstractX4OPhase {
|
||||
private List<RunConfigurator> runConf = null;
|
||||
|
||||
protected X4OPhaseReadRunConfigurator() {
|
||||
runConf = new ArrayList<RunConfigurator>(10);
|
||||
}
|
||||
|
||||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.XML_READ;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return READ_RUN_CONFIGURATOR;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] { READ_RUN };
|
||||
}
|
||||
|
||||
public boolean isElementPhase() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException {
|
||||
for (RunConfigurator conf : runConf) {
|
||||
try {
|
||||
|
|
@ -576,17 +633,21 @@ public class X4OPhaseLanguageRead {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
}
|
||||
|
||||
class RunConfigurator {
|
||||
Element element;
|
||||
ElementConfigurator elementConfigurator;
|
||||
|
||||
RunConfigurator(Element element, ElementConfigurator elementConfigurator) {
|
||||
this.element = element;
|
||||
this.elementConfigurator = elementConfigurator;
|
||||
}
|
||||
}
|
||||
|
||||
public void runElementConfigurator(ElementConfigurator ec, Element e, X4OPhase phase) throws X4OPhaseException {
|
||||
if (ec.isConfigAction()) {
|
||||
runConf.add(new RunConfigurator(e, ec));
|
||||
|
|
@ -615,18 +676,23 @@ public class X4OPhaseLanguageRead {
|
|||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.XML_READ;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return READ_END;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] { READ_RUN_CONFIGURATOR };
|
||||
}
|
||||
|
||||
public boolean isElementPhase() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
// not used.
|
||||
}
|
||||
|
||||
public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException {
|
||||
// print the properties and classes for this language/config
|
||||
if (languageSession.hasX4ODebugWriter()) {
|
||||
|
|
@ -647,29 +713,14 @@ public class X4OPhaseLanguageRead {
|
|||
|
||||
// for debug output TODO: redo release counters
|
||||
/*
|
||||
class ReleasePhaseListener implements X4OPhaseListener {
|
||||
private int elementsReleased = 0;
|
||||
public void preRunPhase(X4OPhase phase,X4OLanguageSession languageSession) throws X4OPhaseException {
|
||||
elementsReleased=0;
|
||||
}
|
||||
public void endRunPhase(X4OPhase phase,X4OLanguageSession languageSession) throws X4OPhaseException {
|
||||
if (languageSession.hasX4ODebugWriter()==false) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "elements", "", "", elementsReleased+"");
|
||||
languageSession.getX4ODebugWriter().getContentWriter().startElement (X4ODebugWriter.DEBUG_URI, "executeReleases", "", atts);
|
||||
languageSession.getX4ODebugWriter().getContentWriter().endElement (X4ODebugWriter.DEBUG_URI, "executeReleases" , "");
|
||||
} catch (SAXException e) {
|
||||
throw new X4OPhaseException(phase,e);
|
||||
}
|
||||
}
|
||||
|
||||
public void addReleasedElement() {
|
||||
elementsReleased++;
|
||||
}
|
||||
}
|
||||
* class ReleasePhaseListener implements X4OPhaseListener { private int elementsReleased = 0; public void preRunPhase(X4OPhase phase,X4OLanguageSession
|
||||
* languageSession) throws X4OPhaseException { elementsReleased=0; } public void endRunPhase(X4OPhase phase,X4OLanguageSession languageSession) throws
|
||||
* X4OPhaseException { if (languageSession.hasX4ODebugWriter()==false) { return; } try { AttributesImpl atts = new AttributesImpl(); atts.addAttribute
|
||||
* ("", "elements", "", "", elementsReleased+""); languageSession.getX4ODebugWriter().getContentWriter().startElement (X4ODebugWriter.DEBUG_URI,
|
||||
* "executeReleases", "", atts); languageSession.getX4ODebugWriter().getContentWriter().endElement (X4ODebugWriter.DEBUG_URI, "executeReleases" , ""); }
|
||||
* catch (SAXException e) { throw new X4OPhaseException(phase,e); } }
|
||||
*
|
||||
* public void addReleasedElement() { elementsReleased++; } }
|
||||
*/
|
||||
|
||||
// final ReleasePhaseListener releaseCounter = new ReleasePhaseListener();
|
||||
|
|
@ -677,14 +728,18 @@ public class X4OPhaseLanguageRead {
|
|||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.XML_READ;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return READ_RELEASE;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] { READ_END };
|
||||
}
|
||||
|
||||
public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException {
|
||||
}
|
||||
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
try {
|
||||
element.release();
|
||||
|
|
|
|||
|
|
@ -66,17 +66,22 @@ public class X4OPhaseLanguageWrite {
|
|||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.XML_WRITE;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return WRITE_BEGIN;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] {};
|
||||
}
|
||||
|
||||
public boolean isElementPhase() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
}
|
||||
|
||||
public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException {
|
||||
logger.finest("Run init begin phase");
|
||||
}
|
||||
|
|
@ -89,17 +94,22 @@ public class X4OPhaseLanguageWrite {
|
|||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.XML_WRITE;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return WRITE_FILL_TREE;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] { WRITE_BEGIN };
|
||||
}
|
||||
|
||||
public boolean isElementPhase() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
}
|
||||
|
||||
public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException {
|
||||
try {
|
||||
Element root = languageSession.getRootElement();
|
||||
|
|
@ -112,7 +122,8 @@ public class X4OPhaseLanguageWrite {
|
|||
}
|
||||
}
|
||||
|
||||
private Element fillElementTree(X4OLanguageSession languageSession,Object object) throws ElementNamespaceInstanceProviderException, ElementBindingHandlerException {
|
||||
private Element fillElementTree(X4OLanguageSession languageSession, Object object)
|
||||
throws ElementNamespaceInstanceProviderException, ElementBindingHandlerException {
|
||||
Element element = findRootElement(languageSession, object.getClass());
|
||||
element.setElementObject(object);
|
||||
languageSession.setRootElement(element);
|
||||
|
|
@ -124,7 +135,8 @@ public class X4OPhaseLanguageWrite {
|
|||
return element;
|
||||
}
|
||||
|
||||
private void fillTree(X4OLanguageSession languageSession,Element element) throws ElementNamespaceInstanceProviderException, ElementBindingHandlerException {
|
||||
private void fillTree(X4OLanguageSession languageSession, Element element)
|
||||
throws ElementNamespaceInstanceProviderException, ElementBindingHandlerException {
|
||||
for (Element e : element.getChilderen()) {
|
||||
Object object = e.getElementObject();
|
||||
for (ElementBindingHandler bind : languageSession.getLanguage().findElementBindingHandlers(object)) {
|
||||
|
|
@ -167,17 +179,22 @@ public class X4OPhaseLanguageWrite {
|
|||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.XML_WRITE;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return WRITE_END;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] { WRITE_FILL_TREE };
|
||||
}
|
||||
|
||||
public boolean isElementPhase() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
}
|
||||
|
||||
public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException {
|
||||
logger.finest("Run init end phase");
|
||||
}
|
||||
|
|
@ -187,22 +204,26 @@ public class X4OPhaseLanguageWrite {
|
|||
public X4OPhaseType getType() {
|
||||
return X4OPhaseType.XML_WRITE;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return WRITE_RELEASE;
|
||||
}
|
||||
|
||||
public String[] getPhaseDependencies() {
|
||||
return new String[] { WRITE_END };
|
||||
}
|
||||
|
||||
public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException {
|
||||
}
|
||||
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
try {
|
||||
element.release();
|
||||
} catch (ElementException e) {
|
||||
throw new X4OPhaseException(this, e);
|
||||
}/* finally {
|
||||
releaseCounter.addReleasedElement();
|
||||
}*/
|
||||
} /*
|
||||
* finally { releaseCounter.addReleasedElement(); }
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,10 +24,8 @@ package org.x4o.xml.lang.phase;
|
|||
|
||||
import org.x4o.xml.lang.X4OLanguageSession;
|
||||
|
||||
|
||||
/**
|
||||
* An X4OPhaseListener can be placed on an X4OPhaseHandler and is called
|
||||
* before and after the phase has runned.
|
||||
* An X4OPhaseListener can be placed on an X4OPhaseHandler and is called before and after the phase has runned.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 31, 2008
|
||||
|
|
@ -36,6 +34,7 @@ public interface X4OPhaseListener {
|
|||
|
||||
/**
|
||||
* Gets called before the X4OPhaseHandler is run.
|
||||
*
|
||||
* @param phase The phase to be run.
|
||||
* @param languageSession The X4O language session of the driver.
|
||||
* @throws X4OPhaseException Is throws when listeners has error.
|
||||
|
|
@ -44,6 +43,7 @@ public interface X4OPhaseListener {
|
|||
|
||||
/**
|
||||
* Gets called after the X4OPhaseHandler is runned.
|
||||
*
|
||||
* @param phase The phase just run.
|
||||
* @param languageSession The X4O language session of the driver.
|
||||
* @throws X4OPhaseException Is throws when listeners has error.
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@ import org.x4o.xml.element.Element;
|
|||
import org.x4o.xml.lang.X4OLanguageSession;
|
||||
|
||||
/**
|
||||
* X4OPhaseManager stores the X4OPhaseHandler and puts them in the right order.
|
||||
* And will execute the phases when runPhases is called.
|
||||
* X4OPhaseManager stores the X4OPhaseHandler and puts them in the right order. And will execute the phases when runPhases is called.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 6, 2008
|
||||
|
|
@ -38,6 +37,7 @@ public interface X4OPhaseManager {
|
|||
|
||||
/**
|
||||
* Gets an X4OPhase object by the phaseName.
|
||||
*
|
||||
* @param phaseName The phaseName to lookup.
|
||||
* @return The X4OPhase requested or null.
|
||||
*/
|
||||
|
|
@ -45,12 +45,14 @@ public interface X4OPhaseManager {
|
|||
|
||||
/**
|
||||
* Gets all the keys of the phases registrated whith this phase manager.
|
||||
*
|
||||
* @return The phase keys.
|
||||
*/
|
||||
List<String> getPhaseKeys();
|
||||
|
||||
/**
|
||||
* Runs release phase if it was requested not to run it automaticly.
|
||||
*
|
||||
* @param languageSession The session to release.
|
||||
* @throws X4OPhaseException When a running handlers throws one.
|
||||
*/
|
||||
|
|
@ -58,12 +60,14 @@ public interface X4OPhaseManager {
|
|||
|
||||
/**
|
||||
* Runs all the phases in the right order.
|
||||
*
|
||||
* @throws X4OPhaseException When a running handlers throws one.
|
||||
*/
|
||||
void runPhases(X4OLanguageSession elementContext, X4OPhaseType type) throws X4OPhaseException;
|
||||
|
||||
/**
|
||||
* Runs phase on single element.
|
||||
*
|
||||
* @param e The Element to process.
|
||||
* @param p The phase to run.
|
||||
* @throws X4OPhaseException When a running handlers throws one.
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
*/
|
||||
package org.x4o.xml.lang.phase;
|
||||
|
||||
|
||||
/**
|
||||
* X4OPhaseManagerLocal has the local config methods.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ package org.x4o.xml.lang.task;
|
|||
|
||||
import org.x4o.xml.lang.X4OLanguage;
|
||||
|
||||
|
||||
/**
|
||||
* X4OLanguageTaskExecutor runs the language task.
|
||||
*
|
||||
|
|
@ -35,6 +34,7 @@ public interface X4OLanguageTaskExecutor {
|
|||
|
||||
/**
|
||||
* Executes a task for which this executor is created.
|
||||
*
|
||||
* @param language The language for which we run the task.
|
||||
* @throws X4OLanguageTaskException Can be thrown in case of error.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ import org.xml.sax.SAXException;
|
|||
*/
|
||||
public class X4OStaticWriter {
|
||||
|
||||
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"x4o-static/";
|
||||
//@formatter:off
|
||||
public final static SAX3PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
||||
|
||||
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"x4o-static/";
|
||||
public final static String OUTPUT_PATH = PROPERTY_CONTEXT_PREFIX+"output/path";
|
||||
public final static String OUTPUT_OASIS_XMLNS_CATALOG = PROPERTY_CONTEXT_PREFIX+"output/oasis-xml-catalog";
|
||||
|
||||
|
|
@ -53,6 +53,7 @@ public class X4OStaticWriter {
|
|||
new PropertyConfigItem(OUTPUT_OASIS_XMLNS_CATALOG, Boolean.class, false)
|
||||
);
|
||||
}
|
||||
//@formatter:on
|
||||
|
||||
private final SAX3PropertyConfig propertyConfig;
|
||||
|
||||
|
|
|
|||
|
|
@ -197,13 +197,16 @@ public class X4OTaskCommandLine {
|
|||
StringBuilder buf = new StringBuilder(defaultValue.length() + 10);
|
||||
for (char c : defaultValue.toCharArray()) {
|
||||
if (c == '\n') {
|
||||
buf.append("\\n");continue;
|
||||
buf.append("\\n");
|
||||
continue;
|
||||
}
|
||||
if (c == '\t') {
|
||||
buf.append("\\t");continue;
|
||||
buf.append("\\t");
|
||||
continue;
|
||||
}
|
||||
if (c == '\r') {
|
||||
buf.append("\\r");continue;
|
||||
buf.append("\\r");
|
||||
continue;
|
||||
}
|
||||
buf.append(c);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ public class X4OTaskProperty {
|
|||
|
||||
/**
|
||||
* Parsed line like 'key=value' into a X4OTaskProperty object.
|
||||
*
|
||||
* @param line The text line to parse.
|
||||
* @return The filled X4OTaskProperty.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -37,8 +37,7 @@ import org.x4o.xml.lang.task.X4OLanguageTaskException;
|
|||
import org.x4o.xml.lang.task.X4OLanguageTaskExecutor;
|
||||
|
||||
/**
|
||||
* X4OTaskRunner finds all x4o objects and configs and then run the x4o langauge
|
||||
* task.
|
||||
* X4OTaskRunner finds all x4o objects and configs and then run the x4o langauge task.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 30, 2013
|
||||
|
|
|
|||
|
|
@ -101,16 +101,13 @@ public class X4ODriverManagerTest {
|
|||
e = catchE;
|
||||
}
|
||||
Assertions.assertNotNull(e);
|
||||
/* TODO
|
||||
assertNotNull(e);
|
||||
assertNotNull(e.getCause());
|
||||
assertNotNull(e.getCause().getCause());
|
||||
assertEquals(X4OPhaseException.class, e.getCause().getClass());
|
||||
assertEquals(X4OLanguageLoaderException.class, e.getCause().getCause().getClass());
|
||||
assertTrue("Error message string is missing language",e.getMessage().contains("language"));
|
||||
assertTrue("Error message string is missing test",e.getMessage().contains("test"));
|
||||
assertTrue("Error message string is missing modules",e.getMessage().contains("modules"));
|
||||
assertTrue("Error message string is missing 2.0",e.getMessage().contains("2.0"));
|
||||
/*
|
||||
* TODO assertNotNull(e); assertNotNull(e.getCause()); assertNotNull(e.getCause().getCause()); assertEquals(X4OPhaseException.class,
|
||||
* e.getCause().getClass()); assertEquals(X4OLanguageLoaderException.class, e.getCause().getCause().getClass());
|
||||
* assertTrue("Error message string is missing language",e.getMessage().contains("language"));
|
||||
* assertTrue("Error message string is missing test",e.getMessage().contains("test"));
|
||||
* assertTrue("Error message string is missing modules",e.getMessage().contains("modules"));
|
||||
* assertTrue("Error message string is missing 2.0",e.getMessage().contains("2.0"));
|
||||
*/
|
||||
}
|
||||
|
||||
|
|
@ -158,8 +155,15 @@ public class X4ODriverManagerTest {
|
|||
Exception e = null;
|
||||
try {
|
||||
X4ODriverManager.registerX4ODriver(new X4ODriver<Object>() {
|
||||
@Override public String[] getLanguageVersions() { return new String[]{"1.0"}; }
|
||||
@Override public String getLanguageName() { return null; }
|
||||
@Override
|
||||
public String[] getLanguageVersions() {
|
||||
return new String[] { "1.0" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguageName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
});
|
||||
} catch (Exception catchE) {
|
||||
|
|
@ -175,8 +179,15 @@ public class X4ODriverManagerTest {
|
|||
Exception e = null;
|
||||
try {
|
||||
X4ODriverManager.registerX4ODriver(new X4ODriver<Object>() {
|
||||
@Override public String[] getLanguageVersions() { return new String[]{"1.0"}; }
|
||||
@Override public String getLanguageName() { return ""; }
|
||||
@Override
|
||||
public String[] getLanguageVersions() {
|
||||
return new String[] { "1.0" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguageName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
});
|
||||
} catch (Exception catchE) {
|
||||
|
|
@ -192,8 +203,15 @@ public class X4ODriverManagerTest {
|
|||
Exception e = null;
|
||||
try {
|
||||
X4ODriverManager.registerX4ODriver(new X4ODriver<Object>() {
|
||||
@Override public String[] getLanguageVersions() { return null; }
|
||||
@Override public String getLanguageName() { return "junit-driver-test"; }
|
||||
@Override
|
||||
public String[] getLanguageVersions() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguageName() {
|
||||
return "junit-driver-test";
|
||||
}
|
||||
|
||||
});
|
||||
} catch (Exception catchE) {
|
||||
|
|
@ -209,8 +227,15 @@ public class X4ODriverManagerTest {
|
|||
Exception e = null;
|
||||
try {
|
||||
X4ODriverManager.registerX4ODriver(new X4ODriver<Object>() {
|
||||
@Override public String[] getLanguageVersions() { return new String[]{}; }
|
||||
@Override public String getLanguageName() { return "junit-driver-test"; }
|
||||
@Override
|
||||
public String[] getLanguageVersions() {
|
||||
return new String[] {};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguageName() {
|
||||
return "junit-driver-test";
|
||||
}
|
||||
|
||||
});
|
||||
} catch (Exception catchE) {
|
||||
|
|
@ -239,8 +264,15 @@ public class X4ODriverManagerTest {
|
|||
Exception e = null;
|
||||
try {
|
||||
X4ODriverManager.deregisterX4ODriver(new X4ODriver<Object>() {
|
||||
@Override public String[] getLanguageVersions() { return new String[]{"1.0"}; }
|
||||
@Override public String getLanguageName() { return null; }
|
||||
@Override
|
||||
public String[] getLanguageVersions() {
|
||||
return new String[] { "1.0" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguageName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
});
|
||||
} catch (Exception catchE) {
|
||||
|
|
@ -256,8 +288,15 @@ public class X4ODriverManagerTest {
|
|||
Exception e = null;
|
||||
try {
|
||||
X4ODriver<?> driver = new X4ODriver<Object>() {
|
||||
@Override public String[] getLanguageVersions() { return new String[]{"1.0"}; }
|
||||
@Override public String getLanguageName() { return "junit-driver-test"; }
|
||||
@Override
|
||||
public String[] getLanguageVersions() {
|
||||
return new String[] { "1.0" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguageName() {
|
||||
return "junit-driver-test";
|
||||
}
|
||||
};
|
||||
X4ODriverManager.registerX4ODriver(driver);
|
||||
Assertions.assertEquals(driver.hashCode(), X4ODriverManager.getX4ODriver("junit-driver-test").hashCode());
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ import org.x4o.xml.lang.phase.X4OPhaseType;
|
|||
import org.x4o.xml.test.TestDriver;
|
||||
|
||||
/**
|
||||
* Tests some code for testing x4o phases.
|
||||
* *
|
||||
* Tests some code for testing x4o phases. *
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 15, 2009
|
||||
*/
|
||||
|
|
@ -67,18 +67,9 @@ public class X4OPhaseManagerTest {
|
|||
}
|
||||
|
||||
/*
|
||||
public void testPhaseManager() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
ElementLanguage context = driver.createLanguageSession();
|
||||
X4OPhaseManager manager = context.getLanguage().getPhaseManager();
|
||||
|
||||
Exception e = null;
|
||||
try {
|
||||
manager.addX4OPhaseHandler(null);
|
||||
} catch (NullPointerException ee) {
|
||||
e = ee;
|
||||
}
|
||||
Assertions.assertEquals(true, e!=null );
|
||||
}
|
||||
* public void testPhaseManager() throws Exception { TestDriver driver = TestDriver.getInstance(); ElementLanguage context = driver.createLanguageSession();
|
||||
* X4OPhaseManager manager = context.getLanguage().getPhaseManager();
|
||||
*
|
||||
* Exception e = null; try { manager.addX4OPhaseHandler(null); } catch (NullPointerException ee) { e = ee; } Assertions.assertEquals(true, e!=null ); }
|
||||
*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,24 +78,12 @@ public class X4OWriteLanguageDocExecutorTest {
|
|||
testDoc(TestDriver.LANGUAGE_NAME, "junit-doc-test");
|
||||
}
|
||||
/*
|
||||
@Test
|
||||
public void testSwiXml2Doc() throws Exception {
|
||||
testDoc(EldDriver.LANGUAGE_NAME,"junit-doc-eld");
|
||||
EldDocLanguageTask writer = new EldDocLanguageTask();
|
||||
writer.setBasePath(createOutputTargetPath("junit-swixml2"));
|
||||
writer.setLanguageName(SwiXmlDriver.LANGUAGE_NAME);
|
||||
writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_2);
|
||||
writer.execute();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwiXml3Doc() throws Exception {
|
||||
testDoc(EldDriver.LANGUAGE_NAME,"junit-doc-eld");
|
||||
EldDocLanguageTask writer = new EldDocLanguageTask();
|
||||
writer.setBasePath(createOutputTargetPath("junit-swixml3"));
|
||||
writer.setLanguageName(SwiXmlDriver.LANGUAGE_NAME);
|
||||
writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_3);
|
||||
writer.execute();
|
||||
}
|
||||
* @Test public void testSwiXml2Doc() throws Exception { testDoc(EldDriver.LANGUAGE_NAME,"junit-doc-eld"); EldDocLanguageTask writer = new
|
||||
* EldDocLanguageTask(); writer.setBasePath(createOutputTargetPath("junit-swixml2")); writer.setLanguageName(SwiXmlDriver.LANGUAGE_NAME);
|
||||
* writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_2); writer.execute(); }
|
||||
*
|
||||
* @Test public void testSwiXml3Doc() throws Exception { testDoc(EldDriver.LANGUAGE_NAME,"junit-doc-eld"); EldDocLanguageTask writer = new
|
||||
* EldDocLanguageTask(); writer.setBasePath(createOutputTargetPath("junit-swixml3")); writer.setLanguageName(SwiXmlDriver.LANGUAGE_NAME);
|
||||
* writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_3); writer.execute(); }
|
||||
*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,12 +180,9 @@ public class X4OReaderSessionTest {
|
|||
public void testReadString() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
|
||||
TestObjectRoot root = reader.readString(
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
|
||||
"<root:root xmlns:root=\"http://test.junit.x4o.org/xml/ns/junit-test-root\" xmlns=\"http://test.junit.x4o.org/xml/ns/junit-test-lang\">"+
|
||||
"<testBean privateIntegerTypeField=\"987654321\"/>"+
|
||||
"</root:root>"
|
||||
);
|
||||
TestObjectRoot root = reader.readString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
+ "<root:root xmlns:root=\"http://test.junit.x4o.org/xml/ns/junit-test-root\" xmlns=\"http://test.junit.x4o.org/xml/ns/junit-test-lang\">"
|
||||
+ "<testBean privateIntegerTypeField=\"987654321\"/>" + "</root:root>");
|
||||
Assertions.assertNotNull(root);
|
||||
Assertions.assertTrue(root.getTestBeans().size() > 0);
|
||||
TestBean bean = root.getTestBeans().get(0);
|
||||
|
|
|
|||
|
|
@ -104,12 +104,9 @@ public class X4OReaderTest {
|
|||
public void testReadString() throws Exception {
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||
TestObjectRoot root = reader.readString(
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
|
||||
"<root:root xmlns:root=\"http://test.junit.x4o.org/xml/ns/junit-test-root\" xmlns=\"http://test.junit.x4o.org/xml/ns/junit-test-lang\">"+
|
||||
"<testBean privateIntegerTypeField=\"987654321\"/>"+
|
||||
"</root:root>"
|
||||
);
|
||||
TestObjectRoot root = reader.readString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
+ "<root:root xmlns:root=\"http://test.junit.x4o.org/xml/ns/junit-test-root\" xmlns=\"http://test.junit.x4o.org/xml/ns/junit-test-lang\">"
|
||||
+ "<testBean privateIntegerTypeField=\"987654321\"/>" + "</root:root>");
|
||||
Assertions.assertNotNull(root);
|
||||
Assertions.assertTrue(root.getTestBeans().size() > 0);
|
||||
TestBean bean = root.getTestBeans().get(0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue