Started with moving write to phases.

Changed eld attribute name to id,
Changed runBeanFill to runBeanValue.
This commit is contained in:
Willem Cazander 2013-04-27 20:10:47 +02:00
parent 226c1f0425
commit d271edb1ee
39 changed files with 615 additions and 337 deletions

View file

@ -29,8 +29,10 @@ import org.x4o.xml.io.DefaultX4OReader;
import org.x4o.xml.io.DefaultX4OSchemaWriter;
import org.x4o.xml.io.DefaultX4OWriter;
import org.x4o.xml.io.X4OReader;
import org.x4o.xml.io.X4OReaderContext;
import org.x4o.xml.io.X4OSchemaWriter;
import org.x4o.xml.io.X4OWriter;
import org.x4o.xml.io.X4OWriterContext;
import org.x4o.xml.lang.X4OLanguageConfiguration;
import org.x4o.xml.lang.X4OLanguageContext;
@ -66,6 +68,7 @@ public abstract class X4ODriver<T> {
abstract public String[] getLanguageVersions();
protected X4OLanguage buildLanguage(String version) {
return X4ODriverManager.getDefaultBuildLanguage(this, version);
}
@ -79,6 +82,7 @@ public abstract class X4ODriver<T> {
}
public X4OSchemaWriter createSchemaWriter() {
return createSchemaWriter(getLanguageVersionDefault());
}
@ -87,22 +91,42 @@ public abstract class X4ODriver<T> {
return new DefaultX4OSchemaWriter(createLanguageContext(version));
}
public X4OReader<T> createReader() {
return createReader(getLanguageVersionDefault());
return createReaderContext();
}
public X4OReader<T> createReader(String version) {
return new DefaultX4OReader<T>(createLanguageContext(version));
return createReaderContext(version);
}
public X4OWriter<T> createWriter() {
return createWriter(getLanguageVersionDefault());
return createWriterContext();
}
public X4OWriter<T> createWriter(String version) {
return createWriterContext(version);
}
public X4OReaderContext<T> createReaderContext() {
return createReaderContext(getLanguageVersionDefault());
}
public X4OReaderContext<T> createReaderContext(String version) {
return new DefaultX4OReader<T>(createLanguageContext(version));
}
public X4OWriterContext<T> createWriterContext() {
return createWriterContext(getLanguageVersionDefault());
}
public X4OWriterContext<T> createWriterContext(String version) {
return new DefaultX4OWriter<T>(createLanguageContext(version));
}
public String getLanguageVersionDefault() {
return X4ODriverManager.getDefaultLanguageVersion(getLanguageVersions());
}

View file

@ -43,6 +43,7 @@ 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.X4OPhaseLanguageWrite;
import org.x4o.xml.lang.phase.X4OPhaseManager;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
@ -92,7 +93,7 @@ public final class X4ODriverManager {
DefaultX4OPhaseManager manager = new DefaultX4OPhaseManager();
new X4OPhaseLanguageInit().createPhases(manager);
new X4OPhaseLanguageRead().createPhases(manager);
//new X4OPhaseLanguageWrite().createPhases(manager);
new X4OPhaseLanguageWrite().createPhases(manager);
return manager;
}

View file

@ -22,7 +22,7 @@
*/
/**
* Provides default java text converters.
* Provides implementations of object to text converters.
*
*
* @since 1.0

View file

@ -22,7 +22,7 @@
*/
/**
* The X4O EL Support classes.
* The Expression Language classes.
*
*
* @since 1.0

View file

@ -254,8 +254,7 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
private ElementClassAttribute createElementClassAttribute(X4OLanguage language,String name,boolean required,ObjectConverter converter) throws X4OLanguageModuleLoaderException {
try {
ElementClassAttribute result = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(language.getLanguageConfiguration().getDefaultElementClassAttribute());
result.setId(name); // ??
result.setName(name);
result.setId(name);
if (required) {
result.setRequired(required);
}

View file

@ -22,7 +22,7 @@
*/
/**
* The X4O ELD Language x4o classes.
* The Element Language Definition language elements.
*
*
* @since 1.0

View file

@ -22,7 +22,7 @@
*/
/**
* The X4O Element Language Definition parser.
* The Element Language Definition drivers.
*
*
* @since 1.0

View file

@ -282,9 +282,9 @@ public class EldXsdXmlWriter {
List<String> attrNames = new ArrayList<String>(30);
for (ElementClassAttribute eca:ec.getElementClassAttributes()) {
attrNames.add(eca.getName());
attrNames.add(eca.getId());
atts = new AttributesImpl();
atts.addAttribute ("", "name", "", "", eca.getName());
atts.addAttribute ("", "name", "", "", eca.getId());
atts.addAttribute ("", "type", "", "", "string");
if (eca.getRequired()!=null && eca.getRequired()) {
atts.addAttribute ("", "use", "", "", "required");

View file

@ -44,7 +44,8 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
private Boolean runResolveEL = null;
//private Boolean runInterfaces = null;
private Boolean runConverters = null;
private Boolean runBeanFill = null;
private Boolean runBeanValue = null;
private Integer writeOrder = null;
public AbstractElementClassAttribute() {
attributeAliases = new ArrayList<String>(3);
@ -156,16 +157,30 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
}
/**
* @return the runBeanFill
* @return the runBeanValue
*/
public Boolean getRunBeanFill() {
return runBeanFill;
public Boolean getRunBeanValue() {
return runBeanValue;
}
/**
* @param runBeanFill the runBeanFill to set
* @param runBeanValue the runBeanValue to set
*/
public void setRunBeanFill(Boolean runBeanFill) {
this.runBeanFill = runBeanFill;
public void setRunBeanValue(Boolean runBeanValue) {
this.runBeanValue = runBeanValue;
}
/**
* @return the writeOrder
*/
public Integer getWriteOrder() {
return writeOrder;
}
/**
* @param writeOrder the writeOrder to set
*/
public void setWriteOrder(Integer writeOrder) {
this.writeOrder = writeOrder;
}
}

View file

@ -66,7 +66,7 @@ public abstract class AbstractElementClassBase extends AbstractElementMetaBase i
* @param elementClassAttribute The ElementClassAttribute to add.
*/
public void addElementClassAttribute(ElementClassAttribute elementClassAttribute) {
elementClassAttributes.put(elementClassAttribute.getName(),elementClassAttribute);
elementClassAttributes.put(elementClassAttribute.getId(),elementClassAttribute);
}
/**

View file

@ -86,7 +86,7 @@ public class DefaultElementAttributeValueParser implements ElementAttributeValue
for (ElementInterface ei:element.getLanguageContext().getLanguage().findElementInterfaces(element.getElementObject())) {
logger.finer("Found interface match executing converter.");
for (ElementClassAttribute attrClass:ei.getElementClassAttributes()) {
if (name.equals(attrClass.getName())==false) {
if (name.equals(attrClass.getId())==false) {
continue;
}
if (attrClass.getObjectConverter()==null) {

View file

@ -36,18 +36,6 @@ import org.x4o.xml.conv.ObjectConverter;
*/
public interface ElementClassAttribute extends ElementMetaBase {
/**
* Gets the attribute name of the ElementClass.
* @return The name.
*/
String getName();
/**
* Sets the attribute name of the ElementClass.
* @param name The name of the attribute.
*/
void setName(String name);
/**
* Gets the ObjectConverter.
* @return The ObjectConverter.
@ -123,12 +111,22 @@ public interface ElementClassAttribute extends ElementMetaBase {
void setRunConverters(Boolean runConverters);
/**
* @return the runBeanFill.
* @return the runBeanValue.
*/
Boolean getRunBeanFill();
Boolean getRunBeanValue();
/**
* @param runBeanFill the runBeanFill to set.
* @param runBeanValue the runBeanValue to set.
*/
void setRunBeanFill(Boolean runBeanFill);
void setRunBeanValue(Boolean runBeanValue);
/**
* @return the writeOrder
*/
Integer getWriteOrder();
/**
* @param writeOrder the writeOrder to set
*/
void setWriteOrder(Integer writeOrder);
}

View file

@ -22,7 +22,7 @@
*/
/**
* The X4O XML Element interfaces.
* The XML Element definitions.
*
*
* @since 1.0

View file

@ -36,16 +36,16 @@ import java.util.Map;
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.ElementInterface;
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.X4OLanguageContext;
import org.x4o.xml.lang.X4OLanguageModule;
import org.x4o.xml.lang.phase.X4OPhaseException;
import org.x4o.xml.lang.phase.X4OPhaseType;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
@ -57,24 +57,20 @@ import org.xml.sax.helpers.AttributesImpl;
*/
public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
public DefaultX4OWriter(X4OLanguageContext elementLanguage) {
super(elementLanguage);
public DefaultX4OWriter(X4OLanguageContext languageContext) {
super(languageContext);
}
public void writeContext(X4OLanguageContext context,OutputStream out) throws ParserConfigurationException,
public void writeContext(X4OLanguageContext languageContext,OutputStream out) throws ParserConfigurationException,
FileNotFoundException, SecurityException, NullPointerException,
SAXException, IOException {
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);
}
try {
languageContext.getLanguage().getPhaseManager().runPhases(languageContext, X4OPhaseType.XML_WRITE);
} catch (X4OPhaseException e1) {
throw new SAXException(e1);
}
Element root = languageContext.getRootElement();
XMLWriter writer = new XMLWriter(out);
writer.startDocument();
@ -120,9 +116,6 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
if (m.getName().startsWith("get")==false) {
continue;
}
if(m.getName().startsWith("getLocationOnScreen")) {
continue; // TODO: rm this
}
String name = m.getName().substring(3,4).toLowerCase()+m.getName().substring(4);
result.add(name);
@ -135,15 +128,37 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
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 (eca.getRunBeanValue()!=null && eca.getRunBeanValue()==false) {
continue;
}
Object value = element.getLanguageContext().getElementObjectPropertyValue().getProperty(element.getElementObject(),eca.getId());
if (value==null) {
continue;
}
atts.addAttribute ("", eca.getName(), "", "", ""+value);
atts.addAttribute ("", eca.getId(), "", "", ""+value);
}
} else {
for (String p:getProperties(element.getElementObject().getClass())) {
ElementClassAttribute eca = element.getElementClass().getElementClassAttributeByName(p);
if (eca!=null && eca.getRunBeanValue()!=null && eca.getRunBeanValue()) {
continue;
}
boolean writeValue = true;
for (ElementInterface ei:element.getLanguageContext().getLanguage().findElementInterfaces(element.getElementObject().getClass())) {
eca = ei.getElementClassAttributeByName(p);
if (eca!=null && eca.getRunBeanValue()!=null && eca.getRunBeanValue()==false) {
writeValue = false;
break;
}
}
if (writeValue==false) {
continue;
}
// TODO: check attr see reader
Object value = element.getLanguageContext().getElementObjectPropertyValue().getProperty(element.getElementObject(),p);
if (value==null) {
continue;
@ -164,7 +179,7 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
}
private String findElementUri(Element e) {
for (X4OLanguageModule mod:e.getLanguageContext().getLanguage().getLanguageModules()) {
for (X4OLanguageModule mod:getLanguageContext().getLanguage().getLanguageModules()) {
for (ElementNamespaceContext c:mod.getElementNamespaceContexts()) {
ElementClass ec = c.getElementClass(e.getElementClass().getTag());
if (ec!=null) {
@ -176,57 +191,11 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
}
private String findNamespacePrefix(Element e,String uri) {
ElementNamespaceContext ns = e.getLanguageContext().getLanguage().findElementNamespaceContext(uri);
ElementNamespaceContext ns = 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());
}
}

View file

@ -422,7 +422,7 @@ public class X4ODebugWriter {
}
}
public void debugElementLanguage(X4OLanguageContext elementLanguage) throws SAXException {
public void debugLanguageContext(X4OLanguageContext elementLanguage) throws SAXException {
AttributesImpl atts = new AttributesImpl();
//atts.addAttribute ("", key, "", "", value);
atts.addAttribute ("", "language", "", "", elementLanguage.getLanguage().getLanguageName());
@ -484,11 +484,11 @@ public class X4ODebugWriter {
private void debugElementClassAttributes(Collection<ElementClassAttribute> elementClassAttributes) throws SAXException {
for (ElementClassAttribute elementClassAttribute:elementClassAttributes) {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "attributeName", "", "", elementClassAttribute.getName());
atts.addAttribute ("", "id", "", "", elementClassAttribute.getId());
atts.addAttribute ("", "description", "", "", elementClassAttribute.getDescription());
atts.addAttribute ("", "className", "", "", elementClassAttribute.getClass().getName());
atts.addAttribute ("", "defaultValue", "", "", ""+elementClassAttribute.getDefaultValue());
atts.addAttribute ("", "runBeanFill", "", "", ""+elementClassAttribute.getRunBeanFill());
atts.addAttribute ("", "runBeanValue", "", "", ""+elementClassAttribute.getRunBeanValue());
atts.addAttribute ("", "runConverters", "", "", ""+elementClassAttribute.getRunConverters());
//atts.addAttribute ("", "runInterfaces", "", "", ""+elementClassAttribute.getRunInterfaces());
atts.addAttribute ("", "runResolveEL", "", "", ""+elementClassAttribute.getRunResolveEL());

View file

@ -22,7 +22,7 @@
*/
/**
* Sax interface based classes.
* The Sax based classes and interfaces.
*
* @since 1.0
*/

View file

@ -23,12 +23,9 @@
package org.x4o.xml.lang;
/**
* Provides elements from tag.<br>
* And ElementClass from a tag.<br>
*
* X4OLanguageModuleLoader Loads all elements and other options
* into the X4OLanguageModule for the X4OLanguageLocal language.
*
* @author Willem Cazander
* @version 1.0 Jul 8, 2006

View file

@ -68,6 +68,16 @@ PHASE_ORDER = { *startupX4OPhase,
* = runOnce
*/
public X4OPhase getPhase(String phaseName) {
for (X4OPhase phase:x4oPhases) {
if (phase.getId().equals(phaseName)) {
return phase;
}
}
return null;
}
/**
* Adds an X4OPhaseHandler.
* @param phase The X4OPhaseHandler to add.
@ -333,7 +343,7 @@ PHASE_ORDER = { *startupX4OPhase,
* @throws X4OPhaseException
*/
private void executePhaseTree(Element element,X4OPhase phase) throws X4OPhaseException {
if (element.getElementClass().getSkipPhases().contains(phase.getId())==false) {
if (element.getElementClass()!=null && element.getElementClass().getSkipPhases().contains(phase.getId())==false) {
phase.runElementPhase(element);
}
for (Element e:element.getChilderen()) {

View file

@ -74,7 +74,7 @@ public class X4OPhaseLanguageInit {
}
public void runElementPhase(Element element) throws X4OPhaseException {
}
public void runPhase(X4OLanguageContext elementLanguage) throws X4OPhaseException {
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException {
logger.finest("Run init start phase");
}
};
@ -98,14 +98,14 @@ public class X4OPhaseLanguageInit {
}
public void runElementPhase(Element element) throws X4OPhaseException {
}
public void runPhase(X4OLanguageContext elementLanguage) throws X4OPhaseException {
public void runPhase(X4OLanguageContext languageContext) 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());
X4OLanguageLoader loader = (X4OLanguageLoader)X4OLanguageClassLoader.newInstance(languageContext.getLanguage().getLanguageConfiguration().getDefaultLanguageLoader());
loader.loadLanguage((X4OLanguageLocal)languageContext.getLanguage(),languageContext.getLanguage().getLanguageName(),languageContext.getLanguage().getLanguageVersion());
if (elementLanguage.hasX4ODebugWriter()) {
elementLanguage.getX4ODebugWriter().debugElementLanguageModules(elementLanguage);
if (languageContext.hasX4ODebugWriter()) {
languageContext.getX4ODebugWriter().debugElementLanguageModules(languageContext);
}
} catch (Exception e) {
throw new X4OPhaseException(this,e);
@ -131,22 +131,22 @@ public class X4OPhaseLanguageInit {
}
public void runElementPhase(Element element) throws X4OPhaseException {
}
public void runPhase(X4OLanguageContext elementLanguage) throws X4OPhaseException {
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException {
try {
List<X4OLanguageModuleLoaderSibling> siblingLoaders = new ArrayList<X4OLanguageModuleLoaderSibling>(3);
for (X4OLanguageModule module:elementLanguage.getLanguage().getLanguageModules()) {
for (X4OLanguageModule module:languageContext.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());
X4OLanguageLoader loader = (X4OLanguageLoader)X4OLanguageClassLoader.newInstance(languageContext.getLanguage().getLanguageConfiguration().getDefaultLanguageLoader());
for (X4OLanguageModuleLoaderSibling siblingLoader:siblingLoaders) {
//debugPhaseMessage("Loading sibling langauge loader: "+siblingLoader,this,elementLanguage);
siblingLoader.loadLanguageSibling((X4OLanguageLocal)elementLanguage.getLanguage(), loader);
siblingLoader.loadLanguageSibling((X4OLanguageLocal)languageContext.getLanguage(), loader);
}
if (elementLanguage.hasX4ODebugWriter()) {
elementLanguage.getX4ODebugWriter().debugElementLanguageModules(elementLanguage);
if (languageContext.hasX4ODebugWriter()) {
languageContext.getX4ODebugWriter().debugElementLanguageModules(languageContext);
}
}
} catch (Exception e) {
@ -173,7 +173,7 @@ public class X4OPhaseLanguageInit {
}
public void runElementPhase(Element element) throws X4OPhaseException {
}
public void runPhase(X4OLanguageContext elementLanguage) throws X4OPhaseException {
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException {
logger.finest("Run init end phase");
}
};

View file

@ -82,11 +82,11 @@ public class X4OPhaseLanguageRead {
manager.addX4OPhase(new X4OPhaseReadXml());
manager.addX4OPhase(new X4OPhaseReadConfigELBeans());
// if (elementLanguage.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
// if (languageContext.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
// meta start point
// manager.addX4OPhase(factory.startX4OPhase());
// if (elementLanguage.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
// if (languageContext.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
// config
X4OPhaseReadRunConfigurator runConf = new X4OPhaseReadRunConfigurator();
@ -97,27 +97,27 @@ public class X4OPhaseLanguageRead {
// run all attribute events
manager.addX4OPhase(new X4OPhaseReadRunAttribute());
// if (elementLanguage.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
// if (languageContext.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
// templating
manager.addX4OPhase(new X4OPhaseReadFillTemplate());
// if (elementLanguage.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
// if (languageContext.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
// transforming
manager.addX4OPhase(new X4OPhaseReadTransform());
manager.addX4OPhase(new X4OPhaseReadRunDirty(manager));
// if (elementLanguage.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
// if (languageContext.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());}
// if (languageContext.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
manager.addX4OPhase(runConf);
manager.addX4OPhase(new X4OPhaseReadRunDirtyLast(manager));
// if (elementLanguage.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
// if (languageContext.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
manager.addX4OPhase(new X4OPhaseReadEnd());
@ -126,9 +126,9 @@ public class X4OPhaseLanguageRead {
manager.addX4OPhase(releasePhase());
// Add debug phase listener to all phases
// if (elementLanguage.hasX4ODebugWriter()) {
// if (languageContext.hasX4ODebugWriter()) {
//for (X4OPhase h:manager.getOrderedPhases()) {
// h.addPhaseListener(elementLanguage.getX4ODebugWriter().createDebugX4OPhaseListener());
// h.addPhaseListener(languageContext.getX4ODebugWriter().createDebugX4OPhaseListener());
//}
//}
@ -166,12 +166,12 @@ public class X4OPhaseLanguageRead {
public void runElementPhase(Element element) throws X4OPhaseException {
// not used.
}
public void runPhase(X4OLanguageContext elementLanguage) throws X4OPhaseException {
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException {
// print the properties and classes for this language/config
if (elementLanguage.hasX4ODebugWriter()) {
if (languageContext.hasX4ODebugWriter()) {
try {
elementLanguage.getX4ODebugWriter().debugLanguageProperties(elementLanguage);
elementLanguage.getX4ODebugWriter().debugLanguageDefaultClasses(elementLanguage);
languageContext.getX4ODebugWriter().debugLanguageProperties(languageContext);
languageContext.getX4ODebugWriter().debugLanguageDefaultClasses(languageContext);
} catch (ElementException e) {
throw new X4OPhaseException(this,e);
}
@ -197,63 +197,63 @@ public class X4OPhaseLanguageRead {
}
public void runElementPhase(Element element) throws X4OPhaseException {
}
public void runPhase(X4OLanguageContext elementLanguage) throws X4OPhaseException {
public void runPhase(X4OLanguageContext languageContext) 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);
X4OTagHandler xth = new X4OTagHandler(languageContext);
XMLReader saxParser = XMLReaderFactory.createXMLReader();
saxParser.setErrorHandler(new X4OErrorHandler(elementLanguage));
saxParser.setEntityResolver(new X4OEntityResolver(elementLanguage));
saxParser.setErrorHandler(new X4OErrorHandler(languageContext));
saxParser.setEntityResolver(new X4OEntityResolver(languageContext));
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);
Map<String,Object> saxParserProperties = languageContext.getLanguage().getLanguageConfiguration().getSAXParserProperties(languageContext);
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);
debugPhaseMessage("Set SAX property: "+name+" to: "+value,this,languageContext);
}
Map<String,Object> saxParserPropertiesOptional = elementLanguage.getLanguage().getLanguageConfiguration().getSAXParserPropertiesOptional(elementLanguage);
Map<String,Object> saxParserPropertiesOptional = languageContext.getLanguage().getLanguageConfiguration().getSAXParserPropertiesOptional(languageContext);
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);
debugPhaseMessage("Set SAX optional property: "+name+" to: "+value,this,languageContext);
} catch (SAXException e) {
debugPhaseMessage("Could not set optional SAX property: "+name+" to: "+value+" error: "+e.getMessage(),this,elementLanguage);
debugPhaseMessage("Could not set optional SAX property: "+name+" to: "+value+" error: "+e.getMessage(),this,languageContext);
}
}
// Set sax features and optional
Map<String, Boolean> features = elementLanguage.getLanguage().getLanguageConfiguration().getSAXParserFeatures(elementLanguage);
Map<String, Boolean> features = languageContext.getLanguage().getLanguageConfiguration().getSAXParserFeatures(languageContext);
for (String key:features.keySet()) {
Boolean value=features.get(key);
saxParser.setFeature(key, value);
debugPhaseMessage("Set SAX feature: "+key+" to: "+value,this,elementLanguage);
debugPhaseMessage("Set SAX feature: "+key+" to: "+value,this,languageContext);
}
Map<String, Boolean> featuresOptional = elementLanguage.getLanguage().getLanguageConfiguration().getSAXParserFeaturesOptional(elementLanguage);
Map<String, Boolean> featuresOptional = languageContext.getLanguage().getLanguageConfiguration().getSAXParserFeaturesOptional(languageContext);
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);
debugPhaseMessage("Set SAX optional feature: "+key+" to: "+value,this,languageContext);
} catch (SAXException e) {
debugPhaseMessage("Could not set optional SAX feature: "+key+" to: "+value+" error: "+e.getMessage(),this,elementLanguage);
debugPhaseMessage("Could not set optional SAX feature: "+key+" to: "+value+" error: "+e.getMessage(),this,languageContext);
}
}
// check for required features
List<String> requiredFeatures = elementLanguage.getLanguage().getLanguageConfiguration().getSAXParserFeaturesRequired(elementLanguage);
List<String> requiredFeatures = languageContext.getLanguage().getLanguageConfiguration().getSAXParserFeaturesRequired(languageContext);
for (String requiredFeature:requiredFeatures) {
debugPhaseMessage("Checking required SAX feature: "+requiredFeature,this,elementLanguage);
debugPhaseMessage("Checking required SAX feature: "+requiredFeature,this,languageContext);
if (saxParser.getFeature(requiredFeature)==false) {
Exception e = new IllegalStateException("Missing required feature: "+requiredFeature);
throw new X4OPhaseException(this,e);
@ -261,21 +261,21 @@ public class X4OPhaseLanguageRead {
}
// Finally start parsing the xml input stream
Object requestInputSource = elementLanguage.getLanguageProperty(X4OLanguageProperty.INPUT_SOURCE_OBJECT);
Object requestInputSource = languageContext.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);
inputStream = (InputStream)languageContext.getLanguageProperty(X4OLanguageProperty.INPUT_SOURCE_STREAM);
input = new InputSource(inputStream);
}
Object requestInputEncoding = elementLanguage.getLanguageProperty(X4OLanguageProperty.INPUT_SOURCE_ENCODING);
Object requestInputEncoding = languageContext.getLanguageProperty(X4OLanguageProperty.INPUT_SOURCE_ENCODING);
if (requestInputEncoding!=null && requestInputEncoding instanceof String) {
input.setEncoding(requestInputEncoding.toString());
}
Object requestSystemId = elementLanguage.getLanguageProperty(X4OLanguageProperty.INPUT_SOURCE_SYSTEM_ID);
Object requestSystemId = languageContext.getLanguageProperty(X4OLanguageProperty.INPUT_SOURCE_SYSTEM_ID);
if (requestSystemId!=null && requestSystemId instanceof String) {
input.setSystemId(requestSystemId.toString());
}
@ -313,17 +313,17 @@ public class X4OPhaseLanguageRead {
// not used.
}
@SuppressWarnings("rawtypes")
public void runPhase(X4OLanguageContext elementLanguage) throws X4OPhaseException {
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException {
try {
Map beanMap = (Map)elementLanguage.getLanguageProperty(X4OLanguageProperty.EL_BEAN_INSTANCE_MAP);
Map beanMap = (Map)languageContext.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);
ValueExpression ve = languageContext.getExpressionLanguageFactory().createValueExpression(languageContext.getExpressionLanguageContext(),"${"+elName+"}", o.getClass());
ve.setValue(languageContext.getExpressionLanguageContext(), o);
debugPhaseMessage("Setting el bean: ${"+elName+"} to: "+o.getClass().getName(),this,languageContext);
}
} catch (Exception e) {
throw new X4OPhaseException(this,e);
@ -359,7 +359,7 @@ public class X4OPhaseLanguageRead {
for (String alias:aliases) {
if (element.getAttributes().containsKey(alias)) {
String attributeValue = element.getAttributes().get(alias);
element.getAttributes().put(eca.getName(), attributeValue);
element.getAttributes().put(eca.getId(), attributeValue);
element.getAttributes().remove(alias);
}
}
@ -520,7 +520,7 @@ public class X4OPhaseLanguageRead {
if (attrClass.getRunConverters()==null || attrClass.getRunConverters()) {
value = attrParser.getConvertedParameterValue(name, value, element);
}
if (attrClass.getRunBeanFill()==null || attrClass.getRunBeanFill()) {
if (attrClass.getRunBeanValue()==null || attrClass.getRunBeanValue()) {
element.getLanguageContext().getElementObjectPropertyValue().setProperty(element.getElementObject(), name, value);
}
} else if (autoAttributes) {
@ -534,15 +534,15 @@ public class X4OPhaseLanguageRead {
}
// check for defaults
for (ElementClassAttribute attrClass:element.getElementClass().getElementClassAttributes()) {
if (attrClass.getDefaultValue()!=null && attr.containsKey(attrClass.getName())==false) {
if (attrClass.getDefaultValue()!=null && attr.containsKey(attrClass.getId())==false) {
Object value = null;
if (attrClass.getDefaultValue() instanceof String) {
value = attrParser.getParameterValue(attrClass.getName(),(String)attrClass.getDefaultValue(),element);
value = attrParser.getParameterValue(attrClass.getId(),(String)attrClass.getDefaultValue(),element);
} else {
value = attrClass.getDefaultValue();
}
if (attrClass.getRunBeanFill()==null || attrClass.getRunBeanFill()) {
element.getLanguageContext().getElementObjectPropertyValue().setProperty(element.getElementObject(), attrClass.getName(), value);
if (attrClass.getRunBeanValue()==null || attrClass.getRunBeanValue()) {
element.getLanguageContext().getElementObjectPropertyValue().setProperty(element.getElementObject(), attrClass.getId(), value);
}
}
}
@ -752,11 +752,11 @@ public class X4OPhaseLanguageRead {
public boolean isElementPhase() {
return false;
}
public void runPhase(X4OLanguageContext elementLanguage) throws X4OPhaseException {
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException {
for (RunConfigurator conf:runConf) {
try {
if (elementLanguage.hasX4ODebugWriter()) {
elementLanguage.getX4ODebugWriter().debugElementConfigurator(conf.elementConfigurator,conf.element);
if (languageContext.hasX4ODebugWriter()) {
languageContext.getX4ODebugWriter().debugElementConfigurator(conf.elementConfigurator,conf.element);
}
conf.elementConfigurator.doConfigElement(conf.element);
} catch (ElementException e) {
@ -815,12 +815,12 @@ public class X4OPhaseLanguageRead {
public void runElementPhase(Element element) throws X4OPhaseException {
// not used.
}
public void runPhase(X4OLanguageContext elementLanguage) throws X4OPhaseException {
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException {
// print the properties and classes for this language/config
if (elementLanguage.hasX4ODebugWriter()) {
if (languageContext.hasX4ODebugWriter()) {
try {
elementLanguage.getX4ODebugWriter().debugLanguageProperties(elementLanguage);
elementLanguage.getX4ODebugWriter().debugLanguageDefaultClasses(elementLanguage);
languageContext.getX4ODebugWriter().debugLanguageProperties(languageContext);
languageContext.getX4ODebugWriter().debugLanguageDefaultClasses(languageContext);
} catch (ElementException e) {
throw new X4OPhaseException(this,e);
}
@ -840,21 +840,21 @@ public class X4OPhaseLanguageRead {
/**
* @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 {
public void preRunPhase(X4OPhase phase,X4OLanguageContext languageContext) 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) {
public void endRunPhase(X4OPhase phase,X4OLanguageContext languageContext) throws X4OPhaseException {
if (languageContext.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" , "");
languageContext.getX4ODebugWriter().getDebugWriter().startElement (X4ODebugWriter.DEBUG_URI, "executeReleases", "", atts);
languageContext.getX4ODebugWriter().getDebugWriter().endElement (X4ODebugWriter.DEBUG_URI, "executeReleases" , "");
} catch (SAXException e) {
throw new X4OPhaseException(phase,e);
}
@ -876,7 +876,7 @@ public class X4OPhaseLanguageRead {
public String[] getPhaseDependencies() {
return new String[] {"READ_END"};
}
public void runPhase(X4OLanguageContext elementLanguage) throws X4OPhaseException {
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException {
}
public void runElementPhase(Element element) throws X4OPhaseException {
try {
@ -912,23 +912,23 @@ public class X4OPhaseLanguageRead {
}
public void runElementPhase(Element element) throws X4OPhaseException {
}
public void runPhase(X4OLanguageContext elementLanguage) throws X4OPhaseException {
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException {
// safety check
if (elementLanguage.hasX4ODebugWriter()==false) {
if (languageContext.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);
languageContext.getX4ODebugWriter().getDebugWriter().startElement (X4ODebugWriter.DEBUG_URI, "printElementTree", "", atts);
startedPrefix.clear();
printXML(elementLanguage.getRootElement());
printXML(languageContext.getRootElement());
for (String prefix:startedPrefix) {
elementLanguage.getX4ODebugWriter().getDebugWriter().endPrefixMapping(prefix);
languageContext.getX4ODebugWriter().getDebugWriter().endPrefixMapping(prefix);
}
elementLanguage.getX4ODebugWriter().getDebugWriter().endElement(X4ODebugWriter.DEBUG_URI, "printElementTree", "");
elementLanguage.getX4ODebugWriter().debugElementLanguage(elementLanguage);
languageContext.getX4ODebugWriter().getDebugWriter().endElement(X4ODebugWriter.DEBUG_URI, "printElementTree", "");
languageContext.getX4ODebugWriter().debugLanguageContext(languageContext);
} catch (SAXException e) {
throw new X4OPhaseException(this,e);
}

View file

@ -0,0 +1,215 @@
/*
* 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.element.ElementBindingHandler;
import org.x4o.xml.element.ElementBindingHandlerException;
import org.x4o.xml.element.ElementClass;
import org.x4o.xml.element.ElementNamespaceContext;
import org.x4o.xml.element.ElementNamespaceInstanceProviderException;
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;
import org.xml.sax.SAXException;
/**
* X4OPhaseLanguageWrite defines all phases to write the language.
*
* @author Willem Cazander
* @version 1.0 Apr 7, 2013
*/
public class X4OPhaseLanguageWrite {
private Logger logger = null;
public X4OPhaseLanguageWrite() {
logger = Logger.getLogger(X4OPhaseLanguageWrite.class.getName());
}
public void createPhases(DefaultX4OPhaseManager manager) {
manager.addX4OPhase(new X4OPhaseWriteStart());
manager.addX4OPhase(new X4OPhaseWriteFillTree());
//manager.addX4OPhase(new X4OPhaseInitLanguageSiblings());
manager.addX4OPhase(new X4OPhaseWriteEnd());
}
/**
* Creates the X4OPhaseWriteStart which is a empty meta phase.
*/
class X4OPhaseWriteStart extends AbstractX4OPhase {
public X4OPhaseType getType() {
return X4OPhaseType.XML_WRITE;
}
public String getId() {
return "WRITE_START";
}
public String[] getPhaseDependencies() {
return new String[]{};
}
public boolean isElementPhase() {
return false;
}
public void runElementPhase(Element element) throws X4OPhaseException {
}
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException {
logger.finest("Run init start phase");
}
};
/**
* Fills the element tree
*/
class X4OPhaseWriteFillTree extends AbstractX4OPhase {
public X4OPhaseType getType() {
return X4OPhaseType.XML_WRITE;
}
public String getId() {
return "WRITE_FILL_TREE";
}
public String[] getPhaseDependencies() {
return new String[]{"WRITE_START"};
}
public boolean isElementPhase() {
return false;
}
public void runElementPhase(Element element) throws X4OPhaseException {
}
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException {
try {
Element root = languageContext.getRootElement();
// TODO: check for read tree then write support as ec is not null then ..
if (root.getElementClass()==null) {
root = fillElementTree(languageContext,root.getElementObject());
}
} catch (Exception e) {
throw new X4OPhaseException(this,e);
}
}
private Element fillElementTree(X4OLanguageContext languageContext,Object object) throws ElementNamespaceInstanceProviderException, ElementBindingHandlerException {
Element element = findRootElement(languageContext,object.getClass());
element.setElementObject(object);
languageContext.setRootElement(element);
for (ElementBindingHandler bind:languageContext.getLanguage().findElementBindingHandlers(object)) {
bind.createChilderen(element);
fillTree(languageContext,element);
}
return element;
}
private void fillTree(X4OLanguageContext languageContext,Element element) throws ElementNamespaceInstanceProviderException, ElementBindingHandlerException {
for (Element e:element.getChilderen()) {
Object object = e.getElementObject();
for (ElementBindingHandler bind:languageContext.getLanguage().findElementBindingHandlers(object)) {
bind.createChilderen(e);
fillTree(languageContext,e);
}
}
}
private Element findRootElement(X4OLanguageContext languageContext,Class<?> objectClass) throws ElementNamespaceInstanceProviderException {
// redo this mess, add nice find for root
for (X4OLanguageModule modContext:languageContext.getLanguage().getLanguageModules()) {
for (ElementNamespaceContext nsContext:modContext.getElementNamespaceContexts()) {
if (nsContext.getLanguageRoot()!=null && nsContext.getLanguageRoot()) {
for (ElementClass ec:nsContext.getElementClasses()) {
if (ec.getObjectClass()!=null && ec.getObjectClass().equals(objectClass)) {
return nsContext.getElementNamespaceInstanceProvider().createElementInstance(languageContext, ec.getTag());
}
}
}
}
}
for (X4OLanguageModule modContext:languageContext.getLanguage().getLanguageModules()) {
for (ElementNamespaceContext nsContext:modContext.getElementNamespaceContexts()) {
for (ElementClass ec:nsContext.getElementClasses()) {
if (ec.getObjectClass()!=null && ec.getObjectClass().equals(objectClass)) {
return nsContext.getElementNamespaceInstanceProvider().createElementInstance(languageContext, ec.getTag());
}
}
}
}
throw new IllegalArgumentException("Could not find ElementClass for: "+objectClass.getName());
}
};
/**
* Loads all sibling languages.
*/
class X4OPhaseInitLanguageSiblings extends AbstractX4OPhase {
public X4OPhaseType getType() {
return X4OPhaseType.XML_WRITE;
}
public String getId() {
return "WRITE_TREE_VALUES";
}
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 {
} catch (Exception e) {
throw new X4OPhaseException(this,e);
}
}
};
/**
* Creates the X4OPhaseWriteEnd which is a empty meta phase.
*/
class X4OPhaseWriteEnd extends AbstractX4OPhase {
public X4OPhaseType getType() {
return X4OPhaseType.XML_WRITE;
}
public String getId() {
return "WRITE_END";
}
public String[] getPhaseDependencies() {
return new String[]{"WRITE_FILL_TREE"};
}
public boolean isElementPhase() {
return false;
}
public void runElementPhase(Element element) throws X4OPhaseException {
}
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException {
logger.finest("Run init end phase");
}
};
}

View file

@ -39,6 +39,8 @@ import org.x4o.xml.lang.X4OLanguageContext;
*/
public interface X4OPhaseManager {
X4OPhase getPhase(String phaseName);
/**
* Returns all the X4OPhaseHandlers.
* @return Returns all X4OPhaseHandlers.

View file

@ -22,7 +22,7 @@
*/
/**
* Provides interfaces for two way object converters.
* The X4O XML Driver program interface.
*
*
* @since 1.0

View file

@ -7,7 +7,7 @@
ModuleName: Core Element Languag Module
Namespaces: 2
Namespace: http://cel.x4o.org/xml/ns/cel-core
Created on: Tue Jan 08 06:02:28 CET 2013
Created on: Sat Apr 27 20:01:59 CEST 2013
-->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:this="http://cel.x4o.org/xml/ns/cel-core"
@ -19,12 +19,12 @@
</choice>
<attribute name="uri" type="string" use="required"/>
<attribute name="name" type="string"/>
<attribute name="prefixMapping" type="string"/>
<attribute name="languageRoot" type="boolean"/>
<attribute name="elementNamespaceInstanceProvider" type="string"/>
<attribute name="schemaUri" type="string"/>
<attribute name="schemaResource" type="string"/>
<attribute name="schemaPrefix" type="string"/>
<attribute name="languageRoot" type="boolean"/>
<attribute name="prefixMapping" type="string"/>
<attribute name="description" type="string"/>
<attribute name="id" type="string"/>
</complexType>
@ -44,11 +44,11 @@
</choice>
<attribute name="objectClass" type="string"/>
<attribute name="elementClass" type="string"/>
<attribute name="schemaContentBase" type="string"/>
<attribute name="autoAttributes" type="boolean"/>
<attribute name="tag" type="string"/>
<attribute name="schemaContentComplex" type="boolean"/>
<attribute name="schemaContentMixed" type="boolean"/>
<attribute name="tag" type="string"/>
<attribute name="schemaContentBase" type="string"/>
<attribute name="autoAttributes" type="boolean"/>
<attribute name="description" type="string"/>
<attribute name="id" type="string"/>
</complexType>
@ -81,12 +81,13 @@
<element name="description" type="this:descriptionType"/>
</choice>
<attribute name="name" type="string"/>
<attribute name="objectConverter" type="string"/>
<attribute name="runResolveEL" type="boolean"/>
<attribute name="runConverters" type="boolean"/>
<attribute name="runBeanFill" type="boolean"/>
<attribute name="required" type="boolean"/>
<attribute name="defaultValue" type="string"/>
<attribute name="runConverters" type="boolean"/>
<attribute name="objectConverter" type="string"/>
<attribute name="runBeanValue" type="boolean"/>
<attribute name="runResolveEL" type="boolean"/>
<attribute name="writeOrder" type="integer"/>
<attribute name="description" type="string"/>
<attribute name="id" type="string"/>
</complexType>
@ -119,15 +120,70 @@
<attribute name="uri" type="string"/>
<anyAttribute/>
</complexType>
<element name="namespace" type="this:namespaceType"/>
<element name="description" type="this:descriptionType"/>
<element name="element" type="this:elementType"/>
<element name="configuratorGlobal" type="this:configuratorGlobalType"/>
<element name="configurator" type="this:configuratorType"/>
<element name="attributeHandler" type="this:attributeHandlerType"/>
<element name="attribute" type="this:attributeType"/>
<element name="classConverter" type="this:classConverterType"/>
<element name="bindingHandler" type="this:bindingHandlerType"/>
<element name="elementInterface" type="this:elementInterfaceType"/>
<element name="elementParent" type="this:elementParentType"/>
<element name="namespace" type="this:namespaceType">
<annotation>
<documentation xml:lang="en">Defines an xml namespace.
</documentation>
</annotation>
</element>
<element name="description" type="this:descriptionType">
<annotation>
<documentation xml:lang="en">Adds description as text on all eld elements.
</documentation>
</annotation>
</element>
<element name="element" type="this:elementType">
<annotation>
<documentation xml:lang="en">Defines xml element tag.
</documentation>
</annotation>
</element>
<element name="configuratorGlobal" type="this:configuratorGlobalType">
<annotation>
<documentation xml:lang="en">Define generic global configuator for languge.
</documentation>
</annotation>
</element>
<element name="configurator" type="this:configuratorType">
<annotation>
<documentation xml:lang="en">Define generic configurator for language.
</documentation>
</annotation>
</element>
<element name="attributeHandler" type="this:attributeHandlerType">
<annotation>
<documentation xml:lang="en">Defines generic attribute handler for language.
</documentation>
</annotation>
</element>
<element name="attribute" type="this:attributeType">
<annotation>
<documentation xml:lang="en">Defines xml element attribute.
</documentation>
</annotation>
</element>
<element name="classConverter" type="this:classConverterType">
<annotation>
<documentation xml:lang="en">Converts string attribute to java class instance.
</documentation>
</annotation>
</element>
<element name="bindingHandler" type="this:bindingHandlerType">
<annotation>
<documentation xml:lang="en">Defines generic binding handler for languge.
</documentation>
</annotation>
</element>
<element name="elementInterface" type="this:elementInterfaceType">
<annotation>
<documentation xml:lang="en">Defines element interface class.
</documentation>
</annotation>
</element>
<element name="elementParent" type="this:elementParentType">
<annotation>
<documentation xml:lang="en">Added (meta) element parent.
</documentation>
</annotation>
</element>
</schema>

View file

@ -7,7 +7,7 @@
ModuleName: Core Element Languag Module
Namespaces: 2
Namespace: http://cel.x4o.org/xml/ns/cel-root
Created on: Tue Jan 08 06:02:28 CET 2013
Created on: Sat Apr 27 20:01:59 CEST 2013
-->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:cel-core="http://cel.x4o.org/xml/ns/cel-core"
@ -24,9 +24,9 @@
<element ref="cel-core:namespace"/>
</choice>
<attribute name="name" type="string"/>
<attribute name="providerName" type="string"/>
<attribute name="sourceResource" type="string"/>
<attribute name="elementLanguageModuleLoader" type="string"/>
<attribute name="languageModuleLoader" type="string"/>
<attribute name="providerName" type="string"/>
<attribute name="description" type="string"/>
<attribute name="id" type="string"/>
</complexType>

View file

@ -7,7 +7,7 @@
ModuleName: Element Language Definition
Namespaces: 3
Namespace: http://eld.x4o.org/xml/ns/eld-conv
Created on: Mon Apr 08 02:26:14 CEST 2013
Created on: Sat Apr 27 20:06:33 CEST 2013
-->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:this="http://eld.x4o.org/xml/ns/eld-conv"

View file

@ -7,7 +7,7 @@
ModuleName: Element Language Definition
Namespaces: 3
Namespace: http://eld.x4o.org/xml/ns/eld-lang
Created on: Mon Apr 08 02:26:14 CEST 2013
Created on: Sat Apr 27 20:06:33 CEST 2013
-->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:conv="http://eld.x4o.org/xml/ns/eld-conv"
@ -20,13 +20,13 @@
<element name="element" type="this:elementType"/>
</choice>
<attribute name="uri" type="string" use="required"/>
<attribute name="name" type="string"/>
<attribute name="prefixMapping" type="string"/>
<attribute name="languageRoot" type="boolean"/>
<attribute name="elementNamespaceInstanceProvider" type="string"/>
<attribute name="schemaUri" type="string"/>
<attribute name="schemaResource" type="string"/>
<attribute name="schemaPrefix" type="string"/>
<attribute name="languageRoot" type="boolean"/>
<attribute name="prefixMapping" type="string"/>
<attribute name="name" type="string"/>
<attribute name="id" type="string"/>
<attribute name="description" type="string"/>
</complexType>
@ -55,10 +55,10 @@
<attribute name="objectClass" type="string"/>
<attribute name="elementClass" type="string"/>
<attribute name="tag" type="string"/>
<attribute name="schemaContentBase" type="string"/>
<attribute name="autoAttributes" type="boolean"/>
<attribute name="schemaContentComplex" type="boolean"/>
<attribute name="schemaContentMixed" type="boolean"/>
<attribute name="schemaContentComplex" type="boolean"/>
<attribute name="autoAttributes" type="boolean"/>
<attribute name="schemaContentBase" type="string"/>
<attribute name="id" type="string"/>
<attribute name="description" type="string"/>
</complexType>
@ -126,13 +126,14 @@
<element name="bean" type="this:beanType"/>
<element name="description" type="this:descriptionType"/>
</choice>
<attribute name="objectConverter" type="string"/>
<attribute name="name" type="string"/>
<attribute name="defaultValue" type="string"/>
<attribute name="required" type="boolean"/>
<attribute name="writeOrder" type="integer"/>
<attribute name="runBeanValue" type="boolean"/>
<attribute name="runResolveEL" type="boolean"/>
<attribute name="runConverters" type="boolean"/>
<attribute name="runBeanFill" type="boolean"/>
<attribute name="name" type="string"/>
<attribute name="required" type="boolean"/>
<attribute name="objectConverter" type="string"/>
<attribute name="id" type="string"/>
<attribute name="description" type="string"/>
</complexType>

View file

@ -53,7 +53,7 @@
>
<description>Single root namespace so xsd schema generation works correct.</description>
<element tag="module" objectClass="${parentLanguageConfiguration.defaultElementLanguageModule}" elementClass="org.x4o.xml.eld.lang.ModuleElement">
<attribute name="id" required="true">
<attribute id="id" required="true">
<description>The module id.</description>
</attribute>
<description>The module root element.</description>
@ -73,27 +73,27 @@
<!-- First copy some core elements over from parent config -->
<element tag="namespace" objectClass="${parentLanguageConfiguration.defaultElementNamespaceContext}">
<description>Defines an namespace for the language.</description>
<attribute name="uri" required="true">
<attribute id="uri" required="true">
<description>The namespace id.</description>
</attribute>
</element>
<element tag="element" objectClass="${parentLanguageConfiguration.defaultElementClass}">
<description>The xml element.</description>
<attribute name="objectClass">
<attribute id="objectClass">
<description>The class of the wrapped object.</description>
<classConverter/>
</attribute>
<attribute name="elementClass">
<attribute id="elementClass">
<description>An custom element class to config object.</description>
<classConverter/>
</attribute>
</element>
<element tag="elementInterface" objectClass="${parentLanguageConfiguration.defaultElementInterface}">
<description>Config element objects by java interface.</description>
<attribute name="id" required="true">
<attribute id="id" required="true">
<description>The interface id.</description>
</attribute>
<attribute name="interfaceClass" required="true">
<attribute id="interfaceClass" required="true">
<description>The interface class.</description>
<classConverter/>
</attribute>
@ -106,10 +106,10 @@
<element tag="bindingHandler" elementClass="org.x4o.xml.eld.lang.BeanElement">
<description>Define an className in bean.class for an ElementBindingHandler interface.</description>
<attribute name="id" required="true">
<attribute id="id" required="true">
<description>The binding handler id.</description>
</attribute>
<attribute name="bean.class" required="true">
<attribute id="bean.class" required="true">
<description>The class of the binding handler.</description>
</attribute>
<elementParent tag="module" uri="http://eld.x4o.org/xml/ns/eld-root"/>
@ -118,13 +118,13 @@
<element tag="attributeHandler" elementClass="org.x4o.xml.eld.lang.BeanElement">
<description>Define an className in bean.class for an ElementAttributeHandler.</description>
<attribute name="id" required="true">
<attribute id="id" required="true">
<description>The atttribute handler id.</description>
</attribute>
<attribute name="bean.class" required="true">
<attribute id="bean.class" required="true">
<description>The class of the attribute handler.</description>
</attribute>
<attribute name="attributeName" required="true">
<attribute id="attributeName" required="true">
<description>The xml attribute name.</description>
</attribute>
<elementParent tag="module" uri="http://eld.x4o.org/xml/ns/eld-root"/>
@ -132,13 +132,13 @@
<element tag="configuratorGlobal" elementClass="org.x4o.xml.eld.lang.BeanElement">
<description>Define an className in bean.class for an ElementConfiguratorGlobal.</description>
<attribute name="id" required="true">
<attribute id="id" required="true">
<description>The global element configurator id.</description>
</attribute>
<attribute name="bean.class" required="true">
<attribute id="bean.class" required="true">
<description>The class of the element configurator.</description>
</attribute>
<attribute name="configAction">
<attribute id="configAction">
<description>If set to true then run in config phase.</description>
</attribute>
<elementParent tag="module" uri="http://eld.x4o.org/xml/ns/eld-root"/>
@ -146,13 +146,13 @@
<element tag="configurator" elementClass="org.x4o.xml.eld.lang.BeanElement">
<description>Define an className in bean.class for an ElementConfigurator.</description>
<attribute name="id" required="true">
<attribute id="id" required="true">
<description>The element configurator id.</description>
</attribute>
<attribute name="bean.class" required="true">
<attribute id="bean.class" required="true">
<description>The class of the global element configurator.</description>
</attribute>
<attribute name="configAction">
<attribute id="configAction">
<description>If set to true then run in config phase.</description>
</attribute>
<elementParent tag="elementInterface"/>
@ -181,17 +181,17 @@
<description>Adds an parent element tag for xsd</description>
<elementParent tag="element"/>
<elementParent tag="elementInterface"/>
<attribute name="tag">
<attribute id="tag">
<description>The parent tag to have object for.</description>
</attribute>
<attribute name="uri">
<attribute id="uri">
<description>The element namespace uri if non local parent.</description>
</attribute>
</element>
<element tag="elementSkipPhase" elementClass="org.x4o.xml.eld.lang.SkipPhaseElement">
<description>Adds an phase to skip to the parent element.</description>
<attribute name="name" required="true">
<attribute id="name" required="true">
<description>The name of the phase to skip.</description>
</attribute>
<elementParent tag="element"/>
@ -199,7 +199,7 @@
<element tag="attributeHandlerNextAttribute" elementClass="org.x4o.xml.eld.lang.NextAttributeElement">
<description>Defines the parameter order.</description>
<attribute name="attributeName" required="true">
<attribute id="attributeName" required="true">
<description>The attribute name to run after this attribute.</description>
</attribute>
<elementParent tag="attributeHandler"/>
@ -208,7 +208,7 @@
<element tag="attributeAlias" elementClass="org.x4o.xml.eld.lang.AttributeAliasElement">
<description>Defines an alias for an attribute name.</description>
<attribute name="name" required="true">
<attribute id="name" required="true">
<description>The alias name to add to the attribute.</description>
</attribute>
<elementParent tag="attribute"/>
@ -216,13 +216,13 @@
<element tag="attributeFromBody" objectClass="org.x4o.xml.eld.lang.AttributeFromBodyConfigurator" autoAttributes="false">
<description>Defines an alias for an attribute name.</description>
<attribute name="id" required="true">
<attribute id="id" required="true">
<description>The id for this configurator.</description>
</attribute>
<attribute name="name" required="true">
<attribute id="name" required="true">
<description>The attribute name to fill the value.</description>
</attribute>
<attribute name="bodyType">
<attribute id="bodyType">
<description>See org.x4o.xml.element.Element.ElementType for options defaults to 'characters'.</description>
</attribute>
</element>
@ -231,21 +231,21 @@
autoAttributes="false"
>
<description>Lets you dynamicly bind to object togecher.</description>
<attribute name="id" required="true">
<attribute id="id" required="true">
<description>The id for this binding handler.</description>
</attribute>
<attribute name="parentClass" required="true">
<attribute id="parentClass" required="true">
<description>The parent class.</description>
<classConverter/>
</attribute>
<attribute name="childClass" required="true">
<attribute id="childClass" required="true">
<description>The child class.</description>
<classConverter/>
</attribute>
<attribute name="addMethod" required="true">
<attribute id="addMethod" required="true">
<description>The method name of the method used to add the child to the parent.</description>
</attribute>
<attribute name="getMethod" required="true">
<attribute id="getMethod" required="true">
<description>The method name of the method used to get the childeren of the parent.</description>
</attribute>
</element>
@ -256,7 +256,7 @@
<element tag="bean" elementClass="org.x4o.xml.eld.lang.BeanElement">
<!-- BIG NOTE: maybe beanElement most go to meta to have clean impl. -->
<description>Loads bean into the Element</description>
<attribute name="bean.class">
<attribute id="bean.class">
<description>The class name of the the class to load.</description>
</attribute>
<elementParent tag="module" uri="http://eld.x4o.org/xml/ns/eld-root"/>
@ -278,7 +278,7 @@
<element tag="beanConverter" elementClass="org.x4o.xml.eld.lang.BeanElement">
<description>Define an loadable in bean.class for an ObjectConverter.</description>
<attribute name="bean.class">
<attribute id="bean.class">
<description>The class name of the converter to load.</description>
</attribute>
<elementParent tag="attribute" uri="http://eld.x4o.org/xml/ns/eld-lang"/>
@ -296,20 +296,20 @@
<element tag="enumConverter" objectClass="org.x4o.xml.conv.text.EnumConverter" />
<element tag="stringSplitConverter" objectClass="org.x4o.xml.conv.text.StringSplitConverter">
<attribute name="classTo" required="true">
<attribute id="classTo" required="true">
<description>The class name to convert the string to.</description>
<classConverter/>
</attribute>
<attribute name="split" required="true" description="The split regex."/>
<attribute name="splitSize" required="true" description="The split value expected size."/>
<attribute name="singleToMethod" description="Shortcut to use only this method for the 'to' convert."/>
<attribute name="useNativeType" description="Set to true to convert to native data type."/>
<attribute id="split" required="true" description="The split regex."/>
<attribute id="splitSize" required="true" description="The split value expected size."/>
<attribute id="singleToMethod" description="Shortcut to use only this method for the 'to' convert."/>
<attribute id="useNativeType" description="Set to true to convert to native data type."/>
</element>
<element tag="stringSplitConverterStep" objectClass="org.x4o.xml.conv.text.StringSplitConverterStep">
<attribute name="fromMethod" required="true" description="The convert 'from' method step."/>
<attribute name="toMethod" required="false" description="The convert 'to' method step."/>
<attribute name="fromOrder" required="true" description="The convert 'from' order."/>
<attribute name="toOrder" required="true" description="The convert 'to' order."/>
<attribute id="fromMethod" required="true" description="The convert 'from' method step."/>
<attribute id="toMethod" required="false" description="The convert 'to' method step."/>
<attribute id="fromOrder" required="true" description="The convert 'from' order."/>
<attribute id="toOrder" required="true" description="The convert 'to' order."/>
</element>
</namespace>
</root:module>

View file

@ -7,7 +7,7 @@
ModuleName: Element Language Definition
Namespaces: 3
Namespace: http://eld.x4o.org/xml/ns/eld-root
Created on: Mon Apr 08 02:26:14 CEST 2013
Created on: Sat Apr 27 20:06:33 CEST 2013
-->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:conv="http://eld.x4o.org/xml/ns/eld-conv"
@ -28,10 +28,10 @@
<element ref="lang:namespace"/>
</choice>
<attribute name="id" type="string" use="required"/>
<attribute name="name" type="string"/>
<attribute name="providerName" type="string"/>
<attribute name="sourceResource" type="string"/>
<attribute name="languageModuleLoader" type="string"/>
<attribute name="name" type="string"/>
<attribute name="description" type="string"/>
</complexType>
</element>

View file

@ -62,10 +62,17 @@ public class X4OWriterTest extends TestCase {
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());
assertTrue(text.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
assertTrue(text.contains("http://test.x4o.org/xml/ns/test-root"));
assertTrue(text.contains("<test-lang:parent name=\"test-bean.xml\"/>"));
assertTrue(text.contains("<test-lang:testBean"));
assertTrue(text.contains("privateIntegerTypeField=\"123\""));
assertTrue(text.contains("privateDoubleObjectField=\"123.45\""));
assertTrue(text.contains("privateStringObjectField=\"x4o\""));
//System.out.println("Output: '\n"+text+"\n' end in "+outputFile.getAbsolutePath());
outputFile.delete();
}

View file

@ -47,12 +47,4 @@ public class TestDriver extends X4ODriver<TestObjectRoot> {
static public TestDriver getInstance() {
return (TestDriver)X4ODriverManager.getX4ODriver(LANGUAGE_NAME);
}
public X4OReaderContext<TestObjectRoot> createReaderContext() {
return (X4OReaderContext<TestObjectRoot>)super.createReader();
}
public X4OWriterContext<TestObjectRoot> createWriterContext() {
return (X4OWriterContext<TestObjectRoot>)super.createWriter();
}
}

View file

@ -55,7 +55,7 @@
<eld:elementInterface id="Component" interfaceClass="java.awt.Component">
<eld:description>Configs the Component based objects.</eld:description>
<eld:attribute name="bounds">
<eld:attribute id="bounds">
<conv:stringSplitConverter classTo="java.awt.Rectangle" split="," splitSize="4" singleToMethod="setRect" useNativeType="true">
<conv:stringSplitConverterStep fromMethod="getX" fromOrder="1" toOrder="1"><conv:doubleConverter/></conv:stringSplitConverterStep>
<conv:stringSplitConverterStep fromMethod="getY" fromOrder="2" toOrder="2"><conv:doubleConverter/></conv:stringSplitConverterStep>

View file

@ -46,7 +46,7 @@
<classBindingHandler id="JRootPane-JComponent" parentClass="javax.swing.JRootPane" childClass="javax.swing.JComponent" addMethod="add" getMethod="getComponents"/>
<elementInterface id="Component" interfaceClass="java.awt.Component">
<attribute name="bounds">
<attribute id="bounds">
<conv:stringSplitConverter classTo="java.awt.Rectangle" split="," splitSize="4" singleToMethod="setRect" useNativeType="true">
<conv:stringSplitConverterStep fromMethod="getX" fromOrder="1" toOrder="1"><conv:doubleConverter/></conv:stringSplitConverterStep>
<conv:stringSplitConverterStep fromMethod="getY" fromOrder="2" toOrder="2"><conv:doubleConverter/></conv:stringSplitConverterStep>
@ -54,36 +54,37 @@
<conv:stringSplitConverterStep fromMethod="getHeight" fromOrder="4" toOrder="4"><conv:doubleConverter/></conv:stringSplitConverterStep>
</conv:stringSplitConverter>
</attribute>
<attribute name="size">
<attribute id="size">
<conv:stringSplitConverter classTo="java.awt.Dimension" split="," splitSize="2" singleToMethod="setSize" useNativeType="true">
<conv:stringSplitConverterStep fromMethod="getHeight" fromOrder="1" toOrder="1"><conv:integerConverter/></conv:stringSplitConverterStep>
<conv:stringSplitConverterStep fromMethod="getWidth" fromOrder="2" toOrder="2"><conv:integerConverter/></conv:stringSplitConverterStep>
</conv:stringSplitConverter>
</attribute>
<attribute name="icon">
<attribute id="icon">
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.IconConverter"/>
</attribute>
<attribute name="background">
<attribute id="background">
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.ColorConverter"/>
</attribute>
<attribute name="location">
<attribute id="location">
<conv:stringSplitConverter classTo="java.awt.Point" split="," splitSize="2" singleToMethod="setLocation" useNativeType="true">
<conv:stringSplitConverterStep fromMethod="getX" fromOrder="1" toOrder="1"><conv:integerConverter/></conv:stringSplitConverterStep>
<conv:stringSplitConverterStep fromMethod="getY" fromOrder="2" toOrder="2"><conv:integerConverter/></conv:stringSplitConverterStep>
</conv:stringSplitConverter>
</attribute>
<attribute id="locationOnScreen" runBeanValue="false"/>
</elementInterface>
<elementInterface id="JComponent" interfaceClass="javax.swing.JComponent">
<attribute name="layout">
<attribute id="layout">
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.LayoutConverter"/>
</attribute>
<attribute name="border">
<attribute id="border">
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.BorderConverter"/>
</attribute>
<attribute name="toolTipText"><attributeAlias name="ToolTipText"/></attribute>
<attribute name="focusPainted"><attributeAlias name="FocusPainted"/></attribute>
<attribute name="borderPainted"><attributeAlias name="BorderPainted"/></attribute>
<attribute id="toolTipText"><attributeAlias name="ToolTipText"/></attribute>
<attribute id="focusPainted"><attributeAlias name="FocusPainted"/></attribute>
<attribute id="borderPainted"><attributeAlias name="BorderPainted"/></attribute>
</elementInterface>
@ -111,21 +112,21 @@
<element tag="menubar" objectClass="javax.swing.JMenuBar"/>
<element tag="menu" objectClass="javax.swing.JMenu"/>
<element tag="menuitem" objectClass="javax.swing.JMenuItem">
<attribute name="accelerator">
<attribute id="accelerator">
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.KeyStrokeConverter"/>
<attributeAlias name="Accelerator"/>
</attribute>
<attribute name="mnemonic" runBeanFill="false"/>
<attribute name="Action" runBeanFill="false"/>
<attribute id="mnemonic" runBeanValue="false"/>
<attribute id="Action" runBeanValue="false"/>
<configurator id="menuitem-action" bean.class="org.x4o.xml.test.swixml.SwiXmlActionConfigurator"/>
</element>
<element tag="separator" />
<element tag="panel" objectClass="javax.swing.JPanel"/>
<element tag="splitpane" objectClass="javax.swing.JSplitPane">
<attribute name="orientation">
<attribute id="orientation">
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.JSplitPaneOrientationConverter"/>
</attribute>
<attribute name="dividerLocation">
<attribute id="dividerLocation">
<conv:integerConverter/>
</attribute>
</element>
@ -142,11 +143,11 @@
<element tag="textfield" objectClass="javax.swing.JTextField"/>
<element tag="desktoppane" objectClass="javax.swing.JDesktopPane"/>
<element tag="internalframe" objectClass="javax.swing.JInternalFrame">
<attribute name="title"><attributeAlias name="Title"/></attribute>
<attribute name="bounds"><attributeAlias name="Bounds"/></attribute>
<attribute name="layout"><attributeAlias name="Layout"/></attribute>
<attribute name="visible"><attributeAlias name="Visible"/></attribute>
<attribute name="resizable"><attributeAlias name="Resizable"/></attribute>
<attribute id="title"><attributeAlias name="Title"/></attribute>
<attribute id="bounds"><attributeAlias name="Bounds"/></attribute>
<attribute id="layout"><attributeAlias name="Layout"/></attribute>
<attribute id="visible"><attributeAlias name="Visible"/></attribute>
<attribute id="resizable"><attributeAlias name="Resizable"/></attribute>
</element>
</namespace>
</root:module>

View file

@ -46,7 +46,7 @@
<classBindingHandler id="JRootPane-JComponent" parentClass="javax.swing.JRootPane" childClass="javax.swing.JComponent" addMethod="add" getMethod="getComponents"/>
<elementInterface id="Component" interfaceClass="java.awt.Component">
<attribute name="bounds">
<attribute id="bounds">
<conv:stringSplitConverter classTo="java.awt.Rectangle" split="," splitSize="4" singleToMethod="setRect" useNativeType="true">
<conv:stringSplitConverterStep fromMethod="getX" fromOrder="1" toOrder="1"><conv:doubleConverter/></conv:stringSplitConverterStep>
<conv:stringSplitConverterStep fromMethod="getY" fromOrder="2" toOrder="2"><conv:doubleConverter/></conv:stringSplitConverterStep>
@ -54,31 +54,32 @@
<conv:stringSplitConverterStep fromMethod="getHeight" fromOrder="4" toOrder="4"><conv:doubleConverter/></conv:stringSplitConverterStep>
</conv:stringSplitConverter>
</attribute>
<attribute name="size">
<attribute id="size">
<conv:stringSplitConverter classTo="java.awt.Dimension" split="," splitSize="2" singleToMethod="setSize" useNativeType="true">
<conv:stringSplitConverterStep fromMethod="getHeight" fromOrder="1" toOrder="1"><conv:integerConverter/></conv:stringSplitConverterStep>
<conv:stringSplitConverterStep fromMethod="getWidth" fromOrder="2" toOrder="2"><conv:integerConverter/></conv:stringSplitConverterStep>
</conv:stringSplitConverter>
</attribute>
<attribute name="icon">
<attribute id="icon">
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.IconConverter"/>
</attribute>
<attribute name="background">
<attribute id="background">
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.ColorConverter"/>
</attribute>
<attribute name="location">
<attribute id="location">
<conv:stringSplitConverter classTo="java.awt.Point" split="," splitSize="2" singleToMethod="setLocation" useNativeType="true">
<conv:stringSplitConverterStep fromMethod="getX" fromOrder="1" toOrder="1"><conv:integerConverter/></conv:stringSplitConverterStep>
<conv:stringSplitConverterStep fromMethod="getY" fromOrder="2" toOrder="2"><conv:integerConverter/></conv:stringSplitConverterStep>
</conv:stringSplitConverter>
</attribute>
<attribute id="locationOnScreen" runBeanValue="false"/>
</elementInterface>
<elementInterface id="JComponent" interfaceClass="javax.swing.JComponent">
<attribute name="layout">
<attribute id="layout">
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.LayoutConverter"/>
</attribute>
<attribute name="border">
<attribute id="border">
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.BorderConverter"/>
</attribute>
</elementInterface>
@ -105,21 +106,21 @@
<element tag="JMenubar" objectClass="javax.swing.JMenuBar"/>
<element tag="JMenu" objectClass="javax.swing.JMenu"/>
<element tag="JMenuItem" objectClass="javax.swing.JMenuItem">
<attribute name="accelerator">
<attribute id="accelerator">
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.KeyStrokeConverter"/>
<attributeAlias name="Accelerator"/>
</attribute>
<attribute name="mnemonic" runBeanFill="false"/>
<attribute name="Action" runBeanFill="false"/>
<attribute id="mnemonic" runBeanValue="false"/>
<attribute id="Action" runBeanValue="false"/>
<configurator id="menuitem-action" bean.class="org.x4o.xml.test.swixml.SwiXmlActionConfigurator"/>
</element>
<element tag="JMenu.Separator" />
<element tag="JPanel" objectClass="javax.swing.JPanel"/>
<element tag="JSplitPane" objectClass="javax.swing.JSplitPane">
<attribute name="orientation">
<attribute id="orientation">
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.JSplitPaneOrientationConverter"/>
</attribute>
<attribute name="dividerLocation">
<attribute id="dividerLocation">
<conv:integerConverter/>
</attribute>
</element>

View file

@ -55,7 +55,7 @@
<eld:elementInterface id="Component" interfaceClass="java.awt.Component">
<eld:description>Configs the Component based objects.</eld:description>
<eld:attribute name="bounds">
<eld:attribute id="bounds">
<conv:stringSplitConverter classTo="java.awt.Rectangle" split="," splitSize="4" singleToMethod="setRect" useNativeType="true">
<conv:stringSplitConverterStep fromMethod="getX" fromOrder="1" toOrder="1"><conv:doubleConverter/></conv:stringSplitConverterStep>
<conv:stringSplitConverterStep fromMethod="getY" fromOrder="2" toOrder="2"><conv:doubleConverter/></conv:stringSplitConverterStep>

View file

@ -807,7 +807,7 @@ public class EldDocHtmlWriter {
private void printElementAttributes(PrintWriter pw,Collection<ElementClassAttribute> elementClassAttributes) {
printTableStart(pw,"Element Attributes");
for (ElementClassAttribute attr:elementClassAttributes) {
printTableRowSummary(pw,attr.getName(),attr.getDescription());
printTableRowSummary(pw,attr.getId(),attr.getDescription());
}
printTableEnd(pw);
}

View file

@ -22,7 +22,7 @@
*/
/**
* The X4O XML Meta Language.
* The XML Meta Language.
*
*
* @since 1.0

View file

@ -25,8 +25,6 @@ package org.x4o.xml.lang.meta;
import org.x4o.xml.X4ODriver;
import org.x4o.xml.X4ODriverManager;
import org.x4o.xml.io.X4OReaderContext;
import org.x4o.xml.io.X4OWriterContext;
public class MTestDriver extends X4ODriver<Object> {
@ -46,12 +44,4 @@ public class MTestDriver extends X4ODriver<Object> {
static public MTestDriver getInstance() {
return (MTestDriver)X4ODriverManager.getX4ODriver(LANGUAGE_NAME);
}
public X4OReaderContext<?> createReaderContext() {
return (X4OReaderContext<?>)super.createReader();
}
public X4OWriterContext<?> createWriterContext() {
return (X4OWriterContext<?>)super.createWriter();
}
}

View file

@ -121,7 +121,7 @@
<target>
<property name="coredir" value="${basedir}/../../x4o-driver/src/main/resources/META-INF"/>
<taskdef name="writeLanguageSchema" classname="org.x4o.plugin.ant.X4OWriteLanguageSchemaTask" classpathref="maven.plugin.classpath"/>
<writeLanguageSchema destdir="${coredir}/cel" languageName="eld"/>
<writeLanguageSchema destdir="${coredir}/eld" languageName="eld"/>
</target>
</configuration>
<goals>