Init commit of full project.
This commit is contained in:
parent
130d471bd9
commit
787b1174b0
286 changed files with 27010 additions and 1 deletions
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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.meta;
|
||||
|
||||
import org.x4o.xml.core.config.X4OLanguageLoader;
|
||||
import org.x4o.xml.core.config.X4OLanguageLoaderException;
|
||||
import org.x4o.xml.element.ElementLanguage;
|
||||
import org.x4o.xml.element.ElementLanguageModule;
|
||||
import org.x4o.xml.element.ElementLanguageModuleLoaderException;
|
||||
import org.x4o.xml.element.ElementLanguageModuleLoaderSibling;
|
||||
|
||||
/**
|
||||
* MetaLanguageSiblingLoader loads the generic x4o meta language into defined language.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 7, 2012
|
||||
*/
|
||||
public class MetaLanguageSiblingLoader implements ElementLanguageModuleLoaderSibling {
|
||||
|
||||
/** Defines the identifier of the meta x4o language. */
|
||||
public final static String META_LANGUAGE = "meta";
|
||||
|
||||
/** Defines the version of the meta x4o language. */
|
||||
public final static String META_LANGUAGE_VERSION = "1.0";
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementLanguageModuleLoader#loadLanguageModule(org.x4o.xml.element.ElementLanguage, org.x4o.xml.element.ElementLanguageModule)
|
||||
*/
|
||||
public void loadLanguageModule(ElementLanguage elementLanguage,ElementLanguageModule elementLanguageModule) throws ElementLanguageModuleLoaderException {
|
||||
elementLanguageModule.setId(META_LANGUAGE);
|
||||
elementLanguageModule.setName(META_LANGUAGE);
|
||||
elementLanguageModule.setProviderName(MetaLanguageSiblingLoader.class.getSimpleName());
|
||||
elementLanguageModule.setDescription("X4O Meta Language");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws X4OLanguageLoaderException
|
||||
* @see org.x4o.xml.element.ElementLanguageModuleLoaderSibling#loadLanguageSibling(org.x4o.xml.element.ElementLanguage, org.x4o.xml.core.config.X4OLanguageLoader)
|
||||
*/
|
||||
public void loadLanguageSibling(ElementLanguage elementLanguage,X4OLanguageLoader loader) throws X4OLanguageLoaderException {
|
||||
|
||||
// Load the meta language.
|
||||
loader.loadLanguage(elementLanguage, META_LANGUAGE, META_LANGUAGE_VERSION);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,176 @@
|
|||
/*
|
||||
* 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.meta.lang;
|
||||
|
||||
import java.lang.Comparable;
|
||||
import java.util.Comparator;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.x4o.xml.impl.DefaultElementObjectPropertyValue;
|
||||
|
||||
|
||||
/**
|
||||
* Compares a property of a java bean.
|
||||
* The property should be Comparable.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 11, 2006
|
||||
*/
|
||||
public class BeanPropertyComparator<T> implements Comparator<T> {
|
||||
|
||||
/** The propery of the bean to compare. */
|
||||
private String property = null;
|
||||
/** The logger to log to. */
|
||||
private Logger logger = null;
|
||||
/** The ascending */
|
||||
private boolean ascending = true;
|
||||
|
||||
private DefaultElementObjectPropertyValue helper = null;
|
||||
|
||||
/**
|
||||
* The constructor inits the logger.
|
||||
*/
|
||||
public BeanPropertyComparator() {
|
||||
logger = Logger.getLogger(BeanPropertyComparator.class.getName());
|
||||
helper = new DefaultElementObjectPropertyValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an BeanPropertyComparator with an property
|
||||
* @param property The property to compare to.
|
||||
*/
|
||||
public BeanPropertyComparator(String property) {
|
||||
this();
|
||||
setProperty(property);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an BeanPropertyComparator with an property
|
||||
* @param property
|
||||
*/
|
||||
public BeanPropertyComparator(String property,boolean ascending) {
|
||||
this();
|
||||
setProperty(property);
|
||||
setAscending(ascending);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares 2 objects by there Comparable property.
|
||||
*
|
||||
* @param o1 Object 1
|
||||
* @param o2 Object 2
|
||||
* @return the differce between the objects.
|
||||
*/
|
||||
public int compare(Object o1,Object o2) throws ClassCastException {
|
||||
|
||||
Comparable<Object> c1 = getComparableProperty(o1);
|
||||
Comparable<Object> c2 = getComparableProperty(o2);
|
||||
|
||||
if(c1==null && c2==null) {
|
||||
return 0;
|
||||
}
|
||||
if(c1==null) {
|
||||
if(ascending) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if(c2==null) {
|
||||
if(ascending) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if(ascending) {
|
||||
return c1.compareTo(c2);
|
||||
} else {
|
||||
return c2.compareTo(c1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Comparable property of the object.
|
||||
* @param object
|
||||
* @return
|
||||
* @throws ClassCastException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private Comparable<Object> getComparableProperty(Object object) throws ClassCastException {
|
||||
|
||||
if(property==null) {
|
||||
throw new IllegalStateException("property is not set.");
|
||||
}
|
||||
Object result = null;
|
||||
try {
|
||||
result = helper.getProperty(object,property);
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING,"property:"+property+" is not an property of object: "+object.getClass().getName(),e);
|
||||
}
|
||||
try {
|
||||
Comparable<Object> c = (Comparable<Object>)result;
|
||||
return c;
|
||||
} catch (ClassCastException e) {
|
||||
logger.log(Level.WARNING,"property:"+property+" is not Comparable",e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the property.
|
||||
*/
|
||||
public String getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param property The property to set.
|
||||
*/
|
||||
public void setProperty(String property) {
|
||||
if(property==null) {
|
||||
throw new NullPointerException("property may not be null");
|
||||
}
|
||||
this.property = property;
|
||||
logger.finest("property="+property);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the ascending.
|
||||
*/
|
||||
public boolean isAscending() {
|
||||
return ascending;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ascending The ascending to set.
|
||||
*/
|
||||
public void setAscending(boolean ascending) {
|
||||
this.ascending = ascending;
|
||||
logger.finest("ascending="+ascending);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* 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.meta.lang;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.el.ValueExpression;
|
||||
|
||||
import org.x4o.xml.element.AbstractElementAttributeHandler;
|
||||
import org.x4o.xml.element.Element;
|
||||
import org.x4o.xml.element.ElementConfiguratorException;
|
||||
|
||||
|
||||
/**
|
||||
* Stores an ElementObject into the EL context.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 23, 2006
|
||||
*/
|
||||
public class ELIDAttributeHandler extends AbstractElementAttributeHandler {
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementConfigurator#doConfigElement(org.x4o.xml.element.Element)
|
||||
*/
|
||||
public void doConfigElement(Element element) throws ElementConfiguratorException {
|
||||
String attributeValue = element.getAttributes().get(getAttributeName());
|
||||
if(attributeValue==null) { return; }
|
||||
if(element.getElementObject()==null) {
|
||||
if (this.isConfigAction()) {
|
||||
throw new NullPointerException("Can't bind null object to el context");
|
||||
}
|
||||
this.setConfigAction(true);
|
||||
return;
|
||||
}
|
||||
if(element.getElementObject()==null) { throw new NullPointerException("Can't bind null object to el context"); }
|
||||
ValueExpression ee = element.getElementLanguage().getExpressionFactory().createValueExpression(element.getElementLanguage().getELContext(),"${"+attributeValue+"}", element.getElementObject().getClass());
|
||||
Logger.getLogger(ELIDAttributeHandler.class.getName()).finer("Set Variable in ELContext: "+"${"+attributeValue+"}"+" object SET: "+element.getElementObject());
|
||||
ee.setValue(element.getElementLanguage().getELContext(), element.getElementObject());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* 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.meta.lang;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.el.ValueExpression;
|
||||
|
||||
import org.x4o.xml.element.AbstractElement;
|
||||
import org.x4o.xml.element.ElementException;
|
||||
|
||||
|
||||
/**
|
||||
* An ELReferenceElement.<br>
|
||||
* Fills the ElementObject with an object from el.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 23, 2007
|
||||
*/
|
||||
public class ELReferenceElement extends AbstractElement {
|
||||
|
||||
@Override
|
||||
public void doElementRun() throws ElementException {
|
||||
String attributeValue = getAttributes().get("el.ref");
|
||||
if("".equals(attributeValue) | attributeValue==null) { throw new ElementException("Set the el.ref attribute"); }
|
||||
ValueExpression ee = getElementLanguage().getExpressionFactory().createValueExpression(getElementLanguage().getELContext(),"${"+attributeValue+"}",Object.class);
|
||||
Logger.getLogger(ELReferenceElement.class.getName()).finer("Get Variable in ELContext: ${"+attributeValue+"}");
|
||||
setElementObject(ee.getValue(getElementLanguage().getELContext()));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* 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.meta.lang;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.x4o.xml.element.AbstractElement;
|
||||
import org.x4o.xml.element.ElementException;
|
||||
|
||||
|
||||
/**
|
||||
* MethodElement invokes an method on a element object.
|
||||
*
|
||||
* TODO: add args
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Nov 21, 2007
|
||||
*/
|
||||
public class MethodElement extends AbstractElement {
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.AbstractElement#doElementRun()
|
||||
*/
|
||||
@Override
|
||||
public void doElementRun() throws ElementException {
|
||||
if (getParent()==null) {
|
||||
throw new IllegalStateException("need to have parent.");
|
||||
}
|
||||
Object parent = getParent().getElementObject();
|
||||
if (parent==null) {
|
||||
throw new IllegalStateException("need to have parent ElementObject.");
|
||||
}
|
||||
String methodString = getAttributes().get("method");
|
||||
Method[] ms = parent.getClass().getMethods();
|
||||
try {
|
||||
for (Method m:ms) {
|
||||
if (methodString.equalsIgnoreCase(m.getName())) {
|
||||
m.invoke(parent);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new ElementException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new ElementException(e);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new ElementException(e);
|
||||
}
|
||||
throw new ElementException("could not find method on parent element object: "+methodString+" on; "+parent);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* 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.meta.lang;
|
||||
|
||||
import org.x4o.xml.element.AbstractElement;
|
||||
|
||||
/**
|
||||
* An ParentObjectElement.<br>
|
||||
* This Element only uses its parent ElementObject.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 14, 2007
|
||||
*/
|
||||
public class ParentObjectElement extends AbstractElement {
|
||||
|
||||
@Override
|
||||
public Object getElementObject() {
|
||||
if (getParent()==null) {
|
||||
return null;
|
||||
}
|
||||
return getParent().getElementObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setElementObject(Object object) {
|
||||
if (getParent()==null) {
|
||||
return;
|
||||
}
|
||||
getParent().setElementObject(object);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* 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.meta.lang;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
import org.x4o.xml.conv.ObjectConverterException;
|
||||
import org.x4o.xml.eld.lang.BeanElement;
|
||||
import org.x4o.xml.element.AbstractElement;
|
||||
import org.x4o.xml.element.ElementException;
|
||||
|
||||
|
||||
/**
|
||||
* An PropertyElement.<br>
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 14, 2007
|
||||
*/
|
||||
public class PropertyElement extends AbstractElement {
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.AbstractElement#doElementStart()
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void doElementRun() throws ElementException {
|
||||
|
||||
if (getParent().getElementObject()==null) {
|
||||
throw new IllegalStateException("need to have parent ElementObject");
|
||||
}
|
||||
|
||||
String name = getAttributes().get("key");
|
||||
String valueString = getAttributes().get("value");
|
||||
Object value = valueString;
|
||||
|
||||
if (name==null) {
|
||||
name = getAttributes().get("name");
|
||||
}
|
||||
if (name==null) {
|
||||
name = getAttributes().get("field");
|
||||
}
|
||||
|
||||
// convert value object
|
||||
try {
|
||||
value = getElementLanguage().getElementAttributeValueParser().getParameterValue(name,valueString,this);
|
||||
} catch (ObjectConverterException ece) {
|
||||
throw new ElementException(ece);
|
||||
}
|
||||
|
||||
if (getParent() instanceof BeanElement) {
|
||||
BeanElement bean = (BeanElement)getParent();
|
||||
bean.addConstuctorArgument(value);
|
||||
return;
|
||||
}
|
||||
|
||||
if (name==null) {
|
||||
throw new IllegalStateException("Can't set properties without key.");
|
||||
}
|
||||
|
||||
// check map interface
|
||||
if (getParent().getElementObject() instanceof Map) {
|
||||
((Map)getParent().getElementObject()).put(name,value);
|
||||
return;
|
||||
}
|
||||
|
||||
// check for setProperty(String,Object) method
|
||||
Method[] methodes = getParent().getElementObject().getClass().getMethods();
|
||||
for (int i=0;i<methodes.length;i++) {
|
||||
Method method = methodes[i];
|
||||
if (method.getName().toLowerCase().equals("setproperty")) {
|
||||
try {
|
||||
method.invoke(getParent().getElementObject(),new Object[]{name,value});
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// try to set as property on bean.
|
||||
try {
|
||||
getElementLanguage().getElementObjectPropertyValue().setProperty(getParent().getElementObject(), name, value);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
throw new ElementException("could not set property on parent element object: "+name,e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The X4O XML Meta Language Classes.
|
||||
*
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
package org.x4o.xml.meta.lang;
|
||||
31
x4o-meta/src/main/java/org/x4o/xml/meta/package-info.java
Normal file
31
x4o-meta/src/main/java/org/x4o/xml/meta/package-info.java
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The X4O XML Meta Language Loader.
|
||||
*
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
package org.x4o.xml.meta;
|
||||
89
x4o-meta/src/main/resources/META-INF/meta/meta-lang.eld
Normal file
89
x4o-meta/src/main/resources/META-INF/meta/meta-lang.eld
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
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.
|
||||
|
||||
-->
|
||||
<root:module
|
||||
xmlns:eld="http://eld.x4o.org/xml/ns/eld-lang"
|
||||
xmlns:root="http://eld.x4o.org/xml/ns/eld-root"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://eld.x4o.org/xml/ns/eld-root http://eld.x4o.org/xml/ns/eld-root-1.0.xsd"
|
||||
name="Meta Language Definition"
|
||||
providerName="x4o.org"
|
||||
id="meta-lang"
|
||||
>
|
||||
<eld:attributeHandler id="global-el-id" attributeName="el.id" bean.class="org.x4o.xml.meta.lang.ELIDAttributeHandler">
|
||||
<eld:description>Lets you bind object into the expression language context.</eld:description>
|
||||
</eld:attributeHandler>
|
||||
<eld:namespace
|
||||
uri="http://meta.x4o.org/xml/ns/meta-lang"
|
||||
schemaUri="http://meta.x4o.org/xml/ns/meta-lang-1.0.xsd"
|
||||
schemaResource="meta-lang-1.0.xsd"
|
||||
name="X4O Meta Language"
|
||||
>
|
||||
|
||||
<eld:element tag="bean" elementClass="org.x4o.xml.eld.lang.BeanElement">
|
||||
<eld:description>
|
||||
This tag is used for creating dynamicly an bean from an classname.
|
||||
And sets it into the ElementContext so it can be used by anything that is global or works on interfaces.
|
||||
</eld:description>
|
||||
</eld:element>
|
||||
|
||||
<eld:element tag="elReference" elementClass="org.x4o.xml.meta.lang.ELReferenceElement">
|
||||
<eld:description>
|
||||
Used to get a reference of an Object into the Element tree.
|
||||
Mostly used in combination with the el.id tag.
|
||||
</eld:description>
|
||||
</eld:element>
|
||||
|
||||
<eld:element tag="parentObject" elementClass="org.x4o.xml.meta.lang.ParentObjectElement">
|
||||
<eld:description>
|
||||
Hack in ElementTree, fills this Element with the ElementObject of his parent Element.
|
||||
</eld:description>
|
||||
</eld:element>
|
||||
|
||||
<eld:element tag="property" elementClass="org.x4o.xml.meta.lang.PropertyElement">
|
||||
<eld:description>
|
||||
Set an property value on the object of the parent Element.
|
||||
|
||||
Uses some magic to try and set the property.
|
||||
</eld:description>
|
||||
</eld:element>
|
||||
|
||||
<eld:element tag="method" elementClass="org.x4o.xml.meta.lang.MethodElement">
|
||||
<eld:description>
|
||||
Executes an Method of an Object.
|
||||
</eld:description>
|
||||
</eld:element>
|
||||
|
||||
</eld:namespace>
|
||||
<!--
|
||||
<eld:namespace
|
||||
uri="http://meta.x4o.org/xml/ns/meta-reference"
|
||||
schemaUri="http://meta.x4o.org/xml/xsd/meta-reference"
|
||||
schemaResource="meta-reference.xsd"
|
||||
name="X4O Meta Language"
|
||||
>
|
||||
</eld:namespace>
|
||||
-->
|
||||
</root:module>
|
||||
34
x4o-meta/src/main/resources/META-INF/meta/meta-modules.xml
Normal file
34
x4o-meta/src/main/resources/META-INF/meta/meta-modules.xml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
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.
|
||||
|
||||
-->
|
||||
<modules version="1.0"
|
||||
xmlns="http://language.x4o.org/xml/ns/modules"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://language.x4o.org/xml/ns/modules http://language.x4o.org/xml/ns/modules-1.0.xsd"
|
||||
>
|
||||
<language version="1.0">
|
||||
<eld-resource>meta-lang.eld</eld-resource>
|
||||
</language>
|
||||
</modules>
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* 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.meta;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.x4o.xml.core.config.X4OLanguagePropertyKeys;
|
||||
import org.x4o.xml.meta.test.MTestParser;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Tests a simple x4o meta xml language.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jul 24, 2006
|
||||
*/
|
||||
public class ReferenceStoreTest extends TestCase {
|
||||
|
||||
public void testMetaGeneric() throws Exception {
|
||||
MTestParser parser = new MTestParser();
|
||||
parser.setProperty(X4OLanguagePropertyKeys.PHASE_SKIP_RELEASE, true);
|
||||
try {
|
||||
parser.parseResource("tests/meta-generic.xml");
|
||||
assertEquals(Date.class.getName(),parser.getElementLanguage().getRootElement().getChilderen().get(0).getElementObject().getClass().getName());
|
||||
} finally {
|
||||
parser.doReleasePhaseManual();
|
||||
}
|
||||
}
|
||||
|
||||
public void testLoadClass() throws Exception {
|
||||
MTestParser parser = new MTestParser();
|
||||
parser.setProperty(X4OLanguagePropertyKeys.PHASE_SKIP_RELEASE, true);
|
||||
try {
|
||||
parser.parseResource("tests/reference/store-ref.xml");
|
||||
assertEquals(Date.class.getName(),parser.getElementLanguage().getRootElement().getChilderen().get(0).getElementObject().getClass().getName());
|
||||
} finally {
|
||||
parser.doReleasePhaseManual();
|
||||
}
|
||||
}
|
||||
|
||||
public void testStoreRef() throws Exception {
|
||||
MTestParser parser = new MTestParser();
|
||||
parser.setProperty(X4OLanguagePropertyKeys.PHASE_SKIP_RELEASE, true);
|
||||
try {
|
||||
parser.parseResource("tests/reference/store-ref.xml");
|
||||
assertEquals(Date.class.getName(),parser.getElementLanguage().getRootElement().getChilderen().get(0).getElementObject().getClass().getName());
|
||||
assertEquals(Date.class.getName(),parser.getElementLanguage().getRootElement().getChilderen().get(1).getElementObject().getClass().getName());
|
||||
assertEquals(Date.class.getName(),parser.getElementLanguage().getRootElement().getChilderen().get(2).getElementObject().getClass().getName());
|
||||
assertEquals(Date.class.getName(),parser.getElementLanguage().getRootElement().getChilderen().get(3).getElementObject().getClass().getName());
|
||||
} finally {
|
||||
parser.doReleasePhaseManual();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* 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.meta.test;
|
||||
|
||||
import org.x4o.xml.core.X4ODriver;
|
||||
import org.x4o.xml.core.X4OParser;
|
||||
import org.x4o.xml.element.ElementLanguage;
|
||||
|
||||
public class MTestParser extends X4OParser {
|
||||
|
||||
public MTestParser() {
|
||||
super("mtest");
|
||||
}
|
||||
|
||||
public ElementLanguage getElementLanguage() {
|
||||
return getDriver().getElementLanguage();
|
||||
}
|
||||
|
||||
public X4ODriver getDriver() {
|
||||
return super.getDriver();
|
||||
}
|
||||
}
|
||||
66
x4o-meta/src/test/resources/META-INF/mtest/mtest-lang.eld
Normal file
66
x4o-meta/src/test/resources/META-INF/mtest/mtest-lang.eld
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
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.
|
||||
|
||||
-->
|
||||
<root:module
|
||||
xmlns:root="http://eld.x4o.org/xml/ns/eld-root"
|
||||
xmlns:eld="http://eld.x4o.org/xml/ns/eld-lang"
|
||||
xmlns:conv="http://eld.x4o.org/xml/ns/eld-conv"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://eld.x4o.org/xml/ns/eld-root http://eld.x4o.org/xml/ns/eld-root-1.0.xsd"
|
||||
providerName="mtest.x4o.org"
|
||||
name="Meta Test Language"
|
||||
id="mtest-lang"
|
||||
>
|
||||
<eld:namespace
|
||||
uri="http://mtest.x4o.org/xml/ns/mtest-root"
|
||||
schemaUri="http://mtest.x4o.org/xml/ns/mtest-root-1.0.xsd"
|
||||
schemaResource="mtest-root-1.0.xsd"
|
||||
schemaPrefix="mroot"
|
||||
name="MTest Root Namespace"
|
||||
languageRoot="true"
|
||||
>
|
||||
<!-- Root Element for nice namespace'ing -->
|
||||
<eld:element tag="root" objectClass="java.lang.Object">
|
||||
<eld:description>The test root element.</eld:description>
|
||||
</eld:element>
|
||||
</eld:namespace>
|
||||
|
||||
<eld:namespace
|
||||
uri="http://mtest.x4o.org/xml/ns/mtest-lang"
|
||||
schemaUri="http://mtest.x4o.org/xml/ns/mtest-lang-1.0.xsd"
|
||||
schemaResource="mtest-lang-1.0.xsd"
|
||||
schemaPrefix="mlang"
|
||||
name="MTest Language Namespace"
|
||||
>
|
||||
<eld:element tag="date" objectClass="java.util.Date"/>
|
||||
<eld:element tag="JFrame" objectClass="javax.swing.JFrame"/>
|
||||
<eld:element tag="JLabel" objectClass="javax.swing.JLabel"/>
|
||||
<eld:element tag="JPanel" objectClass="javax.swing.JPanel"/>
|
||||
<eld:element tag="JTextField" objectClass="javax.swing.JTextField"/>
|
||||
<eld:element tag="JTextArea" objectClass="javax.swing.JTextArea"/>
|
||||
<eld:element tag="JScrollPane" objectClass="javax.swing.JScrollPane"/>
|
||||
|
||||
</eld:namespace>
|
||||
</root:module>
|
||||
35
x4o-meta/src/test/resources/META-INF/mtest/mtest-modules.xml
Normal file
35
x4o-meta/src/test/resources/META-INF/mtest/mtest-modules.xml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
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.
|
||||
|
||||
-->
|
||||
<modules version="1.0"
|
||||
xmlns="http://language.x4o.org/xml/ns/modules"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://language.x4o.org/xml/ns/modules http://language.x4o.org/xml/ns/modules-1.0.xsd"
|
||||
>
|
||||
<language version="1.0">
|
||||
<eld-resource>mtest-lang.eld</eld-resource>
|
||||
<sibling-loader>org.x4o.xml.meta.MetaLanguageSiblingLoader</sibling-loader>
|
||||
</language>
|
||||
</modules>
|
||||
39
x4o-meta/src/test/resources/tests/meta-generic.xml
Normal file
39
x4o-meta/src/test/resources/tests/meta-generic.xml
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
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.
|
||||
|
||||
-->
|
||||
<tree:root
|
||||
xmlns:tree="http://mtest.x4o.org/xml/ns/mtest-root"
|
||||
xmlns:mt="http://mtest.x4o.org/xml/ns/mtest-lang"
|
||||
xmlns:x4o="http://meta.x4o.org/xml/ns/meta-lang"
|
||||
>
|
||||
<x4o:bean el.id="date0" bean.class="java.util.Date"/>
|
||||
<mt:JLabel>
|
||||
<x4o:property name="text" value="label text"/>
|
||||
<x4o:method method="validate"/>
|
||||
<x4o:parentObject>
|
||||
<x4o:property name="text" value="label text2"/>
|
||||
</x4o:parentObject>
|
||||
</mt:JLabel>
|
||||
</tree:root>
|
||||
35
x4o-meta/src/test/resources/tests/reference/store-ref.xml
Normal file
35
x4o-meta/src/test/resources/tests/reference/store-ref.xml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
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.
|
||||
|
||||
-->
|
||||
<tree:root
|
||||
xmlns:tree="http://mtest.x4o.org/xml/ns/mtest-root"
|
||||
xmlns:mt="http://mtest.x4o.org/xml/ns/mtest-lang"
|
||||
xmlns:x4o="http://meta.x4o.org/xml/ns/meta-lang"
|
||||
>
|
||||
<x4o:bean el.id="date0" bean.class="java.util.Date"/>
|
||||
<x4o:elReference el.id="date1" el.ref="date0"/>
|
||||
<x4o:elReference el.id="date2" el.ref="date0"/>
|
||||
<x4o:elReference el.id="date3" el.ref="date0"/>
|
||||
</tree:root>
|
||||
61
x4o-meta/src/test/resources/tests/template/bean-template.xml
Normal file
61
x4o-meta/src/test/resources/tests/template/bean-template.xml
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
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.
|
||||
|
||||
-->
|
||||
<x4o:root xmlns:x4o="http://meta.x4o.org/xml/ns/meta-lang">
|
||||
<x4o:bean el.id="date0" bean.class="java.util.Date"/>
|
||||
|
||||
<x4o:template el.id="superBean">
|
||||
<x4o:bean bean.class="org.x4o.xml.core.TestBean"
|
||||
privateIntegerTypeField="333"
|
||||
privateIntegerObjectField="333"
|
||||
privateLongTypeField="333"
|
||||
privateLongObjectField="333"
|
||||
privateDoubleTypeField="333.333"
|
||||
privateDoubleObjectField = "333.333"
|
||||
privateFloatTypeField="333.333"
|
||||
privateFloatObjectField="333.333"
|
||||
privateByteTypeField="333"
|
||||
privateByteObjectField="333"
|
||||
privateBooleanTypeField="true"
|
||||
privateBooleanObjectField="true"
|
||||
privateCharTypeField="W"
|
||||
privateCharObjectField="C"
|
||||
privateStringObjectField="x4o"
|
||||
privateDateObjectField="${date0}"
|
||||
/>
|
||||
</x4o:template>
|
||||
<x4o:bean el.id="bean1" el.template="superBean" privateLongTypeField="444"/>
|
||||
<x4o:bean el.id="bean2" el.template="superBean" privateBooleanTypeField="false"/>
|
||||
<x4o:bean el.id="bean3" el.template="superBean" privateStringObjectField="testTemplate"/>
|
||||
|
||||
<x4o:forLoop var="item" value="">
|
||||
<x4o:bean el.id="bean1" el.template="superBean" privateStringObjectField="${item}"/>
|
||||
</x4o:forLoop>
|
||||
|
||||
<x4o:for start="0" stop="200" var="i">
|
||||
<entry key="prop${i}" parent.template="${defaultProp}">value${i+250}</entry>
|
||||
</x4o:for>
|
||||
|
||||
</x4o:root>
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
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.
|
||||
|
||||
-->
|
||||
<x4o:root xmlns:test="http://test.x4o.org/xml/ns/test"
|
||||
xmlns:x4o="http://meta.x4o.org/xml/ns/meta-lang"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://meta.x4o.org/xml/ns/meta-lang http://meta.x4o.org/xml/xsd/meta-lang/1
|
||||
http://test.x4o.org/xml/ns/test http://test.x4o.org/xml/ns/test-1.0.xsd"
|
||||
>
|
||||
|
||||
<x4o:template el.id="master1">
|
||||
<test:testObjectChild el.id="CHILD1" name="CHILD1" price="123" size="123.45"/>
|
||||
</x4o:template>
|
||||
<test:testObjectChild el.id="child1" size="123.99" x4o.template="master1"/>
|
||||
|
||||
<x4o:template el.id="master2">
|
||||
<test:testObjectChild el.id="CHILD2" name="CHILD2" price="2323" size="23.24"/>
|
||||
</x4o:template>
|
||||
<x4o:elReference el.id="child2" el.ref="child2" x4o.template="master2"/>
|
||||
|
||||
<test:testObjectParent el.id="parent2">
|
||||
<x4o:templateTag template="${master2}"/>
|
||||
</test:testObjectParent>
|
||||
|
||||
</x4o:root>
|
||||
Loading…
Add table
Add a link
Reference in a new issue