Added release upload script and added more java doc.

This commit is contained in:
Willem Cazander 2013-01-12 03:39:37 +01:00
parent bcce73b2ad
commit 6f4eca935e
49 changed files with 905 additions and 270 deletions

View file

@ -48,7 +48,7 @@ note: the do 'install' is because of circle plugins.
cd project-root/;
mvn clean package;
mvn -B -Dusername=<scm_username> clean install release:clean release:prepare release:perform;
src/build/gnu-up.sh <scm_username> <version>
src/main/build/gnu-up.sh <scm_username> <version>
-- Make site --

61
src/main/build/gnu-up.sh Executable file
View file

@ -0,0 +1,61 @@
#!/bin/sh
#
# Copyright (c) 2013, 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.
#
#
# Small script to sign and upload files to savannah
#
if [ "" == "$1" ]; then
echo "No username given to upload.";
exit 1;
fi;
if [ "" == "$2" ];then
echo "No upload dir given.";
exit 1;
fi;
# Goto project root;
cd `dirname $0`/../../..;
# Copy to one new dir.
mkdir -p target/gnu-up/$2;
cp x4o-core/target/x4o-core-*.jar target/gnu-up/$2;
cp x4o-elddoc/target/x4o-elddoc-*.jar target/gnu-up/$2;
cp x4o-meta/target/x4o-meta-*.jar target/gnu-up/$2;
cp x4o-plugin/x4o-plugin-ant-elddoc/target/x4o-plugin-ant-elddoc-*.jar target/gnu-up/$2;
cp x4o-plugin/x4o-plugin-ant-schema/target/x4o-plugin-ant-schema-*.jar target/gnu-up/$2;
# Sign per file we want to upload.
for FILE in `ls target/gnu-up/$2/*`; do
gpg -b --use-agent $FILE;
done;
# Make sure readable
chmod 644 target/gnu-up/$2/*;
# And copy with new dir to gnu
scp -r target/gnu-up/$2 $1@dl.sv.nongnu.org:/releases/x4o/;
echo "Done";
exit 0;

View file

@ -141,7 +141,9 @@
<module name="AvoidInlineConditionals"/>
<module name="DoubleCheckedLocking"/>
<module name="EmptyStatement"/>
<module name="HiddenField"/>
<module name="HiddenField">
<property name="tokens" value="VARIABLE_DEF"/>
</module>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<!--

View file

@ -38,7 +38,7 @@ import org.x4o.xml.conv.text.LongConverter;
import org.x4o.xml.conv.text.URLConverter;
/**
* DefaultObjectConverterProvider.
* DefaultObjectConverterProvider holds the defined converts.
*
* @author Willem Cazander
* @version 1.0 Jan 20, 2012
@ -89,11 +89,16 @@ public class DefaultObjectConverterProvider implements ObjectConverterProvider {
/**
* @see org.x4o.xml.conv.ObjectConverterProvider#getObjectConverterForClass(java.lang.Class)
* @param clazz The Class to search an ObjectConverter for.
* @return The ObjectConverter or null for the class.
*/
public ObjectConverter getObjectConverterForClass(Class<?> clazz) {
return converters.get(clazz);
}
/**
* @return Returns all ObjectConverted stored in this class.
*/
protected Collection<ObjectConverter> getObjectConverters() {
return converters.values();
}

View file

@ -50,7 +50,7 @@ public interface ObjectConverter extends Cloneable,Serializable {
* @param obj The object to convert.
* @param locale The Object convert locale if needed.
* @return Returns the converted object.
* @throws ObjectConverterException
* @throws ObjectConverterException When the conversion failes.
*/
Object convertTo(Object obj,Locale locale) throws ObjectConverterException;
@ -59,7 +59,7 @@ public interface ObjectConverter extends Cloneable,Serializable {
* @param obj The object to convert.
* @param locale The Object convert locale if needed.
* @return Returns the converted object.
* @throws ObjectConverterException
* @throws ObjectConverterException When the conversion failes.
*/
Object convertBack(Object obj,Locale locale) throws ObjectConverterException;

View file

@ -39,19 +39,48 @@ public class BooleanConverter extends AbstractStringObjectConverter {
private static final long serialVersionUID = -6641858854858931768L;
/**
* Returns the convert to class.
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
* @return The class to convert to.
*/
public Class<?> getObjectClassTo() {
return Boolean.class;
}
/**
* Converts string into object.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
* @param str The string to convert to object.
* @param locale The locale to convert the string from.
* @return The object converted from the string.
* @throws ObjectConverterException When conversion fails.
*/
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
// WARNING: this alway returns a boolean :''(
return Boolean.valueOf(str);
}
/**
* Converts object into string.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
* @param obj The object to convert to string.
* @param locale The locale to convert the object from.
* @return The string converted from the object.
* @throws ObjectConverterException When conversion fails.
*/
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Boolean)obj).toString();
}
/**
* Clone this ObjectConverter.
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
* @return The cloned ObjectConverter.
* @throws CloneNotSupportedException When cloning fails.
*/
@Override
public ObjectConverter clone() throws CloneNotSupportedException {
BooleanConverter result = new BooleanConverter();

View file

@ -39,18 +39,47 @@ public class ByteConverter extends AbstractStringObjectConverter {
private static final long serialVersionUID = -719929830363810123L;
/**
* Returns the convert to class.
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
* @return The class to convert to.
*/
public Class<?> getObjectClassTo() {
return Byte.class;
}
/**
* Converts string into object.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
* @param str The string to convert to object.
* @param locale The locale to convert the string from.
* @return The object converted from the string.
* @throws ObjectConverterException When conversion fails.
*/
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
return new Byte(str);
}
/**
* Converts object into string.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
* @param obj The object to convert to string.
* @param locale The locale to convert the object from.
* @return The string converted from the object.
* @throws ObjectConverterException When conversion fails.
*/
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Byte)obj).toString();
}
/**
* Clone this ObjectConverter.
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
* @return The cloned ObjectConverter.
* @throws CloneNotSupportedException When cloning fails.
*/
@Override
public ObjectConverter clone() throws CloneNotSupportedException {
ByteConverter result = new ByteConverter();

View file

@ -39,18 +39,47 @@ public class CharacterConverter extends AbstractStringObjectConverter {
private static final long serialVersionUID = -5864405229292234565L;
/**
* Returns the convert to class.
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
* @return The class to convert to.
*/
public Class<?> getObjectClassTo() {
return Character.class;
}
/**
* Converts string into object.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
* @param str The string to convert to object.
* @param locale The locale to convert the string from.
* @return The object converted from the string.
* @throws ObjectConverterException When conversion fails.
*/
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
return new Character(str.charAt(0));
}
/**
* Converts object into string.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
* @param obj The object to convert to string.
* @param locale The locale to convert the object from.
* @return The string converted from the object.
* @throws ObjectConverterException When conversion fails.
*/
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Character)obj).toString();
}
/**
* Clone this ObjectConverter.
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
* @return The cloned ObjectConverter.
* @throws CloneNotSupportedException When cloning fails.
*/
@Override
public ObjectConverter clone() throws CloneNotSupportedException {
CharacterConverter result = new CharacterConverter();

View file

@ -40,10 +40,24 @@ public class ClassConverter extends AbstractStringObjectConverter {
private static final long serialVersionUID = -1992327327215087127L;
/**
* Returns the convert to class.
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
* @return The class to convert to.
*/
public Class<?> getObjectClassTo() {
return Class.class;
}
/**
* Converts string into object.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
* @param str The string to convert to object.
* @param locale The locale to convert the string from.
* @return The object converted from the string.
* @throws ObjectConverterException When conversion fails.
*/
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
try {
return X4OLanguageClassLoader.loadClass(str);
@ -52,10 +66,25 @@ public class ClassConverter extends AbstractStringObjectConverter {
}
}
/**
* Converts object into string.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
* @param obj The object to convert to string.
* @param locale The locale to convert the object from.
* @return The string converted from the object.
* @throws ObjectConverterException When conversion fails.
*/
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Class<?>)obj).getName();
}
/**
* Clone this ObjectConverter.
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
* @return The cloned ObjectConverter.
* @throws CloneNotSupportedException When cloning fails.
*/
@Override
public ObjectConverter clone() throws CloneNotSupportedException {
ClassConverter result = new ClassConverter();

View file

@ -39,18 +39,47 @@ public class DoubleConverter extends AbstractStringObjectConverter {
private static final long serialVersionUID = 3283317726435306051L;
/**
* Returns the convert to class.
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
* @return The class to convert to.
*/
public Class<?> getObjectClassTo() {
return Double.class;
}
/**
* Converts string into object.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
* @param str The string to convert to object.
* @param locale The locale to convert the string from.
* @return The object converted from the string.
* @throws ObjectConverterException When conversion fails.
*/
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
return new Double(str);
}
/**
* Converts object into string.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
* @param obj The object to convert to string.
* @param locale The locale to convert the object from.
* @return The string converted from the object.
* @throws ObjectConverterException When conversion fails.
*/
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Double)obj).toString();
}
/**
* Clone this ObjectConverter.
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
* @return The cloned ObjectConverter.
* @throws CloneNotSupportedException When cloning fails.
*/
@Override
public ObjectConverter clone() throws CloneNotSupportedException {
DoubleConverter result = new DoubleConverter();

View file

@ -47,11 +47,24 @@ public class EnumConverter extends AbstractStringObjectConverter {
private Class enumObjectClass = null;
/**
* Returns the convert to class.
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
* @return The class to convert to.
*/
public Class<?> getObjectClassTo() {
return Enum.class;
}
/**
* Converts string into object.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
* @param str The string to convert to object.
* @param locale The locale to convert the string from.
* @return The object converted from the string.
* @throws ObjectConverterException When conversion fails.
*/
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
if (getEnumClass()==null) {
throw new ObjectConverterException(this,"enumClass String attribute is not set.");
@ -73,6 +86,15 @@ public class EnumConverter extends AbstractStringObjectConverter {
}
}
/**
* Converts object into string.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
* @param obj The object to convert to string.
* @param locale The locale to convert the object from.
* @return The string converted from the object.
* @throws ObjectConverterException When conversion fails.
*/
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Enum<?>)obj).name();
}
@ -92,6 +114,12 @@ public class EnumConverter extends AbstractStringObjectConverter {
this.enumClass = enumClass;
}
/**
* Clone this ObjectConverter.
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
* @return The cloned ObjectConverter.
* @throws CloneNotSupportedException When cloning fails.
*/
@Override
public ObjectConverter clone() throws CloneNotSupportedException {
EnumConverter result = new EnumConverter();

View file

@ -39,18 +39,47 @@ public class FloatConverter extends AbstractStringObjectConverter {
private static final long serialVersionUID = 8038640125557062170L;
/**
* Returns the convert to class.
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
* @return The class to convert to.
*/
public Class<?> getObjectClassTo() {
return Float.class;
}
/**
* Converts string into object.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
* @param str The string to convert to object.
* @param locale The locale to convert the string from.
* @return The object converted from the string.
* @throws ObjectConverterException When conversion fails.
*/
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
return new Float(str);
}
/**
* Converts object into string.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
* @param obj The object to convert to string.
* @param locale The locale to convert the object from.
* @return The string converted from the object.
* @throws ObjectConverterException When conversion fails.
*/
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Float)obj).toString();
}
/**
* Clone this ObjectConverter.
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
* @return The cloned ObjectConverter.
* @throws CloneNotSupportedException When cloning fails.
*/
@Override
public ObjectConverter clone() throws CloneNotSupportedException {
FloatConverter result = new FloatConverter();

View file

@ -39,18 +39,47 @@ public class IntegerConverter extends AbstractStringObjectConverter {
private static final long serialVersionUID = 6618552093124468324L;
/**
* Returns the convert to class.
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
* @return The class to convert to.
*/
public Class<?> getObjectClassTo() {
return Integer.class;
}
/**
* Converts string into object.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
* @param str The string to convert to object.
* @param locale The locale to convert the string from.
* @return The object converted from the string.
* @throws ObjectConverterException When conversion fails.
*/
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
return new Integer(str);
}
/**
* Converts object into string.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
* @param obj The object to convert to string.
* @param locale The locale to convert the object from.
* @return The string converted from the object.
* @throws ObjectConverterException When conversion fails.
*/
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Integer)obj).toString();
}
/**
* Clone this ObjectConverter.
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
* @return The cloned ObjectConverter.
* @throws CloneNotSupportedException When cloning fails.
*/
@Override
public ObjectConverter clone() throws CloneNotSupportedException {
IntegerConverter result = new IntegerConverter();

View file

@ -39,18 +39,47 @@ public class LongConverter extends AbstractStringObjectConverter {
private static final long serialVersionUID = 25132217809739854L;
/**
* Returns the convert to class.
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
* @return The class to convert to.
*/
public Class<?> getObjectClassTo() {
return Long.class;
}
/**
* Converts string into object.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
* @param str The string to convert to object.
* @param locale The locale to convert the string from.
* @return The object converted from the string.
* @throws ObjectConverterException When conversion fails.
*/
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
return new Long(str);
}
/**
* Converts object into string.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
* @param obj The object to convert to string.
* @param locale The locale to convert the object from.
* @return The string converted from the object.
* @throws ObjectConverterException When conversion fails.
*/
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Long)obj).toString();
}
/**
* Clone this ObjectConverter.
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
* @return The cloned ObjectConverter.
* @throws CloneNotSupportedException When cloning fails.
*/
@Override
public ObjectConverter clone() throws CloneNotSupportedException {
LongConverter result = new LongConverter();

View file

@ -55,10 +55,24 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
stringSplitConverterSteps = new ArrayList<StringSplitConverterStep>(10);
}
/**
* Returns the convert to class.
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
* @return The class to convert to.
*/
public Class<?> getObjectClassTo() {
return classTo;
}
/**
* Converts string into object.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
* @param str The string to convert to object.
* @param locale The locale to convert the string from.
* @return The object converted from the string.
* @throws ObjectConverterException When conversion fails.
*/
@SuppressWarnings("rawtypes")
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
if (split==null) {
@ -118,6 +132,15 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
}
}
/**
* Converts object into string.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
* @param obj The object to convert to string.
* @param locale The locale to convert the object from.
* @return The string converted from the object.
* @throws ObjectConverterException When conversion fails.
*/
public String convertStringBack(Object object,Locale locale) throws ObjectConverterException {
List<StringSplitConverterStep> steps = getOrderedSteps(false);
if (steps.size()!=splitSize) {
@ -138,6 +161,12 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
}
}
/**
* Clone this ObjectConverter.
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
* @return The cloned ObjectConverter.
* @throws CloneNotSupportedException When cloning fails.
*/
@Override
public ObjectConverter clone() throws CloneNotSupportedException {
StringSplitConverter result = new StringSplitConverter();

View file

@ -42,14 +42,22 @@ public class URLConverter extends AbstractStringObjectConverter {
private static final long serialVersionUID = -611843641266301893L;
/**
* Returns the convert to class.
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
* @return The class to convert to.
*/
public Class<?> getObjectClassTo() {
return URL.class;
}
/**
* Converts string into object.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
* @param str The string to convert to object.
* @param locale The locale to convert the string from.
* @return The object converted from the string.
* @throws ObjectConverterException When conversion fails.
*/
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
try {
@ -60,14 +68,23 @@ public class URLConverter extends AbstractStringObjectConverter {
}
/**
* Converts object into string.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
* @param obj The object to convert to string.
* @param locale The locale to convert the object from.
* @return The string converted from the object.
* @throws ObjectConverterException When conversion fails.
*/
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((URL)obj).toString();
}
/**
* Clone this ObjectConverter.
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
* @return The cloned ObjectConverter.
* @throws CloneNotSupportedException When cloning fails.
*/
@Override
public ObjectConverter clone() throws CloneNotSupportedException {

View file

@ -31,7 +31,7 @@ import org.x4o.xml.element.ElementLanguage;
/**
* An base class for creating X4OPhaseHandlers.
* AbstractX4OPhaseHandler a base class for creating a phase handler.
*
* @author Willem Cazander
* @version 1.0 Dec 31, 2008
@ -39,38 +39,73 @@ import org.x4o.xml.element.ElementLanguage;
public abstract class AbstractX4OPhaseHandler implements X4OPhaseHandler {
protected X4OPhase phase = null;
protected List<X4OPhaseListener> X4OPhaseListeners = null;
protected List<X4OPhaseListener> phaseListeners = null;
/**
* Creates the AbstractX4OPhaseHandler.
*/
public AbstractX4OPhaseHandler() {
X4OPhaseListeners = new ArrayList<X4OPhaseListener>(3);
phaseListeners = new ArrayList<X4OPhaseListener>(3);
setX4OPhase();
}
/**
* Is called from constuctor
* Is called from constructor.
*/
abstract protected void setX4OPhase();
/**
* Gets the current phase.
* @return The current phase.
*/
public X4OPhase getX4OPhase() {
return phase;
}
public List<X4OPhaseListener> getX4OPhaseListeners() {
return X4OPhaseListeners;
}
public void addPhaseListener(X4OPhaseListener listener) {
X4OPhaseListeners.add(listener);
}
public void removePhaseListener(X4OPhaseListener listener) {
X4OPhaseListeners.remove(listener);
/**
* Gets the phase listeners.
* @return The x4o phase listeners.
*/
public List<X4OPhaseListener> getPhaseListeners() {
return phaseListeners;
}
/**
* Adds a phase listener.
* @param listener The phase listener to add.
*/
public void addPhaseListener(X4OPhaseListener listener) {
phaseListeners.add(listener);
}
/**
* Removed a phase listener.
* @param listener The phase listener to remove.
*/
public void removePhaseListener(X4OPhaseListener listener) {
phaseListeners.remove(listener);
}
/**
* If returns true then this handler will run on all elements.
* @return defaults to true.
*/
public boolean isElementPhase() {
return true;
}
/**
* Abstract method.
* @param element The element to run phase for.
* @throws X4OPhaseException when phase has error.
*/
abstract public void runElementPhase(Element element) throws X4OPhaseException;
/**
* Empty method.
* @param elementLanguage The language to run phase for.
* @throws X4OPhaseException when phase has error.
*/
public void runPhase(ElementLanguage elementLanguage) throws X4OPhaseException {
}
}

View file

@ -194,10 +194,10 @@ public class X4ODebugWriter {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "name", "", "", phase.getX4OPhase().name());
atts.addAttribute ("", "runOnce", "", "", phase.getX4OPhase().isRunOnce()+"");
atts.addAttribute ("", "listenersSize", "", "", phase.getX4OPhaseListeners().size()+"");
atts.addAttribute ("", "listenersSize", "", "", phase.getPhaseListeners().size()+"");
debugWriter.startElement (DEBUG_URI, "phase", "", atts);
for (X4OPhaseListener l:phase.getX4OPhaseListeners()) {
for (X4OPhaseListener l:phase.getPhaseListeners()) {
atts = new AttributesImpl();
atts.addAttribute ("", "className", "", "", l.getClass().getName());
debugWriter.startElement (DEBUG_URI, "X4OPhaseListener", "", atts);

View file

@ -60,7 +60,10 @@ public class X4OEntityResolver implements EntityResolver {
private Map<String,String> schemaResources = null;
private Map<String,String> schemaPathResources = null;
/**
* Creates an X4OEntityResolver for a language.
* @param elementLanguage The x4o language to resolve entities for.
*/
protected X4OEntityResolver(ElementLanguage elementLanguage) {
if (elementLanguage==null) {
throw new NullPointerException("Can't provide entities with null ElementLanguage.");
@ -95,6 +98,13 @@ public class X4OEntityResolver implements EntityResolver {
}
}
/**
* Try to resolve xml entities by systemId.
*
* @param publicId The public id to search for.
* @param systemId The system id to search for.
* @return Returns null or the InputSource of the requested ids.
*/
public InputSource resolveEntity(String publicId, String systemId) throws IOException,SAXException {
logger.finer("Fetch sysId: "+systemId+" pubId: "+publicId);
@ -115,7 +125,7 @@ public class X4OEntityResolver implements EntityResolver {
String schemeResource = schemaResources.get(systemId);
File schemaFile = new File(schemaBasePath.getAbsolutePath()+File.separatorChar+schemeResource);
if (schemaFile.exists()) {
if (schemaFile.canRead()==false) {
if (!schemaFile.canRead()) {
throw new SAXException("Can't read schema file: "+schemaFile);
}
try {

View file

@ -45,26 +45,26 @@ public interface X4OPhaseHandler {
/**
* Runs this phase.
* @param elementLanguage
* @throws X4OPhaseException
* @param elementLanguage The elementLanguage running this phase.
* @throws X4OPhaseException When error has happend.
*/
void runPhase(ElementLanguage elementLanguage) throws X4OPhaseException;
/**
* Returns all X4OPhaseListeners which where added.
* Returns all phase listeners which where added.
* @return All X4OPhaseListeners.
*/
List<X4OPhaseListener> getX4OPhaseListeners();
List<X4OPhaseListener> getPhaseListeners();
/**
* Adds an X4OPhaseListener
* @param listener
* Adds an X4OPhaseListener.
* @param listener The listener to add.
*/
void addPhaseListener(X4OPhaseListener listener);
/**
* Removes an X4OPhaseListener
* @param listener
* Removes an X4OPhaseListener.
* @param listener The listener to remove.
*/
void removePhaseListener(X4OPhaseListener listener);
@ -78,8 +78,8 @@ public interface X4OPhaseHandler {
/**
* Run this phase for this Element.
* @param element
* @throws X4OPhaseException
* @param element The element to run this phase for.
* @throws X4OPhaseException Is thrown when error has happen.
*/
void runElementPhase(Element element) throws X4OPhaseException;
}

View file

@ -34,8 +34,8 @@ import org.x4o.xml.element.ElementLanguage;
/**
* X4OPhaseManager stores the X4OPhaseHandler and puts them in the right order
* and will execute the phases when runPhases is called.
* X4OPhaseManager stores the X4OPhaseHandler and puts them in the right order.
* And will execute the phases when runPhases is called.
*
* @author Willem Cazander
* @version 1.0 Jan 6, 2008
@ -51,7 +51,8 @@ public class X4OPhaseManager {
private boolean skipSiblingsPhase = false;
/**
* Local package constuctor
* Local package constructor.
* @param elementLanguage The ElementLanguage to run the phases on.
*/
public X4OPhaseManager(ElementLanguage elementLanguage) {
if (elementLanguage==null) {
@ -107,7 +108,7 @@ public class X4OPhaseManager {
/**
* Runs all the phases in the right order.
* @throws X4OPhaseException
* @throws X4OPhaseException When a running handlers throws one.
*/
public void runPhases() throws X4OPhaseException {
@ -136,7 +137,7 @@ public class X4OPhaseManager {
elementLanguage.setCurrentX4OPhase(phaseHandler.getX4OPhase());
// run listeners
for (X4OPhaseListener l:phaseHandler.getX4OPhaseListeners()) {
for (X4OPhaseListener l:phaseHandler.getPhaseListeners()) {
l.preRunPhase(phaseHandler, elementLanguage);
}
@ -149,7 +150,7 @@ public class X4OPhaseManager {
executePhaseElement(phaseHandler);
} finally {
// run the listeners again
for (X4OPhaseListener l:phaseHandler.getX4OPhaseListeners()) {
for (X4OPhaseListener l:phaseHandler.getPhaseListeners()) {
l.endRunPhase(phaseHandler, elementLanguage);
}
}
@ -160,6 +161,12 @@ public class X4OPhaseManager {
}
}
/**
* Runs phase on single element.
* @param e The Element to process.
* @param p The phase to run.
* @throws X4OPhaseException When a running handlers throws one.
*/
public void runPhasesForElement(Element e,X4OPhase p) throws X4OPhaseException {
// sort for the order
@ -190,6 +197,10 @@ public class X4OPhaseManager {
}
}
/**
* Run release phase manual if auto release is disabled by config.
* @throws X4OPhaseException When a running handlers throws one.
*/
public void doReleasePhaseManual() throws X4OPhaseException {
if (skipReleasePhase==false) {
throw new IllegalStateException("No manual release requested.");
@ -266,6 +277,11 @@ public class X4OPhaseManager {
}
/**
* Execute element phase handler on full tree.
* @param phase The phase to run.
* @throws X4OPhaseException When a running handlers throws one.
*/
private void executePhaseElement(X4OPhaseHandler phase) throws X4OPhaseException {
if (elementLanguage.getRootElement()==null) {
return;
@ -274,10 +290,10 @@ public class X4OPhaseManager {
}
/**
* todo: rewrite to itterator for big deep trees
* todo: rewrite to itterator for big deep trees.
*
* @param element
* @param phase
* @param element The element in the tree.
* @param phase The phase to run.
* @throws X4OPhaseException
*/
private void executePhaseTree(Element element,X4OPhaseHandler phase) throws X4OPhaseException {

View file

@ -31,6 +31,12 @@ package org.x4o.xml.core.config;
*/
public class X4OLanguageClassLoader {
/**
* Made X4OLanguageClassLoader have private constructor.
*/
private X4OLanguageClassLoader() {
}
/**
* Gets the thread classloader or the normal classloader.
* @return Returns the ClassLoader.

View file

@ -23,12 +23,17 @@
package org.x4o.xml.eld;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Logger;
import javax.xml.parsers.ParserConfigurationException;
import org.x4o.xml.element.ElementLanguage;
import org.x4o.xml.element.ElementLanguageModule;
import org.x4o.xml.element.ElementLanguageModuleLoader;
import org.x4o.xml.element.ElementLanguageModuleLoaderException;
import org.xml.sax.SAXException;
/**
* De default X4OElementConfigurator.
@ -60,6 +65,7 @@ public class EldModuleLoader implements ElementLanguageModuleLoader {
* Loads the ELD language into the module.
* @param elementLanguage The langauge to load for.
* @param elementLanguageModule The module to load it in.
* @throws ElementLanguageModuleLoaderException When eld language could not be loaded.
* @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 {
@ -67,7 +73,17 @@ public class EldModuleLoader implements ElementLanguageModuleLoader {
try {
EldParser parser = new EldParser(elementLanguage,elementLanguageModule,isEldCore);
parser.parseResource(eldResource);
} catch (Exception e) {
} catch (FileNotFoundException e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage()+" while parsing: "+eldResource,e);
} catch (SecurityException e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage()+" while parsing: "+eldResource,e);
} catch (NullPointerException e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage()+" while parsing: "+eldResource,e);
} catch (ParserConfigurationException e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage()+" while parsing: "+eldResource,e);
} catch (SAXException e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage()+" while parsing: "+eldResource,e);
} catch (IOException e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage()+" while parsing: "+eldResource,e);
}
}

View file

@ -59,7 +59,8 @@ import org.x4o.xml.impl.DefaultElementClass;
public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
private Logger logger = null;
private static final String PP_CEL_XMLNS = "http://cel.x4o.org/xml/ns/";
private static final String PP_CEL_PROVIDER = "cel.x4o.org";
private static final String PP_CEL_XMLNS = "http://"+PP_CEL_PROVIDER+"/xml/ns/";
private static final String PP_CEL_XSD_FILE = "-1.0.xsd";
private static final String CEL_CORE = "cel-core";
private static final String CEL_ROOT = "cel-root";
@ -87,7 +88,7 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
elementLanguageModule.setId("cel-module");
elementLanguageModule.setName("Core Element Languag Module");
elementLanguageModule.setProviderName("cel.x4o.org");
elementLanguageModule.setProviderName(PP_CEL_PROVIDER);
List<ElementClass> elementClassList = new ArrayList<ElementClass>(10);
elementClassList.add(new DefaultElementClass("attribute",elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute()));
@ -96,57 +97,49 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
createElementClasses(elementClassList,elementLanguage); // adds all meta info
ElementClassAttribute attr;
DefaultElementClass ns = new DefaultElementClass("namespace",elementLanguage.getLanguageConfiguration().getDefaultElementNamespaceContext());
try {
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("uri");
attr.setRequired(true);
ns.addElementClassAttribute(attr);
} catch (Exception e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
attr = newElementClassAttribute(elementLanguage);
attr.setName("uri");
attr.setRequired(true);
ns.addElementClassAttribute(attr);
elementClassList.add(ns);
DefaultElementClass dec = new DefaultElementClass("element",elementLanguage.getLanguageConfiguration().getDefaultElementClass());
attr = newElementClassAttribute(elementLanguage);
attr.setName("objectClass");
attr.setObjectConverter(new ClassConverter());
dec.addElementClassAttribute(attr);
try {
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("objectClass");
attr.setObjectConverter(new ClassConverter());
dec.addElementClassAttribute(attr);
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("elementClass");
attr.setObjectConverter(new ClassConverter());
dec.addElementClassAttribute(attr);
} catch (Exception e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
attr = newElementClassAttribute(elementLanguage);
attr.setName("elementClass");
attr.setObjectConverter(new ClassConverter());
dec.addElementClassAttribute(attr);
elementClassList.add(dec);
DefaultElementClass ec = new DefaultElementClass("elementInterface",elementLanguage.getLanguageConfiguration().getDefaultElementInterface());
try {
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("interfaceClass");
attr.setObjectConverter(new ClassConverter());
ec.addElementClassAttribute(attr);
} catch (Exception e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
attr = newElementClassAttribute(elementLanguage);
attr.setName("interfaceClass");
attr.setObjectConverter(new ClassConverter());
ec.addElementClassAttribute(attr);
elementClassList.add(ec);
logger.finer("Creating eldcore namespace.");
ElementNamespaceContext namespace;
try {
namespace = (ElementNamespaceContext)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementNamespaceContext());
} catch (Exception e) {
} catch (InstantiationException e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
} catch (IllegalAccessException e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
try {
namespace.setElementNamespaceInstanceProvider((ElementNamespaceInstanceProvider)
X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider())
);
} catch (Exception e) {
} catch (InstantiationException e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
} catch (IllegalAccessException e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
@ -179,14 +172,18 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
// And define root
try {
namespace = (ElementNamespaceContext)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementNamespaceContext());
} catch (Exception e) {
} catch (InstantiationException e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
} catch (IllegalAccessException e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
try {
namespace.setElementNamespaceInstanceProvider((ElementNamespaceInstanceProvider)
X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider())
);
} catch (Exception e) {
} catch (InstantiationException e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
} catch (IllegalAccessException e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
@ -218,65 +215,45 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
ec = new DefaultElementClass("bindingHandler",null,BeanElement.class);
ec.addElementParent(CEL_ROOT_URI, "module");
ec.addElementParent(CEL_CORE_URI, "elementInterface");
try {
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("id");
attr.setRequired(true);
ec.addElementClassAttribute(attr);
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("bean.class");
attr.setRequired(true);
ec.addElementClassAttribute(attr);
} catch (Exception e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
attr = newElementClassAttribute(elementLanguage);
attr.setName("id");
attr.setRequired(true);
ec.addElementClassAttribute(attr);
attr = newElementClassAttribute(elementLanguage);
attr.setName("bean.class");
attr.setRequired(true);
ec.addElementClassAttribute(attr);
elementClassList.add(ec);
ec = new DefaultElementClass("attributeHandler",null,BeanElement.class);
ec.addElementParent(CEL_ROOT_URI, "module");
try {
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("bean.class");
attr.setRequired(true);
ec.addElementClassAttribute(attr);
} catch (Exception e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
attr = newElementClassAttribute(elementLanguage);
attr.setName("bean.class");
attr.setRequired(true);
ec.addElementClassAttribute(attr);
elementClassList.add(ec);
ec = new DefaultElementClass("configurator",null,BeanElement.class);
//ec.addElementParent(CEL_ROOT_URI, "module");
ec.addElementParent(CEL_CORE_URI, "elementInterface");
ec.addElementParent(CEL_CORE_URI, "element");
try {
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("bean.class");
attr.setRequired(true);
ec.addElementClassAttribute(attr);
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("configAction");
ec.addElementClassAttribute(attr);
} catch (Exception e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
attr = newElementClassAttribute(elementLanguage);
attr.setName("bean.class");
attr.setRequired(true);
ec.addElementClassAttribute(attr);
attr = newElementClassAttribute(elementLanguage);
attr.setName("configAction");
ec.addElementClassAttribute(attr);
elementClassList.add(ec);
ec = new DefaultElementClass("configuratorGlobal",null,BeanElement.class);
ec.addElementParent(CEL_ROOT_URI, "module");
try {
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("bean.class");
attr.setRequired(true);
ec.addElementClassAttribute(attr);
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("configAction");
ec.addElementClassAttribute(attr);
} catch (Exception e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
attr = newElementClassAttribute(elementLanguage);
attr.setName("bean.class");
attr.setRequired(true);
ec.addElementClassAttribute(attr);
attr = newElementClassAttribute(elementLanguage);
attr.setName("configAction");
ec.addElementClassAttribute(attr);
elementClassList.add(ec);
ec = new DefaultElementClass("description",null,DescriptionElement.class);
@ -295,21 +272,38 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
ec = new DefaultElementClass("elementParent",null,ElementClassAddParentElement.class);
ec.addElementParent(CEL_CORE_URI, "element");
ec.addElementParent(CEL_CORE_URI, "elementInterface");
try {
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("tag");
attr.setRequired(true);
ec.addElementClassAttribute(attr);
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("uri");
ec.addElementClassAttribute(attr);
} catch (Exception e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
attr = newElementClassAttribute(elementLanguage);
attr.setName("tag");
attr.setRequired(true);
ec.addElementClassAttribute(attr);
attr = newElementClassAttribute(elementLanguage);
attr.setName("uri");
ec.addElementClassAttribute(attr);
elementClassList.add(ec);
}
/**
* Creates new ElementClassAttribute instance.
* @param elementLanguage The ElementLanguage to create from.
* @return The new ElementClassAttribute instance.
* @throws ElementLanguageModuleLoaderException When class could not be created.
*/
private ElementClassAttribute newElementClassAttribute(ElementLanguage elementLanguage) throws ElementLanguageModuleLoaderException {
try {
return (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
} catch (InstantiationException e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
} catch (IllegalAccessException e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
}
/**
* Adds binding handler to module.
* @param id The id to set on the handler.
* @param handler The handler to add the the module.
* @param elementLanguageModule The module to add the handler to.
*/
private void addBindingHandler(String id,ElementBindingHandler handler,ElementLanguageModule elementLanguageModule) {
handler.setId(id);
elementLanguageModule.addElementBindingHandler(handler);

View file

@ -36,7 +36,9 @@ import org.x4o.xml.element.ElementException;
public class AttributeAliasElement extends AbstractElement {
/**
* Add the xml attribute 'name' to ElementClassAttribute as attribute alias.
* @see org.x4o.xml.element.AbstractElement#doElementEnd()
* @throws ElementException When name attribute is not set or when parent element object is not ElementClassAttribute interface.
*/
@Override
public void doElementEnd() throws ElementException {

View file

@ -24,6 +24,7 @@
package org.x4o.xml.eld.lang;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
@ -32,8 +33,7 @@ import org.x4o.xml.element.AbstractElement;
import org.x4o.xml.element.ElementException;
/**
* An BeanElement.<br>
* This BeanElement fills it elementObject from source with the bean.class attribute.
* BeanElement fills it elementObject from source with the bean.class attribute.
*
* @author Willem Cazander
* @version 1.0 Jan 21, 2007
@ -42,16 +42,23 @@ public class BeanElement extends AbstractElement {
private List<Object> constructorArguments = null;
/**
* Creates a BeanElement.
*/
public BeanElement() {
constructorArguments = new ArrayList<Object>(3);
}
/**
* On start of element create the element object, filled from the bean.class attribute.
* @throws ElementException When bean could not be created.
*/
@Override
public void doElementStart() throws ElementException {
String className = getAttributes().get("bean.class");
if("".equals(className) | className==null) { throw new ElementException("Set the bean.class attribute"); }
try {
Class<?> beanClass = X4OLanguageClassLoader.loadClass(className);
Class<?> beanClass = X4OLanguageClassLoader.loadClass(className);
if (constructorArguments.isEmpty()) {
setElementObject(beanClass.newInstance());
} else {
@ -60,11 +67,25 @@ public class BeanElement extends AbstractElement {
Constructor<?> c = beanClass.getConstructor(arguClass);
setElementObject(c.newInstance(constructorArguments));
}
} catch (Exception e) {
} catch (ClassNotFoundException e) {
throw new ElementException(e);
} catch (InstantiationException e) {
throw new ElementException(e);
} catch (IllegalAccessException e) {
throw new ElementException(e);
} catch (NoSuchMethodException e) {
throw new ElementException(e);
} catch (IllegalArgumentException e) {
throw new ElementException(e);
} catch (InvocationTargetException e) {
throw new ElementException(e);
}
}
/**
* Add bean constructor arguments.
* @param argu The argument to add to constructor.
*/
public void addConstuctorArgument(Object argu) {
if (argu==null) {
throw new NullPointerException("Can't add null argument for constructor.");

View file

@ -37,6 +37,7 @@ public class ElementClassAddParentElement extends AbstractElement {
/**
* @see org.x4o.xml.element.AbstractElement#doElementEnd()
* @throws ElementException When parent is not ElementClassBase.
*/
@Override
public void doElementEnd() throws ElementException {

View file

@ -24,9 +24,7 @@
package org.x4o.xml.element;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* An AbstractElementClass.

View file

@ -30,7 +30,7 @@ import java.util.List;
import java.util.Map;
/**
* An AbstractElementClassBase.
* AbstractElementClassBase provides basic element meta class support.
*
* @author Willem Cazander
* @version 1.0 Jan 19, 2012
@ -56,31 +56,40 @@ public abstract class AbstractElementClassBase extends AbstractElementMetaBase i
/**
* @see ElementClass#addElementConfigurators(ElementConfigurator)
* @param elementConfigurator The ElementConfigurator to add.
*/
public void addElementConfigurators(ElementConfigurator elementConfigurator) {
elementConfigurators.add(elementConfigurator);
}
/**
* @param elementClassAttribute The ElementClassAttribute to add.
*/
public void addElementClassAttribute(ElementClassAttribute elementClassAttribute) {
elementClassAttributes.put(elementClassAttribute.getName(),elementClassAttribute);
}
/**
* @return All the element attributes.
*/
public Collection<ElementClassAttribute> getElementClassAttributes() {
return elementClassAttributes.values();
}
/**
* Get the ElementClassAttribute from its name.
* @param attributeName The attribute name.
* @return The element class attribute for the name.
*/
public ElementClassAttribute getElementClassAttributeByName(String attributeName) {
return elementClassAttributes.get(attributeName);
}
/**
* Adds parent tag.
* @see org.x4o.xml.element.ElementClassBase#addElementParent(java.lang.String,java.lang.String)
* @param namespaceUri The namespace uri of the parent tag.
* @param tag The tag of the parent of this tag.
*/
public void addElementParent(String namespaceUri,String tag) {
if (namespaceUri==null) {
@ -98,7 +107,10 @@ public abstract class AbstractElementClassBase extends AbstractElementMetaBase i
}
/**
* Removes parent tag.
* @see org.x4o.xml.element.ElementClassBase#removeElementParent(java.lang.String,java.lang.String)
* @param namespaceUri The namespace uri of the parent tag.
* @param tag The tag of the parent of this tag.
*/
public void removeElementParent(String namespaceUri,String tag) {
List<String> tags = elementParents.get(namespaceUri);
@ -109,7 +121,10 @@ public abstract class AbstractElementClassBase extends AbstractElementMetaBase i
}
/**
* Returns the parent per namespace uri.
* @see org.x4o.xml.element.ElementClassBase#getElementParents(java.lang.String)
* @param namespaceUri The namespace uri to gets the parents of.
* @return List of parent tags of requested parent namespace uri.
*/
public List<String> getElementParents(String namespaceUri) {
return elementParents.get(namespaceUri);

View file

@ -38,13 +38,14 @@ public abstract class AbstractElementConfigurator extends AbstractElementMetaBas
/**
* Defaults to false.
* @see org.x4o.xml.element.ElementConfigurator#isConfigAction()
* @return True if set to configAction
*/
public boolean isConfigAction() {
return configAction;
}
/**
* Sets the configAction
* Sets the configAction.
* @param configAction The configAction to set.
*/
public void setConfigAction(boolean configAction) {

View file

@ -27,7 +27,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* An AbstractElement.
* AbstractElementInterface extends base support with element interface support.
*
* @author Willem Cazander
* @version 1.0 Apr 15, 2008
@ -37,12 +37,16 @@ public abstract class AbstractElementInterface extends AbstractElementClassBase
private Class<?> interfaceClass = null;
private List<ElementBindingHandler> elementBindingHandlers = null;
/**
* Creates AbstractElementInterface.
*/
public AbstractElementInterface() {
elementBindingHandlers = new ArrayList<ElementBindingHandler>(4);
}
/**
* @see org.x4o.xml.element.ElementInterface#addElementBindingHandler(org.x4o.xml.element.ElementBindingHandler)
* @param elementBindingHandler The binding handler to add.
*/
public void addElementBindingHandler(ElementBindingHandler elementBindingHandler) {
elementBindingHandlers.add(elementBindingHandler);
@ -50,6 +54,7 @@ public abstract class AbstractElementInterface extends AbstractElementClassBase
/**
* @see org.x4o.xml.element.ElementInterface#getElementBindingHandlers()
* @return All binding handlers.
*/
public List<ElementBindingHandler> getElementBindingHandlers() {
return elementBindingHandlers;
@ -57,6 +62,7 @@ public abstract class AbstractElementInterface extends AbstractElementClassBase
/**
* @see org.x4o.xml.element.ElementInterface#getInterfaceClass()
* @return The interface class
*/
public Class<?> getInterfaceClass() {
return interfaceClass;
@ -64,6 +70,7 @@ public abstract class AbstractElementInterface extends AbstractElementClassBase
/**
* @see org.x4o.xml.element.ElementInterface#setInterfaceClass(java.lang.Class)
* @param interfaceClass The interface class to set.
*/
public void setInterfaceClass(Class<?> interfaceClass) {
this.interfaceClass=interfaceClass;

View file

@ -32,35 +32,43 @@ package org.x4o.xml.element;
*/
public abstract class AbstractElementMetaBase implements ElementMetaBase {
/** The description */
/** The id */
private String id = null;
/** The description */
private String description = null;
/**
* @see org.x4o.xml.element.ElementMetaBase#setId(java.lang.String)
*/
public void setId(String id) {
this.id=id;
}
/**
* Gets the id.
* @see org.x4o.xml.element.ElementMetaBase#getId()
* @return The id.
*/
public String getId() {
return id;
}
/**
* Sets the id.
* @see org.x4o.xml.element.ElementMetaBase#setId(java.lang.String)
* @param id The id to set.
*/
public void setId(String id) {
this.id=id;
}
/**
* Gets the description.
* @see org.x4o.xml.element.ElementConfigurator#getDescription()
* @return The description.
*/
public String getDescription() {
return description;
}
/**
* Sets the description.
* @see org.x4o.xml.element.ElementConfigurator#setDescription(java.lang.String)
* @param description The description to set.
*/
public void setDescription(String description) {
this.description=description;

View file

@ -53,13 +53,19 @@ public interface Element {
/** The xml comments in xml. */
comment,
/** ignorableWhitespace in xml */
/** ignorableWhitespace in xml. */
ignorableWhitespace,
/** Receive raw sax event on elementObject */
/** Receive raw sax event on elementObject. */
overrideSax;
static public List<Element> filterElements(List<Element> elements,ElementType elementType) {
/**
* Filters the given elments list to elementType.
* @param elements The elements to filter.
* @param elementType The elementType to filter on.
* @return Always returns List of Elements of filter type.
*/
public static List<Element> filterElements(List<Element> elements,ElementType elementType) {
List<Element> result = new ArrayList<Element>(3);
for (int i=0;i<elements.size();i++) {
Element element = elements.get(i);
@ -73,16 +79,19 @@ public interface Element {
/**
* This method is fired when the end xml tag is parsed.
* @throws ElementException Can be thrown when structure is not correct.
*/
void doElementEnd() throws ElementException;
/**
* This method is fired when the start of xml tag is parsed.
* @throws ElementException Can be thrown when structure is not correct.
*/
void doElementStart() throws ElementException;
/**
* This method is fired only once in the run phase.
* @throws ElementException Can be thrown when structure is not correct.
*/
void doElementRun() throws ElementException;
@ -103,6 +112,7 @@ public interface Element {
/**
* This method get called when this Element object is not needed anymore.<br>
* Can be used to close resources.
* @throws ElementException Can be thrown when structure is not correct.
*/
void release() throws ElementException;
@ -135,19 +145,21 @@ public interface Element {
/**
* Sets the body texts on an event based system.
* @param body The body text.
* @throws ElementException Can be thrown when structure is not correct.
*/
void doCharacters(String body) throws ElementException;
/**
* Sets the comment texts on an event based system.
* @param comment The comment text.
* @throws ElementException Can be thrown when structure is not correct.
*/
void doComment(String comment) throws ElementException;
/**
* Is called when there is whitespace in xml.
* @param space The space.
* @throws ElementException
* @throws ElementException Can be thrown when structure is not correct.
*/
void doIgnorableWhitespace(String space) throws ElementException;

View file

@ -41,25 +41,25 @@ public interface ElementAttributeHandler extends ElementConfigurator {
/**
* Sets the attribute name this attribute handler handles.
* @param attributeName
* @param attributeName The attribute to handle.
*/
void setAttributeName(String attributeName);
/**
* Adds an NextAttribute.
* There next attributes will defines the order in which the ElementAttributeHandlers are executed.
* @param attribute
* @param attribute Add attribute which be will processed after this one.
*/
void addNextAttribute(String attribute);
/**
* Removes an next attribute
* @param attribute
* Removes an next attribute.
* @param attribute Removes this next attribute.
*/
void removeNextAttribute(String attribute);
/**
* Get all next attributes
* Get all next attributes.
* @return Returns the list of all next attributes.
*/
List<String> getNextAttributes();

View file

@ -50,7 +50,8 @@ public interface ElementBindingHandler extends ElementMetaBase {
* Do the binding of this child to the parent object.
* @param parentObject The parentObject of this childElement.
* @param childObject The childObject of this childElement.
* @param childElement The child element to bind to the parent.
* @param childElement The child element to bind to the parent.'
* @throws ElementBindingHandlerException When binding could not happen.
*/
void doBind(Object parentObject,Object childObject,Element childElement) throws ElementBindingHandlerException;
}

View file

@ -37,27 +37,31 @@ import org.x4o.xml.conv.ObjectConverter;
public interface ElementClassAttribute extends ElementMetaBase {
/**
* Gets the attribute name which this ElementAttributeConverter handlers
* Gets the attribute name of the ElementClass.
* @return The name.
*/
String getName();
/**
* Sets the attribute name which this ElementAttributeConverter handlers
* Sets the attribute name of the ElementClass.
* @param name The name of the attribute.
*/
void setName(String name);
/**
* Gets the ObjectConverter
* Gets the ObjectConverter.
* @return The ObjectConverter.
*/
ObjectConverter getObjectConverter();
/**
* Add the ObjectConverter whichs converts
* Add the ObjectConverter whichs converts.
* @param objectConverter The objectConverter to set for this attribute.
*/
void setObjectConverter(ObjectConverter objectConverter);
/**
* Sets the defaultValue of this attribute
* Sets the defaultValue of this attribute.
* @param defaultValue The defaultValue to set.
*/
void setDefaultValue(Object defaultValue);
@ -87,42 +91,44 @@ public interface ElementClassAttribute extends ElementMetaBase {
List<String> getAttributeAliases();
/**
* @return the required
* Gets the required state of this attribute.
* @return If true then attribute is required.
*/
Boolean getRequired();
/**
* @param required the required to set
* Sets the required state of this attribute.
* @param required the required to set.
*/
void setRequired(Boolean required);
/**
* @return the runResolveEL
* @return the runResolveEL.
*/
Boolean getRunResolveEL();
/**
* @param runResolveEL the runResolveEL to set
* @param runResolveEL the runResolveEL to set.
*/
void setRunResolveEL(Boolean runResolveEL);
/**
* @return the runConverters
* @return the runConverters.
*/
Boolean getRunConverters();
/**
* @param runConverters the runConverters to set
* @param runConverters the runConverters to set.
*/
void setRunConverters(Boolean runConverters);
/**
* @return the runBeanFill
* @return the runBeanFill.
*/
Boolean getRunBeanFill();
/**
* @param runBeanFill the runBeanFill to set
* @param runBeanFill the runBeanFill to set.
*/
void setRunBeanFill(Boolean runBeanFill);
}

View file

@ -23,11 +23,8 @@
package org.x4o.xml.element;
/**
* ElementNamespaceLoaderException.<br>
*
*
* ElementNamespaceLoaderException holds ElementLanguageModuleLoader which created the exception.<br>
*
* @author Willem Cazander
* @version 1.0 Aug 29, 2008
@ -37,16 +34,31 @@ public class ElementLanguageModuleLoaderException extends ElementException {
private ElementLanguageModuleLoader elementLanguageModuleLoader = null;
/**
* Creates module loader exception.
* @param elementLanguageModuleLoader The loader module which creates this exception.
* @param message The message of the exception.
*/
public ElementLanguageModuleLoaderException(ElementLanguageModuleLoader elementLanguageModuleLoader,String message) {
super(message);
this.elementLanguageModuleLoader=elementLanguageModuleLoader;
}
/**
* Creates module loader exception.
* @param elementLanguageModuleLoader The loader module which creates this exception.
* @param message The message of the exception.
* @param exception The root cause of the exception.
*/
public ElementLanguageModuleLoaderException(ElementLanguageModuleLoader elementLanguageModuleLoader,String message,Exception exception) {
super(message,exception);
this.elementLanguageModuleLoader=elementLanguageModuleLoader;
}
/**
* Returns the module loader which created the exception.
* @return Returns the module loader.
*/
public ElementLanguageModuleLoader getElementProvider() {
return elementLanguageModuleLoader;
}

View file

@ -24,9 +24,7 @@
package org.x4o.xml.element;
/**
* Provides elements from tag.<br>
* And ElementClass from a tag.<br>
*
* ElementNamespaceInstanceProvider is provider for creating new Element instances for an xml tag.<br>
*
* @author Willem Cazander
* @version 1.0 Jul 8, 2006
@ -34,23 +32,18 @@ package org.x4o.xml.element;
public interface ElementNamespaceInstanceProvider {
/**
* Starts the ElementProvider
* @throws ElementLanguageModuleLoaderException
* Starts the ElementProvider.
* @param elementLanguage The ElementLanguage to start in.
* @param elementNamespaceContext The ElementNamespaceContext to start for.
* @throws ElementNamespaceInstanceProviderException Thrown when error happened in language.
*/
void start(ElementLanguage elementLanguage,ElementNamespaceContext elementNamespaceContext) throws ElementNamespaceInstanceProviderException;
/**
* Provide an Element for an tag
* @param tag The xml tag
* @return An Element
* @throws ElementLanguageModuleLoaderException
* Provide an Element for an xml tag.
* @param tag The xml tag to create instance for.
* @return An new Element instance.
* @throws ElementNamespaceInstanceProviderException Thrown when error happened in language.
*/
Element createElementInstance(String tag) throws ElementNamespaceInstanceProviderException;
/*
* Sets the debug writer
* @param debugWriter
*
void setX4ODebugWriter(X4OParserDebugWriter debugWriter);
*/
}

View file

@ -25,9 +25,7 @@ package org.x4o.xml.element;
/**
* ElementNamespaceInstanceProviderException.<br>
*
*
* ElementNamespaceInstanceProviderException holds the ElementNamespaceInstanceProvider which created this Exception.<br>
*
* @author Willem Cazander
* @version 1.0 Aug 2, 2012
@ -37,16 +35,31 @@ public class ElementNamespaceInstanceProviderException extends ElementException
private ElementNamespaceInstanceProvider elementNamespaceInstanceProvider = null;
/**
* Creates provider instance exception.
* @param elementNamespaceInstanceProvider The provider which creates this exception.
* @param message The message of this exception.
*/
public ElementNamespaceInstanceProviderException(ElementNamespaceInstanceProvider elementNamespaceInstanceProvider,String message) {
super(message);
this.elementNamespaceInstanceProvider=elementNamespaceInstanceProvider;
}
/**
* Creates provider instance exception.
* @param elementNamespaceInstanceProvider The provider which creates this exception.
* @param message The message of this exception.
* @param exception The root cause of this exception.
*/
public ElementNamespaceInstanceProviderException(ElementNamespaceInstanceProvider elementNamespaceInstanceProvider,String message,Exception exception) {
super(message,exception);
this.elementNamespaceInstanceProvider=elementNamespaceInstanceProvider;
}
/**
* Gets the ElementNamespaceInstanceProvider which created this exception.
* @return The provider which created the exception.
*/
public ElementNamespaceInstanceProvider getElementNamespaceInstanceProvider() {
return elementNamespaceInstanceProvider;
}

View file

@ -52,7 +52,7 @@ import org.xml.sax.ext.DefaultHandler2;
import org.xml.sax.helpers.XMLReaderFactory;
/**
* Loads the namepsace defintions of language and create needed providers into the context.
* DefaultX4OLanguageLoader loads the modules of language.
*
* @author Willem Cazander
* @version 1.0 28 Oct 2009
@ -62,11 +62,19 @@ public class DefaultX4OLanguageLoader implements X4OLanguageLoader {
private Logger logger = null;
protected List<Map<String,Map<String,String>>> modulesAll = null;
/**
* Creates the DefaultX4OLanguageLoader.
*/
public DefaultX4OLanguageLoader() {
logger = Logger.getLogger(DefaultX4OLanguageLoader.class.getName());
modulesAll = new ArrayList<Map<String,Map<String,String>>>(20);
}
/**
* Write log message to debug writer.
* @param elementLanguage The elementLanguage we are loading.
* @param message The message to log to the debug output.
*/
private void logMessage(ElementLanguage elementLanguage,String message) {
logger.finest(message);
if (elementLanguage.getLanguageConfiguration().hasX4ODebugWriter()) {
@ -154,7 +162,9 @@ public class DefaultX4OLanguageLoader implements X4OLanguageLoader {
}
/**
* Loads all modules of an language
* Loads all modules of an language.
* @param elementLanguage The ElementLanguage to load for.
* @param language The language to load.
*/
protected void loadLanguageModules(ElementLanguage elementLanguage,String language) throws IOException, SAXException {
StringBuilder buf = new StringBuilder(150);
@ -182,7 +192,7 @@ public class DefaultX4OLanguageLoader implements X4OLanguageLoader {
}
/**
* Parser xml inputstream to languge modules
* Parser xml inputstream to languge modules.
* @param in The inputstream to parser.
* @throws IOException
* @throws SAXException

View file

@ -38,6 +38,9 @@ public class DefaultX4OLanguageVersionFilter implements X4OLanguageVersionFilter
/**
* Filters to the best version.
* @see org.x4o.xml.core.config.X4OLanguageVersionFilter#filterVersion(java.lang.String, java.util.List)
* @return The perfect or best match or null if no match for requested language.
* @param requestVersion The language version to search for.
* @param versions The list of version to search in.
*/
public String filterVersion(String requestVersion, List<String> versions) {
for (int i=0;i<versions.size();i++) {

View file

@ -42,11 +42,20 @@ public class X4OELResolver extends ELResolver {
private ELResolver delegate = null;
private Map<Object,Object> objectStore = null;
/**
* Creates X4OELResolver which is backed by the objectStore.
* @param objectStore The objectStore.
*/
public X4OELResolver(Map<Object, Object> objectStore) {
this.objectStore = objectStore;
delegate = new MapELResolver();
}
/**
* Checks if base object is null and else return objectStore.
* @param base The base object to check.
* @return Returns the base object or objectStore.
*/
private Object checkBase(Object base) {
if (base==null) {
return objectStore;

View file

@ -49,6 +49,8 @@ public class X4OELVariableMapper extends VariableMapper {
/**
* @see javax.el.VariableMapper#resolveVariable(java.lang.String)
* @param var Resolve this var to an ValueExpression.
* @return The resolved ValueExpression of the var.
*/
@Override
public ValueExpression resolveVariable(String var) {
@ -57,10 +59,12 @@ public class X4OELVariableMapper extends VariableMapper {
/**
* @see javax.el.VariableMapper#setVariable(java.lang.String, javax.el.ValueExpression)
* @param var Resolve this var to an ValueExpression.
* @param expression The ValueExpression of the var.
* @return The ValueExpression being set.
*/
@Override
public ValueExpression setVariable(String var, ValueExpression expression) {
return expressions.put(var, expression);
}
}

View file

@ -35,6 +35,8 @@ import java.util.Set;
*
* @author Willem Cazander
* @version 1.0 17/04/2005
* @param <K> The key class.
* @param <V> The value class.
*/
public class AttributeMap<K,V> implements Map<K,V> {
@ -45,22 +47,19 @@ public class AttributeMap<K,V> implements Map<K,V> {
private String uri = null;
/**
* Constuctes an new AttributeMap
* Constuctes an new AttributeMap.
*
* @param attributes
* The data backend of this map.
* @param attributes The data backend of this map.
*/
public AttributeMap(Attributes attributes) {
setAttributes(attributes);
}
/**
* Constructes an new AttributesMap
* Constructes an new AttributesMap.
*
* @param attributes
* The dat backed of this map.
* @param uri
* The namespace of these attributes.
* @param attributes The data backed of this map.
* @param uri The namespace of these attributes.
*/
public AttributeMap(Attributes attributes, String uri) {
setAttributes(attributes);
@ -70,8 +69,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
/**
* Sets the data backend of this map.
*
* @param attributes
* The Attributes to be used as data backend.
* @param attributes The Attributes to be used as data backend.
*/
public void setAttributes(Attributes attributes) {
this.attributes = attributes;
@ -89,9 +87,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
/**
* Sets the namespace uri, when set to null it is disabled(default).
*
* @param uri
* The namespace uri for when parsing when an certain namespace
* is required.
* @param uri The namespace uri for when parsing when an certain namespace is required.
*/
public void setNameSpace(String uri) {
this.uri = uri;
@ -111,8 +107,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
/**
* Gets the local of full name by index.
*
* @param index
* The index of the attribute.
* @param index The index of the attribute.
* @return The name of the attribute.
*/
private String getName(int index) {
@ -176,8 +171,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
/**
* Checks if there is an attributes with an certain key.
*
* @param key
* The name of an attribute.
* @param key The name of an attribute.
* @return True if the attributes excist.
*/
public boolean containsKey(Object key) {
@ -190,8 +184,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
/**
* Checks if there is an attributes with an value.
*
* @param value
* The value to check.
* @param value The value to check.
* @return True if an attributes has this value.
*/
public boolean containsValue(Object value) {
@ -206,8 +199,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
/**
* Returns The value of an attribute.
*
* @param key
* The name of the attribute.
* @param key The name of the attribute.
* @return The value of the attribute.
*/
@SuppressWarnings("unchecked")
@ -218,34 +210,28 @@ public class AttributeMap<K,V> implements Map<K,V> {
/**
* Function not implements. because we can't add to the attributes.
*
* @param key
* ignored.
* @param value
* ignored.
* @param key ignored.
* @param value ignored.
* @return always null
*/
public V put(K key, V value) {
// we can't add.
return null;
return null; // we can't add.
}
/**
* Function not implements. because we can't remove to the attributes.
*
* @param key
* ignored.
* @param key ignored.
* @return always null
*/
public V remove(Object key) {
// we can't remove
return null;
return null ;// we can't remove
}
/**
* Function not implements. because we can't add to the attributes.
*
* @param t
* ignored.
* @param t ignored.
*/
@SuppressWarnings("rawtypes")
public void putAll(Map t) {
@ -312,8 +298,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
* @return True if the object are equal.
*/
public boolean equals(Object o) {
// compare to attributes
return attributes.equals(o);
return attributes.equals(o); // compare to attributes
}
/**
@ -334,24 +319,43 @@ public class AttributeMap<K,V> implements Map<K,V> {
private Object key = null;
private Object value = null;
/**
* Creates AttributeMapEntry with key object.
* @param key The key.
*/
protected AttributeMapEntry(Object key) {
this.key = key;
}
/**
* @return Returns the key.
*/
public Object getKey() {
return key;
}
/**
* Sets the value of this Map.Entry.
* @param value The value to set.
* @return The old value.
*/
public Object setValue(Object value) {
Object result = this.value;
this.value = value;
return result;
}
/**
* @return The value of this Map.Entry.
*/
public Object getValue() {
return value;
}
/**
* @param o Check if o is equal.
* @return True if key and value of Map.Entry are equal.
*/
public boolean equals(Object o) {
if (o instanceof Map.Entry) {
Map.Entry mapEntry = (Map.Entry) o;
@ -361,5 +365,14 @@ public class AttributeMap<K,V> implements Map<K,V> {
}
return false;
}
/**
* @see java.lang.Object#hashCode()
* @return The hashCode.
*/
@Override
public int hashCode() {
return super.hashCode();
}
}
}

View file

@ -55,10 +55,19 @@ public class XMLWriter extends DefaultHandler2 {
private StringBuffer startElement = null;
private boolean printedReturn = false;
/**
* Creates XmlWriter which prints to the Writer interface.
* @param out The writer to print the xml to.
*/
public XMLWriter(Writer out) {
this.out = out;
}
/**
* Creates XmlWriter which prints to the OutputStream interface.
* @param out The OutputStream to write to.
* @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed.
*/
public XMLWriter(OutputStream out) throws UnsupportedEncodingException {
this.out = new OutputStreamWriter(out, "UTF-8");
}
@ -89,6 +98,10 @@ public class XMLWriter extends DefaultHandler2 {
}
/**
* @param uri The xml namespace uri.
* @param localName The local name of the xml tag.
* @param name The (full) name of the xml tag.
* @param atts The attributes of the xml tag.
* @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
*/
@Override
@ -219,6 +232,9 @@ public class XMLWriter extends DefaultHandler2 {
}
/**
* @param uri The xml namespace uri.
* @param localName The local name of the xml tag.
* @param name The (full) name of the xml tag.
* @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
*/
@Override
@ -265,6 +281,9 @@ public class XMLWriter extends DefaultHandler2 {
}
/**
* Starts the prefix mapping of an xml namespace uri.
* @param prefix The xml prefix of this xml namespace uri.
* @param uri The xml namespace uri to add the prefix for.
* @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String)
*/
@Override
@ -273,6 +292,7 @@ public class XMLWriter extends DefaultHandler2 {
}
/**
* @param prefix The xml prefix of this xml namespace uri to be ended.
* @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String)
*/
@Override
@ -294,6 +314,12 @@ public class XMLWriter extends DefaultHandler2 {
}
/**
* Prints xml characters.
*
* @param ch Character buffer.
* @param start The start index of the chars in the ch buffer.
* @param length The length index of the chars in the ch buffer.
* @throws SAXException When IOException has happend while printing.
* @see org.xml.sax.ContentHandler#characters(char[], int, int)
*/
@Override
@ -319,6 +345,12 @@ public class XMLWriter extends DefaultHandler2 {
}
/**
* Prints xml ignorable whitespace.
*
* @param ch Character buffer.
* @param start The start index of the chars in the ch buffer.
* @param length The length index of the chars in the ch buffer.
* @throws SAXException When IOException has happend while printing.
* @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
*/
@Override
@ -335,7 +367,11 @@ public class XMLWriter extends DefaultHandler2 {
}
/**
* Prints xml instructions.
*
* @see org.xml.sax.ContentHandler#processingInstruction(java.lang.String, java.lang.String)
* @param target The target.
* @param data The data.
*/
@Override
public void processingInstruction(String target, String data) throws SAXException {
@ -348,14 +384,20 @@ public class XMLWriter extends DefaultHandler2 {
}
/**
* Not implemented.
*
* @see org.xml.sax.ContentHandler#setDocumentLocator(org.xml.sax.Locator)
* @param locator The DocumentLocator to set.
*/
@Override
public void setDocumentLocator(Locator locator) {
}
/**
* Not implemented.
*
* @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String)
* @param name The name of the skipped entity.
*/
@Override
public void skippedEntity(String name) throws SAXException {
@ -363,6 +405,12 @@ public class XMLWriter extends DefaultHandler2 {
}
/**
* Prints xml comment.
*
* @param ch Character buffer.
* @param start The start index of the chars in the ch buffer.
* @param length The length index of the chars in the ch buffer.
* @throws SAXException When IOException has happend while printing.
* @see org.xml.sax.ext.DefaultHandler2#comment(char[], int, int)
*/
@Override
@ -387,6 +435,10 @@ public class XMLWriter extends DefaultHandler2 {
}
}
/**
* Indent the output writer with tabs by indent count.
* @throws IOException When prints gives exception.
*/
private void indent() throws IOException {
for (int i = 0; i < indent; i++) {
out.write('\t');

View file

@ -34,7 +34,6 @@ import junit.framework.TestCase;
public class X4OLanguageClassLoaderTest extends TestCase {
public void testLoadObject() throws Exception {
new X4OLanguageClassLoader();
Object o = X4OLanguageClassLoader.newInstance("java.lang.Object");
assertNotNull(o);
assertEquals(Object.class, o.getClass());

View file

@ -315,7 +315,7 @@ public class EldDocHtmlWriter {
if (ec.getObjectClass()==null) {
continue;
}
// Check interfaces of child , and see if parent tag is there.
// Check interfaces of parent , and see if child tag is there.
for (ElementInterface ei:node.context.findElementInterfaces(ec.getObjectClass())) {
List<String> eiTags = ei.getElementParents(node.namespace.getUri());
if (eiTags!=null && eiTags.contains(node.elementClass.getTag())) {
@ -356,10 +356,10 @@ public class EldDocHtmlWriter {
private boolean isInTree(TreeNode node,TreeNode checkNode) {
if (node.namespace.getUri().equals(checkNode.namespace.getUri())) {
if (node.elementClass.getTag().equals(checkNode.elementClass.getTag())) {
return true;
}
if ( node.namespace.getUri().equals(checkNode.namespace.getUri()) &&
node.elementClass.getTag().equals(checkNode.elementClass.getTag())
) {
return true;
}
if (node.parent!=null) {
return isInTree(node.parent,checkNode);
@ -389,24 +389,27 @@ public class EldDocHtmlWriter {
}
}
for (ElementClass ec:ns.getElementClasses()) {
// Check interfaces of parent , and see if child tag is there.
if (node.elementClass.getObjectClass()!=null) {
for (ElementInterface ei:node.context.findElementInterfaces(node.elementClass.getObjectClass())) {
List<String> eiTags = ei.getElementParents(ns.getUri());
if (eiTags!=null && eiTags.contains(ec.getTag())) {
n = new TreeNode();
n.context=node.context;
n.module=mod;
n.namespace=ns;
n.elementClass=ec;
n.indent=node.indent+1;
n.parent=node;
result.add(n);
break;
}
}
}
if (ec.getObjectClass()==null) {
continue;
}
// Check interfaces of child , and see if parent tag is there.
for (ElementInterface ei:node.context.findElementInterfaces(ec.getObjectClass())) {
List<String> eiTags = ei.getElementParents(node.namespace.getUri());
if (eiTags!=null && eiTags.contains(node.elementClass.getTag())) {
n = new TreeNode();
n.context=node.context;
n.module=mod;
n.namespace=ns;
n.elementClass=ec;
n.indent=node.indent+1;
n.parent=node;
result.add(n);
break;
}
}
if (node.elementClass.getObjectClass()==null) {
continue;
}

View file

@ -48,6 +48,7 @@ public class MetaLanguageSiblingLoader implements ElementLanguageModuleLoaderSib
* Loads an ElementLanguageModule.
* @param elementLanguage The ElementLanguage to load for.
* @param elementLanguageModule The ElementLanguageModule to load into.
* @throws ElementLanguageModuleLoaderException Is thrown when meta language could not be loaded.
* @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 {