Made first crude writing impl for x4o.
This commit is contained in:
parent
b4225f6b0c
commit
179c0f3bfe
|
@ -31,11 +31,12 @@ import org.x4o.xml.io.DefaultX4OWriter;
|
||||||
import org.x4o.xml.io.X4OReader;
|
import org.x4o.xml.io.X4OReader;
|
||||||
import org.x4o.xml.io.X4OSchemaWriter;
|
import org.x4o.xml.io.X4OSchemaWriter;
|
||||||
import org.x4o.xml.io.X4OWriter;
|
import org.x4o.xml.io.X4OWriter;
|
||||||
|
|
||||||
|
import org.x4o.xml.lang.X4OLanguageConfiguration;
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
import org.x4o.xml.lang.X4OLanguage;
|
import org.x4o.xml.lang.X4OLanguage;
|
||||||
import org.x4o.xml.lang.X4OLanguagePropertyKeys;
|
import org.x4o.xml.lang.X4OLanguagePropertyKeys;
|
||||||
import org.x4o.xml.lang.phase.X4OPhaseException;
|
import org.x4o.xml.lang.phase.X4OPhaseManager;
|
||||||
import org.x4o.xml.lang.phase.X4OPhaseType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the starting point of the XML X4O Language Driver.
|
* This is the starting point of the XML X4O Language Driver.
|
||||||
|
@ -55,38 +56,32 @@ public abstract class X4ODriver<T> {
|
||||||
X4ODriverManager.registerX4ODriver(this);
|
X4ODriverManager.registerX4ODriver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the langauge name of this driver.
|
||||||
|
*/
|
||||||
abstract public String getLanguageName();
|
abstract public String getLanguageName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the supported language versions for this driver.
|
||||||
|
*/
|
||||||
abstract public String[] getLanguageVersions();
|
abstract public String[] getLanguageVersions();
|
||||||
|
|
||||||
abstract public X4OLanguage buildLanguage(String version);
|
|
||||||
|
|
||||||
public X4OLanguage createLanguage(String version) {
|
|
||||||
X4OLanguage result = null;
|
protected X4OLanguage buildLanguage(String version) {
|
||||||
if (result==null) {
|
return X4ODriverManager.getDefaultBuildLanguage(this, version);
|
||||||
result = buildLanguage(version);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public X4OLanguageContext createLanguageContext() {
|
protected X4OPhaseManager buildPhaseManager() {
|
||||||
return createLanguageContext(getLanguageVersionDefault());
|
return X4ODriverManager.getDefaultBuildPhaseManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public X4OLanguageContext createLanguageContext(String version) {
|
protected X4OLanguageConfiguration buildLanguageConfiguration() {
|
||||||
X4OLanguage language = createLanguage(version);
|
return X4ODriverManager.getDefaultBuildLanguageConfiguration();
|
||||||
X4OLanguageContext result = language.getLanguageConfiguration().createElementLanguage(this);
|
|
||||||
|
|
||||||
try {
|
|
||||||
result.getLanguage().getPhaseManager().runPhases(result, X4OPhaseType.INIT);
|
|
||||||
} catch (X4OPhaseException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public X4OSchemaWriter createSchemaWriter() {
|
public X4OSchemaWriter createSchemaWriter() {
|
||||||
return createSchemaWriter(getLanguageVersionDefault());
|
return createSchemaWriter(getLanguageVersionDefault());
|
||||||
}
|
}
|
||||||
|
@ -112,24 +107,27 @@ public abstract class X4ODriver<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLanguageVersionDefault() {
|
public String getLanguageVersionDefault() {
|
||||||
String[] lang = getLanguageVersions();
|
return X4ODriverManager.getDefaultLanguageVersion(getLanguageVersions());
|
||||||
if (lang==null || lang.length==0) {
|
|
||||||
return DEFAULT_LANGUAGE_VERSION;
|
|
||||||
}
|
|
||||||
String langVersion = lang[lang.length-1];
|
|
||||||
return langVersion;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Returns the property keys which can be set.
|
|
||||||
*/
|
|
||||||
public String[] getGlobalPropertyKeySet() {
|
public String[] getGlobalPropertyKeySet() {
|
||||||
return X4OLanguagePropertyKeys.DEFAULT_X4O_GLOBAL_KEYS;
|
return X4OLanguagePropertyKeys.DEFAULT_X4O_GLOBAL_KEYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Returns the property keys which are set.
|
|
||||||
*/
|
final public X4OLanguage createLanguage(String version) {
|
||||||
|
return buildLanguage(version);
|
||||||
|
}
|
||||||
|
|
||||||
|
final public X4OLanguageContext createLanguageContext() {
|
||||||
|
return createLanguageContext(getLanguageVersionDefault());
|
||||||
|
}
|
||||||
|
|
||||||
|
final public X4OLanguageContext createLanguageContext(String version) {
|
||||||
|
return createLanguage(version).createLanguageContext(this);
|
||||||
|
}
|
||||||
|
|
||||||
final public Collection<String> getGlobalPropertyKeys() {
|
final public Collection<String> getGlobalPropertyKeys() {
|
||||||
return X4ODriverManager.getGlobalPropertyKeys(this);
|
return X4ODriverManager.getGlobalPropertyKeys(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,15 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.x4o.xml.lang.DefaultX4OLanguage;
|
||||||
|
import org.x4o.xml.lang.DefaultX4OLanguageConfiguration;
|
||||||
|
import org.x4o.xml.lang.X4OLanguage;
|
||||||
import org.x4o.xml.lang.X4OLanguageClassLoader;
|
import org.x4o.xml.lang.X4OLanguageClassLoader;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageConfiguration;
|
||||||
|
import org.x4o.xml.lang.phase.DefaultX4OPhaseManager;
|
||||||
|
import org.x4o.xml.lang.phase.X4OPhaseLanguageInit;
|
||||||
|
import org.x4o.xml.lang.phase.X4OPhaseLanguageRead;
|
||||||
|
import org.x4o.xml.lang.phase.X4OPhaseManager;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
@ -66,6 +74,38 @@ public final class X4ODriverManager {
|
||||||
instance = new X4ODriverManager();
|
instance = new X4ODriverManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static protected String getDefaultLanguageVersion(String[] languages) {
|
||||||
|
if (languages==null || languages.length==0) {
|
||||||
|
return X4ODriver.DEFAULT_LANGUAGE_VERSION;
|
||||||
|
}
|
||||||
|
String languageVersion = languages[languages.length-1];
|
||||||
|
return languageVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
static protected X4OPhaseManager getDefaultBuildPhaseManager() {
|
||||||
|
DefaultX4OPhaseManager manager = new DefaultX4OPhaseManager();
|
||||||
|
new X4OPhaseLanguageInit().createPhases(manager);
|
||||||
|
new X4OPhaseLanguageRead().createPhases(manager);
|
||||||
|
//new X4OPhaseLanguageWrite().createPhases(manager);
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
static protected X4OLanguage getDefaultBuildLanguage(X4ODriver<?> driver,String version) {
|
||||||
|
if (version==null) {
|
||||||
|
version = driver.getLanguageVersionDefault();
|
||||||
|
}
|
||||||
|
return new DefaultX4OLanguage(
|
||||||
|
driver.buildLanguageConfiguration(),
|
||||||
|
driver.buildPhaseManager(),
|
||||||
|
driver.getLanguageName(),
|
||||||
|
version
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static protected X4OLanguageConfiguration getDefaultBuildLanguageConfiguration() {
|
||||||
|
return new DefaultX4OLanguageConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
static public Collection<String> getGlobalPropertyKeys(X4ODriver<?> driver) {
|
static public Collection<String> getGlobalPropertyKeys(X4ODriver<?> driver) {
|
||||||
Map<String,Object> driverProperties = instance.globalProperties.get(driver.getLanguageName());
|
Map<String,Object> driverProperties = instance.globalProperties.get(driver.getLanguageName());
|
||||||
if (driverProperties==null) {
|
if (driverProperties==null) {
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2012, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.x4o.xml.el;
|
||||||
|
|
||||||
|
import javax.el.ExpressionFactory;
|
||||||
|
|
||||||
|
import org.x4o.xml.lang.X4OLanguageClassLoader;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OExpressionFactory finds and loads the needed impl.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Apr 7, 2013
|
||||||
|
*/
|
||||||
|
public class X4OExpressionFactory {
|
||||||
|
|
||||||
|
static public final String EL_FACTORY_IMPL_APACHE = "org.apache.el.ExpressionFactoryImpl";
|
||||||
|
static public final String EL_FACTORY_IMPL_ODYSSEUS = "de.odysseus.el.ExpressionFactoryImpl";
|
||||||
|
|
||||||
|
static public ExpressionFactory createExpressionFactory(X4OLanguageContext elementContext) {
|
||||||
|
ExpressionFactory factory = (ExpressionFactory)elementContext.getLanguageProperty(X4OLanguageProperty.EL_FACTORY_INSTANCE);
|
||||||
|
if (factory!=null) {
|
||||||
|
return factory;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Class<?> expressionFactoryClass = X4OLanguageClassLoader.loadClass(EL_FACTORY_IMPL_APACHE);
|
||||||
|
ExpressionFactory expressionFactory = (ExpressionFactory) expressionFactoryClass.newInstance();
|
||||||
|
return expressionFactory;
|
||||||
|
} catch (Exception e) {
|
||||||
|
try {
|
||||||
|
Class<?> expressionFactoryClass = X4OLanguageClassLoader.loadClass(EL_FACTORY_IMPL_ODYSSEUS);
|
||||||
|
ExpressionFactory expressionFactory = (ExpressionFactory) expressionFactoryClass.newInstance();
|
||||||
|
return expressionFactory;
|
||||||
|
} catch (Exception ee) {
|
||||||
|
throw new RuntimeException("Could not load ExpressionFactory tried: "+EL_FACTORY_IMPL_APACHE+" and "+EL_FACTORY_IMPL_ODYSSEUS+" but could not load one of them.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,12 +24,7 @@
|
||||||
package org.x4o.xml.eld;
|
package org.x4o.xml.eld;
|
||||||
|
|
||||||
import org.x4o.xml.X4ODriver;
|
import org.x4o.xml.X4ODriver;
|
||||||
import org.x4o.xml.lang.DefaultX4OLanguage;
|
|
||||||
import org.x4o.xml.lang.DefaultX4OLanguageConfiguration;
|
|
||||||
import org.x4o.xml.lang.X4OLanguageModule;
|
import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
import org.x4o.xml.lang.X4OLanguage;
|
|
||||||
import org.x4o.xml.lang.phase.X4OPhaseManagerFactory;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CelDriver is the Core Element Language driver.
|
* CelDriver is the Core Element Language driver.
|
||||||
|
@ -52,9 +47,4 @@ public class CelDriver extends X4ODriver<X4OLanguageModule> {
|
||||||
public String[] getLanguageVersions() {
|
public String[] getLanguageVersions() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public X4OLanguage buildLanguage(String version) {
|
|
||||||
return new DefaultX4OLanguage(new DefaultX4OLanguageConfiguration(),X4OPhaseManagerFactory.createDefaultX4OPhaseManager(),getLanguageName(),getLanguageVersionDefault());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,7 @@
|
||||||
package org.x4o.xml.eld;
|
package org.x4o.xml.eld;
|
||||||
|
|
||||||
import org.x4o.xml.X4ODriver;
|
import org.x4o.xml.X4ODriver;
|
||||||
import org.x4o.xml.lang.DefaultX4OLanguage;
|
|
||||||
import org.x4o.xml.lang.DefaultX4OLanguageConfiguration;
|
|
||||||
import org.x4o.xml.lang.X4OLanguageModule;
|
import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
import org.x4o.xml.lang.X4OLanguage;
|
|
||||||
import org.x4o.xml.lang.phase.X4OPhaseManagerFactory;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An Element Language Definition X4O parser.
|
* An Element Language Definition X4O parser.
|
||||||
|
@ -55,9 +50,4 @@ public class EldDriver extends X4ODriver<X4OLanguageModule> {
|
||||||
public String[] getLanguageVersions() {
|
public String[] getLanguageVersions() {
|
||||||
return LANGUAGE_VERSIONS;
|
return LANGUAGE_VERSIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public X4OLanguage buildLanguage(String version) {
|
|
||||||
return new DefaultX4OLanguage(new DefaultX4OLanguageConfiguration(),X4OPhaseManagerFactory.createDefaultX4OPhaseManager(),getLanguageName(),getLanguageVersionDefault());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.x4o.xml.element.ElementClassAttribute;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Aug 21, 2012
|
* @version 1.0 Aug 21, 2012
|
||||||
*/
|
*/
|
||||||
public class ElementClassAttributeBindingHandler extends AbstractElementBindingHandler {
|
public class ElementClassAttributeBindingHandler extends AbstractElementBindingHandler<ElementClassAttribute> {
|
||||||
|
|
||||||
|
|
||||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
||||||
|
@ -56,13 +56,13 @@ public class ElementClassAttributeBindingHandler extends AbstractElementBindingH
|
||||||
return CLASSES_CHILD;
|
return CLASSES_CHILD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void bindChild(Element childElement,ElementClassAttribute parentObject,Object childObject) throws ElementBindingHandlerException {
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#doBind(java.lang.Object, java.lang.Object, org.x4o.xml.element.Element)
|
|
||||||
*/
|
|
||||||
public void doBind(Object parentObject, Object childObject,Element childElement) throws ElementBindingHandlerException {
|
|
||||||
ElementClassAttribute parent = (ElementClassAttribute)parentObject;
|
|
||||||
if (childObject instanceof ObjectConverter) {
|
if (childObject instanceof ObjectConverter) {
|
||||||
parent.setObjectConverter((ObjectConverter)childObject);
|
parentObject.setObjectConverter((ObjectConverter)childObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void createChilderen(Element parentElement,ElementClassAttribute parentObject) throws ElementBindingHandlerException {
|
||||||
|
createChild(parentElement, parentObject.getObjectConverter());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.x4o.xml.element.ElementConfigurator;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Jan 31, 2007
|
* @version 1.0 Jan 31, 2007
|
||||||
*/
|
*/
|
||||||
public class ElementClassBindingHandler extends AbstractElementBindingHandler {
|
public class ElementClassBindingHandler extends AbstractElementBindingHandler<ElementClass> {
|
||||||
|
|
||||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
||||||
ElementClassAttribute.class,
|
ElementClassAttribute.class,
|
||||||
|
@ -59,10 +59,9 @@ public class ElementClassBindingHandler extends AbstractElementBindingHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#doBind(java.lang.Object, java.lang.Object, org.x4o.xml.element.Element)
|
* @see org.x4o.xml.element.ElementBindingHandler#bindChild(org.x4o.xml.element.Element,java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void doBind(Object parentObject, Object childObject,Element childElement) throws ElementBindingHandlerException {
|
public void bindChild(Element childElement,ElementClass parent, Object childObject) throws ElementBindingHandlerException {
|
||||||
ElementClass parent = (ElementClass)parentObject;
|
|
||||||
if (childObject instanceof ElementClassAttribute) {
|
if (childObject instanceof ElementClassAttribute) {
|
||||||
parent.addElementClassAttribute((ElementClassAttribute)childObject);
|
parent.addElementClassAttribute((ElementClassAttribute)childObject);
|
||||||
}
|
}
|
||||||
|
@ -70,4 +69,13 @@ public class ElementClassBindingHandler extends AbstractElementBindingHandler {
|
||||||
parent.addElementConfigurators((ElementConfigurator)childObject);
|
parent.addElementConfigurators((ElementConfigurator)childObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void createChilderen(Element parentElement,ElementClass parent) throws ElementBindingHandlerException {
|
||||||
|
for (ElementClassAttribute child:parent.getElementClassAttributes()) {
|
||||||
|
createChild(parentElement, child);
|
||||||
|
}
|
||||||
|
for (ElementConfigurator child:parent.getElementConfigurators()) {
|
||||||
|
createChild(parentElement, child);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.x4o.xml.element.ElementInterface;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Aug 21, 2012
|
* @version 1.0 Aug 21, 2012
|
||||||
*/
|
*/
|
||||||
public class ElementInterfaceBindingHandler extends AbstractElementBindingHandler {
|
public class ElementInterfaceBindingHandler extends AbstractElementBindingHandler<ElementInterface> {
|
||||||
|
|
||||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
||||||
ElementClassAttribute.class,
|
ElementClassAttribute.class,
|
||||||
|
@ -60,10 +60,9 @@ public class ElementInterfaceBindingHandler extends AbstractElementBindingHandle
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#doBind(java.lang.Object, java.lang.Object, org.x4o.xml.element.Element)
|
* @see org.x4o.xml.element.ElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void doBind(Object parentObject, Object childObject,Element childElement) throws ElementBindingHandlerException {
|
public void bindChild(Element childElement,ElementInterface parent, Object childObject) throws ElementBindingHandlerException {
|
||||||
ElementInterface parent = (ElementInterface)parentObject;
|
|
||||||
if (childObject instanceof ElementBindingHandler) {
|
if (childObject instanceof ElementBindingHandler) {
|
||||||
parent.addElementBindingHandler((ElementBindingHandler)childObject);
|
parent.addElementBindingHandler((ElementBindingHandler)childObject);
|
||||||
}
|
}
|
||||||
|
@ -74,4 +73,16 @@ public class ElementInterfaceBindingHandler extends AbstractElementBindingHandle
|
||||||
parent.addElementConfigurators((ElementConfigurator)childObject);
|
parent.addElementConfigurators((ElementConfigurator)childObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void createChilderen(Element parentElement,ElementInterface parent) throws ElementBindingHandlerException {
|
||||||
|
for (ElementBindingHandler child:parent.getElementBindingHandlers()) {
|
||||||
|
createChild(parentElement, child);
|
||||||
|
}
|
||||||
|
for (ElementClassAttribute child:parent.getElementClassAttributes()) {
|
||||||
|
createChild(parentElement, child);
|
||||||
|
}
|
||||||
|
for (ElementConfigurator child:parent.getElementConfigurators()) {
|
||||||
|
createChild(parentElement, child);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ import org.x4o.xml.lang.X4OLanguageProperty;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Jan 19, 2007
|
* @version 1.0 Jan 19, 2007
|
||||||
*/
|
*/
|
||||||
public class ElementModuleBindingHandler extends AbstractElementBindingHandler {
|
public class ElementModuleBindingHandler extends AbstractElementBindingHandler<X4OLanguageModule> {
|
||||||
|
|
||||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
||||||
ElementInterface.class,
|
ElementInterface.class,
|
||||||
|
@ -75,34 +75,33 @@ public class ElementModuleBindingHandler extends AbstractElementBindingHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#doBind(java.lang.Object, java.lang.Object, org.x4o.xml.element.Element)
|
* @see org.x4o.xml.element.ElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void doBind(Object parentObject, Object childObject,Element childElement) throws ElementBindingHandlerException {
|
public void bindChild(Element childElement,X4OLanguageModule languageModule, Object childObject) throws ElementBindingHandlerException {
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
Map m = (Map)childElement.getElementLanguage().getLanguageProperty(X4OLanguageProperty.EL_BEAN_INSTANCE_MAP);
|
Map m = (Map)childElement.getLanguageContext().getLanguageProperty(X4OLanguageProperty.EL_BEAN_INSTANCE_MAP);
|
||||||
if (m==null) {
|
if (m==null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
X4OLanguage x4oParsingContext = (X4OLanguage)m.get(EldModuleLoader.EL_PARENT_LANGUAGE);
|
X4OLanguage x4oParsingContext = (X4OLanguage)m.get(EldModuleLoader.EL_PARENT_LANGUAGE);
|
||||||
//ElementLanguageModule elementLanguageModule = (ElementLanguageModule)m.get(EldParser.PARENT_ELEMENT_LANGUAGE_MODULE);
|
//ElementLanguageModule elementLanguageModule = (ElementLanguageModule)m.get(EldParser.PARENT_ELEMENT_LANGUAGE_MODULE);
|
||||||
X4OLanguageModule elementLanguageModule = (X4OLanguageModule)parentObject;
|
|
||||||
if (x4oParsingContext==null) {
|
if (x4oParsingContext==null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (elementLanguageModule==null) {
|
if (languageModule==null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (childObject instanceof ElementInterface) {
|
if (childObject instanceof ElementInterface) {
|
||||||
ElementInterface elementInterface = (ElementInterface)childObject;
|
ElementInterface elementInterface = (ElementInterface)childObject;
|
||||||
elementLanguageModule.addElementInterface(elementInterface);
|
languageModule.addElementInterface(elementInterface);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (childObject instanceof ElementNamespaceContext) {
|
if (childObject instanceof ElementNamespaceContext) {
|
||||||
ElementNamespaceContext elementNamespaceContext = (ElementNamespaceContext)childObject;
|
ElementNamespaceContext elementNamespaceContext = (ElementNamespaceContext)childObject;
|
||||||
try {
|
try {
|
||||||
elementNamespaceContext.setElementNamespaceInstanceProvider((ElementNamespaceInstanceProvider)X4OLanguageClassLoader.newInstance(childElement.getElementLanguage().getLanguage().getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider()));
|
elementNamespaceContext.setElementNamespaceInstanceProvider((ElementNamespaceInstanceProvider)X4OLanguageClassLoader.newInstance(childElement.getLanguageContext().getLanguage().getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ElementBindingHandlerException("Error loading: "+e.getMessage(),e);
|
throw new ElementBindingHandlerException("Error loading: "+e.getMessage(),e);
|
||||||
}
|
}
|
||||||
|
@ -112,23 +111,41 @@ public class ElementModuleBindingHandler extends AbstractElementBindingHandler
|
||||||
} catch (ElementNamespaceInstanceProviderException e) {
|
} catch (ElementNamespaceInstanceProviderException e) {
|
||||||
throw new ElementBindingHandlerException("Error starting: "+e.getMessage(),e);
|
throw new ElementBindingHandlerException("Error starting: "+e.getMessage(),e);
|
||||||
}
|
}
|
||||||
elementLanguageModule.addElementNamespaceContext(elementNamespaceContext);
|
languageModule.addElementNamespaceContext(elementNamespaceContext);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (childObject instanceof ElementBindingHandler) {
|
if (childObject instanceof ElementBindingHandler) {
|
||||||
ElementBindingHandler elementBindingHandler = (ElementBindingHandler)childObject;
|
ElementBindingHandler elementBindingHandler = (ElementBindingHandler)childObject;
|
||||||
elementLanguageModule.addElementBindingHandler(elementBindingHandler);
|
languageModule.addElementBindingHandler(elementBindingHandler);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (childObject instanceof ElementAttributeHandler) {
|
if (childObject instanceof ElementAttributeHandler) {
|
||||||
ElementAttributeHandler elementAttributeHandler = (ElementAttributeHandler)childObject;
|
ElementAttributeHandler elementAttributeHandler = (ElementAttributeHandler)childObject;
|
||||||
elementLanguageModule.addElementAttributeHandler(elementAttributeHandler);
|
languageModule.addElementAttributeHandler(elementAttributeHandler);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (childObject instanceof ElementConfiguratorGlobal) {
|
if (childObject instanceof ElementConfiguratorGlobal) {
|
||||||
ElementConfiguratorGlobal elementConfigurator = (ElementConfiguratorGlobal)childObject;
|
ElementConfiguratorGlobal elementConfigurator = (ElementConfiguratorGlobal)childObject;
|
||||||
elementLanguageModule.addElementConfiguratorGlobal(elementConfigurator);
|
languageModule.addElementConfiguratorGlobal(elementConfigurator);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void createChilderen(Element parentElement,X4OLanguageModule parent) throws ElementBindingHandlerException {
|
||||||
|
for (ElementInterface child:parent.getElementInterfaces()) {
|
||||||
|
createChild(parentElement, child);
|
||||||
|
}
|
||||||
|
for (ElementNamespaceContext child:parent.getElementNamespaceContexts()) {
|
||||||
|
createChild(parentElement, child);
|
||||||
|
}
|
||||||
|
for (ElementBindingHandler child:parent.getElementBindingHandlers()) {
|
||||||
|
createChild(parentElement, child);
|
||||||
|
}
|
||||||
|
for (ElementAttributeHandler child:parent.getElementAttributeHandlers()) {
|
||||||
|
createChild(parentElement, child);
|
||||||
|
}
|
||||||
|
for (ElementConfiguratorGlobal child:parent.getElementConfiguratorGlobals()) {
|
||||||
|
createChild(parentElement, child);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.x4o.xml.element.ElementNamespaceContext;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Aug 21, 2012
|
* @version 1.0 Aug 21, 2012
|
||||||
*/
|
*/
|
||||||
public class ElementNamespaceContextBindingHandler extends AbstractElementBindingHandler {
|
public class ElementNamespaceContextBindingHandler extends AbstractElementBindingHandler<ElementNamespaceContext> {
|
||||||
|
|
||||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
||||||
ElementClass.class
|
ElementClass.class
|
||||||
|
@ -56,12 +56,17 @@ public class ElementNamespaceContextBindingHandler extends AbstractElementBindin
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#doBind(java.lang.Object, java.lang.Object, org.x4o.xml.element.Element)
|
* @see org.x4o.xml.element.ElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void doBind(Object parentObject, Object childObject,Element childElement) throws ElementBindingHandlerException {
|
public void bindChild(Element childElement,ElementNamespaceContext parent, Object childObject) throws ElementBindingHandlerException {
|
||||||
ElementNamespaceContext parent = (ElementNamespaceContext)parentObject;
|
|
||||||
if (childObject instanceof ElementClass) {
|
if (childObject instanceof ElementClass) {
|
||||||
parent.addElementClass((ElementClass)childObject);
|
parent.addElementClass((ElementClass)childObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void createChilderen(Element parentElement,ElementNamespaceContext parent) throws ElementBindingHandlerException {
|
||||||
|
for (ElementClass child:parent.getElementClasses()) {
|
||||||
|
createChild(parentElement, child);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,10 @@
|
||||||
|
|
||||||
package org.x4o.xml.eld.lang;
|
package org.x4o.xml.eld.lang;
|
||||||
|
|
||||||
|
import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.x4o.xml.element.AbstractElementBindingHandler;
|
import org.x4o.xml.element.AbstractElementBindingHandler;
|
||||||
import org.x4o.xml.element.Element;
|
import org.x4o.xml.element.Element;
|
||||||
|
@ -35,11 +38,12 @@ import org.x4o.xml.element.ElementBindingHandlerException;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Nov 21, 2007
|
* @version 1.0 Nov 21, 2007
|
||||||
*/
|
*/
|
||||||
public class ElementRefectionBindingHandler extends AbstractElementBindingHandler {
|
public class ElementRefectionBindingHandler extends AbstractElementBindingHandler<Object> {
|
||||||
|
|
||||||
private Class<?> parentClass = null;
|
private Class<?> parentClass = null;
|
||||||
private Class<?> childClass = null;
|
private Class<?> childClass = null;
|
||||||
private String method = null;
|
private String addMethod = null;
|
||||||
|
private String getMethod = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||||
|
@ -56,12 +60,12 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#doBind(java.lang.Object, java.lang.Object, org.x4o.xml.element.Element)
|
* @see org.x4o.xml.element.ElementBindingHandler#bindChild(org.x4o.xml.element.Element,java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void doBind(Object parentObject, Object childObject, Element childElement) throws ElementBindingHandlerException {
|
public void bindChild(Element childElement, Object parentObject, Object childObject) throws ElementBindingHandlerException {
|
||||||
|
|
||||||
if (parentClass==null | childClass==null | method==null) {
|
if (parentClass==null | childClass==null | addMethod==null) {
|
||||||
throw new IllegalStateException("Missing property: parentClass="+parentClass+" childClass="+childClass+" method="+method+".");
|
throw new IllegalStateException("Missing property: parentClass="+parentClass+" childClass="+childClass+" addMethod="+addMethod+".");
|
||||||
}
|
}
|
||||||
Method[] ms = parentObject.getClass().getMethods();
|
Method[] ms = parentObject.getClass().getMethods();
|
||||||
for (Method m:ms) {
|
for (Method m:ms) {
|
||||||
|
@ -72,7 +76,7 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
||||||
if (types.length > 1) {
|
if (types.length > 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (method.equalsIgnoreCase(m.getName())==false) {
|
if (addMethod.equalsIgnoreCase(m.getName())==false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (types[0].isAssignableFrom(childClass)) {
|
if (types[0].isAssignableFrom(childClass)) {
|
||||||
|
@ -84,7 +88,53 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new ElementBindingHandlerException("Could not find method: "+method+" on: "+childClass+" id:"+getId());
|
throw new ElementBindingHandlerException("Could not find method: "+addMethod+" on: "+childClass+" id:"+getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public void createChilderen(Element parentElement,Object parentObject) throws ElementBindingHandlerException {
|
||||||
|
if (parentClass==null | childClass==null | getMethod==null) {
|
||||||
|
throw new IllegalStateException("Missing property: parentClass="+parentClass+" childClass="+childClass+" getMethod="+getMethod+".");
|
||||||
|
}
|
||||||
|
Method[] ms = parentObject.getClass().getMethods();
|
||||||
|
for (Method m:ms) {
|
||||||
|
Class<?>[] types = m.getParameterTypes();
|
||||||
|
if (types.length != 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (getMethod.equalsIgnoreCase(m.getName())==false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Object result = m.invoke(parentObject, new Object[]{});
|
||||||
|
if (result==null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (result instanceof List) {
|
||||||
|
for (Object o:(List)result) {
|
||||||
|
createChild(parentElement, o);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} else if (result instanceof Collection) {
|
||||||
|
for (Object o:(Collection)result) {
|
||||||
|
createChild(parentElement, o);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} else if (result instanceof Array) {
|
||||||
|
for (Object o:(Object[])result) {
|
||||||
|
createChild(parentElement, o);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
throw new ElementBindingHandlerException("Unsuported return type: "+result.getClass()+" from: "+getMethod+" on: "+parentObject);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ElementBindingHandlerException("Error invoke binding method of: "+getId()+" error: "+e.getMessage(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new ElementBindingHandlerException("Could not find method: "+getMethod+" on: "+parentObject+" id:"+getId());
|
||||||
|
|
||||||
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,16 +166,30 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the method
|
* @return the addMethod
|
||||||
*/
|
*/
|
||||||
public String getMethod() {
|
public String getAddMethod() {
|
||||||
return method;
|
return addMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param method the method to set
|
* @param addMethod the addMethod to set
|
||||||
*/
|
*/
|
||||||
public void setMethod(String method) {
|
public void setAddMethod(String addMethod) {
|
||||||
this.method = method;
|
this.addMethod = addMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the getMethod
|
||||||
|
*/
|
||||||
|
public String getGetMethod() {
|
||||||
|
return getMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param getMethod the getMethod to set
|
||||||
|
*/
|
||||||
|
public void setGetMethod(String getMethod) {
|
||||||
|
this.getMethod = getMethod;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class ModuleElement extends AbstractElement {
|
||||||
throw new ElementException("Need to be root tag");
|
throw new ElementException("Need to be root tag");
|
||||||
}
|
}
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
Map m = (Map)getElementLanguage().getLanguageProperty(X4OLanguageProperty.EL_BEAN_INSTANCE_MAP);
|
Map m = (Map)getLanguageContext().getLanguageProperty(X4OLanguageProperty.EL_BEAN_INSTANCE_MAP);
|
||||||
if (m==null) {
|
if (m==null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.x4o.xml.element.ElementBindingHandlerException;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Aug 21, 2012
|
* @version 1.0 Aug 21, 2012
|
||||||
*/
|
*/
|
||||||
public class StringSplitConverterBindingHandler extends AbstractElementBindingHandler {
|
public class StringSplitConverterBindingHandler extends AbstractElementBindingHandler<StringSplitConverter> {
|
||||||
|
|
||||||
|
|
||||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
||||||
|
@ -57,12 +57,21 @@ public class StringSplitConverterBindingHandler extends AbstractElementBindingHa
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#doBind(java.lang.Object, java.lang.Object, org.x4o.xml.element.Element)
|
* @see org.x4o.xml.element.ElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void doBind(Object parentObject, Object childObject,Element childElement) throws ElementBindingHandlerException {
|
public void bindChild(Element childElement,StringSplitConverter parent, Object childObject) throws ElementBindingHandlerException {
|
||||||
StringSplitConverter parent = (StringSplitConverter)parentObject;
|
|
||||||
if (childObject instanceof StringSplitConverterStep) {
|
if (childObject instanceof StringSplitConverterStep) {
|
||||||
parent.addStringSplitConverterStep((StringSplitConverterStep)childObject);
|
parent.addStringSplitConverterStep((StringSplitConverterStep)childObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void createChilderen(Element parentElement,StringSplitConverter parentObject) throws ElementBindingHandlerException {
|
||||||
|
for (StringSplitConverterStep child:parentObject.getStringSplitConverterSteps()) {
|
||||||
|
createChild(parentElement, child);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.x4o.xml.element.ElementBindingHandlerException;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Aug 21, 2012
|
* @version 1.0 Aug 21, 2012
|
||||||
*/
|
*/
|
||||||
public class StringSplitConverterStepBindingHandler extends AbstractElementBindingHandler {
|
public class StringSplitConverterStepBindingHandler extends AbstractElementBindingHandler<StringSplitConverterStep> {
|
||||||
|
|
||||||
|
|
||||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
||||||
|
@ -57,12 +57,19 @@ public class StringSplitConverterStepBindingHandler extends AbstractElementBindi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#doBind(java.lang.Object, java.lang.Object, org.x4o.xml.element.Element)
|
* @see org.x4o.xml.element.ElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void doBind(Object parentObject, Object childObject,Element childElement) throws ElementBindingHandlerException {
|
public void bindChild(Element childElement,StringSplitConverterStep parent, Object childObject) throws ElementBindingHandlerException {
|
||||||
StringSplitConverterStep parent = (StringSplitConverterStep)parentObject;
|
|
||||||
if (childObject instanceof ObjectConverter) {
|
if (childObject instanceof ObjectConverter) {
|
||||||
parent.setObjectConverter((ObjectConverter)childObject);
|
parent.setObjectConverter((ObjectConverter)childObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void createChilderen(Element parentElement,StringSplitConverterStep parentObject) throws ElementBindingHandlerException {
|
||||||
|
createChild(parentElement, parentObject.getObjectConverter());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,9 +122,9 @@ public abstract class AbstractElement implements Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Element#getElementLanguage()
|
* @see Element#getLanguageContext()
|
||||||
*/
|
*/
|
||||||
public X4OLanguageContext getElementLanguage() {
|
public X4OLanguageContext getLanguageContext() {
|
||||||
return elementLanguage;
|
return elementLanguage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ public abstract class AbstractElement implements Element {
|
||||||
*/
|
*/
|
||||||
public void doCharacters(String characters) throws ElementException {
|
public void doCharacters(String characters) throws ElementException {
|
||||||
try {
|
try {
|
||||||
Element e = (Element)X4OLanguageClassLoader.newInstance(getElementLanguage().getLanguage().getLanguageConfiguration().getDefaultElementBodyCharacters());
|
Element e = (Element)X4OLanguageClassLoader.newInstance(getLanguageContext().getLanguage().getLanguageConfiguration().getDefaultElementBodyCharacters());
|
||||||
e.setElementObject(characters);
|
e.setElementObject(characters);
|
||||||
addChild(e);
|
addChild(e);
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
|
@ -146,7 +146,7 @@ public abstract class AbstractElement implements Element {
|
||||||
*/
|
*/
|
||||||
public void doComment(String comment) throws ElementException {
|
public void doComment(String comment) throws ElementException {
|
||||||
try {
|
try {
|
||||||
Element e = (Element)X4OLanguageClassLoader.newInstance(getElementLanguage().getLanguage().getLanguageConfiguration().getDefaultElementBodyComment());
|
Element e = (Element)X4OLanguageClassLoader.newInstance(getLanguageContext().getLanguage().getLanguageConfiguration().getDefaultElementBodyComment());
|
||||||
e.setElementObject(comment);
|
e.setElementObject(comment);
|
||||||
addChild(e);
|
addChild(e);
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
|
@ -159,7 +159,7 @@ public abstract class AbstractElement implements Element {
|
||||||
*/
|
*/
|
||||||
public void doIgnorableWhitespace(String space) throws ElementException {
|
public void doIgnorableWhitespace(String space) throws ElementException {
|
||||||
try {
|
try {
|
||||||
Element e = (Element)X4OLanguageClassLoader.newInstance(getElementLanguage().getLanguage().getLanguageConfiguration().getDefaultElementBodyWhitespace());
|
Element e = (Element)X4OLanguageClassLoader.newInstance(getLanguageContext().getLanguage().getLanguageConfiguration().getDefaultElementBodyWhitespace());
|
||||||
e.setElementObject(space);
|
e.setElementObject(space);
|
||||||
addChild(e);
|
addChild(e);
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An AbstractElementBindingHandler.<br>
|
* An AbstractElementBindingHandler.<br>
|
||||||
* Does nothing.
|
* Does nothing.
|
||||||
|
@ -30,6 +31,35 @@ package org.x4o.xml.element;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Apr 16, 2006
|
* @version 1.0 Apr 16, 2006
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractElementBindingHandler extends AbstractElementMetaBase implements ElementBindingHandler {
|
public abstract class AbstractElementBindingHandler<T> extends AbstractElementMetaBase implements ElementBindingHandler {
|
||||||
|
|
||||||
|
abstract public void bindChild(Element childElement,T parentObject,Object childObject) throws ElementBindingHandlerException;
|
||||||
|
|
||||||
|
abstract public void createChilderen(Element parentElement,T parentObject) throws ElementBindingHandlerException;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void bindChild(Element childElement) throws ElementBindingHandlerException {
|
||||||
|
bindChild(childElement,(T)childElement.getParent().getElementObject(), childElement.getElementObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void createChilderen(Element parentElement) throws ElementBindingHandlerException {
|
||||||
|
createChilderen(parentElement,(T)parentElement.getElementObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void createChild(Element parentElement,Object childObject) {
|
||||||
|
if (childObject==null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (parentElement==null) {
|
||||||
|
throw new NullPointerException("Can't create child with null parent.");
|
||||||
|
}
|
||||||
|
Element childElement = parentElement.getLanguageContext().getLanguage().createElementInstance(parentElement.getLanguageContext(), childObject.getClass());
|
||||||
|
if (childElement==null) {
|
||||||
|
throw new NullPointerException("Could not find Element for child: "+childObject.getClass());
|
||||||
|
}
|
||||||
|
childElement.setElementObject(childObject);
|
||||||
|
childElement.setParent(parentElement);
|
||||||
|
parentElement.addChild(childElement);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class DefaultElementAttributeValueParser implements ElementAttributeValue
|
||||||
if (element.getElementObject()==null) {
|
if (element.getElementObject()==null) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
for (ElementInterface ei:element.getElementLanguage().getLanguage().findElementInterfaces(element.getElementObject())) {
|
for (ElementInterface ei:element.getLanguageContext().getLanguage().findElementInterfaces(element.getElementObject())) {
|
||||||
logger.finer("Found interface match executing converter.");
|
logger.finer("Found interface match executing converter.");
|
||||||
for (ElementClassAttribute attrClass:ei.getElementClassAttributes()) {
|
for (ElementClassAttribute attrClass:ei.getElementClassAttributes()) {
|
||||||
if (name.equals(attrClass.getName())==false) {
|
if (name.equals(attrClass.getName())==false) {
|
||||||
|
@ -107,8 +107,8 @@ public class DefaultElementAttributeValueParser implements ElementAttributeValue
|
||||||
* @see org.x4o.xml.element.ElementAttributeValueParser#getELParameterValue(java.lang.String, org.x4o.xml.element.Element)
|
* @see org.x4o.xml.element.ElementAttributeValueParser#getELParameterValue(java.lang.String, org.x4o.xml.element.Element)
|
||||||
*/
|
*/
|
||||||
public Object getELParameterValue(String value, Element element) throws ElementAttributeValueParserException {
|
public Object getELParameterValue(String value, Element element) throws ElementAttributeValueParserException {
|
||||||
ValueExpression e = element.getElementLanguage().getExpressionLanguageFactory().createValueExpression(element.getElementLanguage().getExpressionLanguageContext(), (String)value,Object.class);
|
ValueExpression e = element.getLanguageContext().getExpressionLanguageFactory().createValueExpression(element.getLanguageContext().getExpressionLanguageContext(), (String)value,Object.class);
|
||||||
return e.getValue(element.getElementLanguage().getExpressionLanguageContext());
|
return e.getValue(element.getLanguageContext().getExpressionLanguageContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,7 +130,7 @@ public class DefaultElementAttributeValueParser implements ElementAttributeValue
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ElementInterface ei:element.getElementLanguage().getLanguage().findElementInterfaces(element.getElementObject())) {
|
for (ElementInterface ei:element.getLanguageContext().getLanguage().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);
|
||||||
|
|
|
@ -125,9 +125,9 @@ public class DefaultElementBodyCharacters implements Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.Element#getElementLanguage()
|
* @see org.x4o.xml.element.Element#getLanguageContext()
|
||||||
*/
|
*/
|
||||||
public X4OLanguageContext getElementLanguage() {
|
public X4OLanguageContext getLanguageContext() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ public interface Element {
|
||||||
* Gets the ElementLanguage.
|
* Gets the ElementLanguage.
|
||||||
* @return Returns the ElementLanguage.
|
* @return Returns the ElementLanguage.
|
||||||
*/
|
*/
|
||||||
X4OLanguageContext getElementLanguage();
|
X4OLanguageContext getLanguageContext();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the body texts on an event based system.
|
* Sets the body texts on an event based system.
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind ElementObjects together.
|
* Bind ElementObjects together.
|
||||||
*
|
*
|
||||||
|
@ -53,5 +54,7 @@ public interface ElementBindingHandler extends ElementMetaBase {
|
||||||
* @param childElement The child element to bind to the parent.'
|
* @param childElement The child element to bind to the parent.'
|
||||||
* @throws ElementBindingHandlerException When binding could not happen.
|
* @throws ElementBindingHandlerException When binding could not happen.
|
||||||
*/
|
*/
|
||||||
void doBind(Object parentObject,Object childObject,Element childElement) throws ElementBindingHandlerException;
|
void bindChild(Element childElement) throws ElementBindingHandlerException;
|
||||||
|
|
||||||
|
void createChilderen(Element parentElement) throws ElementBindingHandlerException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import java.io.OutputStream;
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
|
import org.x4o.xml.element.Element;
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
import org.x4o.xml.lang.X4OLanguagePropertyKeys;
|
import org.x4o.xml.lang.X4OLanguagePropertyKeys;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
@ -50,7 +51,16 @@ public abstract class AbstractX4OWriter<T> extends AbstractX4OWriterContext<T> i
|
||||||
|
|
||||||
public void write(T object,OutputStream output) throws ParserConfigurationException, SAXException, IOException {
|
public void write(T object,OutputStream output) throws ParserConfigurationException, SAXException, IOException {
|
||||||
X4OLanguageContext context = getLanguageContext();
|
X4OLanguageContext context = getLanguageContext();
|
||||||
context.getRootElement().setElementObject(object); //TODO: check ??
|
Element rootElement = null;
|
||||||
|
try {
|
||||||
|
rootElement = (Element)context.getLanguage().getLanguageConfiguration().getDefaultElement().newInstance();
|
||||||
|
} catch (InstantiationException e) {
|
||||||
|
throw new SAXException(e);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new SAXException(e);
|
||||||
|
}
|
||||||
|
rootElement.setElementObject(object);
|
||||||
|
context.setRootElement(rootElement);
|
||||||
writeContext(context,output);
|
writeContext(context,output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,9 +75,6 @@ public abstract class AbstractX4OWriter<T> extends AbstractX4OWriterContext<T> i
|
||||||
if (file==null) {
|
if (file==null) {
|
||||||
throw new NullPointerException("Can't read null file.");
|
throw new NullPointerException("Can't read null file.");
|
||||||
}
|
}
|
||||||
if (file.exists()) {
|
|
||||||
throw new FileNotFoundException("File does already exists; "+file);
|
|
||||||
}
|
|
||||||
if (file.canWrite()==false) {
|
if (file.canWrite()==false) {
|
||||||
throw new IOException("Can't write file: "+file);
|
throw new IOException("Can't write file: "+file);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,6 @@
|
||||||
package org.x4o.xml.io;
|
package org.x4o.xml.io;
|
||||||
|
|
||||||
import org.x4o.xml.X4ODriver;
|
import org.x4o.xml.X4ODriver;
|
||||||
import org.x4o.xml.lang.DefaultX4OLanguage;
|
|
||||||
import org.x4o.xml.lang.DefaultX4OLanguageConfiguration;
|
|
||||||
import org.x4o.xml.lang.X4OLanguage;
|
|
||||||
import org.x4o.xml.lang.phase.X4OPhaseManagerFactory;
|
|
||||||
|
|
||||||
public class DefaultX4ODriver<T> extends X4ODriver<T> {
|
public class DefaultX4ODriver<T> extends X4ODriver<T> {
|
||||||
|
|
||||||
|
@ -49,11 +45,6 @@ public class DefaultX4ODriver<T> extends X4ODriver<T> {
|
||||||
return languageName;
|
return languageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public X4OLanguage buildLanguage(String version) {
|
|
||||||
return new DefaultX4OLanguage(new DefaultX4OLanguageConfiguration(),X4OPhaseManagerFactory.createDefaultX4OPhaseManager(),getLanguageName(),languageVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getLanguageVersions() {
|
public String[] getLanguageVersions() {
|
||||||
return new String[]{languageVersion};
|
return new String[]{languageVersion};
|
||||||
|
|
|
@ -26,11 +26,29 @@ package org.x4o.xml.io;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
|
import org.x4o.xml.element.Element;
|
||||||
|
import org.x4o.xml.element.ElementBindingHandler;
|
||||||
|
import org.x4o.xml.element.ElementBindingHandlerException;
|
||||||
|
import org.x4o.xml.element.ElementClass;
|
||||||
|
import org.x4o.xml.element.ElementClassAttribute;
|
||||||
|
import org.x4o.xml.element.ElementNamespaceContext;
|
||||||
|
import org.x4o.xml.element.ElementNamespaceInstanceProviderException;
|
||||||
|
import org.x4o.xml.element.ElementObjectPropertyValueException;
|
||||||
|
import org.x4o.xml.io.sax.XMLWriter;
|
||||||
|
import org.x4o.xml.lang.X4OLanguage;
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
import org.xml.sax.helpers.AttributesImpl;
|
||||||
|
|
||||||
public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
|
public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
|
||||||
|
|
||||||
|
@ -42,7 +60,165 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
|
||||||
FileNotFoundException, SecurityException, NullPointerException,
|
FileNotFoundException, SecurityException, NullPointerException,
|
||||||
SAXException, IOException {
|
SAXException, IOException {
|
||||||
|
|
||||||
// getLanguageContext().setRootElement(element)
|
Element root = getLanguageContext().getRootElement();
|
||||||
|
if (root.getElementClass()==null) {
|
||||||
|
try {
|
||||||
|
root = fillElementTree(root.getElementObject());
|
||||||
|
} catch (ElementNamespaceInstanceProviderException e) {
|
||||||
|
throw new SAXException(e);
|
||||||
|
} catch (ElementBindingHandlerException e) {
|
||||||
|
throw new SAXException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
XMLWriter writer = new XMLWriter(out);
|
||||||
|
writer.startDocument();
|
||||||
|
|
||||||
|
Map<String,String> prefixes = new HashMap<String,String>();
|
||||||
|
startPrefixTree(root,prefixes);
|
||||||
|
for (String uri:prefixes.keySet()) {
|
||||||
|
String prefix = prefixes.get(uri);
|
||||||
|
writer.startPrefixMapping(prefix, uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
writeTree(writer,root);
|
||||||
|
} catch (ElementObjectPropertyValueException e) {
|
||||||
|
throw new SAXException(e);
|
||||||
|
}
|
||||||
|
writer.endDocument();
|
||||||
|
out.flush();
|
||||||
|
out.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startPrefixTree(Element element,Map<String,String> result) throws SAXException {
|
||||||
|
String elementUri = findElementUri(element);
|
||||||
|
if (result.containsKey(elementUri)==false) {
|
||||||
|
String elementUriPrefix = findNamespacePrefix(element,elementUri);
|
||||||
|
result.put(elementUri, elementUriPrefix);
|
||||||
|
}
|
||||||
|
for (Element e:element.getChilderen()) {
|
||||||
|
startPrefixTree(e,result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> getProperties(Class<?> objectClass) {
|
||||||
|
List<String> result = new ArrayList<String>();
|
||||||
|
for (Method m:objectClass.getMethods()) {
|
||||||
|
Class<?>[] types = m.getParameterTypes();
|
||||||
|
if (types.length != 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (m.getName().equals("getClass")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (m.getName().startsWith("get")==false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String name = m.getName().substring(3,4).toLowerCase()+m.getName().substring(4);
|
||||||
|
result.add(name);
|
||||||
|
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeTree(XMLWriter writer,Element element) throws SAXException, ElementObjectPropertyValueException {
|
||||||
|
AttributesImpl atts = new AttributesImpl();
|
||||||
|
|
||||||
|
if (element.getElementClass().getAutoAttributes()!=null && element.getElementClass().getAutoAttributes()==false) {
|
||||||
|
for (ElementClassAttribute eca:element.getElementClass().getElementClassAttributes()) {
|
||||||
|
Object value = element.getLanguageContext().getElementObjectPropertyValue().getProperty(element.getElementObject(),eca.getName());
|
||||||
|
if (value==null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
atts.addAttribute ("", eca.getName(), "", "", ""+value);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
for (String p:getProperties(element.getElementObject().getClass())) {
|
||||||
|
Object value = element.getLanguageContext().getElementObjectPropertyValue().getProperty(element.getElementObject(),p);
|
||||||
|
if (value==null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (value instanceof List || value instanceof Collection) {
|
||||||
|
continue; // TODO; filter on type of childeren
|
||||||
|
}
|
||||||
|
atts.addAttribute ("", p, "", "", ""+value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String elementUri = findElementUri(element);
|
||||||
|
writer.startElement(elementUri, element.getElementClass().getTag(), "", atts);
|
||||||
|
for (Element e:element.getChilderen()) {
|
||||||
|
writeTree(writer,e);
|
||||||
|
}
|
||||||
|
writer.endElement(elementUri, element.getElementClass().getTag(), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String findElementUri(Element e) {
|
||||||
|
for (X4OLanguageModule mod:e.getLanguageContext().getLanguage().getLanguageModules()) {
|
||||||
|
for (ElementNamespaceContext c:mod.getElementNamespaceContexts()) {
|
||||||
|
ElementClass ec = c.getElementClass(e.getElementClass().getTag());
|
||||||
|
if (ec!=null) {
|
||||||
|
return c.getUri();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String findNamespacePrefix(Element e,String uri) {
|
||||||
|
ElementNamespaceContext ns = e.getLanguageContext().getLanguage().findElementNamespaceContext(uri);
|
||||||
|
if (ns.getPrefixMapping()!=null) {
|
||||||
|
return ns.getPrefixMapping();
|
||||||
|
}
|
||||||
|
return ns.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Element fillElementTree(Object object) throws ElementNamespaceInstanceProviderException, ElementBindingHandlerException {
|
||||||
|
Element element = findRootElement(object.getClass());
|
||||||
|
element.setElementObject(object);
|
||||||
|
|
||||||
|
for (ElementBindingHandler bind:getLanguageContext().getLanguage().findElementBindingHandlers(object)) {
|
||||||
|
bind.createChilderen(element);
|
||||||
|
fillTree(element);
|
||||||
|
}
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillTree(Element element) throws ElementNamespaceInstanceProviderException, ElementBindingHandlerException {
|
||||||
|
for (Element e:element.getChilderen()) {
|
||||||
|
Object object = e.getElementObject();
|
||||||
|
for (ElementBindingHandler bind:getLanguageContext().getLanguage().findElementBindingHandlers(object)) {
|
||||||
|
bind.createChilderen(e);
|
||||||
|
fillTree(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Element findRootElement(Class<?> objectClass) throws ElementNamespaceInstanceProviderException {
|
||||||
|
// redo this mess, add nice find for root
|
||||||
|
for (X4OLanguageModule modContext:getLanguageContext().getLanguage().getLanguageModules()) {
|
||||||
|
for (ElementNamespaceContext nsContext:modContext.getElementNamespaceContexts()) {
|
||||||
|
if (nsContext.getLanguageRoot()!=null && nsContext.getLanguageRoot()) {
|
||||||
|
for (ElementClass ec:nsContext.getElementClasses()) {
|
||||||
|
if (ec.getObjectClass()!=null && ec.getObjectClass().equals(objectClass)) {
|
||||||
|
return nsContext.getElementNamespaceInstanceProvider().createElementInstance(getLanguageContext(), ec.getTag());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (X4OLanguageModule modContext:getLanguageContext().getLanguage().getLanguageModules()) {
|
||||||
|
for (ElementNamespaceContext nsContext:modContext.getElementNamespaceContexts()) {
|
||||||
|
for (ElementClass ec:nsContext.getElementClasses()) {
|
||||||
|
if (ec.getObjectClass()!=null && ec.getObjectClass().equals(objectClass)) {
|
||||||
|
return nsContext.getElementNamespaceInstanceProvider().createElementInstance(getLanguageContext(), ec.getTag());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Could not find ElementClass for: "+objectClass.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,7 +222,7 @@ public final class XMLConstants {
|
||||||
result.append("'");
|
result.append("'");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (isNameChar(c)==false) {
|
if (/*isNameChar(c)*/true==false) {// TODO: add correct
|
||||||
result.append("#x");
|
result.append("#x");
|
||||||
result.append(Integer.toHexString(c));
|
result.append(Integer.toHexString(c));
|
||||||
result.append(";");
|
result.append(";");
|
||||||
|
|
|
@ -428,7 +428,7 @@ public class X4ODebugWriter {
|
||||||
atts.addAttribute ("", "language", "", "", elementLanguage.getLanguage().getLanguageName());
|
atts.addAttribute ("", "language", "", "", elementLanguage.getLanguage().getLanguageName());
|
||||||
atts.addAttribute ("", "languageVersion", "", "", elementLanguage.getLanguage().getLanguageVersion());
|
atts.addAttribute ("", "languageVersion", "", "", elementLanguage.getLanguage().getLanguageVersion());
|
||||||
atts.addAttribute ("", "className", "", "", elementLanguage.getClass().getName()+"");
|
atts.addAttribute ("", "className", "", "", elementLanguage.getClass().getName()+"");
|
||||||
atts.addAttribute ("", "currentX4OPhase", "", "", elementLanguage.getCurrentX4OPhase().getId());
|
atts.addAttribute ("", "currentX4OPhase", "", "", elementLanguage.getCurrentPhase().getId());
|
||||||
debugWriter.startElement (DEBUG_URI, "printElementLanguage", "", atts);
|
debugWriter.startElement (DEBUG_URI, "printElementLanguage", "", atts);
|
||||||
debugWriter.endElement(DEBUG_URI, "printElementLanguage", "");
|
debugWriter.endElement(DEBUG_URI, "printElementLanguage", "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,23 +59,17 @@ public abstract class AbstractX4OLanguageContext implements X4OLanguageContextLo
|
||||||
/**
|
/**
|
||||||
* Creates a new empty ElementLanguage.
|
* Creates a new empty ElementLanguage.
|
||||||
*/
|
*/
|
||||||
public AbstractX4OLanguageContext(X4OLanguage language,String languageVersion) {
|
public AbstractX4OLanguageContext(X4OLanguage language) {
|
||||||
if (language==null) {
|
if (language==null) {
|
||||||
throw new NullPointerException("language may not be null");
|
throw new NullPointerException("language may not be null");
|
||||||
}
|
}
|
||||||
if (languageVersion==null) {
|
|
||||||
throw new NullPointerException("languageVersion may not be null");
|
|
||||||
}
|
|
||||||
if (languageVersion.length()==0) {
|
|
||||||
throw new IllegalArgumentException("languageVersion may not be empty");
|
|
||||||
}
|
|
||||||
logger = Logger.getLogger(AbstractX4OLanguageContext.class.getName());
|
logger = Logger.getLogger(AbstractX4OLanguageContext.class.getName());
|
||||||
logger.finest("Creating new ParsingContext");
|
logger.finest("Creating new ParsingContext");
|
||||||
this.language=language;
|
this.language=language;
|
||||||
dirtyElements = new HashMap<Element, X4OPhase>(40);
|
dirtyElements = new HashMap<Element, X4OPhase>(40);
|
||||||
languageProperties = new HashMap<String,Object>(20);
|
languageProperties = new HashMap<String,Object>(20);
|
||||||
languageProperties.put(X4OLanguageProperty.LANGUAGE_NAME.toUri(), language.getLanguageName());
|
languageProperties.put(X4OLanguageProperty.LANGUAGE_NAME.toUri(), language.getLanguageName());
|
||||||
languageProperties.put(X4OLanguageProperty.LANGUAGE_VERSION.toUri(), languageVersion);
|
languageProperties.put(X4OLanguageProperty.LANGUAGE_VERSION.toUri(), language.getLanguageVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
public X4OLanguage getLanguage() {
|
public X4OLanguage getLanguage() {
|
||||||
|
@ -151,16 +145,16 @@ public abstract class AbstractX4OLanguageContext implements X4OLanguageContextLo
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.lang.X4OLanguageContext#getCurrentX4OPhase()
|
* @see org.x4o.xml.lang.X4OLanguageContext#getCurrentPhase()
|
||||||
*/
|
*/
|
||||||
public X4OPhase getCurrentX4OPhase() {
|
public X4OPhase getCurrentPhase() {
|
||||||
return currentX4OPhase;
|
return currentX4OPhase;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.lang.X4OLanguageContext#setCurrentX4OPhase(org.x4o.xml.lang.phase.X4OPhase)
|
* @see org.x4o.xml.lang.X4OLanguageContext#setCurrentPhase(org.x4o.xml.lang.phase.X4OPhase)
|
||||||
*/
|
*/
|
||||||
public void setCurrentX4OPhase(X4OPhase currentX4OPhase) {
|
public void setCurrentPhase(X4OPhase currentX4OPhase) {
|
||||||
this.currentX4OPhase = currentX4OPhase;
|
this.currentX4OPhase = currentX4OPhase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,21 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.el.ELContext;
|
||||||
|
|
||||||
|
import org.x4o.xml.X4ODriver;
|
||||||
|
import org.x4o.xml.el.X4OExpressionFactory;
|
||||||
|
import org.x4o.xml.element.Element;
|
||||||
|
import org.x4o.xml.element.ElementAttributeValueParser;
|
||||||
import org.x4o.xml.element.ElementBindingHandler;
|
import org.x4o.xml.element.ElementBindingHandler;
|
||||||
|
import org.x4o.xml.element.ElementClass;
|
||||||
import org.x4o.xml.element.ElementInterface;
|
import org.x4o.xml.element.ElementInterface;
|
||||||
import org.x4o.xml.element.ElementNamespaceContext;
|
import org.x4o.xml.element.ElementNamespaceContext;
|
||||||
|
import org.x4o.xml.element.ElementNamespaceInstanceProviderException;
|
||||||
|
import org.x4o.xml.element.ElementObjectPropertyValue;
|
||||||
|
import org.x4o.xml.lang.phase.X4OPhaseException;
|
||||||
import org.x4o.xml.lang.phase.X4OPhaseManager;
|
import org.x4o.xml.lang.phase.X4OPhaseManager;
|
||||||
|
import org.x4o.xml.lang.phase.X4OPhaseType;
|
||||||
|
|
||||||
public class DefaultX4OLanguage implements X4OLanguageLocal {
|
public class DefaultX4OLanguage implements X4OLanguageLocal {
|
||||||
|
|
||||||
|
@ -19,6 +30,12 @@ public class DefaultX4OLanguage implements X4OLanguageLocal {
|
||||||
private X4OPhaseManager phaseManager = null;
|
private X4OPhaseManager phaseManager = null;
|
||||||
|
|
||||||
public DefaultX4OLanguage(X4OLanguageConfiguration languageConfiguration,X4OPhaseManager phaseManager,String languageName,String languageVersion) {
|
public DefaultX4OLanguage(X4OLanguageConfiguration languageConfiguration,X4OPhaseManager phaseManager,String languageName,String languageVersion) {
|
||||||
|
if (languageName==null) {
|
||||||
|
throw new NullPointerException("Can't define myself with null name.");
|
||||||
|
}
|
||||||
|
if (languageVersion==null) {
|
||||||
|
throw new NullPointerException("Can't define myself with null version.");
|
||||||
|
}
|
||||||
logger = Logger.getLogger(DefaultX4OLanguage.class.getName());
|
logger = Logger.getLogger(DefaultX4OLanguage.class.getName());
|
||||||
elementLanguageModules = new ArrayList<X4OLanguageModule>(20);
|
elementLanguageModules = new ArrayList<X4OLanguageModule>(20);
|
||||||
this.languageConfiguration=languageConfiguration;
|
this.languageConfiguration=languageConfiguration;
|
||||||
|
@ -55,13 +72,6 @@ public class DefaultX4OLanguage implements X4OLanguageLocal {
|
||||||
return languageConfiguration;
|
return languageConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @param languageConfiguration the languageConfiguration to set
|
|
||||||
|
|
||||||
public void setLanguageConfiguration() {
|
|
||||||
this.languageConfiguration = languageConfiguration;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.lang.X4OLanguageContext#addLanguageModule(org.x4o.xml.lang.X4OLanguageModule)
|
* @see org.x4o.xml.lang.X4OLanguageContext#addLanguageModule(org.x4o.xml.lang.X4OLanguageModule)
|
||||||
*/
|
*/
|
||||||
|
@ -79,6 +89,82 @@ public class DefaultX4OLanguage implements X4OLanguageLocal {
|
||||||
return elementLanguageModules;
|
return elementLanguageModules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws X4OPhaseException
|
||||||
|
* @see org.x4o.xml.lang.X4OLanguage#createLanguageContext(org.x4o.xml.X4ODriver)
|
||||||
|
*/
|
||||||
|
public X4OLanguageContext createLanguageContext(X4ODriver<?> driver){
|
||||||
|
X4OLanguageContext result = buildElementLanguage(new DefaultX4OLanguageContext(this),driver);
|
||||||
|
try {
|
||||||
|
getPhaseManager().runPhases(result, X4OPhaseType.INIT);
|
||||||
|
} catch (X4OPhaseException e) {
|
||||||
|
throw new RuntimeException(e); //TODO: change layer
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected X4OLanguageContext buildElementLanguage(X4OLanguageContext languageContext,X4ODriver<?> driver) {
|
||||||
|
if ((languageContext instanceof X4OLanguageContextLocal)==false) {
|
||||||
|
throw new RuntimeException("Can't init X4OLanguageContext which has not X4OLanguageContextLocal interface obj: "+languageContext);
|
||||||
|
}
|
||||||
|
X4OLanguageContextLocal contextInit = (X4OLanguageContextLocal)languageContext;
|
||||||
|
for (String key:driver.getGlobalPropertyKeys()) {
|
||||||
|
Object value = driver.getGlobalProperty(key);
|
||||||
|
contextInit.setLanguageProperty(key, value);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (contextInit.getExpressionLanguageFactory()==null) {
|
||||||
|
contextInit.setExpressionLanguageFactory(X4OExpressionFactory.createExpressionFactory(contextInit));
|
||||||
|
}
|
||||||
|
if (contextInit.getExpressionLanguageContext()==null) {
|
||||||
|
contextInit.setExpressionLanguageContext((ELContext)X4OLanguageClassLoader.newInstance(getLanguageConfiguration().getDefaultExpressionLanguageContext()));
|
||||||
|
}
|
||||||
|
if (contextInit.getElementAttributeValueParser()==null) {
|
||||||
|
contextInit.setElementAttributeValueParser((ElementAttributeValueParser)X4OLanguageClassLoader.newInstance(getLanguageConfiguration().getDefaultElementAttributeValueParser()));
|
||||||
|
}
|
||||||
|
if (contextInit.getElementObjectPropertyValue()==null) {
|
||||||
|
contextInit.setElementObjectPropertyValue((ElementObjectPropertyValue)X4OLanguageClassLoader.newInstance(getLanguageConfiguration().getDefaultElementObjectPropertyValue()));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e.getMessage(),e);
|
||||||
|
}
|
||||||
|
return contextInit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.x4o.xml.lang.X4OLanguage#createElementInstance(java.lang.Class)
|
||||||
|
*/
|
||||||
|
public Element createElementInstance(X4OLanguageContext context,Class<?> objectClass) {
|
||||||
|
for (X4OLanguageModule modContext:getLanguageModules()) {
|
||||||
|
for (ElementNamespaceContext nsContext:modContext.getElementNamespaceContexts()) {
|
||||||
|
for (ElementClass ec:nsContext.getElementClasses()) {
|
||||||
|
if (ec.getObjectClass()!=null && ec.getObjectClass().equals(objectClass)) {
|
||||||
|
try {
|
||||||
|
return nsContext.getElementNamespaceInstanceProvider().createElementInstance(context, ec.getTag());
|
||||||
|
} catch (ElementNamespaceInstanceProviderException e) {
|
||||||
|
throw new RuntimeException(e.getMessage(),e); // TODO: fix me
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Could not find ElementClass for: "+objectClass.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.x4o.xml.lang.X4OLanguageContext#findElementBindingHandlers(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public List<ElementBindingHandler> findElementBindingHandlers(Object parent) {
|
||||||
|
List<ElementBindingHandler> result = new ArrayList<ElementBindingHandler>(50);
|
||||||
|
for (int i=0;i<elementLanguageModules.size();i++) {
|
||||||
|
X4OLanguageModule module = elementLanguageModules.get(i);
|
||||||
|
findElementBindingHandlerInList(parent,null,result,module.getElementBindingHandlers(),false);
|
||||||
|
}
|
||||||
|
for (ElementInterface ei:findElementInterfaces(parent)) {
|
||||||
|
findElementBindingHandlerInList(parent,null,result,ei.getElementBindingHandlers(),false);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.lang.X4OLanguageContext#findElementBindingHandlers(java.lang.Object,java.lang.Object)
|
* @see org.x4o.xml.lang.X4OLanguageContext#findElementBindingHandlers(java.lang.Object,java.lang.Object)
|
||||||
|
@ -87,15 +173,15 @@ public class DefaultX4OLanguage implements X4OLanguageLocal {
|
||||||
List<ElementBindingHandler> result = new ArrayList<ElementBindingHandler>(50);
|
List<ElementBindingHandler> result = new ArrayList<ElementBindingHandler>(50);
|
||||||
for (int i=0;i<elementLanguageModules.size();i++) {
|
for (int i=0;i<elementLanguageModules.size();i++) {
|
||||||
X4OLanguageModule module = elementLanguageModules.get(i);
|
X4OLanguageModule module = elementLanguageModules.get(i);
|
||||||
findElementBindingHandlerInList(parent,child,result,module.getElementBindingHandlers());
|
findElementBindingHandlerInList(parent,child,result,module.getElementBindingHandlers(),true);
|
||||||
}
|
}
|
||||||
for (ElementInterface ei:findElementInterfaces(parent)) {
|
for (ElementInterface ei:findElementInterfaces(parent)) {
|
||||||
findElementBindingHandlerInList(parent,child,result,ei.getElementBindingHandlers());
|
findElementBindingHandlerInList(parent,child,result,ei.getElementBindingHandlers(),true);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findElementBindingHandlerInList(Object parent,Object child,List<ElementBindingHandler> result,List<ElementBindingHandler> checkList) {
|
private void findElementBindingHandlerInList(Object parent,Object child,List<ElementBindingHandler> result,List<ElementBindingHandler> checkList,boolean checkChild) {
|
||||||
for (ElementBindingHandler binding:checkList) {
|
for (ElementBindingHandler binding:checkList) {
|
||||||
boolean parentBind = false;
|
boolean parentBind = false;
|
||||||
if (parent instanceof Class) {
|
if (parent instanceof Class) {
|
||||||
|
@ -106,6 +192,10 @@ public class DefaultX4OLanguage implements X4OLanguageLocal {
|
||||||
if (parentBind==false) {
|
if (parentBind==false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (checkChild==false) {
|
||||||
|
result.add(binding); // All all handlers for parent only
|
||||||
|
continue;
|
||||||
|
}
|
||||||
boolean childBind = false;
|
boolean childBind = false;
|
||||||
for (Class<?> childClass:binding.getBindChildClasses()) {
|
for (Class<?> childClass:binding.getBindChildClasses()) {
|
||||||
if (child instanceof Class && childClass.isAssignableFrom((Class<?>)child)) {
|
if (child instanceof Class && childClass.isAssignableFrom((Class<?>)child)) {
|
||||||
|
|
|
@ -28,9 +28,6 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.el.ExpressionFactory;
|
|
||||||
|
|
||||||
import org.x4o.xml.X4ODriver;
|
|
||||||
import org.x4o.xml.el.X4OELContext;
|
import org.x4o.xml.el.X4OELContext;
|
||||||
import org.x4o.xml.eld.EldDriver;
|
import org.x4o.xml.eld.EldDriver;
|
||||||
import org.x4o.xml.element.DefaultElement;
|
import org.x4o.xml.element.DefaultElement;
|
||||||
|
@ -45,9 +42,6 @@ import org.x4o.xml.element.DefaultElementNamespaceContext;
|
||||||
import org.x4o.xml.element.DefaultElementNamespaceInstanceProvider;
|
import org.x4o.xml.element.DefaultElementNamespaceInstanceProvider;
|
||||||
import org.x4o.xml.element.DefaultElementObjectPropertyValue;
|
import org.x4o.xml.element.DefaultElementObjectPropertyValue;
|
||||||
import org.x4o.xml.element.DefaultGlobalAttributeHandlerComparator;
|
import org.x4o.xml.element.DefaultGlobalAttributeHandlerComparator;
|
||||||
import org.x4o.xml.element.ElementAttributeValueParser;
|
|
||||||
import org.x4o.xml.element.ElementObjectPropertyValue;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides all implementions of the different parts of the language parser.
|
* Provides all implementions of the different parts of the language parser.
|
||||||
|
@ -168,73 +162,22 @@ public class DefaultX4OLanguageConfiguration implements X4OLanguageConfiguration
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.lang.X4OLanguageConfiguration#getDefaultX4OLanguageVersionFilter()
|
* @see org.x4o.xml.lang.X4OLanguageConfiguration#getDefaultX4OLanguageVersionFilter()
|
||||||
*/
|
*/
|
||||||
public Class<?> getDefaultX4OLanguageVersionFilter() {
|
public Class<?> getDefaultLanguageVersionFilter() {
|
||||||
return DefaultX4OLanguageVersionFilter.class;
|
return DefaultX4OLanguageVersionFilter.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.lang.X4OLanguageConfiguration#getDefaultX4OLanguageLoader()
|
* @see org.x4o.xml.lang.X4OLanguageConfiguration#getDefaultX4OLanguageLoader()
|
||||||
*/
|
*/
|
||||||
public Class<?> getDefaultX4OLanguageLoader() {
|
public Class<?> getDefaultLanguageLoader() {
|
||||||
return DefaultX4OLanguageLoader.class;
|
return DefaultX4OLanguageLoader.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.lang.X4OLanguageConfiguration#createElementLanguage()
|
* @see org.x4o.xml.lang.X4OLanguageConfiguration#getDefaultExpressionLanguageContext()
|
||||||
*/
|
*/
|
||||||
public X4OLanguageContext createElementLanguage(X4ODriver<?> driver) {
|
public Class<?> getDefaultExpressionLanguageContext() {
|
||||||
String v = X4ODriver.DEFAULT_LANGUAGE_VERSION; // TODO:fixme
|
return X4OELContext.class;
|
||||||
return configElementLanguage(new DefaultX4OLanguageContext(driver.createLanguage(v),v),driver);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected X4OLanguageContext configElementLanguage(X4OLanguageContext elementLanguage,X4ODriver<?> driver) {
|
|
||||||
if ((elementLanguage instanceof X4OLanguageContextLocal)==false) {
|
|
||||||
throw new RuntimeException("Can't init ElementLanguage which has not ElementLanguageLocal interface obj: "+elementLanguage);
|
|
||||||
}
|
|
||||||
X4OLanguageContextLocal contextInit = (X4OLanguageContextLocal)elementLanguage;
|
|
||||||
//contextInit.setLanguageConfiguration(this);
|
|
||||||
for (String key:driver.getGlobalPropertyKeys()) {
|
|
||||||
Object value = driver.getGlobalProperty(key);
|
|
||||||
contextInit.setLanguageProperty(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contextInit.getExpressionLanguageFactory()==null) {
|
|
||||||
contextInit.setExpressionLanguageFactory(configExpressionFactory(contextInit));
|
|
||||||
}
|
|
||||||
if (contextInit.getExpressionLanguageContext()==null) {
|
|
||||||
contextInit.setExpressionLanguageContext(new X4OELContext());
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
if (contextInit.getElementAttributeValueParser()==null) {
|
|
||||||
contextInit.setElementAttributeValueParser((ElementAttributeValueParser)X4OLanguageClassLoader.newInstance(getDefaultElementAttributeValueParser()));
|
|
||||||
}
|
|
||||||
if (contextInit.getElementObjectPropertyValue()==null) {
|
|
||||||
contextInit.setElementObjectPropertyValue((ElementObjectPropertyValue)X4OLanguageClassLoader.newInstance(getDefaultElementObjectPropertyValue()));
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e.getMessage(),e);
|
|
||||||
}
|
|
||||||
return elementLanguage;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ExpressionFactory configExpressionFactory(X4OLanguageContext elementContext) {
|
|
||||||
ExpressionFactory factory = (ExpressionFactory)elementContext.getLanguageProperty(X4OLanguageProperty.EL_FACTORY_INSTANCE);
|
|
||||||
if (factory!=null) {
|
|
||||||
return factory;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Class<?> expressionFactoryClass = X4OLanguageClassLoader.loadClass("org.apache.el.ExpressionFactoryImpl");
|
|
||||||
ExpressionFactory expressionFactory = (ExpressionFactory) expressionFactoryClass.newInstance();
|
|
||||||
return expressionFactory;
|
|
||||||
} 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.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,7 +32,7 @@ package org.x4o.xml.lang;
|
||||||
*/
|
*/
|
||||||
public class DefaultX4OLanguageContext extends AbstractX4OLanguageContext {
|
public class DefaultX4OLanguageContext extends AbstractX4OLanguageContext {
|
||||||
|
|
||||||
public DefaultX4OLanguageContext(X4OLanguage language, String languageVersion) {
|
public DefaultX4OLanguageContext(X4OLanguage language) {
|
||||||
super(language, languageVersion);
|
super(language);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class DefaultX4OLanguageLoader implements X4OLanguageLoader {
|
||||||
logger.finer("Loading all modules for language: "+language);
|
logger.finer("Loading all modules for language: "+language);
|
||||||
loadLanguageModules(languageLocal,language);
|
loadLanguageModules(languageLocal,language);
|
||||||
|
|
||||||
X4OLanguageVersionFilter lvf = (X4OLanguageVersionFilter)X4OLanguageClassLoader.newInstance(languageLocal.getLanguageConfiguration().getDefaultX4OLanguageVersionFilter());
|
X4OLanguageVersionFilter lvf = (X4OLanguageVersionFilter)X4OLanguageClassLoader.newInstance(languageLocal.getLanguageConfiguration().getDefaultLanguageVersionFilter());
|
||||||
|
|
||||||
for (Map<String,Map<String,String>> map:modulesAll) {
|
for (Map<String,Map<String,String>> map:modulesAll) {
|
||||||
List<String> versions = new ArrayList<String>(map.keySet());
|
List<String> versions = new ArrayList<String>(map.keySet());
|
||||||
|
|
|
@ -25,6 +25,8 @@ package org.x4o.xml.lang;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.x4o.xml.X4ODriver;
|
||||||
|
import org.x4o.xml.element.Element;
|
||||||
import org.x4o.xml.element.ElementBindingHandler;
|
import org.x4o.xml.element.ElementBindingHandler;
|
||||||
import org.x4o.xml.element.ElementInterface;
|
import org.x4o.xml.element.ElementInterface;
|
||||||
import org.x4o.xml.element.ElementNamespaceContext;
|
import org.x4o.xml.element.ElementNamespaceContext;
|
||||||
|
@ -60,7 +62,27 @@ public interface X4OLanguage {
|
||||||
X4OLanguageConfiguration getLanguageConfiguration();
|
X4OLanguageConfiguration getLanguageConfiguration();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all ElementBindingHandlers.
|
* Creates and filles the inital element language used to store the language.
|
||||||
|
* @return The newly created ElementLanguage.
|
||||||
|
*/
|
||||||
|
X4OLanguageContext createLanguageContext(X4ODriver<?> driver);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search language for object and create elememt for it.
|
||||||
|
* @param object The object to search for.
|
||||||
|
* @return Returns an new Elememt instance for the object.
|
||||||
|
*/
|
||||||
|
Element createElementInstance(X4OLanguageContext context,Class<?> objectClass);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
List<ElementBindingHandler> findElementBindingHandlers(Object parent);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all ElementBindingHandlers for parent and child combination.
|
||||||
* @param parent The parent element object or class to search for.
|
* @param parent The parent element object or class to search for.
|
||||||
* @param child 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.
|
* @return Returns an List with all ElementBindingHandler for the search pair.
|
||||||
|
|
|
@ -26,9 +26,6 @@ package org.x4o.xml.lang;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.x4o.xml.X4ODriver;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* X4OLanguageConfiguration first used interface in x4o parser which does the hard config of the x4o xml parsing.
|
* X4OLanguageConfiguration first used interface in x4o parser which does the hard config of the x4o xml parsing.
|
||||||
*
|
*
|
||||||
|
@ -73,18 +70,17 @@ public interface X4OLanguageConfiguration {
|
||||||
/**
|
/**
|
||||||
* @return Returns the X4OLanguageVersionFilter which filters the best version to use.
|
* @return Returns the X4OLanguageVersionFilter which filters the best version to use.
|
||||||
*/
|
*/
|
||||||
Class<?> getDefaultX4OLanguageVersionFilter();
|
Class<?> getDefaultLanguageVersionFilter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the X4OLanguageLoader which loads languages into the element context.
|
* @return Returns the X4OLanguageLoader which loads languages into the element context.
|
||||||
*/
|
*/
|
||||||
Class<?> getDefaultX4OLanguageLoader();
|
Class<?> getDefaultLanguageLoader();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and filles the inital element language used to store the language.
|
* @return Returns the Expression Language Context which holds the el objects.
|
||||||
* @return The newly created ElementLanguage.
|
|
||||||
*/
|
*/
|
||||||
X4OLanguageContext createElementLanguage(X4ODriver<?> driver);
|
Class<?> getDefaultExpressionLanguageContext();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns Map of SAX properties which are set.
|
* @return Returns Map of SAX properties which are set.
|
||||||
|
|
|
@ -70,14 +70,7 @@ public interface X4OLanguageContext {
|
||||||
* Returns the current X4OPhase of the parser.
|
* Returns the current X4OPhase of the parser.
|
||||||
* @return Returns the current phase.
|
* @return Returns the current phase.
|
||||||
*/
|
*/
|
||||||
X4OPhase getCurrentX4OPhase();
|
X4OPhase getCurrentPhase();
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the phase of the context.
|
|
||||||
* TODO: Do never call this, methode sould be moved to local interface.
|
|
||||||
* @param phase The current phase to set.
|
|
||||||
*/
|
|
||||||
void setCurrentX4OPhase(X4OPhase phase);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks an (new) Element as dirty and run the phases from this start phase.
|
* Marks an (new) Element as dirty and run the phases from this start phase.
|
||||||
|
|
|
@ -29,6 +29,7 @@ import javax.el.ExpressionFactory;
|
||||||
import org.x4o.xml.element.ElementAttributeValueParser;
|
import org.x4o.xml.element.ElementAttributeValueParser;
|
||||||
import org.x4o.xml.element.ElementObjectPropertyValue;
|
import org.x4o.xml.element.ElementObjectPropertyValue;
|
||||||
import org.x4o.xml.io.sax.X4ODebugWriter;
|
import org.x4o.xml.io.sax.X4ODebugWriter;
|
||||||
|
import org.x4o.xml.lang.phase.X4OPhase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElementLanguageLocal is the local set interface for ElementLanguage.
|
* ElementLanguageLocal is the local set interface for ElementLanguage.
|
||||||
|
@ -60,6 +61,12 @@ public interface X4OLanguageContextLocal extends X4OLanguageContext {
|
||||||
*/
|
*/
|
||||||
void setElementObjectPropertyValue(ElementObjectPropertyValue elementObjectPropertyValue);
|
void setElementObjectPropertyValue(ElementObjectPropertyValue elementObjectPropertyValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the phase of the context.
|
||||||
|
* @param phase The current phase to set.
|
||||||
|
*/
|
||||||
|
void setCurrentPhase(X4OPhase phase);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param debugWriter The debug writer to set
|
* @param debugWriter The debug writer to set
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -30,9 +30,9 @@ import java.util.List;
|
||||||
|
|
||||||
import org.x4o.xml.element.Element;
|
import org.x4o.xml.element.Element;
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageContextLocal;
|
||||||
import org.x4o.xml.lang.X4OLanguageProperty;
|
import org.x4o.xml.lang.X4OLanguageProperty;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* X4OPhaseManager stores the X4OPhaseHandler and puts them in the right order.
|
* X4OPhaseManager stores the X4OPhaseHandler and puts them in the right order.
|
||||||
* And will execute the phases when runPhases is called.
|
* And will execute the phases when runPhases is called.
|
||||||
|
@ -44,11 +44,6 @@ public class DefaultX4OPhaseManager implements X4OPhaseManager {
|
||||||
|
|
||||||
/** The X4OPhaseHandler */
|
/** The X4OPhaseHandler */
|
||||||
private List<X4OPhase> x4oPhases = null;
|
private List<X4OPhase> x4oPhases = null;
|
||||||
//private ElementLanguage elementLanguage = null;
|
|
||||||
//private X4OPhase stopPhase = null;
|
|
||||||
//private boolean skipReleasePhase = false;
|
|
||||||
//private boolean skipRunPhase = false;
|
|
||||||
//private boolean skipSiblingsPhase = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Local package constructor.
|
* Local package constructor.
|
||||||
|
@ -56,26 +51,24 @@ public class DefaultX4OPhaseManager implements X4OPhaseManager {
|
||||||
*/
|
*/
|
||||||
public DefaultX4OPhaseManager() {
|
public DefaultX4OPhaseManager() {
|
||||||
x4oPhases = new ArrayList<X4OPhase>(25);
|
x4oPhases = new ArrayList<X4OPhase>(25);
|
||||||
/*
|
|
||||||
if (elementLanguage==null) {
|
|
||||||
throw new NullPointerException("Can't manage phases with null elementLanguage in constuctor.");
|
|
||||||
}
|
|
||||||
x4oPhases = new ArrayList<X4OPhaseHandler>(15);
|
|
||||||
this.elementLanguage = elementLanguage;
|
|
||||||
|
|
||||||
// Manual
|
|
||||||
skipReleasePhase = elementLanguage.getLanguagePropertyBoolean(X4OLanguageProperty.PHASE_SKIP_RELEASE);
|
|
||||||
skipRunPhase = elementLanguage.getLanguagePropertyBoolean(X4OLanguageProperty.PHASE_SKIP_RUN);
|
|
||||||
skipSiblingsPhase = elementLanguage.getLanguagePropertyBoolean(X4OLanguageProperty.PHASE_SKIP_SIBLINGS);
|
|
||||||
|
|
||||||
// Check if we need to stop after a certain phase
|
|
||||||
Object stopPhaseObject = elementLanguage.getLanguageProperty(X4OLanguageProperty.PHASE_STOP_AFTER);
|
|
||||||
if (stopPhaseObject instanceof X4OPhase) {
|
|
||||||
stopPhase = (X4OPhase)stopPhaseObject;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
|
||||||
|
PHASE_ORDER = { *startupX4OPhase,
|
||||||
|
*createLanguagePhase,
|
||||||
|
*createLanguageSiblingsPhase,
|
||||||
|
*parseSAXStreamPhase,
|
||||||
|
*configGlobalElBeansPhase,
|
||||||
|
*startX4OPhase,
|
||||||
|
configElementPhase,configElementInterfacePhase,configGlobalElementPhase,
|
||||||
|
configGlobalAttributePhase,runAttributesPhase,fillTemplatingPhase,
|
||||||
|
transformPhase,*runDirtyElementPhase,bindElementPhase,
|
||||||
|
*runPhase,runDirtyElementLastPhase,
|
||||||
|
*releasePhase
|
||||||
|
};
|
||||||
|
* = runOnce
|
||||||
|
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* Adds an X4OPhaseHandler.
|
* Adds an X4OPhaseHandler.
|
||||||
* @param phase The X4OPhaseHandler to add.
|
* @param phase The X4OPhaseHandler to add.
|
||||||
|
@ -164,7 +157,7 @@ public class DefaultX4OPhaseManager implements X4OPhaseManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// debug output
|
// debug output
|
||||||
languageContext.setCurrentX4OPhase(phase);
|
((X4OLanguageContextLocal)languageContext).setCurrentPhase(phase);
|
||||||
|
|
||||||
// run listeners
|
// run listeners
|
||||||
for (X4OPhaseListener l:phase.getPhaseListeners()) {
|
for (X4OPhaseListener l:phase.getPhaseListeners()) {
|
||||||
|
@ -198,11 +191,10 @@ public class DefaultX4OPhaseManager implements X4OPhaseManager {
|
||||||
* @throws X4OPhaseException When a running handlers throws one.
|
* @throws X4OPhaseException When a running handlers throws one.
|
||||||
*/
|
*/
|
||||||
public void runPhasesForElement(Element e,X4OPhaseType type,X4OPhase p) throws X4OPhaseException {
|
public void runPhasesForElement(Element e,X4OPhaseType type,X4OPhase p) throws X4OPhaseException {
|
||||||
X4OLanguageContext languageContext = e.getElementLanguage();
|
X4OLanguageContext languageContext = e.getLanguageContext();
|
||||||
boolean skipRunPhase = languageContext.getLanguagePropertyBoolean(X4OLanguageProperty.PHASE_SKIP_RUN);
|
boolean skipRunPhase = languageContext.getLanguagePropertyBoolean(X4OLanguageProperty.PHASE_SKIP_RUN);
|
||||||
String stopPhase = languageContext.getLanguagePropertyString(X4OLanguageProperty.PHASE_STOP_AFTER);
|
String stopPhase = languageContext.getLanguagePropertyString(X4OLanguageProperty.PHASE_STOP_AFTER);
|
||||||
|
|
||||||
|
|
||||||
// sort for the order
|
// sort for the order
|
||||||
List<X4OPhase> x4oPhasesOrder = getOrderedPhases(type);
|
List<X4OPhase> x4oPhasesOrder = getOrderedPhases(type);
|
||||||
for (X4OPhase phase:x4oPhasesOrder) {
|
for (X4OPhase phase:x4oPhasesOrder) {
|
||||||
|
@ -217,7 +209,7 @@ public class DefaultX4OPhaseManager implements X4OPhaseManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// set phase
|
// set phase
|
||||||
languageContext.setCurrentX4OPhase(phase);
|
((X4OLanguageContextLocal)languageContext).setCurrentPhase(phase);
|
||||||
|
|
||||||
// do the run interface
|
// do the run interface
|
||||||
phase.runPhase(languageContext);
|
phase.runPhase(languageContext);
|
||||||
|
@ -259,7 +251,7 @@ public class DefaultX4OPhaseManager implements X4OPhaseManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// set phase
|
// set phase
|
||||||
languageContext.setCurrentX4OPhase(h);
|
((X4OLanguageContextLocal)languageContext).setCurrentPhase(h);
|
||||||
|
|
||||||
// do the run interface
|
// do the run interface
|
||||||
h.runPhase(languageContext);
|
h.runPhase(languageContext);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,180 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2012, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.x4o.xml.lang.phase;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.x4o.xml.element.Element;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageModuleLoaderSibling;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageClassLoader;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageLoader;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageLocal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OPhaseLanguageInit defines all phases to initialize the language.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Apr 7, 2013
|
||||||
|
*/
|
||||||
|
public class X4OPhaseLanguageInit {
|
||||||
|
|
||||||
|
private Logger logger = null;
|
||||||
|
|
||||||
|
public X4OPhaseLanguageInit() {
|
||||||
|
logger = Logger.getLogger(X4OPhaseLanguageInit.class.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createPhases(DefaultX4OPhaseManager manager) {
|
||||||
|
manager.addX4OPhase(new X4OPhaseInitStart());
|
||||||
|
manager.addX4OPhase(new X4OPhaseInitLanguage());
|
||||||
|
manager.addX4OPhase(new X4OPhaseInitLanguageSiblings());
|
||||||
|
manager.addX4OPhase(new X4OPhaseInitEnd());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the X4OPhaseInitStart which is a empty meta phase.
|
||||||
|
*/
|
||||||
|
class X4OPhaseInitStart extends AbstractX4OPhase {
|
||||||
|
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(X4OLanguageContext elementLanguage) throws X4OPhaseException {
|
||||||
|
logger.finest("Run init start phase");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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(X4OLanguageContext elementLanguage) throws X4OPhaseException {
|
||||||
|
try {
|
||||||
|
//debugPhaseMessage("Loading main language: "+elementLanguage.getLanguage(),this,elementLanguage);
|
||||||
|
X4OLanguageLoader loader = (X4OLanguageLoader)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguage().getLanguageConfiguration().getDefaultLanguageLoader());
|
||||||
|
loader.loadLanguage((X4OLanguageLocal)elementLanguage.getLanguage(),elementLanguage.getLanguage().getLanguageName(),elementLanguage.getLanguage().getLanguageVersion());
|
||||||
|
|
||||||
|
if (elementLanguage.hasX4ODebugWriter()) {
|
||||||
|
elementLanguage.getX4ODebugWriter().debugElementLanguageModules(elementLanguage);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new X4OPhaseException(this,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads all sibling languages.
|
||||||
|
*/
|
||||||
|
class X4OPhaseInitLanguageSiblings extends AbstractX4OPhase {
|
||||||
|
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(X4OLanguageContext elementLanguage) throws X4OPhaseException {
|
||||||
|
try {
|
||||||
|
List<X4OLanguageModuleLoaderSibling> siblingLoaders = new ArrayList<X4OLanguageModuleLoaderSibling>(3);
|
||||||
|
for (X4OLanguageModule module:elementLanguage.getLanguage().getLanguageModules()) {
|
||||||
|
if (module.getLanguageModuleLoader() instanceof X4OLanguageModuleLoaderSibling) {
|
||||||
|
siblingLoaders.add((X4OLanguageModuleLoaderSibling)module.getLanguageModuleLoader());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (siblingLoaders.isEmpty()==false) {
|
||||||
|
X4OLanguageLoader loader = (X4OLanguageLoader)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguage().getLanguageConfiguration().getDefaultLanguageLoader());
|
||||||
|
for (X4OLanguageModuleLoaderSibling siblingLoader:siblingLoaders) {
|
||||||
|
//debugPhaseMessage("Loading sibling langauge loader: "+siblingLoader,this,elementLanguage);
|
||||||
|
siblingLoader.loadLanguageSibling((X4OLanguageLocal)elementLanguage.getLanguage(), loader);
|
||||||
|
}
|
||||||
|
if (elementLanguage.hasX4ODebugWriter()) {
|
||||||
|
elementLanguage.getX4ODebugWriter().debugElementLanguageModules(elementLanguage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new X4OPhaseException(this,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the X4OPhaseInitEnd which is a empty meta phase.
|
||||||
|
*/
|
||||||
|
class X4OPhaseInitEnd extends AbstractX4OPhase {
|
||||||
|
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(X4OLanguageContext elementLanguage) throws X4OPhaseException {
|
||||||
|
logger.finest("Run init end phase");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,993 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2012, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.x4o.xml.lang.phase;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.el.ValueExpression;
|
||||||
|
|
||||||
|
import org.x4o.xml.conv.ObjectConverterException;
|
||||||
|
|
||||||
|
import org.x4o.xml.element.Element;
|
||||||
|
import org.x4o.xml.element.ElementAttributeHandler;
|
||||||
|
import org.x4o.xml.element.ElementAttributeValueParser;
|
||||||
|
import org.x4o.xml.element.ElementBindingHandler;
|
||||||
|
import org.x4o.xml.element.ElementClass;
|
||||||
|
import org.x4o.xml.element.ElementClassAttribute;
|
||||||
|
import org.x4o.xml.element.ElementConfigurator;
|
||||||
|
import org.x4o.xml.element.ElementConfiguratorGlobal;
|
||||||
|
import org.x4o.xml.element.ElementException;
|
||||||
|
import org.x4o.xml.element.ElementInterface;
|
||||||
|
import org.x4o.xml.element.ElementNamespaceContext;
|
||||||
|
import org.x4o.xml.io.sax.X4ODebugWriter;
|
||||||
|
import org.x4o.xml.io.sax.X4OEntityResolver;
|
||||||
|
import org.x4o.xml.io.sax.X4OErrorHandler;
|
||||||
|
import org.x4o.xml.io.sax.X4OTagHandler;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageClassLoader;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageProperty;
|
||||||
|
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
import org.xml.sax.XMLReader;
|
||||||
|
import org.xml.sax.ext.DefaultHandler2;
|
||||||
|
import org.xml.sax.helpers.AttributesImpl;
|
||||||
|
import org.xml.sax.helpers.XMLReaderFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory which can create X4OPhaseHandlers for all the predefined phases used in default x4o language parsing.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Dec 31, 2008
|
||||||
|
*/
|
||||||
|
public class X4OPhaseLanguageRead {
|
||||||
|
|
||||||
|
private Logger logger = null;
|
||||||
|
|
||||||
|
public X4OPhaseLanguageRead() {
|
||||||
|
logger = Logger.getLogger(X4OPhaseLanguageRead.class.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void createPhases(DefaultX4OPhaseManager manager) {
|
||||||
|
manager.addX4OPhase(new X4OPhaseReadStart());
|
||||||
|
manager.addX4OPhase(new X4OPhaseReadXml());
|
||||||
|
|
||||||
|
manager.addX4OPhase(new X4OPhaseReadConfigELBeans());
|
||||||
|
// if (elementLanguage.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
|
||||||
|
|
||||||
|
// meta start point
|
||||||
|
// manager.addX4OPhase(factory.startX4OPhase());
|
||||||
|
// if (elementLanguage.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
|
||||||
|
|
||||||
|
// config
|
||||||
|
X4OPhaseReadRunConfigurator runConf = new X4OPhaseReadRunConfigurator();
|
||||||
|
manager.addX4OPhase(new X4OPhaseReadConfigElement(runConf));
|
||||||
|
manager.addX4OPhase(new X4OPhaseReadConfigElementInterface(runConf));
|
||||||
|
manager.addX4OPhase(new X4OPhaseReadConfigGlobalElement(runConf));
|
||||||
|
manager.addX4OPhase(new X4OPhaseReadConfigGlobalAttribute(runConf));
|
||||||
|
|
||||||
|
// run all attribute events
|
||||||
|
manager.addX4OPhase(new X4OPhaseReadRunAttribute());
|
||||||
|
// if (elementLanguage.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
|
||||||
|
// templating
|
||||||
|
manager.addX4OPhase(new X4OPhaseReadFillTemplate());
|
||||||
|
// if (elementLanguage.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
|
||||||
|
|
||||||
|
// transforming
|
||||||
|
manager.addX4OPhase(new X4OPhaseReadTransform());
|
||||||
|
manager.addX4OPhase(new X4OPhaseReadRunDirty(manager));
|
||||||
|
// if (elementLanguage.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
|
||||||
|
|
||||||
|
// binding elements
|
||||||
|
manager.addX4OPhase(new X4OPhaseReadBindElement());
|
||||||
|
|
||||||
|
// runing and releasing
|
||||||
|
manager.addX4OPhase(new X4OPhaseReadRun());
|
||||||
|
// if (elementLanguage.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
|
||||||
|
|
||||||
|
manager.addX4OPhase(runConf);
|
||||||
|
|
||||||
|
manager.addX4OPhase(new X4OPhaseReadRunDirtyLast(manager));
|
||||||
|
// if (elementLanguage.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
|
||||||
|
|
||||||
|
|
||||||
|
manager.addX4OPhase(new X4OPhaseReadEnd());
|
||||||
|
|
||||||
|
// after release phase Element Tree is not avible anymore
|
||||||
|
manager.addX4OPhase(releasePhase());
|
||||||
|
|
||||||
|
// Add debug phase listener to all phases
|
||||||
|
// if (elementLanguage.hasX4ODebugWriter()) {
|
||||||
|
//for (X4OPhase h:manager.getOrderedPhases()) {
|
||||||
|
// h.addPhaseListener(elementLanguage.getX4ODebugWriter().createDebugX4OPhaseListener());
|
||||||
|
//}
|
||||||
|
//}
|
||||||
|
|
||||||
|
// We are done
|
||||||
|
}
|
||||||
|
|
||||||
|
private void debugPhaseMessage(String message,X4OPhase phaseHandler,X4OLanguageContext languageContext) throws X4OPhaseException {
|
||||||
|
if (languageContext.hasX4ODebugWriter()) {
|
||||||
|
try {
|
||||||
|
languageContext.getX4ODebugWriter().debugPhaseMessage(message,phaseHandler.getClass());
|
||||||
|
} catch (ElementException ee) {
|
||||||
|
throw new X4OPhaseException(phaseHandler,ee);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the startX4OPhase which is a empty meta phase.
|
||||||
|
*/
|
||||||
|
class X4OPhaseReadStart extends AbstractX4OPhase {
|
||||||
|
public X4OPhaseType getType() {
|
||||||
|
return X4OPhaseType.XML_READ;
|
||||||
|
}
|
||||||
|
public String getId() {
|
||||||
|
return "READ_START";
|
||||||
|
}
|
||||||
|
public String[] getPhaseDependencies() {
|
||||||
|
return new String[]{};
|
||||||
|
}
|
||||||
|
public boolean isElementPhase() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||||
|
// not used.
|
||||||
|
}
|
||||||
|
public void runPhase(X4OLanguageContext elementLanguage) throws X4OPhaseException {
|
||||||
|
// print the properties and classes for this language/config
|
||||||
|
if (elementLanguage.hasX4ODebugWriter()) {
|
||||||
|
try {
|
||||||
|
elementLanguage.getX4ODebugWriter().debugLanguageProperties(elementLanguage);
|
||||||
|
elementLanguage.getX4ODebugWriter().debugLanguageDefaultClasses(elementLanguage);
|
||||||
|
} catch (ElementException e) {
|
||||||
|
throw new X4OPhaseException(this,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the xml resource(s) and creates an Element tree.
|
||||||
|
*/
|
||||||
|
class X4OPhaseReadXml extends AbstractX4OPhase {
|
||||||
|
public X4OPhaseType getType() {
|
||||||
|
return X4OPhaseType.XML_READ;
|
||||||
|
}
|
||||||
|
public String getId() {
|
||||||
|
return "READ_XML";
|
||||||
|
}
|
||||||
|
public String[] getPhaseDependencies() {
|
||||||
|
return new String[]{"READ_START"};
|
||||||
|
}
|
||||||
|
public boolean isElementPhase() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||||
|
}
|
||||||
|
public void runPhase(X4OLanguageContext elementLanguage) throws X4OPhaseException {
|
||||||
|
try {
|
||||||
|
//XMLParserConfiguration config = new XIncludeAwareParserConfiguration();
|
||||||
|
//config.setProperty("http://apache.org/xml/properties/internal/grammar-pool",myFullGrammarPool);
|
||||||
|
//SAXParser parser = new SAXParser(config);
|
||||||
|
|
||||||
|
// Create Sax parser with x4o tag handler
|
||||||
|
X4OTagHandler xth = new X4OTagHandler(elementLanguage);
|
||||||
|
XMLReader saxParser = XMLReaderFactory.createXMLReader();
|
||||||
|
saxParser.setErrorHandler(new X4OErrorHandler(elementLanguage));
|
||||||
|
saxParser.setEntityResolver(new X4OEntityResolver(elementLanguage));
|
||||||
|
saxParser.setContentHandler(xth);
|
||||||
|
saxParser.setProperty("http://xml.org/sax/properties/lexical-handler", xth);
|
||||||
|
saxParser.setProperty("http://xml.org/sax/properties/declaration-handler",xth);
|
||||||
|
|
||||||
|
// Set properties and optional
|
||||||
|
Map<String,Object> saxParserProperties = elementLanguage.getLanguage().getLanguageConfiguration().getSAXParserProperties(elementLanguage);
|
||||||
|
for (Map.Entry<String,Object> entry:saxParserProperties.entrySet()) {
|
||||||
|
String name = entry.getKey();
|
||||||
|
Object value= entry.getValue();
|
||||||
|
saxParser.setProperty(name, value);
|
||||||
|
debugPhaseMessage("Set SAX property: "+name+" to: "+value,this,elementLanguage);
|
||||||
|
}
|
||||||
|
Map<String,Object> saxParserPropertiesOptional = elementLanguage.getLanguage().getLanguageConfiguration().getSAXParserPropertiesOptional(elementLanguage);
|
||||||
|
for (Map.Entry<String,Object> entry:saxParserPropertiesOptional.entrySet()) {
|
||||||
|
String name = entry.getKey();
|
||||||
|
Object value= entry.getValue();
|
||||||
|
try {
|
||||||
|
saxParser.setProperty(name, value);
|
||||||
|
debugPhaseMessage("Set SAX optional property: "+name+" to: "+value,this,elementLanguage);
|
||||||
|
} catch (SAXException e) {
|
||||||
|
debugPhaseMessage("Could not set optional SAX property: "+name+" to: "+value+" error: "+e.getMessage(),this,elementLanguage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set sax features and optional
|
||||||
|
Map<String, Boolean> features = elementLanguage.getLanguage().getLanguageConfiguration().getSAXParserFeatures(elementLanguage);
|
||||||
|
for (String key:features.keySet()) {
|
||||||
|
Boolean value=features.get(key);
|
||||||
|
saxParser.setFeature(key, value);
|
||||||
|
debugPhaseMessage("Set SAX feature: "+key+" to: "+value,this,elementLanguage);
|
||||||
|
}
|
||||||
|
Map<String, Boolean> featuresOptional = elementLanguage.getLanguage().getLanguageConfiguration().getSAXParserFeaturesOptional(elementLanguage);
|
||||||
|
for (String key:featuresOptional.keySet()) {
|
||||||
|
Boolean value=featuresOptional.get(key);
|
||||||
|
try {
|
||||||
|
saxParser.setFeature(key, value);
|
||||||
|
debugPhaseMessage("Set SAX optional feature: "+key+" to: "+value,this,elementLanguage);
|
||||||
|
} catch (SAXException e) {
|
||||||
|
debugPhaseMessage("Could not set optional SAX feature: "+key+" to: "+value+" error: "+e.getMessage(),this,elementLanguage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for required features
|
||||||
|
List<String> requiredFeatures = elementLanguage.getLanguage().getLanguageConfiguration().getSAXParserFeaturesRequired(elementLanguage);
|
||||||
|
for (String requiredFeature:requiredFeatures) {
|
||||||
|
debugPhaseMessage("Checking required SAX feature: "+requiredFeature,this,elementLanguage);
|
||||||
|
if (saxParser.getFeature(requiredFeature)==false) {
|
||||||
|
Exception e = new IllegalStateException("Missing required feature: "+requiredFeature);
|
||||||
|
throw new X4OPhaseException(this,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finally start parsing the xml input stream
|
||||||
|
Object requestInputSource = elementLanguage.getLanguageProperty(X4OLanguageProperty.INPUT_SOURCE_OBJECT);
|
||||||
|
InputSource input = null;
|
||||||
|
InputStream inputStream = null;
|
||||||
|
if (requestInputSource instanceof InputSource) {
|
||||||
|
input = (InputSource)requestInputSource;
|
||||||
|
} else {
|
||||||
|
inputStream = (InputStream)elementLanguage.getLanguageProperty(X4OLanguageProperty.INPUT_SOURCE_STREAM);
|
||||||
|
input = new InputSource(inputStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
Object requestInputEncoding = elementLanguage.getLanguageProperty(X4OLanguageProperty.INPUT_SOURCE_ENCODING);
|
||||||
|
if (requestInputEncoding!=null && requestInputEncoding instanceof String) {
|
||||||
|
input.setEncoding(requestInputEncoding.toString());
|
||||||
|
}
|
||||||
|
Object requestSystemId = elementLanguage.getLanguageProperty(X4OLanguageProperty.INPUT_SOURCE_SYSTEM_ID);
|
||||||
|
if (requestSystemId!=null && requestSystemId instanceof String) {
|
||||||
|
input.setSystemId(requestSystemId.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
saxParser.parse(input);
|
||||||
|
} finally {
|
||||||
|
if (inputStream!=null) {
|
||||||
|
inputStream.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new X4OPhaseException(this,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the configGlobalElBeansPhase which adds beans to the el context.
|
||||||
|
*/
|
||||||
|
class X4OPhaseReadConfigELBeans extends AbstractX4OPhase {
|
||||||
|
public X4OPhaseType getType() {
|
||||||
|
return X4OPhaseType.XML_RW;
|
||||||
|
}
|
||||||
|
public String getId() {
|
||||||
|
return "READ_CONFIG_EL_BEANS";
|
||||||
|
}
|
||||||
|
public String[] getPhaseDependencies() {
|
||||||
|
return new String[] {"READ_XML"};
|
||||||
|
}
|
||||||
|
public boolean isElementPhase() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||||
|
// not used.
|
||||||
|
}
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public void runPhase(X4OLanguageContext elementLanguage) throws X4OPhaseException {
|
||||||
|
try {
|
||||||
|
Map beanMap = (Map)elementLanguage.getLanguageProperty(X4OLanguageProperty.EL_BEAN_INSTANCE_MAP);
|
||||||
|
if (beanMap==null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (Object elName:beanMap.keySet()) {
|
||||||
|
Object o = beanMap.get(elName);
|
||||||
|
ValueExpression ve = elementLanguage.getExpressionLanguageFactory().createValueExpression(elementLanguage.getExpressionLanguageContext(),"${"+elName+"}", o.getClass());
|
||||||
|
ve.setValue(elementLanguage.getExpressionLanguageContext(), o);
|
||||||
|
debugPhaseMessage("Setting el bean: ${"+elName+"} to: "+o.getClass().getName(),this,elementLanguage);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new X4OPhaseException(this,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OPhaseReadConfigElement
|
||||||
|
*/
|
||||||
|
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_CONFIG_EL_BEANS"};
|
||||||
|
}
|
||||||
|
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||||
|
|
||||||
|
// First phase is to rename attributes, maybe move so sax phase
|
||||||
|
for (ElementClassAttribute eca:element.getElementClass().getElementClassAttributes()) {
|
||||||
|
List<String> aliases = eca.getAttributeAliases();
|
||||||
|
if (aliases.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (String alias:aliases) {
|
||||||
|
if (element.getAttributes().containsKey(alias)) {
|
||||||
|
String attributeValue = element.getAttributes().get(alias);
|
||||||
|
element.getAttributes().put(eca.getName(), attributeValue);
|
||||||
|
element.getAttributes().remove(alias);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.finest("Do ElementClass Config Configurators: "+element.getElementClass().getElementConfigurators().size());
|
||||||
|
for (ElementConfigurator ec:element.getElementClass().getElementConfigurators()) {
|
||||||
|
runConf.runElementConfigurator(ec,element,this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OPhaseReadConfigElementInterface
|
||||||
|
*/
|
||||||
|
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_EL_BEANS"};
|
||||||
|
}
|
||||||
|
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||||
|
if (element.getElementObject()==null) {
|
||||||
|
logger.finest("Null elementObject skipping, interfaces");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (ElementInterface ei:element.getLanguageContext().getLanguage().findElementInterfaces(element.getElementObject())) {
|
||||||
|
logger.finest("Do ElementInterface Config Configurators: "+ei.getElementConfigurators().size());
|
||||||
|
for (ElementConfigurator ec:ei.getElementConfigurators()) {
|
||||||
|
runConf.runElementConfigurator(ec,element,this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OPhaseReadConfigGlobalElement
|
||||||
|
*/
|
||||||
|
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.getLanguageContext().getLanguage().getLanguageModules()) {
|
||||||
|
logger.finest("Do Element Config Global Configurators: "+mod.getElementConfiguratorGlobals().size());
|
||||||
|
for (ElementConfiguratorGlobal ec:mod.getElementConfiguratorGlobals()) {
|
||||||
|
runConf.runElementConfigurator(ec,element,this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OPhaseReadConfigGlobalAttribute
|
||||||
|
*/
|
||||||
|
class X4OPhaseReadConfigGlobalAttribute extends AbstractX4OPhase {
|
||||||
|
Comparator<ElementAttributeHandler> elementAttributeHandlerComparator = 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 (elementAttributeHandlerComparator==null) {
|
||||||
|
try {
|
||||||
|
elementAttributeHandlerComparator = (Comparator<ElementAttributeHandler>)X4OLanguageClassLoader.newInstance(element.getLanguageContext().getLanguage().getLanguageConfiguration().getDefaultElementAttributeHandlerComparator());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new X4OPhaseException(this,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// do global parameters
|
||||||
|
logger.finest("Do Element Global AttributeHandlers.");
|
||||||
|
List<ElementAttributeHandler> handlers = new ArrayList<ElementAttributeHandler>();
|
||||||
|
for (X4OLanguageModule mod:element.getLanguageContext().getLanguage().getLanguageModules()) {
|
||||||
|
for (ElementAttributeHandler global:mod.getElementAttributeHandlers()) {
|
||||||
|
|
||||||
|
String attribute = element.getAttributes().get(global.getAttributeName());
|
||||||
|
if (attribute!=null) {
|
||||||
|
handlers.add(global);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Collections.sort(handlers,elementAttributeHandlerComparator);
|
||||||
|
List<ElementConfigurator> handlers2 = new ArrayList<ElementConfigurator>(handlers.size());
|
||||||
|
handlers2.addAll(handlers);
|
||||||
|
for (ElementConfigurator ec:handlers) {
|
||||||
|
runConf.runElementConfigurator(ec,element,this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OPhaseReadRunAttribute
|
||||||
|
*/
|
||||||
|
class X4OPhaseReadRunAttribute extends AbstractX4OPhase {
|
||||||
|
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) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// do config
|
||||||
|
Map<String,String> attr = element.getAttributes();
|
||||||
|
ElementAttributeValueParser attrParser = element.getLanguageContext().getElementAttributeValueParser();
|
||||||
|
Boolean autoAttributes = element.getElementClass().getAutoAttributes();
|
||||||
|
if (autoAttributes==null) {
|
||||||
|
autoAttributes = true;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
for (String name:attr.keySet()) {
|
||||||
|
String valueString = (String)attr.get(name);
|
||||||
|
if (valueString==null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Object value = valueString;
|
||||||
|
ElementClassAttribute attrClass = element.getElementClass().getElementClassAttributeByName(name);
|
||||||
|
if (attrClass!=null) {
|
||||||
|
if (attrClass.getRunResolveEL()==null || attrClass.getRunResolveEL() && attrParser.isELParameter(name, valueString, element)) {
|
||||||
|
value = attrParser.getELParameterValue(valueString, element);
|
||||||
|
}
|
||||||
|
if (attrClass.getRunConverters()==null || attrClass.getRunConverters()) {
|
||||||
|
value = attrParser.getConvertedParameterValue(name, value, element);
|
||||||
|
}
|
||||||
|
if (attrClass.getRunBeanFill()==null || attrClass.getRunBeanFill()) {
|
||||||
|
element.getLanguageContext().getElementObjectPropertyValue().setProperty(element.getElementObject(), name, value);
|
||||||
|
}
|
||||||
|
} else if (autoAttributes) {
|
||||||
|
|
||||||
|
value = attrParser.getParameterValue(name,valueString,element);
|
||||||
|
element.getLanguageContext().getElementObjectPropertyValue().setProperty(element.getElementObject(), name, value);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
continue; // skip all non auto attribute non attribute defined xml attributes, or throw exception ?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check for defaults
|
||||||
|
for (ElementClassAttribute attrClass:element.getElementClass().getElementClassAttributes()) {
|
||||||
|
if (attrClass.getDefaultValue()!=null && attr.containsKey(attrClass.getName())==false) {
|
||||||
|
Object value = null;
|
||||||
|
if (attrClass.getDefaultValue() instanceof String) {
|
||||||
|
value = attrParser.getParameterValue(attrClass.getName(),(String)attrClass.getDefaultValue(),element);
|
||||||
|
} else {
|
||||||
|
value = attrClass.getDefaultValue();
|
||||||
|
}
|
||||||
|
if (attrClass.getRunBeanFill()==null || attrClass.getRunBeanFill()) {
|
||||||
|
element.getLanguageContext().getElementObjectPropertyValue().setProperty(element.getElementObject(), attrClass.getName(), value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (ObjectConverterException oce) {
|
||||||
|
throw new X4OPhaseException(this,"Error while converting parameters: "+oce.getMessage(),oce);
|
||||||
|
} catch (ElementException e) {
|
||||||
|
throw new X4OPhaseException(this,"Error while setting parameters: "+e.getMessage(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OPhaseReadFillTemplate
|
||||||
|
*/
|
||||||
|
class X4OPhaseReadFillTemplate extends AbstractX4OPhase {
|
||||||
|
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 {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OPhaseReadTransform
|
||||||
|
*/
|
||||||
|
class X4OPhaseReadTransform extends AbstractX4OPhase {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (element.getLanguageContext().hasX4ODebugWriter()) {
|
||||||
|
element.getLanguageContext().getX4ODebugWriter().debugElement(element);
|
||||||
|
}
|
||||||
|
element.doElementRun();
|
||||||
|
} catch (ElementException e) {
|
||||||
|
throw new X4OPhaseException(this,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OPhaseReadRunDirty
|
||||||
|
*/
|
||||||
|
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 {
|
||||||
|
Map<Element,X4OPhase> dirtyElements = element.getLanguageContext().getDirtyElements();
|
||||||
|
if (dirtyElements.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
debugPhaseMessage("Dirty elements: "+dirtyElements.size(), this,element.getLanguageContext());
|
||||||
|
for (Element e:dirtyElements.keySet()) {
|
||||||
|
X4OPhase p = dirtyElements.get(e);
|
||||||
|
phaseManager.runPhasesForElement(e,getType(), p);
|
||||||
|
}
|
||||||
|
element.getLanguageContext().getDirtyElements().clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OPhaseReadRunDirtyLast
|
||||||
|
*/
|
||||||
|
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 {
|
||||||
|
Map<Element,X4OPhase> dirtyElements = element.getLanguageContext().getDirtyElements();
|
||||||
|
if (dirtyElements.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
debugPhaseMessage("Dirty elements last: "+dirtyElements.size(), this,element.getLanguageContext());
|
||||||
|
for (Element e:dirtyElements.keySet()) {
|
||||||
|
X4OPhase p = dirtyElements.get(e);
|
||||||
|
phaseManager.runPhasesForElement(e,getType(), p);
|
||||||
|
}
|
||||||
|
element.getLanguageContext().getDirtyElements().clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OPhaseReadBindElement
|
||||||
|
*/
|
||||||
|
class X4OPhaseReadBindElement extends AbstractX4OPhase {
|
||||||
|
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) {
|
||||||
|
logger.finest("No parent element, so no binding needed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Object parentObject = parentElement.getElementObject();
|
||||||
|
if(parentObject==null) {
|
||||||
|
logger.finest("No parent object, so no binding needed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Object childObject = element.getElementObject();
|
||||||
|
if (childObject==null) {
|
||||||
|
logger.finest("No child object, so no binding needed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ElementBindingHandler> binds = element.getLanguageContext().getLanguage().findElementBindingHandlers(parentObject, childObject);
|
||||||
|
logger.finest("Calling bindings handlers; "+binds.size());
|
||||||
|
try {
|
||||||
|
for (ElementBindingHandler binding:binds) {
|
||||||
|
if (element.getLanguageContext().hasX4ODebugWriter()) {
|
||||||
|
element.getLanguageContext().getX4ODebugWriter().debugElementBindingHandler(binding,element);
|
||||||
|
}
|
||||||
|
binding.bindChild(element);
|
||||||
|
}
|
||||||
|
} catch (ElementException e) {
|
||||||
|
throw new X4OPhaseException(this,"Error while binding",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OPhaseReadRun
|
||||||
|
*/
|
||||||
|
class X4OPhaseReadRun extends AbstractX4OPhase {
|
||||||
|
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.
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
//if (parser.hasX4ODebugWriter()) {
|
||||||
|
// parser.getX4ODebugWriter().debugElement(element);
|
||||||
|
//}
|
||||||
|
element.doElementRun();
|
||||||
|
} catch (ElementException e) {
|
||||||
|
throw new X4OPhaseException(this,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
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(X4OLanguageContext elementLanguage) throws X4OPhaseException {
|
||||||
|
for (RunConfigurator conf:runConf) {
|
||||||
|
try {
|
||||||
|
if (elementLanguage.hasX4ODebugWriter()) {
|
||||||
|
elementLanguage.getX4ODebugWriter().debugElementConfigurator(conf.elementConfigurator,conf.element);
|
||||||
|
}
|
||||||
|
conf.elementConfigurator.doConfigElement(conf.element);
|
||||||
|
} catch (ElementException e) {
|
||||||
|
throw new X4OPhaseException(this,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@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));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (e.getLanguageContext().hasX4ODebugWriter()) {
|
||||||
|
e.getLanguageContext().getX4ODebugWriter().debugElementConfigurator(ec,e);
|
||||||
|
}
|
||||||
|
ec.doConfigElement(e);
|
||||||
|
|
||||||
|
// may request rerun of config
|
||||||
|
if (ec.isConfigAction()) {
|
||||||
|
runConf.add(new RunConfigurator(e,ec));
|
||||||
|
}
|
||||||
|
} catch (ElementException ee) {
|
||||||
|
throw new X4OPhaseException(phase,ee);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OPhaseReadEnd Is the read end phase.
|
||||||
|
*/
|
||||||
|
class X4OPhaseReadEnd extends AbstractX4OPhase {
|
||||||
|
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(X4OLanguageContext elementLanguage) throws X4OPhaseException {
|
||||||
|
// print the properties and classes for this language/config
|
||||||
|
if (elementLanguage.hasX4ODebugWriter()) {
|
||||||
|
try {
|
||||||
|
elementLanguage.getX4ODebugWriter().debugLanguageProperties(elementLanguage);
|
||||||
|
elementLanguage.getX4ODebugWriter().debugLanguageDefaultClasses(elementLanguage);
|
||||||
|
} catch (ElementException e) {
|
||||||
|
throw new X4OPhaseException(this,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return The X4OPhaseHandler for this phase.
|
||||||
|
*/
|
||||||
|
public X4OPhase releasePhase() {
|
||||||
|
|
||||||
|
// for debug output
|
||||||
|
class ReleasePhaseListener implements X4OPhaseListener {
|
||||||
|
private int elementsReleased = 0;
|
||||||
|
/**
|
||||||
|
* @see org.x4o.xml.lang.phase.X4OPhaseListener#preRunPhase(org.x4o.xml.lang.phase.X4OPhase, org.x4o.xml.lang.X4OLanguageContext)
|
||||||
|
*/
|
||||||
|
public void preRunPhase(X4OPhase phase,X4OLanguageContext elementLanguage) throws X4OPhaseException {
|
||||||
|
elementsReleased=0;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @see org.x4o.xml.lang.phase.X4OPhaseListener#endRunPhase(org.x4o.xml.lang.phase.X4OPhase, org.x4o.xml.lang.X4OLanguageContext)
|
||||||
|
*/
|
||||||
|
public void endRunPhase(X4OPhase phase,X4OLanguageContext elementLanguage) throws X4OPhaseException {
|
||||||
|
if (elementLanguage.hasX4ODebugWriter()==false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
AttributesImpl atts = new AttributesImpl();
|
||||||
|
atts.addAttribute ("", "elements", "", "", elementsReleased+"");
|
||||||
|
elementLanguage.getX4ODebugWriter().getDebugWriter().startElement (X4ODebugWriter.DEBUG_URI, "executeReleases", "", atts);
|
||||||
|
elementLanguage.getX4ODebugWriter().getDebugWriter().endElement (X4ODebugWriter.DEBUG_URI, "executeReleases" , "");
|
||||||
|
} catch (SAXException e) {
|
||||||
|
throw new X4OPhaseException(phase,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addReleasedElement() {
|
||||||
|
elementsReleased++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final ReleasePhaseListener releaseCounter = new ReleasePhaseListener();
|
||||||
|
X4OPhase result = new AbstractX4OPhase() {
|
||||||
|
public X4OPhaseType getType() {
|
||||||
|
return X4OPhaseType.XML_RW;
|
||||||
|
}
|
||||||
|
public String getId() {
|
||||||
|
return "X4O_RELEASE";
|
||||||
|
}
|
||||||
|
public String[] getPhaseDependencies() {
|
||||||
|
return new String[] {"READ_END"};
|
||||||
|
}
|
||||||
|
public void runPhase(X4OLanguageContext elementLanguage) throws X4OPhaseException {
|
||||||
|
}
|
||||||
|
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||||
|
try {
|
||||||
|
element.release();
|
||||||
|
} catch (ElementException e) {
|
||||||
|
throw new X4OPhaseException(this,e);
|
||||||
|
} finally {
|
||||||
|
releaseCounter.addReleasedElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
result.addPhaseListener(releaseCounter);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an debug phase
|
||||||
|
* @return The X4OPhaseHandler for this phase.
|
||||||
|
*/
|
||||||
|
public X4OPhase debugPhase(final X4OPhase afterPhase) {
|
||||||
|
X4OPhase result = new AbstractX4OPhase() {
|
||||||
|
public X4OPhaseType getType() {
|
||||||
|
return X4OPhaseType.XML_RW;
|
||||||
|
}
|
||||||
|
public String getId() {
|
||||||
|
return "X4O_DEBUG_"+afterPhase.getId();
|
||||||
|
}
|
||||||
|
public String[] getPhaseDependencies() {
|
||||||
|
return new String[] {afterPhase.getId()};
|
||||||
|
}
|
||||||
|
public boolean isElementPhase() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||||
|
}
|
||||||
|
public void runPhase(X4OLanguageContext elementLanguage) throws X4OPhaseException {
|
||||||
|
// safety check
|
||||||
|
if (elementLanguage.hasX4ODebugWriter()==false) {
|
||||||
|
throw new X4OPhaseException(this,"Use debugPhase only when X4OParser.debugWriter is filled.");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
AttributesImpl atts = new AttributesImpl();
|
||||||
|
//atts.addAttribute ("", key, "", "", value);
|
||||||
|
//atts.addAttribute ("", "verbose", "", "", "true");
|
||||||
|
elementLanguage.getX4ODebugWriter().getDebugWriter().startElement (X4ODebugWriter.DEBUG_URI, "printElementTree", "", atts);
|
||||||
|
startedPrefix.clear();
|
||||||
|
printXML(elementLanguage.getRootElement());
|
||||||
|
for (String prefix:startedPrefix) {
|
||||||
|
elementLanguage.getX4ODebugWriter().getDebugWriter().endPrefixMapping(prefix);
|
||||||
|
}
|
||||||
|
elementLanguage.getX4ODebugWriter().getDebugWriter().endElement(X4ODebugWriter.DEBUG_URI, "printElementTree", "");
|
||||||
|
elementLanguage.getX4ODebugWriter().debugElementLanguage(elementLanguage);
|
||||||
|
} catch (SAXException e) {
|
||||||
|
throw new X4OPhaseException(this,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<String> startedPrefix = new ArrayList<String>(10);
|
||||||
|
|
||||||
|
// note: slow version
|
||||||
|
private String getNamespaceForElement(Element e) {
|
||||||
|
for (X4OLanguageModule mod:e.getLanguageContext().getLanguage().getLanguageModules()) {
|
||||||
|
for (ElementNamespaceContext enc:mod.getElementNamespaceContexts()) {
|
||||||
|
List<ElementClass> l = enc.getElementClasses();
|
||||||
|
if (l.contains(e.getElementClass())) {
|
||||||
|
return enc.getUri();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void printXML(Element element) throws SAXException {
|
||||||
|
if (element==null) {
|
||||||
|
throw new SAXException("Can't print debug xml of null element.");
|
||||||
|
}
|
||||||
|
DefaultHandler2 handler = element.getLanguageContext().getX4ODebugWriter().getDebugWriter();
|
||||||
|
if (element.getElementType().equals(Element.ElementType.comment)) {
|
||||||
|
char[] msg = ((String)element.getElementObject()).toCharArray();
|
||||||
|
handler.comment(msg,0,msg.length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (element.getElementType().equals(Element.ElementType.characters)) {
|
||||||
|
char[] msg = ((String)element.getElementObject()).toCharArray();
|
||||||
|
handler.characters(msg,0,msg.length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (element.getElementClass()==null) {
|
||||||
|
throw new SAXException("Element without ElementClass is not valid: "+element+" obj: "+element.getElementObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
AttributesImpl atts = new AttributesImpl();
|
||||||
|
for (String key:element.getAttributes().keySet()) {
|
||||||
|
String value = element.getAttributes().get(key);
|
||||||
|
//uri, localName, xml1.0name, type, value
|
||||||
|
atts.addAttribute ("", key, "", "", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
String nameSpace = getNamespaceForElement(element);
|
||||||
|
String prefix = element.getLanguageContext().getLanguage().findElementNamespaceContext(nameSpace).getPrefixMapping();
|
||||||
|
|
||||||
|
if (startedPrefix.contains(prefix)==false) {
|
||||||
|
handler.startPrefixMapping(prefix, nameSpace);
|
||||||
|
startedPrefix.add(prefix);
|
||||||
|
}
|
||||||
|
handler.startElement (nameSpace, element.getElementClass().getTag(), "", atts);
|
||||||
|
for (Element e:element.getAllChilderen()) {
|
||||||
|
printXML(e);
|
||||||
|
}
|
||||||
|
handler.endElement (nameSpace, element.getElementClass().getTag(), "");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -51,13 +51,13 @@ public interface X4OPhaseManager {
|
||||||
*/
|
*/
|
||||||
List<X4OPhase> getOrderedPhases(X4OPhaseType type);
|
List<X4OPhase> getOrderedPhases(X4OPhaseType type);
|
||||||
|
|
||||||
public void doReleasePhaseManual(X4OLanguageContext languageContext) throws X4OPhaseException;
|
void doReleasePhaseManual(X4OLanguageContext languageContext) throws X4OPhaseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs all the phases in the right order.
|
* Runs all the phases in the right order.
|
||||||
* @throws X4OPhaseException When a running handlers throws one.
|
* @throws X4OPhaseException When a running handlers throws one.
|
||||||
*/
|
*/
|
||||||
public void runPhases(X4OLanguageContext elementContext,X4OPhaseType type) throws X4OPhaseException;
|
void runPhases(X4OLanguageContext elementContext,X4OPhaseType type) throws X4OPhaseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs phase on single element.
|
* Runs phase on single element.
|
||||||
|
@ -65,5 +65,5 @@ public interface X4OPhaseManager {
|
||||||
* @param p The phase to run.
|
* @param p The phase to run.
|
||||||
* @throws X4OPhaseException When a running handlers throws one.
|
* @throws X4OPhaseException When a running handlers throws one.
|
||||||
*/
|
*/
|
||||||
public void runPhasesForElement(Element e,X4OPhaseType type,X4OPhase p) throws X4OPhaseException;
|
void runPhasesForElement(Element e,X4OPhaseType type,X4OPhase p) throws X4OPhaseException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,213 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2004-2012, Willem Cazander
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
|
||||||
* that the following conditions are met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
|
||||||
* following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
|
||||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
||||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
|
||||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.x4o.xml.lang.phase;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.x4o.xml.element.Element;
|
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
|
||||||
import org.x4o.xml.lang.phase.X4OPhaseFactory.X4OPhaseReadRunConfigurator;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* X4OPhaseManagerFactory
|
|
||||||
*
|
|
||||||
* @author Willem Cazander
|
|
||||||
* @version 1.0 Apr 30, 2013
|
|
||||||
*/
|
|
||||||
public class X4OPhaseManagerFactory {
|
|
||||||
|
|
||||||
static public X4OPhaseManager createDefaultX4OPhaseManager() {
|
|
||||||
X4OPhaseFactory factory = new X4OPhaseFactory();
|
|
||||||
DefaultX4OPhaseManager phaseManager = new DefaultX4OPhaseManager();
|
|
||||||
createPhasesInit(phaseManager,factory);
|
|
||||||
createPhasesRead(phaseManager,factory);
|
|
||||||
return phaseManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
static private void createPhasesInit(DefaultX4OPhaseManager manager,X4OPhaseFactory factory) {
|
|
||||||
manager.addX4OPhase(factory.initX4OPhase());
|
|
||||||
manager.addX4OPhase(factory.createLanguagePhase());
|
|
||||||
manager.addX4OPhase(factory.createLanguageSiblingsPhase());
|
|
||||||
}
|
|
||||||
|
|
||||||
static private void createPhasesRead(DefaultX4OPhaseManager manager,X4OPhaseFactory factory) {
|
|
||||||
// main startup
|
|
||||||
manager.addX4OPhase(factory.readStartX4OPhase());
|
|
||||||
//manager.addX4OPhase(factory.createLanguagePhase());
|
|
||||||
//manager.addX4OPhase(factory.createLanguageSiblingsPhase());
|
|
||||||
manager.addX4OPhase(factory.readSAXStreamPhase());
|
|
||||||
|
|
||||||
// inject and opt phase
|
|
||||||
manager.addX4OPhase(factory.configGlobalElBeansPhase());
|
|
||||||
// if (elementLanguage.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
|
|
||||||
|
|
||||||
// meta start point
|
|
||||||
// manager.addX4OPhase(factory.startX4OPhase());
|
|
||||||
// if (elementLanguage.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
|
|
||||||
|
|
||||||
// config
|
|
||||||
X4OPhaseReadRunConfigurator runConf = factory.readRunConfiguratorPhase();
|
|
||||||
manager.addX4OPhase(factory.configElementPhase(runConf));
|
|
||||||
manager.addX4OPhase(factory.configElementInterfacePhase(runConf));
|
|
||||||
manager.addX4OPhase(factory.configGlobalElementPhase(runConf));
|
|
||||||
manager.addX4OPhase(factory.configGlobalAttributePhase(runConf));
|
|
||||||
|
|
||||||
// run all attribute events
|
|
||||||
manager.addX4OPhase(factory.runAttributesPhase());
|
|
||||||
// if (elementLanguage.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
|
|
||||||
// templating
|
|
||||||
manager.addX4OPhase(factory.fillTemplatingPhase());
|
|
||||||
// if (elementLanguage.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
|
|
||||||
|
|
||||||
// transforming
|
|
||||||
manager.addX4OPhase(factory.transformPhase());
|
|
||||||
manager.addX4OPhase(factory.runDirtyElementPhase(manager));
|
|
||||||
// if (elementLanguage.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
|
|
||||||
|
|
||||||
// binding elements
|
|
||||||
manager.addX4OPhase(factory.bindElementPhase());
|
|
||||||
|
|
||||||
// runing and releasing
|
|
||||||
manager.addX4OPhase(factory.runPhase());
|
|
||||||
// if (elementLanguage.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
|
|
||||||
|
|
||||||
manager.addX4OPhase(runConf);
|
|
||||||
|
|
||||||
manager.addX4OPhase(factory.runDirtyElementLastPhase(manager));
|
|
||||||
// if (elementLanguage.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
|
|
||||||
|
|
||||||
|
|
||||||
manager.addX4OPhase(factory.readEndX4OPhase());
|
|
||||||
|
|
||||||
// after release phase Element Tree is not avible anymore
|
|
||||||
manager.addX4OPhase(factory.releasePhase());
|
|
||||||
|
|
||||||
// Add debug phase listener to all phases
|
|
||||||
// if (elementLanguage.hasX4ODebugWriter()) {
|
|
||||||
//for (X4OPhase h:manager.getOrderedPhases()) {
|
|
||||||
// h.addPhaseListener(elementLanguage.getX4ODebugWriter().createDebugX4OPhaseListener());
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
|
|
||||||
// We are done
|
|
||||||
}
|
|
||||||
|
|
||||||
enum R {
|
|
||||||
|
|
||||||
/** Defines this meta startup phase. */
|
|
||||||
startupX4OPhase(true),
|
|
||||||
|
|
||||||
/** Load all meta info of the language we are creating. */
|
|
||||||
createLanguagePhase(true),
|
|
||||||
|
|
||||||
/** Load all siblings languages. */
|
|
||||||
createLanguageSiblingsPhase(true),
|
|
||||||
|
|
||||||
/** Parse the xml from sax events. */
|
|
||||||
parseSAXStreamPhase(true),
|
|
||||||
|
|
||||||
/** Optional extra config phase for injecting bean instances into the EL context. */
|
|
||||||
configGlobalElBeansPhase(true),
|
|
||||||
|
|
||||||
/** emty meta phase to refer to that sax is ready and element s are waiting for processing. */
|
|
||||||
startX4OPhase(true),
|
|
||||||
|
|
||||||
/** re runnable phases which config xml to beans and binds them together. */
|
|
||||||
configElementPhase,
|
|
||||||
configElementInterfacePhase,
|
|
||||||
configGlobalElementPhase,
|
|
||||||
configGlobalAttributePhase,
|
|
||||||
|
|
||||||
/** Fill the bean attributes from the Element xml attributes. */
|
|
||||||
runAttributesPhase,
|
|
||||||
|
|
||||||
/** Fill in the x4o templating objects. */
|
|
||||||
fillTemplatingPhase,
|
|
||||||
|
|
||||||
/** transform phase , modifies the Element Tree. */
|
|
||||||
transformPhase,
|
|
||||||
|
|
||||||
/** Run the phases which needs to be runned again from a phase. */
|
|
||||||
runDirtyElementPhase(true),
|
|
||||||
|
|
||||||
/** Binds objects together */
|
|
||||||
bindElementPhase,
|
|
||||||
|
|
||||||
/** Run action stuff, we are ready with it. */
|
|
||||||
runPhase(true),
|
|
||||||
|
|
||||||
/** Rerun all needed phases for all element that requested it. */
|
|
||||||
runDirtyElementLastPhase,
|
|
||||||
|
|
||||||
/** Releases all Elements, which clears attributes and childeren etc. */
|
|
||||||
releasePhase(true),
|
|
||||||
|
|
||||||
/** write all phases and stuff to debug sax stream. */
|
|
||||||
debugPhase;
|
|
||||||
|
|
||||||
/** Defines which phase we start, when context is created. */
|
|
||||||
public static final R FIRST_PHASE = startupX4OPhase;
|
|
||||||
|
|
||||||
/** The order in which the phases are executed */
|
|
||||||
static final R[] PHASE_ORDER = { startupX4OPhase,
|
|
||||||
createLanguagePhase,
|
|
||||||
createLanguageSiblingsPhase,
|
|
||||||
|
|
||||||
parseSAXStreamPhase,
|
|
||||||
configGlobalElBeansPhase,
|
|
||||||
startX4OPhase,
|
|
||||||
configElementPhase,configElementInterfacePhase,configGlobalElementPhase,
|
|
||||||
configGlobalAttributePhase,runAttributesPhase,fillTemplatingPhase,
|
|
||||||
transformPhase,runDirtyElementPhase,bindElementPhase,
|
|
||||||
runPhase,runDirtyElementLastPhase,
|
|
||||||
releasePhase
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Boolean indicating that this phase only may be run'ed once. */
|
|
||||||
private boolean runOnce = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an X4O Phase.
|
|
||||||
*/
|
|
||||||
private R() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an X4O Phase
|
|
||||||
* @param runOnce Flag indicating that this phase is runnable multiple times.
|
|
||||||
*/
|
|
||||||
private R(boolean runOnce) {
|
|
||||||
this.runOnce=runOnce;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a flag indicating that this phase is runnable multiple times.
|
|
||||||
* @return True if phase is restricted to run once.
|
|
||||||
*/
|
|
||||||
public boolean isRunOnce() {
|
|
||||||
return runOnce;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,7 +7,7 @@
|
||||||
ModuleName: Element Language Definition
|
ModuleName: Element Language Definition
|
||||||
Namespaces: 3
|
Namespaces: 3
|
||||||
Namespace: http://eld.x4o.org/xml/ns/eld-conv
|
Namespace: http://eld.x4o.org/xml/ns/eld-conv
|
||||||
Created on: Tue Jan 08 06:03:20 CET 2013
|
Created on: Mon Apr 08 02:26:14 CEST 2013
|
||||||
-->
|
-->
|
||||||
<schema xmlns="http://www.w3.org/2001/XMLSchema"
|
<schema xmlns="http://www.w3.org/2001/XMLSchema"
|
||||||
xmlns:this="http://eld.x4o.org/xml/ns/eld-conv"
|
xmlns:this="http://eld.x4o.org/xml/ns/eld-conv"
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
ModuleName: Element Language Definition
|
ModuleName: Element Language Definition
|
||||||
Namespaces: 3
|
Namespaces: 3
|
||||||
Namespace: http://eld.x4o.org/xml/ns/eld-lang
|
Namespace: http://eld.x4o.org/xml/ns/eld-lang
|
||||||
Created on: Tue Jan 08 06:03:20 CET 2013
|
Created on: Mon Apr 08 02:26:14 CEST 2013
|
||||||
-->
|
-->
|
||||||
<schema xmlns="http://www.w3.org/2001/XMLSchema"
|
<schema xmlns="http://www.w3.org/2001/XMLSchema"
|
||||||
xmlns:conv="http://eld.x4o.org/xml/ns/eld-conv"
|
xmlns:conv="http://eld.x4o.org/xml/ns/eld-conv"
|
||||||
|
@ -20,13 +20,13 @@
|
||||||
<element name="element" type="this:elementType"/>
|
<element name="element" type="this:elementType"/>
|
||||||
</choice>
|
</choice>
|
||||||
<attribute name="uri" type="string" use="required"/>
|
<attribute name="uri" type="string" use="required"/>
|
||||||
<attribute name="name" type="string"/>
|
|
||||||
<attribute name="elementNamespaceInstanceProvider" type="string"/>
|
<attribute name="elementNamespaceInstanceProvider" type="string"/>
|
||||||
<attribute name="schemaUri" type="string"/>
|
<attribute name="schemaUri" type="string"/>
|
||||||
<attribute name="schemaResource" type="string"/>
|
<attribute name="schemaResource" type="string"/>
|
||||||
<attribute name="schemaPrefix" type="string"/>
|
<attribute name="schemaPrefix" type="string"/>
|
||||||
<attribute name="languageRoot" type="boolean"/>
|
<attribute name="languageRoot" type="boolean"/>
|
||||||
<attribute name="prefixMapping" type="string"/>
|
<attribute name="prefixMapping" type="string"/>
|
||||||
|
<attribute name="name" type="string"/>
|
||||||
<attribute name="id" type="string"/>
|
<attribute name="id" type="string"/>
|
||||||
<attribute name="description" type="string"/>
|
<attribute name="description" type="string"/>
|
||||||
</complexType>
|
</complexType>
|
||||||
|
@ -55,10 +55,10 @@
|
||||||
<attribute name="objectClass" type="string"/>
|
<attribute name="objectClass" type="string"/>
|
||||||
<attribute name="elementClass" type="string"/>
|
<attribute name="elementClass" type="string"/>
|
||||||
<attribute name="tag" type="string"/>
|
<attribute name="tag" type="string"/>
|
||||||
|
<attribute name="schemaContentBase" type="string"/>
|
||||||
<attribute name="autoAttributes" type="boolean"/>
|
<attribute name="autoAttributes" type="boolean"/>
|
||||||
<attribute name="schemaContentComplex" type="boolean"/>
|
<attribute name="schemaContentComplex" type="boolean"/>
|
||||||
<attribute name="schemaContentMixed" type="boolean"/>
|
<attribute name="schemaContentMixed" type="boolean"/>
|
||||||
<attribute name="schemaContentBase" type="string"/>
|
|
||||||
<attribute name="id" type="string"/>
|
<attribute name="id" type="string"/>
|
||||||
<attribute name="description" type="string"/>
|
<attribute name="description" type="string"/>
|
||||||
</complexType>
|
</complexType>
|
||||||
|
@ -126,13 +126,13 @@
|
||||||
<element name="bean" type="this:beanType"/>
|
<element name="bean" type="this:beanType"/>
|
||||||
<element name="description" type="this:descriptionType"/>
|
<element name="description" type="this:descriptionType"/>
|
||||||
</choice>
|
</choice>
|
||||||
<attribute name="name" type="string"/>
|
|
||||||
<attribute name="defaultValue" type="string"/>
|
|
||||||
<attribute name="required" type="boolean"/>
|
|
||||||
<attribute name="objectConverter" type="string"/>
|
<attribute name="objectConverter" type="string"/>
|
||||||
|
<attribute name="defaultValue" type="string"/>
|
||||||
<attribute name="runResolveEL" type="boolean"/>
|
<attribute name="runResolveEL" type="boolean"/>
|
||||||
<attribute name="runConverters" type="boolean"/>
|
<attribute name="runConverters" type="boolean"/>
|
||||||
<attribute name="runBeanFill" type="boolean"/>
|
<attribute name="runBeanFill" type="boolean"/>
|
||||||
|
<attribute name="name" type="string"/>
|
||||||
|
<attribute name="required" type="boolean"/>
|
||||||
<attribute name="id" type="string"/>
|
<attribute name="id" type="string"/>
|
||||||
<attribute name="description" type="string"/>
|
<attribute name="description" type="string"/>
|
||||||
</complexType>
|
</complexType>
|
||||||
|
@ -156,9 +156,10 @@
|
||||||
<element name="description" type="this:descriptionType"/>
|
<element name="description" type="this:descriptionType"/>
|
||||||
</choice>
|
</choice>
|
||||||
<attribute name="id" type="string" use="required"/>
|
<attribute name="id" type="string" use="required"/>
|
||||||
<attribute name="childClass" type="string"/>
|
<attribute name="childClass" type="string" use="required"/>
|
||||||
<attribute name="parentClass" type="string"/>
|
<attribute name="parentClass" type="string" use="required"/>
|
||||||
<attribute name="method" type="string"/>
|
<attribute name="getMethod" type="string" use="required"/>
|
||||||
|
<attribute name="addMethod" type="string" use="required"/>
|
||||||
</complexType>
|
</complexType>
|
||||||
<complexType name="elementInterfaceType">
|
<complexType name="elementInterfaceType">
|
||||||
<choice minOccurs="0" maxOccurs="unbounded">
|
<choice minOccurs="0" maxOccurs="unbounded">
|
||||||
|
|
|
@ -234,17 +234,20 @@
|
||||||
<attribute name="id" required="true">
|
<attribute name="id" required="true">
|
||||||
<description>The id for this binding handler.</description>
|
<description>The id for this binding handler.</description>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="parentClass">
|
<attribute name="parentClass" required="true">
|
||||||
<description>The parent class.</description>
|
<description>The parent class.</description>
|
||||||
<classConverter/>
|
<classConverter/>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="childClass">
|
<attribute name="childClass" required="true">
|
||||||
<description>The child class.</description>
|
<description>The child class.</description>
|
||||||
<classConverter/>
|
<classConverter/>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="method">
|
<attribute name="addMethod" required="true">
|
||||||
<description>The method name of the method used to add the child to the parent.</description>
|
<description>The method name of the method used to add the child to the parent.</description>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<attribute name="getMethod" required="true">
|
||||||
|
<description>The method name of the method used to get the childeren of the parent.</description>
|
||||||
|
</attribute>
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
<!-- Config some helper elements -->
|
<!-- Config some helper elements -->
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
ModuleName: Element Language Definition
|
ModuleName: Element Language Definition
|
||||||
Namespaces: 3
|
Namespaces: 3
|
||||||
Namespace: http://eld.x4o.org/xml/ns/eld-root
|
Namespace: http://eld.x4o.org/xml/ns/eld-root
|
||||||
Created on: Tue Jan 08 06:03:20 CET 2013
|
Created on: Mon Apr 08 02:26:14 CEST 2013
|
||||||
-->
|
-->
|
||||||
<schema xmlns="http://www.w3.org/2001/XMLSchema"
|
<schema xmlns="http://www.w3.org/2001/XMLSchema"
|
||||||
xmlns:conv="http://eld.x4o.org/xml/ns/eld-conv"
|
xmlns:conv="http://eld.x4o.org/xml/ns/eld-conv"
|
||||||
|
@ -28,10 +28,10 @@
|
||||||
<element ref="lang:namespace"/>
|
<element ref="lang:namespace"/>
|
||||||
</choice>
|
</choice>
|
||||||
<attribute name="id" type="string" use="required"/>
|
<attribute name="id" type="string" use="required"/>
|
||||||
<attribute name="name" type="string"/>
|
|
||||||
<attribute name="providerName" type="string"/>
|
<attribute name="providerName" type="string"/>
|
||||||
<attribute name="sourceResource" type="string"/>
|
<attribute name="sourceResource" type="string"/>
|
||||||
<attribute name="elementLanguageModuleLoader" type="string"/>
|
<attribute name="languageModuleLoader" type="string"/>
|
||||||
|
<attribute name="name" type="string"/>
|
||||||
<attribute name="description" type="string"/>
|
<attribute name="description" type="string"/>
|
||||||
</complexType>
|
</complexType>
|
||||||
</element>
|
</element>
|
||||||
|
|
|
@ -26,8 +26,6 @@ package org.x4o.xml;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.x4o.xml.X4ODriverManager;
|
import org.x4o.xml.X4ODriverManager;
|
||||||
import org.x4o.xml.lang.X4OLanguageLoaderException;
|
|
||||||
import org.x4o.xml.lang.phase.X4OPhaseException;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
@ -68,13 +66,14 @@ public class X4ODriverManagerTest extends TestCase {
|
||||||
public void testLanguageVersionNonExcisting() throws Exception {
|
public void testLanguageVersionNonExcisting() throws Exception {
|
||||||
String language = "test";
|
String language = "test";
|
||||||
String version = "99.9";
|
String version = "99.9";
|
||||||
Exception e = null;
|
Throwable e = null;
|
||||||
try {
|
try {
|
||||||
X4ODriver driver = X4ODriverManager.getX4ODriver(language);
|
X4ODriver<?> driver = X4ODriverManager.getX4ODriver(language);
|
||||||
driver.createLanguageContext(version);
|
driver.createLanguageContext(version);
|
||||||
} catch (Exception catchE) {
|
} catch (Throwable catchE) {
|
||||||
e = catchE;
|
e = catchE;
|
||||||
}
|
}
|
||||||
|
assertNotNull(e);
|
||||||
/* TODO
|
/* TODO
|
||||||
assertNotNull(e);
|
assertNotNull(e);
|
||||||
assertNotNull(e.getCause());
|
assertNotNull(e.getCause());
|
||||||
|
|
70
x4o-core/src/test/java/org/x4o/xml/io/X4OWriterTest.java
Normal file
70
x4o-core/src/test/java/org/x4o/xml/io/X4OWriterTest.java
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2012, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.x4o.xml.io;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
import org.x4o.xml.X4ODriver;
|
||||||
|
import org.x4o.xml.io.X4OReader;
|
||||||
|
import org.x4o.xml.lang.X4OLanguagePropertyKeys;
|
||||||
|
import org.x4o.xml.test.TestDriver;
|
||||||
|
import org.x4o.xml.test.models.TestObjectRoot;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4ODebugWriterTest runs parser with debug output.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Aug 26, 2012
|
||||||
|
*/
|
||||||
|
public class X4OWriterTest extends TestCase {
|
||||||
|
|
||||||
|
|
||||||
|
private File createOutputFile() throws IOException {
|
||||||
|
File outputFile = File.createTempFile("test-writer", ".xml");
|
||||||
|
outputFile.deleteOnExit();
|
||||||
|
return outputFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testWriterOutput() throws Exception {
|
||||||
|
File outputFile = createOutputFile();
|
||||||
|
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||||
|
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||||
|
X4OWriter<TestObjectRoot> writer = driver.createWriter();
|
||||||
|
|
||||||
|
TestObjectRoot root = reader.readResource("tests/attributes/test-bean.xml");
|
||||||
|
writer.writeFile(root, outputFile);
|
||||||
|
|
||||||
|
assertTrue("Debug file does not exists.",outputFile.exists());
|
||||||
|
|
||||||
|
String text = new Scanner( outputFile ).useDelimiter("\\A").next();
|
||||||
|
System.out.println("Output: '\n"+text+"\n' end in "+outputFile.getAbsolutePath());
|
||||||
|
|
||||||
|
outputFile.delete();
|
||||||
|
}
|
||||||
|
}
|
|
@ -48,7 +48,7 @@ public class DefaultX4OLanguageLoaderTest extends TestCase {
|
||||||
//X4OReader<TestObjectRoot> reader = driver.createReader();
|
//X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||||
//reader.readResource("tests/namespace/uri-simple.xml");
|
//reader.readResource("tests/namespace/uri-simple.xml");
|
||||||
language = driver.createLanguageContext().getLanguage();
|
language = driver.createLanguageContext().getLanguage();
|
||||||
loader = (X4OLanguageLoader)language.getLanguageConfiguration().getDefaultX4OLanguageLoader().newInstance();
|
loader = (X4OLanguageLoader)language.getLanguageConfiguration().getDefaultLanguageLoader().newInstance();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,10 @@ public class TestObjectParent {
|
||||||
testObjectChilds.add(c);
|
testObjectChilds.add(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<TestObjectChild> getTestObjectChilds() {
|
||||||
|
return testObjectChilds;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the name
|
* @return the name
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class SwiXmlActionConfigurator extends AbstractElementConfigurator {
|
||||||
if (actionName==null) {
|
if (actionName==null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SwingEngine se = SwiXmlDriver.getSwingEngine(element.getElementLanguage());
|
SwingEngine se = SwiXmlDriver.getSwingEngine(element.getLanguageContext());
|
||||||
Action action = se.getUIActionByName(actionName);
|
Action action = se.getUIActionByName(actionName);
|
||||||
Object object = element.getElementObject();
|
Object object = element.getElementObject();
|
||||||
if (object instanceof JMenuItem) {
|
if (object instanceof JMenuItem) {
|
||||||
|
|
|
@ -34,7 +34,6 @@ import org.x4o.xml.lang.DefaultX4OLanguageConfiguration;
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
import org.x4o.xml.lang.X4OLanguage;
|
import org.x4o.xml.lang.X4OLanguage;
|
||||||
import org.x4o.xml.lang.X4OLanguagePropertyKeys;
|
import org.x4o.xml.lang.X4OLanguagePropertyKeys;
|
||||||
import org.x4o.xml.lang.phase.X4OPhaseManagerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SwiXmlParser works with the SwingEngine to config the UI tree.
|
* SwiXmlParser works with the SwingEngine to config the UI tree.
|
||||||
|
@ -111,9 +110,4 @@ public class SwiXmlDriver extends X4ODriver<Component> {
|
||||||
public String[] getLanguageVersions() {
|
public String[] getLanguageVersions() {
|
||||||
return LANGUAGE_VERSIONS;
|
return LANGUAGE_VERSIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public X4OLanguage buildLanguage(String version) {
|
|
||||||
return new DefaultX4OLanguage(new DefaultX4OLanguageConfiguration(),X4OPhaseManagerFactory.createDefaultX4OPhaseManager(),getLanguageName(),getLanguageVersionDefault());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
package org.x4o.xml.test.swixml.bind;
|
package org.x4o.xml.test.swixml.bind;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Component;
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
@ -39,7 +40,7 @@ import org.x4o.xml.element.ElementBindingHandlerException;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Aug 16, 2012
|
* @version 1.0 Aug 16, 2012
|
||||||
*/
|
*/
|
||||||
public class JFrameBindingHandler extends AbstractElementBindingHandler {
|
public class JFrameBindingHandler extends AbstractElementBindingHandler<JFrame> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||||
|
@ -56,9 +57,9 @@ public class JFrameBindingHandler extends AbstractElementBindingHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#doBind(java.lang.Object, java.lang.Object, org.x4o.xml.element.Element)
|
* @see org.x4o.xml.element.ElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void doBind(Object parentObject, Object childObject, Element childElement) throws ElementBindingHandlerException {
|
public void bindChild(Element childElement, JFrame parentObject, Object childObject) throws ElementBindingHandlerException {
|
||||||
JFrame frame = (JFrame)parentObject;
|
JFrame frame = (JFrame)parentObject;
|
||||||
if (childObject instanceof JMenuBar) {
|
if (childObject instanceof JMenuBar) {
|
||||||
JMenuBar child = (JMenuBar)childObject;
|
JMenuBar child = (JMenuBar)childObject;
|
||||||
|
@ -85,4 +86,17 @@ public class JFrameBindingHandler extends AbstractElementBindingHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void createChilderen(Element parentElement,JFrame parent) throws ElementBindingHandlerException {
|
||||||
|
createChild(parentElement, parent.getMenuBar());
|
||||||
|
for (Component c:parent.getComponents()) {
|
||||||
|
if (c instanceof JComponent) {
|
||||||
|
createChild(parentElement, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -24,6 +24,7 @@
|
||||||
package org.x4o.xml.test.swixml.bind;
|
package org.x4o.xml.test.swixml.bind;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Component;
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JInternalFrame;
|
import javax.swing.JInternalFrame;
|
||||||
|
@ -38,7 +39,7 @@ import org.x4o.xml.element.ElementBindingHandlerException;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Aug 16, 2012
|
* @version 1.0 Aug 16, 2012
|
||||||
*/
|
*/
|
||||||
public class JInternalFrameBindingHandler extends AbstractElementBindingHandler {
|
public class JInternalFrameBindingHandler extends AbstractElementBindingHandler<JInternalFrame> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||||
|
@ -55,9 +56,9 @@ public class JInternalFrameBindingHandler extends AbstractElementBindingHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#doBind(java.lang.Object, java.lang.Object, org.x4o.xml.element.Element)
|
* @see org.x4o.xml.element.ElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void doBind(Object parentObject, Object childObject, Element childElement) throws ElementBindingHandlerException {
|
public void bindChild(Element childElement, JInternalFrame frame, Object childObject) throws ElementBindingHandlerException {
|
||||||
JComponent child = (JComponent)childObject;
|
JComponent child = (JComponent)childObject;
|
||||||
|
|
||||||
String c = childElement.getAttributes().get("constraints");
|
String c = childElement.getAttributes().get("constraints");
|
||||||
|
@ -71,12 +72,22 @@ public class JInternalFrameBindingHandler extends AbstractElementBindingHandler
|
||||||
} else if ("BorderLayout.SOUTH".equals(c)) {
|
} else if ("BorderLayout.SOUTH".equals(c)) {
|
||||||
con = BorderLayout.SOUTH;
|
con = BorderLayout.SOUTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
JInternalFrame frame = (JInternalFrame)parentObject;
|
|
||||||
if (con==null) {
|
if (con==null) {
|
||||||
frame.getContentPane().add(child);
|
frame.getContentPane().add(child);
|
||||||
} else {
|
} else {
|
||||||
frame.getContentPane().add(child,con);
|
frame.getContentPane().add(child,con);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void createChilderen(Element parentElement,JInternalFrame parent) throws ElementBindingHandlerException {
|
||||||
|
for (Component c:parent.getComponents()) {
|
||||||
|
if (c instanceof JComponent) {
|
||||||
|
createChild(parentElement, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -24,6 +24,7 @@
|
||||||
package org.x4o.xml.test.swixml.bind;
|
package org.x4o.xml.test.swixml.bind;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Component;
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
@ -38,7 +39,7 @@ import org.x4o.xml.element.ElementBindingHandlerException;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Aug 16, 2012
|
* @version 1.0 Aug 16, 2012
|
||||||
*/
|
*/
|
||||||
public class JPanelBindingHandler extends AbstractElementBindingHandler {
|
public class JPanelBindingHandler extends AbstractElementBindingHandler<JPanel> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||||
|
@ -55,9 +56,9 @@ public class JPanelBindingHandler extends AbstractElementBindingHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#doBind(java.lang.Object, java.lang.Object, org.x4o.xml.element.Element)
|
* @see org.x4o.xml.element.ElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void doBind(Object parentObject, Object childObject, Element childElement) throws ElementBindingHandlerException {
|
public void bindChild(Element childElement, JPanel parent, Object childObject) throws ElementBindingHandlerException {
|
||||||
JComponent child = (JComponent)childObject;
|
JComponent child = (JComponent)childObject;
|
||||||
|
|
||||||
String c = childElement.getAttributes().get("constraints");
|
String c = childElement.getAttributes().get("constraints");
|
||||||
|
@ -71,12 +72,22 @@ public class JPanelBindingHandler extends AbstractElementBindingHandler {
|
||||||
} else if ("BorderLayout.SOUTH".equals(c)) {
|
} else if ("BorderLayout.SOUTH".equals(c)) {
|
||||||
con = BorderLayout.SOUTH;
|
con = BorderLayout.SOUTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
JPanel parent = (JPanel)parentObject;
|
|
||||||
if (con==null) {
|
if (con==null) {
|
||||||
parent.add(child);
|
parent.add(child);
|
||||||
} else {
|
} else {
|
||||||
parent.add(child,con);
|
parent.add(child,con);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void createChilderen(Element parentElement,JPanel parent) throws ElementBindingHandlerException {
|
||||||
|
for (Component c:parent.getComponents()) {
|
||||||
|
if (c instanceof JComponent) {
|
||||||
|
createChild(parentElement, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.x4o.xml.element.ElementBindingHandlerException;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Aug 16, 2012
|
* @version 1.0 Aug 16, 2012
|
||||||
*/
|
*/
|
||||||
public class JSplitPaneBindingHandler extends AbstractElementBindingHandler {
|
public class JSplitPaneBindingHandler extends AbstractElementBindingHandler<JSplitPane> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||||
|
@ -54,11 +54,10 @@ public class JSplitPaneBindingHandler extends AbstractElementBindingHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#doBind(java.lang.Object, java.lang.Object, org.x4o.xml.element.Element)
|
* @see org.x4o.xml.element.ElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object, )
|
||||||
*/
|
*/
|
||||||
public void doBind(Object parentObject, Object childObject, Element childElement) throws ElementBindingHandlerException {
|
public void bindChild(Element childElement, JSplitPane pane, Object childObject) throws ElementBindingHandlerException {
|
||||||
JComponent child = (JComponent)childObject;
|
JComponent child = (JComponent)childObject;
|
||||||
JSplitPane pane = (JSplitPane)parentObject;
|
|
||||||
if (pane.getLeftComponent() instanceof JButton) { // strange swing constructor for splitpane
|
if (pane.getLeftComponent() instanceof JButton) { // strange swing constructor for splitpane
|
||||||
pane.setLeftComponent(child);
|
pane.setLeftComponent(child);
|
||||||
} else if (pane.getRightComponent() instanceof JButton) {
|
} else if (pane.getRightComponent() instanceof JButton) {
|
||||||
|
@ -67,4 +66,13 @@ public class JSplitPaneBindingHandler extends AbstractElementBindingHandler {
|
||||||
throw new ElementBindingHandlerException("SplitPane is full.");
|
throw new ElementBindingHandlerException("SplitPane is full.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void createChilderen(Element parentElement,JSplitPane parentObject) throws ElementBindingHandlerException {
|
||||||
|
createChild(parentElement, parentObject.getLeftComponent());
|
||||||
|
createChild(parentElement, parentObject.getRightComponent());
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -38,11 +38,11 @@
|
||||||
<bindingHandler id="JInternalFrameBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JInternalFrameBindingHandler"/>
|
<bindingHandler id="JInternalFrameBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JInternalFrameBindingHandler"/>
|
||||||
<bindingHandler id="JPanelBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JPanelBindingHandler"/>
|
<bindingHandler id="JPanelBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JPanelBindingHandler"/>
|
||||||
<bindingHandler id="JSplitPaneBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JSplitPaneBindingHandler"/>
|
<bindingHandler id="JSplitPaneBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JSplitPaneBindingHandler"/>
|
||||||
<classBindingHandler id="JScrollPane-JComponent" parentClass="javax.swing.JScrollPane" childClass="javax.swing.JComponent" method="setViewportView"/>
|
<classBindingHandler id="JScrollPane-JComponent" parentClass="javax.swing.JScrollPane" childClass="javax.swing.JComponent" addMethod="setViewportView" getMethod="todo"/>
|
||||||
<classBindingHandler id="JDesktopPane-JInternalFrame" parentClass="javax.swing.JDesktopPane" childClass="javax.swing.JInternalFrame" method="add"/>
|
<classBindingHandler id="JDesktopPane-JInternalFrame" parentClass="javax.swing.JDesktopPane" childClass="javax.swing.JInternalFrame" addMethod="add" getMethod="todo"/>
|
||||||
<classBindingHandler id="JFrame-JDesktopPane" parentClass="javax.swing.JFrame" childClass="javax.swing.JDesktopPane" method="setContentPane"/>
|
<classBindingHandler id="JFrame-JDesktopPane" parentClass="javax.swing.JFrame" childClass="javax.swing.JDesktopPane" addMethod="setContentPane" getMethod="todo"/>
|
||||||
<classBindingHandler id="JMenuBar-JMenu" parentClass="javax.swing.JMenuBar" childClass="javax.swing.JMenu" method="add"/>
|
<classBindingHandler id="JMenuBar-JMenu" parentClass="javax.swing.JMenuBar" childClass="javax.swing.JMenu" addMethod="add" getMethod="todo"/>
|
||||||
<classBindingHandler id="JMenu-JMenuItem" parentClass="javax.swing.JMenu" childClass="javax.swing.JMenuItem" method="add"/>
|
<classBindingHandler id="JMenu-JMenuItem" parentClass="javax.swing.JMenu" childClass="javax.swing.JMenuItem" addMethod="add" getMethod="todo"/>
|
||||||
|
|
||||||
<elementInterface id="Component" interfaceClass="java.awt.Component">
|
<elementInterface id="Component" interfaceClass="java.awt.Component">
|
||||||
<attribute name="bounds">
|
<attribute name="bounds">
|
||||||
|
|
|
@ -38,11 +38,11 @@
|
||||||
<bindingHandler id="JInternalFrameBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JInternalFrameBindingHandler"/>
|
<bindingHandler id="JInternalFrameBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JInternalFrameBindingHandler"/>
|
||||||
<bindingHandler id="JPanelBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JPanelBindingHandler"/>
|
<bindingHandler id="JPanelBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JPanelBindingHandler"/>
|
||||||
<bindingHandler id="JSplitPaneBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JSplitPaneBindingHandler"/>
|
<bindingHandler id="JSplitPaneBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JSplitPaneBindingHandler"/>
|
||||||
<classBindingHandler id="JScrollPane-JComponent" parentClass="javax.swing.JScrollPane" childClass="javax.swing.JComponent" method="setViewportView"/>
|
<classBindingHandler id="JScrollPane-JComponent" parentClass="javax.swing.JScrollPane" childClass="javax.swing.JComponent" addMethod="setViewportView" getMethod="todo"/>
|
||||||
<classBindingHandler id="JDesktopPane-JInternalFrame" parentClass="javax.swing.JDesktopPane" childClass="javax.swing.JInternalFrame" method="add"/>
|
<classBindingHandler id="JDesktopPane-JInternalFrame" parentClass="javax.swing.JDesktopPane" childClass="javax.swing.JInternalFrame" addMethod="add" getMethod="todo"/>
|
||||||
<classBindingHandler id="JFrame-JDesktopPane" parentClass="javax.swing.JFrame" childClass="javax.swing.JDesktopPane" method="setContentPane"/>
|
<classBindingHandler id="JFrame-JDesktopPane" parentClass="javax.swing.JFrame" childClass="javax.swing.JDesktopPane" addMethod="setContentPane" getMethod="todo"/>
|
||||||
<classBindingHandler id="JMenuBar-JMenu" parentClass="javax.swing.JMenuBar" childClass="javax.swing.JMenu" method="add"/>
|
<classBindingHandler id="JMenuBar-JMenu" parentClass="javax.swing.JMenuBar" childClass="javax.swing.JMenu" addMethod="add" getMethod="todo"/>
|
||||||
<classBindingHandler id="JMenu-JMenuItem" parentClass="javax.swing.JMenu" childClass="javax.swing.JMenuItem" method="add"/>
|
<classBindingHandler id="JMenu-JMenuItem" parentClass="javax.swing.JMenu" childClass="javax.swing.JMenuItem" addMethod="add" getMethod="todo"/>
|
||||||
|
|
||||||
<elementInterface id="Component" interfaceClass="java.awt.Component">
|
<elementInterface id="Component" interfaceClass="java.awt.Component">
|
||||||
<attribute name="bounds">
|
<attribute name="bounds">
|
||||||
|
|
|
@ -34,22 +34,22 @@
|
||||||
id="test-module"
|
id="test-module"
|
||||||
>
|
>
|
||||||
|
|
||||||
<eld:classBindingHandler id="Parent-Child" parentClass="org.x4o.xml.test.models.TestObjectParent" childClass="org.x4o.xml.test.models.TestObjectChild" method="addTestObjectChild">
|
<eld:classBindingHandler id="Parent-Child" parentClass="org.x4o.xml.test.models.TestObjectParent" childClass="org.x4o.xml.test.models.TestObjectChild" addMethod="addTestObjectChild" getMethod="getTestObjectChilds">
|
||||||
<eld:description>Binds the TestObjectChild to the TestObjectParent</eld:description>
|
<eld:description>Binds the TestObjectChild to the TestObjectParent</eld:description>
|
||||||
</eld:classBindingHandler>
|
</eld:classBindingHandler>
|
||||||
<eld:classBindingHandler id="Root-Child" parentClass="org.x4o.xml.test.models.TestObjectRoot" childClass="org.x4o.xml.test.models.TestObjectChild" method="addChild">
|
<eld:classBindingHandler id="Root-Child" parentClass="org.x4o.xml.test.models.TestObjectRoot" childClass="org.x4o.xml.test.models.TestObjectChild" addMethod="addChild" getMethod="getTestObjectChilds">
|
||||||
<eld:description>Binds the TestBean to the TestObjectChild</eld:description>
|
<eld:description>Binds the TestBean to the TestObjectChild</eld:description>
|
||||||
</eld:classBindingHandler>
|
</eld:classBindingHandler>
|
||||||
<eld:classBindingHandler id="Root-Parent" parentClass="org.x4o.xml.test.models.TestObjectRoot" childClass="org.x4o.xml.test.models.TestObjectParent" method="addParent">
|
<eld:classBindingHandler id="Root-Parent" parentClass="org.x4o.xml.test.models.TestObjectRoot" childClass="org.x4o.xml.test.models.TestObjectParent" addMethod="addParent" getMethod="getTestObjectParents">
|
||||||
<eld:description>Binds the TestObjectParent to the TestObjectRoot</eld:description>
|
<eld:description>Binds the TestObjectParent to the TestObjectRoot</eld:description>
|
||||||
</eld:classBindingHandler>
|
</eld:classBindingHandler>
|
||||||
<eld:classBindingHandler id="Root-Bean" parentClass="org.x4o.xml.test.models.TestObjectRoot" childClass="org.x4o.xml.test.models.TestBean" method="addTestBean">
|
<eld:classBindingHandler id="Root-Bean" parentClass="org.x4o.xml.test.models.TestObjectRoot" childClass="org.x4o.xml.test.models.TestBean" addMethod="addTestBean" getMethod="getTestBeans">
|
||||||
<eld:description>Binds the TestBean to the TestObjectRoot</eld:description>
|
<eld:description>Binds the TestBean to the TestObjectRoot</eld:description>
|
||||||
</eld:classBindingHandler>
|
</eld:classBindingHandler>
|
||||||
<eld:classBindingHandler id="JComponent-JComponent" parentClass="javax.swing.JComponent" childClass="javax.swing.JComponent" method="addComponent">
|
<eld:classBindingHandler id="JComponent-JComponent" parentClass="javax.swing.JComponent" childClass="javax.swing.JComponent" addMethod="addComponent" getMethod="">
|
||||||
<eld:description>Binds j components.</eld:description>
|
<eld:description>Binds j components.</eld:description>
|
||||||
</eld:classBindingHandler>
|
</eld:classBindingHandler>
|
||||||
<eld:classBindingHandler id="JFrame-JPanel" parentClass="javax.swing.JFrame" childClass="javax.swing.JPanel" method="add">
|
<eld:classBindingHandler id="JFrame-JPanel" parentClass="javax.swing.JFrame" childClass="javax.swing.JPanel" addMethod="add" getMethod="getComponents">
|
||||||
<eld:description>Binds panel to frame components as unit check.</eld:description>
|
<eld:description>Binds panel to frame components as unit check.</eld:description>
|
||||||
</eld:classBindingHandler>
|
</eld:classBindingHandler>
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
|
|
||||||
<eld:elementInterface id="JComponent" interfaceClass="javax.swing.JComponent">
|
<eld:elementInterface id="JComponent" interfaceClass="javax.swing.JComponent">
|
||||||
<eld:description>Configs the JComponent based objects.</eld:description>
|
<eld:description>Configs the JComponent based objects.</eld:description>
|
||||||
<eld:classBindingHandler id="JComponent-JComponent" parentClass="javax.swing.JComponent" childClass="javax.swing.JComponent" method="add">
|
<eld:classBindingHandler id="JComponent-JComponent" parentClass="javax.swing.JComponent" childClass="javax.swing.JComponent" addMethod="add" getMethod="getComponents">
|
||||||
<eld:description>Binds the JComponent to the JComponent.</eld:description>
|
<eld:description>Binds the JComponent to the JComponent.</eld:description>
|
||||||
</eld:classBindingHandler>
|
</eld:classBindingHandler>
|
||||||
</eld:elementInterface>
|
</eld:elementInterface>
|
||||||
|
|
|
@ -54,8 +54,8 @@ public class ELIDAttributeHandler extends AbstractElementAttributeHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(element.getElementObject()==null) { throw new NullPointerException("Can't bind null object to el context"); }
|
if(element.getElementObject()==null) { throw new NullPointerException("Can't bind null object to el context"); }
|
||||||
ValueExpression ee = element.getElementLanguage().getExpressionLanguageFactory().createValueExpression(element.getElementLanguage().getExpressionLanguageContext(),"${"+attributeValue+"}", element.getElementObject().getClass());
|
ValueExpression ee = element.getLanguageContext().getExpressionLanguageFactory().createValueExpression(element.getLanguageContext().getExpressionLanguageContext(),"${"+attributeValue+"}", element.getElementObject().getClass());
|
||||||
Logger.getLogger(ELIDAttributeHandler.class.getName()).finer("Set Variable in ELContext: "+"${"+attributeValue+"}"+" object SET: "+element.getElementObject());
|
Logger.getLogger(ELIDAttributeHandler.class.getName()).finer("Set Variable in ELContext: "+"${"+attributeValue+"}"+" object SET: "+element.getElementObject());
|
||||||
ee.setValue(element.getElementLanguage().getExpressionLanguageContext(), element.getElementObject());
|
ee.setValue(element.getLanguageContext().getExpressionLanguageContext(), element.getElementObject());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,8 @@ public class ELReferenceElement extends AbstractElement {
|
||||||
public void doElementRun() throws ElementException {
|
public void doElementRun() throws ElementException {
|
||||||
String attributeValue = getAttributes().get("el.ref");
|
String attributeValue = getAttributes().get("el.ref");
|
||||||
if("".equals(attributeValue) | attributeValue==null) { throw new ElementException("Set the el.ref attribute"); }
|
if("".equals(attributeValue) | attributeValue==null) { throw new ElementException("Set the el.ref attribute"); }
|
||||||
ValueExpression ee = getElementLanguage().getExpressionLanguageFactory().createValueExpression(getElementLanguage().getExpressionLanguageContext(),"${"+attributeValue+"}",Object.class);
|
ValueExpression ee = getLanguageContext().getExpressionLanguageFactory().createValueExpression(getLanguageContext().getExpressionLanguageContext(),"${"+attributeValue+"}",Object.class);
|
||||||
Logger.getLogger(ELReferenceElement.class.getName()).finer("Get Variable in ELContext: ${"+attributeValue+"}");
|
Logger.getLogger(ELReferenceElement.class.getName()).finer("Get Variable in ELContext: ${"+attributeValue+"}");
|
||||||
setElementObject(ee.getValue(getElementLanguage().getExpressionLanguageContext()));
|
setElementObject(ee.getValue(getLanguageContext().getExpressionLanguageContext()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class PropertyElement extends AbstractElement {
|
||||||
|
|
||||||
// convert value object
|
// convert value object
|
||||||
try {
|
try {
|
||||||
value = getElementLanguage().getElementAttributeValueParser().getParameterValue(name,valueString,this);
|
value = getLanguageContext().getElementAttributeValueParser().getParameterValue(name,valueString,this);
|
||||||
} catch (ObjectConverterException ece) {
|
} catch (ObjectConverterException ece) {
|
||||||
throw new ElementException(ece);
|
throw new ElementException(ece);
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ public class PropertyElement extends AbstractElement {
|
||||||
|
|
||||||
// try to set as property on bean.
|
// try to set as property on bean.
|
||||||
try {
|
try {
|
||||||
getElementLanguage().getElementObjectPropertyValue().setProperty(getParent().getElementObject(), name, value);
|
getLanguageContext().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);
|
||||||
|
|
|
@ -27,10 +27,6 @@ import org.x4o.xml.X4ODriver;
|
||||||
import org.x4o.xml.X4ODriverManager;
|
import org.x4o.xml.X4ODriverManager;
|
||||||
import org.x4o.xml.io.X4OReaderContext;
|
import org.x4o.xml.io.X4OReaderContext;
|
||||||
import org.x4o.xml.io.X4OWriterContext;
|
import org.x4o.xml.io.X4OWriterContext;
|
||||||
import org.x4o.xml.lang.DefaultX4OLanguage;
|
|
||||||
import org.x4o.xml.lang.DefaultX4OLanguageConfiguration;
|
|
||||||
import org.x4o.xml.lang.X4OLanguage;
|
|
||||||
import org.x4o.xml.lang.phase.X4OPhaseManagerFactory;
|
|
||||||
|
|
||||||
public class MTestDriver extends X4ODriver {
|
public class MTestDriver extends X4ODriver {
|
||||||
|
|
||||||
|
@ -47,11 +43,6 @@ public class MTestDriver extends X4ODriver {
|
||||||
return LANGUAGE_VERSIONS;
|
return LANGUAGE_VERSIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public X4OLanguage buildLanguage(String version) {
|
|
||||||
return new DefaultX4OLanguage(new DefaultX4OLanguageConfiguration(),X4OPhaseManagerFactory.createDefaultX4OPhaseManager(),getLanguageName(),getLanguageVersionDefault());
|
|
||||||
}
|
|
||||||
|
|
||||||
static public MTestDriver getInstance() {
|
static public MTestDriver getInstance() {
|
||||||
return (MTestDriver)X4ODriverManager.getX4ODriver(LANGUAGE_NAME);
|
return (MTestDriver)X4ODriverManager.getX4ODriver(LANGUAGE_NAME);
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,11 +94,11 @@
|
||||||
<mkdir dir="${coredir}/junit-swixml2"/>
|
<mkdir dir="${coredir}/junit-swixml2"/>
|
||||||
<mkdir dir="${coredir}/junit-swixml3"/>
|
<mkdir dir="${coredir}/junit-swixml3"/>
|
||||||
<taskdef name="eldDocWriter" classname="org.x4o.plugin.ant.eld.doc.EldDocWriterTask" classpathref="maven.plugin.classpath"/>
|
<taskdef name="eldDocWriter" classname="org.x4o.plugin.ant.eld.doc.EldDocWriterTask" classpathref="maven.plugin.classpath"/>
|
||||||
<eldDocWriter destdir="${coredir}/cel" supportclass="org.x4o.xml.eld.EldParserSupportCore"/>
|
<eldDocWriter destdir="${coredir}/cel" language="cel"/>
|
||||||
<eldDocWriter destdir="${coredir}/eld" supportclass="org.x4o.xml.eld.EldParserSupport"/>
|
<eldDocWriter destdir="${coredir}/eld" language="eld"/>
|
||||||
<eldDocWriter destdir="${coredir}/junit-test" supportclass="org.x4o.xml.test.TestParserSupport"/>
|
<eldDocWriter destdir="${coredir}/junit-test" language="test"/>
|
||||||
<eldDocWriter destdir="${coredir}/junit-swixml2" supportclass="org.x4o.xml.test.swixml.SwiXmlParserSupport2"/>
|
<eldDocWriter destdir="${coredir}/junit-swixml2" language="swixml" version="2.0"/>
|
||||||
<eldDocWriter destdir="${coredir}/junit-swixml3" supportclass="org.x4o.xml.test.swixml.SwiXmlParserSupport3"/>
|
<eldDocWriter destdir="${coredir}/junit-swixml3" language="swixml"/>
|
||||||
</target>
|
</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
<goals>
|
<goals>
|
||||||
|
|
|
@ -83,7 +83,7 @@
|
||||||
<target>
|
<target>
|
||||||
<property name="coredir" value="${basedir}/../../x4o-core/src/main/resources/META-INF"/>
|
<property name="coredir" value="${basedir}/../../x4o-core/src/main/resources/META-INF"/>
|
||||||
<taskdef name="eldXsdWriter" classname="org.x4o.plugin.ant.eld.xsd.EldXsdWriterTask" classpathref="maven.plugin.classpath"/>
|
<taskdef name="eldXsdWriter" classname="org.x4o.plugin.ant.eld.xsd.EldXsdWriterTask" classpathref="maven.plugin.classpath"/>
|
||||||
<eldXsdWriter destdir="${coredir}/cel" supportclass="org.x4o.xml.eld.EldParserSupportCore"/>
|
<eldXsdWriter destdir="${coredir}/cel" language="cel"/>
|
||||||
</target>
|
</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
<goals>
|
<goals>
|
||||||
|
@ -118,7 +118,7 @@
|
||||||
<target>
|
<target>
|
||||||
<property name="coredir" value="${basedir}/../../x4o-core/src/main/resources/META-INF"/>
|
<property name="coredir" value="${basedir}/../../x4o-core/src/main/resources/META-INF"/>
|
||||||
<taskdef name="eldXsdWriter" classname="org.x4o.plugin.ant.eld.xsd.EldXsdWriterTask" classpathref="maven.plugin.classpath"/>
|
<taskdef name="eldXsdWriter" classname="org.x4o.plugin.ant.eld.xsd.EldXsdWriterTask" classpathref="maven.plugin.classpath"/>
|
||||||
<eldXsdWriter destdir="${coredir}/eld" supportclass="org.x4o.xml.eld.EldParserSupport"/>
|
<eldXsdWriter destdir="${coredir}/eld" language="eld"/>
|
||||||
</target>
|
</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
<goals>
|
<goals>
|
||||||
|
|
Loading…
Reference in a new issue