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/; cd project-root/;
mvn clean package; mvn clean package;
mvn -B -Dusername=<scm_username> clean install release:clean release:prepare release:perform; 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 -- -- 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="AvoidInlineConditionals"/>
<module name="DoubleCheckedLocking"/> <module name="DoubleCheckedLocking"/>
<module name="EmptyStatement"/> <module name="EmptyStatement"/>
<module name="HiddenField"/> <module name="HiddenField">
<property name="tokens" value="VARIABLE_DEF"/>
</module>
<module name="IllegalInstantiation"/> <module name="IllegalInstantiation"/>
<module name="InnerAssignment"/> <module name="InnerAssignment"/>
<!-- <!--

View file

@ -38,7 +38,7 @@ import org.x4o.xml.conv.text.LongConverter;
import org.x4o.xml.conv.text.URLConverter; import org.x4o.xml.conv.text.URLConverter;
/** /**
* DefaultObjectConverterProvider. * DefaultObjectConverterProvider holds the defined converts.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Jan 20, 2012 * @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) * @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) { public ObjectConverter getObjectConverterForClass(Class<?> clazz) {
return converters.get(clazz); return converters.get(clazz);
} }
/**
* @return Returns all ObjectConverted stored in this class.
*/
protected Collection<ObjectConverter> getObjectConverters() { protected Collection<ObjectConverter> getObjectConverters() {
return converters.values(); return converters.values();
} }

View file

@ -50,7 +50,7 @@ public interface ObjectConverter extends Cloneable,Serializable {
* @param obj The object to convert. * @param obj The object to convert.
* @param locale The Object convert locale if needed. * @param locale The Object convert locale if needed.
* @return Returns the converted object. * @return Returns the converted object.
* @throws ObjectConverterException * @throws ObjectConverterException When the conversion failes.
*/ */
Object convertTo(Object obj,Locale locale) throws ObjectConverterException; 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 obj The object to convert.
* @param locale The Object convert locale if needed. * @param locale The Object convert locale if needed.
* @return Returns the converted object. * @return Returns the converted object.
* @throws ObjectConverterException * @throws ObjectConverterException When the conversion failes.
*/ */
Object convertBack(Object obj,Locale locale) throws ObjectConverterException; 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; 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() { public Class<?> getObjectClassTo() {
return Boolean.class; 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 { public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
// WARNING: this alway returns a boolean :''( // WARNING: this alway returns a boolean :''(
return Boolean.valueOf(str); 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 { public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Boolean)obj).toString(); return ((Boolean)obj).toString();
} }
/**
* Clone this ObjectConverter.
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
* @return The cloned ObjectConverter.
* @throws CloneNotSupportedException When cloning fails.
*/
@Override @Override
public ObjectConverter clone() throws CloneNotSupportedException { public ObjectConverter clone() throws CloneNotSupportedException {
BooleanConverter result = new BooleanConverter(); BooleanConverter result = new BooleanConverter();

View file

@ -39,18 +39,47 @@ public class ByteConverter extends AbstractStringObjectConverter {
private static final long serialVersionUID = -719929830363810123L; 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() { public Class<?> getObjectClassTo() {
return Byte.class; 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 { public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
return new Byte(str); 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 { public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Byte)obj).toString(); return ((Byte)obj).toString();
} }
/**
* Clone this ObjectConverter.
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
* @return The cloned ObjectConverter.
* @throws CloneNotSupportedException When cloning fails.
*/
@Override @Override
public ObjectConverter clone() throws CloneNotSupportedException { public ObjectConverter clone() throws CloneNotSupportedException {
ByteConverter result = new ByteConverter(); ByteConverter result = new ByteConverter();

View file

@ -39,18 +39,47 @@ public class CharacterConverter extends AbstractStringObjectConverter {
private static final long serialVersionUID = -5864405229292234565L; 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() { public Class<?> getObjectClassTo() {
return Character.class; 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 { public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
return new Character(str.charAt(0)); 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 { public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Character)obj).toString(); return ((Character)obj).toString();
} }
/**
* Clone this ObjectConverter.
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
* @return The cloned ObjectConverter.
* @throws CloneNotSupportedException When cloning fails.
*/
@Override @Override
public ObjectConverter clone() throws CloneNotSupportedException { public ObjectConverter clone() throws CloneNotSupportedException {
CharacterConverter result = new CharacterConverter(); CharacterConverter result = new CharacterConverter();

View file

@ -40,10 +40,24 @@ public class ClassConverter extends AbstractStringObjectConverter {
private static final long serialVersionUID = -1992327327215087127L; 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() { public Class<?> getObjectClassTo() {
return Class.class; 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 { public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
try { try {
return X4OLanguageClassLoader.loadClass(str); 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 { public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Class<?>)obj).getName(); return ((Class<?>)obj).getName();
} }
/**
* Clone this ObjectConverter.
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
* @return The cloned ObjectConverter.
* @throws CloneNotSupportedException When cloning fails.
*/
@Override @Override
public ObjectConverter clone() throws CloneNotSupportedException { public ObjectConverter clone() throws CloneNotSupportedException {
ClassConverter result = new ClassConverter(); ClassConverter result = new ClassConverter();

View file

@ -39,18 +39,47 @@ public class DoubleConverter extends AbstractStringObjectConverter {
private static final long serialVersionUID = 3283317726435306051L; 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() { public Class<?> getObjectClassTo() {
return Double.class; 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 { public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
return new Double(str); 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 { public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Double)obj).toString(); return ((Double)obj).toString();
} }
/**
* Clone this ObjectConverter.
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
* @return The cloned ObjectConverter.
* @throws CloneNotSupportedException When cloning fails.
*/
@Override @Override
public ObjectConverter clone() throws CloneNotSupportedException { public ObjectConverter clone() throws CloneNotSupportedException {
DoubleConverter result = new DoubleConverter(); DoubleConverter result = new DoubleConverter();

View file

@ -47,11 +47,24 @@ public class EnumConverter extends AbstractStringObjectConverter {
private Class enumObjectClass = null; 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() { public Class<?> getObjectClassTo() {
return Enum.class; 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 { public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
if (getEnumClass()==null) { if (getEnumClass()==null) {
throw new ObjectConverterException(this,"enumClass String attribute is not set."); 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 { public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Enum<?>)obj).name(); return ((Enum<?>)obj).name();
} }
@ -92,6 +114,12 @@ public class EnumConverter extends AbstractStringObjectConverter {
this.enumClass = enumClass; this.enumClass = enumClass;
} }
/**
* Clone this ObjectConverter.
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
* @return The cloned ObjectConverter.
* @throws CloneNotSupportedException When cloning fails.
*/
@Override @Override
public ObjectConverter clone() throws CloneNotSupportedException { public ObjectConverter clone() throws CloneNotSupportedException {
EnumConverter result = new EnumConverter(); EnumConverter result = new EnumConverter();

View file

@ -39,18 +39,47 @@ public class FloatConverter extends AbstractStringObjectConverter {
private static final long serialVersionUID = 8038640125557062170L; 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() { public Class<?> getObjectClassTo() {
return Float.class; 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 { public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
return new Float(str); 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 { public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Float)obj).toString(); return ((Float)obj).toString();
} }
/**
* Clone this ObjectConverter.
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
* @return The cloned ObjectConverter.
* @throws CloneNotSupportedException When cloning fails.
*/
@Override @Override
public ObjectConverter clone() throws CloneNotSupportedException { public ObjectConverter clone() throws CloneNotSupportedException {
FloatConverter result = new FloatConverter(); FloatConverter result = new FloatConverter();

View file

@ -39,18 +39,47 @@ public class IntegerConverter extends AbstractStringObjectConverter {
private static final long serialVersionUID = 6618552093124468324L; 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() { public Class<?> getObjectClassTo() {
return Integer.class; 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 { public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
return new Integer(str); 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 { public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Integer)obj).toString(); return ((Integer)obj).toString();
} }
/**
* Clone this ObjectConverter.
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
* @return The cloned ObjectConverter.
* @throws CloneNotSupportedException When cloning fails.
*/
@Override @Override
public ObjectConverter clone() throws CloneNotSupportedException { public ObjectConverter clone() throws CloneNotSupportedException {
IntegerConverter result = new IntegerConverter(); IntegerConverter result = new IntegerConverter();

View file

@ -39,18 +39,47 @@ public class LongConverter extends AbstractStringObjectConverter {
private static final long serialVersionUID = 25132217809739854L; 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() { public Class<?> getObjectClassTo() {
return Long.class; 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 { public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
return new Long(str); 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 { public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Long)obj).toString(); return ((Long)obj).toString();
} }
/**
* Clone this ObjectConverter.
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
* @return The cloned ObjectConverter.
* @throws CloneNotSupportedException When cloning fails.
*/
@Override @Override
public ObjectConverter clone() throws CloneNotSupportedException { public ObjectConverter clone() throws CloneNotSupportedException {
LongConverter result = new LongConverter(); LongConverter result = new LongConverter();

View file

@ -55,10 +55,24 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
stringSplitConverterSteps = new ArrayList<StringSplitConverterStep>(10); 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() { public Class<?> getObjectClassTo() {
return classTo; 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") @SuppressWarnings("rawtypes")
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException { public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
if (split==null) { 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 { public String convertStringBack(Object object,Locale locale) throws ObjectConverterException {
List<StringSplitConverterStep> steps = getOrderedSteps(false); List<StringSplitConverterStep> steps = getOrderedSteps(false);
if (steps.size()!=splitSize) { 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 @Override
public ObjectConverter clone() throws CloneNotSupportedException { public ObjectConverter clone() throws CloneNotSupportedException {
StringSplitConverter result = new StringSplitConverter(); StringSplitConverter result = new StringSplitConverter();

View file

@ -42,14 +42,22 @@ public class URLConverter extends AbstractStringObjectConverter {
private static final long serialVersionUID = -611843641266301893L; private static final long serialVersionUID = -611843641266301893L;
/** /**
* Returns the convert to class.
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo() * @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
* @return The class to convert to.
*/ */
public Class<?> getObjectClassTo() { public Class<?> getObjectClassTo() {
return URL.class; return URL.class;
} }
/** /**
* Converts string into object.
*
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale) * @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 { public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
try { 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) * @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 { public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((URL)obj).toString(); return ((URL)obj).toString();
} }
/** /**
* Clone this ObjectConverter.
* @see org.x4o.xml.conv.AbstractObjectConverter#clone() * @see org.x4o.xml.conv.AbstractObjectConverter#clone()
* @return The cloned ObjectConverter.
* @throws CloneNotSupportedException When cloning fails.
*/ */
@Override @Override
public ObjectConverter clone() throws CloneNotSupportedException { 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 * @author Willem Cazander
* @version 1.0 Dec 31, 2008 * @version 1.0 Dec 31, 2008
@ -39,38 +39,73 @@ import org.x4o.xml.element.ElementLanguage;
public abstract class AbstractX4OPhaseHandler implements X4OPhaseHandler { public abstract class AbstractX4OPhaseHandler implements X4OPhaseHandler {
protected X4OPhase phase = null; protected X4OPhase phase = null;
protected List<X4OPhaseListener> X4OPhaseListeners = null; protected List<X4OPhaseListener> phaseListeners = null;
/**
* Creates the AbstractX4OPhaseHandler.
*/
public AbstractX4OPhaseHandler() { public AbstractX4OPhaseHandler() {
X4OPhaseListeners = new ArrayList<X4OPhaseListener>(3); phaseListeners = new ArrayList<X4OPhaseListener>(3);
setX4OPhase(); setX4OPhase();
} }
/** /**
* Is called from constuctor * Is called from constructor.
*/ */
abstract protected void setX4OPhase(); abstract protected void setX4OPhase();
/**
* Gets the current phase.
* @return The current phase.
*/
public X4OPhase getX4OPhase() { public X4OPhase getX4OPhase() {
return phase; return phase;
} }
public List<X4OPhaseListener> getX4OPhaseListeners() { /**
return X4OPhaseListeners; * Gets the phase listeners.
} * @return The x4o phase listeners.
public void addPhaseListener(X4OPhaseListener listener) { */
X4OPhaseListeners.add(listener); public List<X4OPhaseListener> getPhaseListeners() {
} return phaseListeners;
public void removePhaseListener(X4OPhaseListener listener) {
X4OPhaseListeners.remove(listener);
} }
/**
* 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() { public boolean isElementPhase() {
return true; 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; 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 { public void runPhase(ElementLanguage elementLanguage) throws X4OPhaseException {
} }
} }

View file

@ -194,10 +194,10 @@ public class X4ODebugWriter {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "name", "", "", phase.getX4OPhase().name()); atts.addAttribute ("", "name", "", "", phase.getX4OPhase().name());
atts.addAttribute ("", "runOnce", "", "", phase.getX4OPhase().isRunOnce()+""); atts.addAttribute ("", "runOnce", "", "", phase.getX4OPhase().isRunOnce()+"");
atts.addAttribute ("", "listenersSize", "", "", phase.getX4OPhaseListeners().size()+""); atts.addAttribute ("", "listenersSize", "", "", phase.getPhaseListeners().size()+"");
debugWriter.startElement (DEBUG_URI, "phase", "", atts); debugWriter.startElement (DEBUG_URI, "phase", "", atts);
for (X4OPhaseListener l:phase.getX4OPhaseListeners()) { for (X4OPhaseListener l:phase.getPhaseListeners()) {
atts = new AttributesImpl(); atts = new AttributesImpl();
atts.addAttribute ("", "className", "", "", l.getClass().getName()); atts.addAttribute ("", "className", "", "", l.getClass().getName());
debugWriter.startElement (DEBUG_URI, "X4OPhaseListener", "", atts); 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> schemaResources = null;
private Map<String,String> schemaPathResources = 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) { protected X4OEntityResolver(ElementLanguage elementLanguage) {
if (elementLanguage==null) { if (elementLanguage==null) {
throw new NullPointerException("Can't provide entities with null ElementLanguage."); 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 { public InputSource resolveEntity(String publicId, String systemId) throws IOException,SAXException {
logger.finer("Fetch sysId: "+systemId+" pubId: "+publicId); logger.finer("Fetch sysId: "+systemId+" pubId: "+publicId);
@ -115,7 +125,7 @@ public class X4OEntityResolver implements EntityResolver {
String schemeResource = schemaResources.get(systemId); String schemeResource = schemaResources.get(systemId);
File schemaFile = new File(schemaBasePath.getAbsolutePath()+File.separatorChar+schemeResource); File schemaFile = new File(schemaBasePath.getAbsolutePath()+File.separatorChar+schemeResource);
if (schemaFile.exists()) { if (schemaFile.exists()) {
if (schemaFile.canRead()==false) { if (!schemaFile.canRead()) {
throw new SAXException("Can't read schema file: "+schemaFile); throw new SAXException("Can't read schema file: "+schemaFile);
} }
try { try {

View file

@ -45,26 +45,26 @@ public interface X4OPhaseHandler {
/** /**
* Runs this phase. * Runs this phase.
* @param elementLanguage * @param elementLanguage The elementLanguage running this phase.
* @throws X4OPhaseException * @throws X4OPhaseException When error has happend.
*/ */
void runPhase(ElementLanguage elementLanguage) throws X4OPhaseException; void runPhase(ElementLanguage elementLanguage) throws X4OPhaseException;
/** /**
* Returns all X4OPhaseListeners which where added. * Returns all phase listeners which where added.
* @return All X4OPhaseListeners. * @return All X4OPhaseListeners.
*/ */
List<X4OPhaseListener> getX4OPhaseListeners(); List<X4OPhaseListener> getPhaseListeners();
/** /**
* Adds an X4OPhaseListener * Adds an X4OPhaseListener.
* @param listener * @param listener The listener to add.
*/ */
void addPhaseListener(X4OPhaseListener listener); void addPhaseListener(X4OPhaseListener listener);
/** /**
* Removes an X4OPhaseListener * Removes an X4OPhaseListener.
* @param listener * @param listener The listener to remove.
*/ */
void removePhaseListener(X4OPhaseListener listener); void removePhaseListener(X4OPhaseListener listener);
@ -78,8 +78,8 @@ public interface X4OPhaseHandler {
/** /**
* Run this phase for this Element. * Run this phase for this Element.
* @param element * @param element The element to run this phase for.
* @throws X4OPhaseException * @throws X4OPhaseException Is thrown when error has happen.
*/ */
void runElementPhase(Element element) throws X4OPhaseException; 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 * X4OPhaseManager stores the X4OPhaseHandler and puts them in the right order.
* and will execute the phases when runPhases is called. * And will execute the phases when runPhases is called.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Jan 6, 2008 * @version 1.0 Jan 6, 2008
@ -51,7 +51,8 @@ public class X4OPhaseManager {
private boolean skipSiblingsPhase = false; private boolean skipSiblingsPhase = false;
/** /**
* Local package constuctor * Local package constructor.
* @param elementLanguage The ElementLanguage to run the phases on.
*/ */
public X4OPhaseManager(ElementLanguage elementLanguage) { public X4OPhaseManager(ElementLanguage elementLanguage) {
if (elementLanguage==null) { if (elementLanguage==null) {
@ -107,7 +108,7 @@ public class X4OPhaseManager {
/** /**
* Runs all the phases in the right order. * Runs all the phases in the right order.
* @throws X4OPhaseException * @throws X4OPhaseException When a running handlers throws one.
*/ */
public void runPhases() throws X4OPhaseException { public void runPhases() throws X4OPhaseException {
@ -136,7 +137,7 @@ public class X4OPhaseManager {
elementLanguage.setCurrentX4OPhase(phaseHandler.getX4OPhase()); elementLanguage.setCurrentX4OPhase(phaseHandler.getX4OPhase());
// run listeners // run listeners
for (X4OPhaseListener l:phaseHandler.getX4OPhaseListeners()) { for (X4OPhaseListener l:phaseHandler.getPhaseListeners()) {
l.preRunPhase(phaseHandler, elementLanguage); l.preRunPhase(phaseHandler, elementLanguage);
} }
@ -149,7 +150,7 @@ public class X4OPhaseManager {
executePhaseElement(phaseHandler); executePhaseElement(phaseHandler);
} finally { } finally {
// run the listeners again // run the listeners again
for (X4OPhaseListener l:phaseHandler.getX4OPhaseListeners()) { for (X4OPhaseListener l:phaseHandler.getPhaseListeners()) {
l.endRunPhase(phaseHandler, elementLanguage); 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 { public void runPhasesForElement(Element e,X4OPhase p) throws X4OPhaseException {
// sort for the order // 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 { public void doReleasePhaseManual() throws X4OPhaseException {
if (skipReleasePhase==false) { if (skipReleasePhase==false) {
throw new IllegalStateException("No manual release requested."); 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 { private void executePhaseElement(X4OPhaseHandler phase) throws X4OPhaseException {
if (elementLanguage.getRootElement()==null) { if (elementLanguage.getRootElement()==null) {
return; 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 element The element in the tree.
* @param phase * @param phase The phase to run.
* @throws X4OPhaseException * @throws X4OPhaseException
*/ */
private void executePhaseTree(Element element,X4OPhaseHandler phase) 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 { public class X4OLanguageClassLoader {
/**
* Made X4OLanguageClassLoader have private constructor.
*/
private X4OLanguageClassLoader() {
}
/** /**
* Gets the thread classloader or the normal classloader. * Gets the thread classloader or the normal classloader.
* @return Returns the ClassLoader. * @return Returns the ClassLoader.

View file

@ -23,12 +23,17 @@
package org.x4o.xml.eld; package org.x4o.xml.eld;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.xml.parsers.ParserConfigurationException;
import org.x4o.xml.element.ElementLanguage; import org.x4o.xml.element.ElementLanguage;
import org.x4o.xml.element.ElementLanguageModule; import org.x4o.xml.element.ElementLanguageModule;
import org.x4o.xml.element.ElementLanguageModuleLoader; import org.x4o.xml.element.ElementLanguageModuleLoader;
import org.x4o.xml.element.ElementLanguageModuleLoaderException; import org.x4o.xml.element.ElementLanguageModuleLoaderException;
import org.xml.sax.SAXException;
/** /**
* De default X4OElementConfigurator. * De default X4OElementConfigurator.
@ -60,6 +65,7 @@ public class EldModuleLoader implements ElementLanguageModuleLoader {
* Loads the ELD language into the module. * Loads the ELD language into the module.
* @param elementLanguage The langauge to load for. * @param elementLanguage The langauge to load for.
* @param elementLanguageModule The module to load it in. * @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) * @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 { public void loadLanguageModule(ElementLanguage elementLanguage,ElementLanguageModule elementLanguageModule) throws ElementLanguageModuleLoaderException {
@ -67,7 +73,17 @@ public class EldModuleLoader implements ElementLanguageModuleLoader {
try { try {
EldParser parser = new EldParser(elementLanguage,elementLanguageModule,isEldCore); EldParser parser = new EldParser(elementLanguage,elementLanguageModule,isEldCore);
parser.parseResource(eldResource); 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); 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 { public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
private Logger logger = null; 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 PP_CEL_XSD_FILE = "-1.0.xsd";
private static final String CEL_CORE = "cel-core"; private static final String CEL_CORE = "cel-core";
private static final String CEL_ROOT = "cel-root"; private static final String CEL_ROOT = "cel-root";
@ -87,7 +88,7 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
elementLanguageModule.setId("cel-module"); elementLanguageModule.setId("cel-module");
elementLanguageModule.setName("Core Element Languag Module"); elementLanguageModule.setName("Core Element Languag Module");
elementLanguageModule.setProviderName("cel.x4o.org"); elementLanguageModule.setProviderName(PP_CEL_PROVIDER);
List<ElementClass> elementClassList = new ArrayList<ElementClass>(10); List<ElementClass> elementClassList = new ArrayList<ElementClass>(10);
elementClassList.add(new DefaultElementClass("attribute",elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute())); elementClassList.add(new DefaultElementClass("attribute",elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute()));
@ -96,57 +97,49 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
createElementClasses(elementClassList,elementLanguage); // adds all meta info createElementClasses(elementClassList,elementLanguage); // adds all meta info
ElementClassAttribute attr; ElementClassAttribute attr;
DefaultElementClass ns = new DefaultElementClass("namespace",elementLanguage.getLanguageConfiguration().getDefaultElementNamespaceContext()); DefaultElementClass ns = new DefaultElementClass("namespace",elementLanguage.getLanguageConfiguration().getDefaultElementNamespaceContext());
try { attr = newElementClassAttribute(elementLanguage);
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("uri"); attr.setName("uri");
attr.setRequired(true); attr.setRequired(true);
ns.addElementClassAttribute(attr); ns.addElementClassAttribute(attr);
} catch (Exception e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
elementClassList.add(ns); elementClassList.add(ns);
DefaultElementClass dec = new DefaultElementClass("element",elementLanguage.getLanguageConfiguration().getDefaultElementClass()); DefaultElementClass dec = new DefaultElementClass("element",elementLanguage.getLanguageConfiguration().getDefaultElementClass());
attr = newElementClassAttribute(elementLanguage);
try {
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("objectClass"); attr.setName("objectClass");
attr.setObjectConverter(new ClassConverter()); attr.setObjectConverter(new ClassConverter());
dec.addElementClassAttribute(attr); dec.addElementClassAttribute(attr);
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute()); attr = newElementClassAttribute(elementLanguage);
attr.setName("elementClass"); attr.setName("elementClass");
attr.setObjectConverter(new ClassConverter()); attr.setObjectConverter(new ClassConverter());
dec.addElementClassAttribute(attr); dec.addElementClassAttribute(attr);
} catch (Exception e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
elementClassList.add(dec); elementClassList.add(dec);
DefaultElementClass ec = new DefaultElementClass("elementInterface",elementLanguage.getLanguageConfiguration().getDefaultElementInterface()); DefaultElementClass ec = new DefaultElementClass("elementInterface",elementLanguage.getLanguageConfiguration().getDefaultElementInterface());
try { attr = newElementClassAttribute(elementLanguage);
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("interfaceClass"); attr.setName("interfaceClass");
attr.setObjectConverter(new ClassConverter()); attr.setObjectConverter(new ClassConverter());
ec.addElementClassAttribute(attr); ec.addElementClassAttribute(attr);
} catch (Exception e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
elementClassList.add(ec); elementClassList.add(ec);
logger.finer("Creating eldcore namespace."); logger.finer("Creating eldcore namespace.");
ElementNamespaceContext namespace; ElementNamespaceContext namespace;
try { try {
namespace = (ElementNamespaceContext)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementNamespaceContext()); 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); throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
} }
try { try {
namespace.setElementNamespaceInstanceProvider((ElementNamespaceInstanceProvider) namespace.setElementNamespaceInstanceProvider((ElementNamespaceInstanceProvider)
X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider()) 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); throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
} }
@ -179,14 +172,18 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
// And define root // And define root
try { try {
namespace = (ElementNamespaceContext)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementNamespaceContext()); 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); throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
} }
try { try {
namespace.setElementNamespaceInstanceProvider((ElementNamespaceInstanceProvider) namespace.setElementNamespaceInstanceProvider((ElementNamespaceInstanceProvider)
X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider()) 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); throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
} }
@ -218,65 +215,45 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
ec = new DefaultElementClass("bindingHandler",null,BeanElement.class); ec = new DefaultElementClass("bindingHandler",null,BeanElement.class);
ec.addElementParent(CEL_ROOT_URI, "module"); ec.addElementParent(CEL_ROOT_URI, "module");
ec.addElementParent(CEL_CORE_URI, "elementInterface"); ec.addElementParent(CEL_CORE_URI, "elementInterface");
try { attr = newElementClassAttribute(elementLanguage);
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("id"); attr.setName("id");
attr.setRequired(true); attr.setRequired(true);
ec.addElementClassAttribute(attr); ec.addElementClassAttribute(attr);
attr = newElementClassAttribute(elementLanguage);
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("bean.class"); attr.setName("bean.class");
attr.setRequired(true); attr.setRequired(true);
ec.addElementClassAttribute(attr); ec.addElementClassAttribute(attr);
} catch (Exception e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
elementClassList.add(ec); elementClassList.add(ec);
ec = new DefaultElementClass("attributeHandler",null,BeanElement.class); ec = new DefaultElementClass("attributeHandler",null,BeanElement.class);
ec.addElementParent(CEL_ROOT_URI, "module"); ec.addElementParent(CEL_ROOT_URI, "module");
try { attr = newElementClassAttribute(elementLanguage);
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("bean.class"); attr.setName("bean.class");
attr.setRequired(true); attr.setRequired(true);
ec.addElementClassAttribute(attr); ec.addElementClassAttribute(attr);
} catch (Exception e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
elementClassList.add(ec); elementClassList.add(ec);
ec = new DefaultElementClass("configurator",null,BeanElement.class); ec = new DefaultElementClass("configurator",null,BeanElement.class);
//ec.addElementParent(CEL_ROOT_URI, "module");
ec.addElementParent(CEL_CORE_URI, "elementInterface"); ec.addElementParent(CEL_CORE_URI, "elementInterface");
ec.addElementParent(CEL_CORE_URI, "element"); ec.addElementParent(CEL_CORE_URI, "element");
try { attr = newElementClassAttribute(elementLanguage);
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("bean.class"); attr.setName("bean.class");
attr.setRequired(true); attr.setRequired(true);
ec.addElementClassAttribute(attr); ec.addElementClassAttribute(attr);
attr = newElementClassAttribute(elementLanguage);
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("configAction"); attr.setName("configAction");
ec.addElementClassAttribute(attr); ec.addElementClassAttribute(attr);
} catch (Exception e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
elementClassList.add(ec); elementClassList.add(ec);
ec = new DefaultElementClass("configuratorGlobal",null,BeanElement.class); ec = new DefaultElementClass("configuratorGlobal",null,BeanElement.class);
ec.addElementParent(CEL_ROOT_URI, "module"); ec.addElementParent(CEL_ROOT_URI, "module");
try { attr = newElementClassAttribute(elementLanguage);
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("bean.class"); attr.setName("bean.class");
attr.setRequired(true); attr.setRequired(true);
ec.addElementClassAttribute(attr); ec.addElementClassAttribute(attr);
attr = newElementClassAttribute(elementLanguage);
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("configAction"); attr.setName("configAction");
ec.addElementClassAttribute(attr); ec.addElementClassAttribute(attr);
} catch (Exception e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
elementClassList.add(ec); elementClassList.add(ec);
ec = new DefaultElementClass("description",null,DescriptionElement.class); ec = new DefaultElementClass("description",null,DescriptionElement.class);
@ -295,21 +272,38 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
ec = new DefaultElementClass("elementParent",null,ElementClassAddParentElement.class); ec = new DefaultElementClass("elementParent",null,ElementClassAddParentElement.class);
ec.addElementParent(CEL_CORE_URI, "element"); ec.addElementParent(CEL_CORE_URI, "element");
ec.addElementParent(CEL_CORE_URI, "elementInterface"); ec.addElementParent(CEL_CORE_URI, "elementInterface");
try { attr = newElementClassAttribute(elementLanguage);
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("tag"); attr.setName("tag");
attr.setRequired(true); attr.setRequired(true);
ec.addElementClassAttribute(attr); ec.addElementClassAttribute(attr);
attr = newElementClassAttribute(elementLanguage);
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("uri"); attr.setName("uri");
ec.addElementClassAttribute(attr); ec.addElementClassAttribute(attr);
} catch (Exception e) {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
elementClassList.add(ec); 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) { private void addBindingHandler(String id,ElementBindingHandler handler,ElementLanguageModule elementLanguageModule) {
handler.setId(id); handler.setId(id);
elementLanguageModule.addElementBindingHandler(handler); elementLanguageModule.addElementBindingHandler(handler);

View file

@ -36,7 +36,9 @@ import org.x4o.xml.element.ElementException;
public class AttributeAliasElement extends AbstractElement { public class AttributeAliasElement extends AbstractElement {
/** /**
* Add the xml attribute 'name' to ElementClassAttribute as attribute alias.
* @see org.x4o.xml.element.AbstractElement#doElementEnd() * @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 @Override
public void doElementEnd() throws ElementException { public void doElementEnd() throws ElementException {

View file

@ -24,6 +24,7 @@
package org.x4o.xml.eld.lang; package org.x4o.xml.eld.lang;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -32,8 +33,7 @@ import org.x4o.xml.element.AbstractElement;
import org.x4o.xml.element.ElementException; import org.x4o.xml.element.ElementException;
/** /**
* An BeanElement.<br> * BeanElement fills it elementObject from source with the bean.class attribute.
* This BeanElement fills it elementObject from source with the bean.class attribute.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Jan 21, 2007 * @version 1.0 Jan 21, 2007
@ -42,10 +42,17 @@ public class BeanElement extends AbstractElement {
private List<Object> constructorArguments = null; private List<Object> constructorArguments = null;
/**
* Creates a BeanElement.
*/
public BeanElement() { public BeanElement() {
constructorArguments = new ArrayList<Object>(3); 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 @Override
public void doElementStart() throws ElementException { public void doElementStart() throws ElementException {
String className = getAttributes().get("bean.class"); String className = getAttributes().get("bean.class");
@ -60,11 +67,25 @@ public class BeanElement extends AbstractElement {
Constructor<?> c = beanClass.getConstructor(arguClass); Constructor<?> c = beanClass.getConstructor(arguClass);
setElementObject(c.newInstance(constructorArguments)); 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); throw new ElementException(e);
} }
} }
/**
* Add bean constructor arguments.
* @param argu The argument to add to constructor.
*/
public void addConstuctorArgument(Object argu) { public void addConstuctorArgument(Object argu) {
if (argu==null) { if (argu==null) {
throw new NullPointerException("Can't add null argument for constructor."); 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() * @see org.x4o.xml.element.AbstractElement#doElementEnd()
* @throws ElementException When parent is not ElementClassBase.
*/ */
@Override @Override
public void doElementEnd() throws ElementException { public void doElementEnd() throws ElementException {

View file

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

View file

@ -30,7 +30,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* An AbstractElementClassBase. * AbstractElementClassBase provides basic element meta class support.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Jan 19, 2012 * @version 1.0 Jan 19, 2012
@ -56,31 +56,40 @@ public abstract class AbstractElementClassBase extends AbstractElementMetaBase i
/** /**
* @see ElementClass#addElementConfigurators(ElementConfigurator) * @see ElementClass#addElementConfigurators(ElementConfigurator)
* @param elementConfigurator The ElementConfigurator to add.
*/ */
public void addElementConfigurators(ElementConfigurator elementConfigurator) { public void addElementConfigurators(ElementConfigurator elementConfigurator) {
elementConfigurators.add(elementConfigurator); elementConfigurators.add(elementConfigurator);
} }
/** /**
* @param elementClassAttribute The ElementClassAttribute to add.
*/ */
public void addElementClassAttribute(ElementClassAttribute elementClassAttribute) { public void addElementClassAttribute(ElementClassAttribute elementClassAttribute) {
elementClassAttributes.put(elementClassAttribute.getName(),elementClassAttribute); elementClassAttributes.put(elementClassAttribute.getName(),elementClassAttribute);
} }
/** /**
* @return All the element attributes.
*/ */
public Collection<ElementClassAttribute> getElementClassAttributes() { public Collection<ElementClassAttribute> getElementClassAttributes() {
return elementClassAttributes.values(); 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) { public ElementClassAttribute getElementClassAttributeByName(String attributeName) {
return elementClassAttributes.get(attributeName); return elementClassAttributes.get(attributeName);
} }
/** /**
* Adds parent tag.
* @see org.x4o.xml.element.ElementClassBase#addElementParent(java.lang.String,java.lang.String) * @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) { public void addElementParent(String namespaceUri,String tag) {
if (namespaceUri==null) { 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) * @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) { public void removeElementParent(String namespaceUri,String tag) {
List<String> tags = elementParents.get(namespaceUri); 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) * @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) { public List<String> getElementParents(String namespaceUri) {
return elementParents.get(namespaceUri); return elementParents.get(namespaceUri);

View file

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

View file

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

View file

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

View file

@ -53,13 +53,19 @@ public interface Element {
/** The xml comments in xml. */ /** The xml comments in xml. */
comment, comment,
/** ignorableWhitespace in xml */ /** ignorableWhitespace in xml. */
ignorableWhitespace, ignorableWhitespace,
/** Receive raw sax event on elementObject */ /** Receive raw sax event on elementObject. */
overrideSax; 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); List<Element> result = new ArrayList<Element>(3);
for (int i=0;i<elements.size();i++) { for (int i=0;i<elements.size();i++) {
Element element = elements.get(i); Element element = elements.get(i);
@ -73,16 +79,19 @@ public interface Element {
/** /**
* This method is fired when the end xml tag is parsed. * 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; void doElementEnd() throws ElementException;
/** /**
* This method is fired when the start of xml tag is parsed. * 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; void doElementStart() throws ElementException;
/** /**
* This method is fired only once in the run phase. * This method is fired only once in the run phase.
* @throws ElementException Can be thrown when structure is not correct.
*/ */
void doElementRun() throws ElementException; void doElementRun() throws ElementException;
@ -103,6 +112,7 @@ public interface Element {
/** /**
* This method get called when this Element object is not needed anymore.<br> * This method get called when this Element object is not needed anymore.<br>
* Can be used to close resources. * Can be used to close resources.
* @throws ElementException Can be thrown when structure is not correct.
*/ */
void release() throws ElementException; void release() throws ElementException;
@ -135,19 +145,21 @@ public interface Element {
/** /**
* Sets the body texts on an event based system. * Sets the body texts on an event based system.
* @param body The body text. * @param body The body text.
* @throws ElementException Can be thrown when structure is not correct.
*/ */
void doCharacters(String body) throws ElementException; void doCharacters(String body) throws ElementException;
/** /**
* Sets the comment texts on an event based system. * Sets the comment texts on an event based system.
* @param comment The comment text. * @param comment The comment text.
* @throws ElementException Can be thrown when structure is not correct.
*/ */
void doComment(String comment) throws ElementException; void doComment(String comment) throws ElementException;
/** /**
* Is called when there is whitespace in xml. * Is called when there is whitespace in xml.
* @param space The space. * @param space The space.
* @throws ElementException * @throws ElementException Can be thrown when structure is not correct.
*/ */
void doIgnorableWhitespace(String space) throws ElementException; 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. * Sets the attribute name this attribute handler handles.
* @param attributeName * @param attributeName The attribute to handle.
*/ */
void setAttributeName(String attributeName); void setAttributeName(String attributeName);
/** /**
* Adds an NextAttribute. * Adds an NextAttribute.
* There next attributes will defines the order in which the ElementAttributeHandlers are executed. * 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); void addNextAttribute(String attribute);
/** /**
* Removes an next attribute * Removes an next attribute.
* @param attribute * @param attribute Removes this next attribute.
*/ */
void removeNextAttribute(String attribute); void removeNextAttribute(String attribute);
/** /**
* Get all next attributes * Get all next attributes.
* @return Returns the list of all next attributes. * @return Returns the list of all next attributes.
*/ */
List<String> getNextAttributes(); List<String> getNextAttributes();

View file

@ -50,7 +50,8 @@ public interface ElementBindingHandler extends ElementMetaBase {
* Do the binding of this child to the parent object. * Do the binding of this child to the parent object.
* @param parentObject The parentObject of this childElement. * @param parentObject The parentObject of this childElement.
* @param childObject The childObject 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; 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 { 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(); 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); void setName(String name);
/** /**
* Gets the ObjectConverter * Gets the ObjectConverter.
* @return The ObjectConverter.
*/ */
ObjectConverter getObjectConverter(); 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); void setObjectConverter(ObjectConverter objectConverter);
/** /**
* Sets the defaultValue of this attribute * Sets the defaultValue of this attribute.
* @param defaultValue The defaultValue to set. * @param defaultValue The defaultValue to set.
*/ */
void setDefaultValue(Object defaultValue); void setDefaultValue(Object defaultValue);
@ -87,42 +91,44 @@ public interface ElementClassAttribute extends ElementMetaBase {
List<String> getAttributeAliases(); List<String> getAttributeAliases();
/** /**
* @return the required * Gets the required state of this attribute.
* @return If true then attribute is required.
*/ */
Boolean getRequired(); 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); void setRequired(Boolean required);
/** /**
* @return the runResolveEL * @return the runResolveEL.
*/ */
Boolean getRunResolveEL(); Boolean getRunResolveEL();
/** /**
* @param runResolveEL the runResolveEL to set * @param runResolveEL the runResolveEL to set.
*/ */
void setRunResolveEL(Boolean runResolveEL); void setRunResolveEL(Boolean runResolveEL);
/** /**
* @return the runConverters * @return the runConverters.
*/ */
Boolean getRunConverters(); Boolean getRunConverters();
/** /**
* @param runConverters the runConverters to set * @param runConverters the runConverters to set.
*/ */
void setRunConverters(Boolean runConverters); void setRunConverters(Boolean runConverters);
/** /**
* @return the runBeanFill * @return the runBeanFill.
*/ */
Boolean getRunBeanFill(); Boolean getRunBeanFill();
/** /**
* @param runBeanFill the runBeanFill to set * @param runBeanFill the runBeanFill to set.
*/ */
void setRunBeanFill(Boolean runBeanFill); void setRunBeanFill(Boolean runBeanFill);
} }

View file

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

View file

@ -24,9 +24,7 @@
package org.x4o.xml.element; package org.x4o.xml.element;
/** /**
* Provides elements from tag.<br> * ElementNamespaceInstanceProvider is provider for creating new Element instances for an xml tag.<br>
* And ElementClass from a tag.<br>
*
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Jul 8, 2006 * @version 1.0 Jul 8, 2006
@ -34,23 +32,18 @@ package org.x4o.xml.element;
public interface ElementNamespaceInstanceProvider { public interface ElementNamespaceInstanceProvider {
/** /**
* Starts the ElementProvider * Starts the ElementProvider.
* @throws ElementLanguageModuleLoaderException * @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; void start(ElementLanguage elementLanguage,ElementNamespaceContext elementNamespaceContext) throws ElementNamespaceInstanceProviderException;
/** /**
* Provide an Element for an tag * Provide an Element for an xml tag.
* @param tag The xml tag * @param tag The xml tag to create instance for.
* @return An Element * @return An new Element instance.
* @throws ElementLanguageModuleLoaderException * @throws ElementNamespaceInstanceProviderException Thrown when error happened in language.
*/ */
Element createElementInstance(String tag) throws ElementNamespaceInstanceProviderException; 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 * @author Willem Cazander
* @version 1.0 Aug 2, 2012 * @version 1.0 Aug 2, 2012
@ -37,16 +35,31 @@ public class ElementNamespaceInstanceProviderException extends ElementException
private ElementNamespaceInstanceProvider elementNamespaceInstanceProvider = null; 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) { public ElementNamespaceInstanceProviderException(ElementNamespaceInstanceProvider elementNamespaceInstanceProvider,String message) {
super(message); super(message);
this.elementNamespaceInstanceProvider=elementNamespaceInstanceProvider; 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) { public ElementNamespaceInstanceProviderException(ElementNamespaceInstanceProvider elementNamespaceInstanceProvider,String message,Exception exception) {
super(message,exception); super(message,exception);
this.elementNamespaceInstanceProvider=elementNamespaceInstanceProvider; this.elementNamespaceInstanceProvider=elementNamespaceInstanceProvider;
} }
/**
* Gets the ElementNamespaceInstanceProvider which created this exception.
* @return The provider which created the exception.
*/
public ElementNamespaceInstanceProvider getElementNamespaceInstanceProvider() { public ElementNamespaceInstanceProvider getElementNamespaceInstanceProvider() {
return elementNamespaceInstanceProvider; return elementNamespaceInstanceProvider;
} }

View file

@ -52,7 +52,7 @@ import org.xml.sax.ext.DefaultHandler2;
import org.xml.sax.helpers.XMLReaderFactory; 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 * @author Willem Cazander
* @version 1.0 28 Oct 2009 * @version 1.0 28 Oct 2009
@ -62,11 +62,19 @@ public class DefaultX4OLanguageLoader implements X4OLanguageLoader {
private Logger logger = null; private Logger logger = null;
protected List<Map<String,Map<String,String>>> modulesAll = null; protected List<Map<String,Map<String,String>>> modulesAll = null;
/**
* Creates the DefaultX4OLanguageLoader.
*/
public DefaultX4OLanguageLoader() { public DefaultX4OLanguageLoader() {
logger = Logger.getLogger(DefaultX4OLanguageLoader.class.getName()); logger = Logger.getLogger(DefaultX4OLanguageLoader.class.getName());
modulesAll = new ArrayList<Map<String,Map<String,String>>>(20); 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) { private void logMessage(ElementLanguage elementLanguage,String message) {
logger.finest(message); logger.finest(message);
if (elementLanguage.getLanguageConfiguration().hasX4ODebugWriter()) { 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 { protected void loadLanguageModules(ElementLanguage elementLanguage,String language) throws IOException, SAXException {
StringBuilder buf = new StringBuilder(150); 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. * @param in The inputstream to parser.
* @throws IOException * @throws IOException
* @throws SAXException * @throws SAXException

View file

@ -38,6 +38,9 @@ public class DefaultX4OLanguageVersionFilter implements X4OLanguageVersionFilter
/** /**
* Filters to the best version. * Filters to the best version.
* @see org.x4o.xml.core.config.X4OLanguageVersionFilter#filterVersion(java.lang.String, java.util.List) * @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) { public String filterVersion(String requestVersion, List<String> versions) {
for (int i=0;i<versions.size();i++) { for (int i=0;i<versions.size();i++) {

View file

@ -42,11 +42,20 @@ public class X4OELResolver extends ELResolver {
private ELResolver delegate = null; private ELResolver delegate = null;
private Map<Object,Object> objectStore = 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) { public X4OELResolver(Map<Object, Object> objectStore) {
this.objectStore = objectStore; this.objectStore = objectStore;
delegate = new MapELResolver(); 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) { private Object checkBase(Object base) {
if (base==null) { if (base==null) {
return objectStore; return objectStore;

View file

@ -49,6 +49,8 @@ public class X4OELVariableMapper extends VariableMapper {
/** /**
* @see javax.el.VariableMapper#resolveVariable(java.lang.String) * @see javax.el.VariableMapper#resolveVariable(java.lang.String)
* @param var Resolve this var to an ValueExpression.
* @return The resolved ValueExpression of the var.
*/ */
@Override @Override
public ValueExpression resolveVariable(String var) { 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) * @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 @Override
public ValueExpression setVariable(String var, ValueExpression expression) { public ValueExpression setVariable(String var, ValueExpression expression) {
return expressions.put(var, expression); return expressions.put(var, expression);
} }
} }

View file

@ -35,6 +35,8 @@ import java.util.Set;
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 17/04/2005 * @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> { 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; private String uri = null;
/** /**
* Constuctes an new AttributeMap * Constuctes an new AttributeMap.
* *
* @param attributes * @param attributes The data backend of this map.
* The data backend of this map.
*/ */
public AttributeMap(Attributes attributes) { public AttributeMap(Attributes attributes) {
setAttributes(attributes); setAttributes(attributes);
} }
/** /**
* Constructes an new AttributesMap * Constructes an new AttributesMap.
* *
* @param attributes * @param attributes The data backed of this map.
* The dat backed of this map. * @param uri The namespace of these attributes.
* @param uri
* The namespace of these attributes.
*/ */
public AttributeMap(Attributes attributes, String uri) { public AttributeMap(Attributes attributes, String uri) {
setAttributes(attributes); setAttributes(attributes);
@ -70,8 +69,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
/** /**
* Sets the data backend of this map. * Sets the data backend of this map.
* *
* @param attributes * @param attributes The Attributes to be used as data backend.
* The Attributes to be used as data backend.
*/ */
public void setAttributes(Attributes attributes) { public void setAttributes(Attributes attributes) {
this.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). * Sets the namespace uri, when set to null it is disabled(default).
* *
* @param uri * @param uri The namespace uri for when parsing when an certain namespace is required.
* The namespace uri for when parsing when an certain namespace
* is required.
*/ */
public void setNameSpace(String uri) { public void setNameSpace(String uri) {
this.uri = 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. * Gets the local of full name by index.
* *
* @param index * @param index The index of the attribute.
* The index of the attribute.
* @return The name of the attribute. * @return The name of the attribute.
*/ */
private String getName(int index) { 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. * Checks if there is an attributes with an certain key.
* *
* @param key * @param key The name of an attribute.
* The name of an attribute.
* @return True if the attributes excist. * @return True if the attributes excist.
*/ */
public boolean containsKey(Object key) { 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. * Checks if there is an attributes with an value.
* *
* @param value * @param value The value to check.
* The value to check.
* @return True if an attributes has this value. * @return True if an attributes has this value.
*/ */
public boolean containsValue(Object 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. * Returns The value of an attribute.
* *
* @param key * @param key The name of the attribute.
* The name of the attribute.
* @return The value of the attribute. * @return The value of the attribute.
*/ */
@SuppressWarnings("unchecked") @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. * Function not implements. because we can't add to the attributes.
* *
* @param key * @param key ignored.
* ignored. * @param value ignored.
* @param value
* ignored.
* @return always null * @return always null
*/ */
public V put(K key, V value) { public V put(K key, V value) {
// we can't add. return null; // we can't add.
return null;
} }
/** /**
* Function not implements. because we can't remove to the attributes. * Function not implements. because we can't remove to the attributes.
* *
* @param key * @param key ignored.
* ignored.
* @return always null * @return always null
*/ */
public V remove(Object key) { public V remove(Object key) {
// we can't remove return null ;// we can't remove
return null;
} }
/** /**
* Function not implements. because we can't add to the attributes. * Function not implements. because we can't add to the attributes.
* *
* @param t * @param t ignored.
* ignored.
*/ */
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public void putAll(Map t) { 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. * @return True if the object are equal.
*/ */
public boolean equals(Object o) { public boolean equals(Object o) {
// compare to attributes return attributes.equals(o); // compare to attributes
return attributes.equals(o);
} }
/** /**
@ -334,24 +319,43 @@ public class AttributeMap<K,V> implements Map<K,V> {
private Object key = null; private Object key = null;
private Object value = null; private Object value = null;
/**
* Creates AttributeMapEntry with key object.
* @param key The key.
*/
protected AttributeMapEntry(Object key) { protected AttributeMapEntry(Object key) {
this.key = key; this.key = key;
} }
/**
* @return Returns the key.
*/
public Object getKey() { public Object getKey() {
return key; return key;
} }
/**
* Sets the value of this Map.Entry.
* @param value The value to set.
* @return The old value.
*/
public Object setValue(Object value) { public Object setValue(Object value) {
Object result = this.value; Object result = this.value;
this.value = value; this.value = value;
return result; return result;
} }
/**
* @return The value of this Map.Entry.
*/
public Object getValue() { public Object getValue() {
return value; 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) { public boolean equals(Object o) {
if (o instanceof Map.Entry) { if (o instanceof Map.Entry) {
Map.Entry mapEntry = (Map.Entry) o; Map.Entry mapEntry = (Map.Entry) o;
@ -361,5 +365,14 @@ public class AttributeMap<K,V> implements Map<K,V> {
} }
return false; 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 StringBuffer startElement = null;
private boolean printedReturn = false; 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) { public XMLWriter(Writer out) {
this.out = 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 { public XMLWriter(OutputStream out) throws UnsupportedEncodingException {
this.out = new OutputStreamWriter(out, "UTF-8"); 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) * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
*/ */
@Override @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) * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
*/ */
@Override @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) * @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String)
*/ */
@Override @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) * @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String)
*/ */
@Override @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) * @see org.xml.sax.ContentHandler#characters(char[], int, int)
*/ */
@Override @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) * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
*/ */
@Override @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) * @see org.xml.sax.ContentHandler#processingInstruction(java.lang.String, java.lang.String)
* @param target The target.
* @param data The data.
*/ */
@Override @Override
public void processingInstruction(String target, String data) throws SAXException { 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) * @see org.xml.sax.ContentHandler#setDocumentLocator(org.xml.sax.Locator)
* @param locator The DocumentLocator to set.
*/ */
@Override @Override
public void setDocumentLocator(Locator locator) { public void setDocumentLocator(Locator locator) {
} }
/** /**
* Not implemented.
*
* @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String) * @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String)
* @param name The name of the skipped entity.
*/ */
@Override @Override
public void skippedEntity(String name) throws SAXException { 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) * @see org.xml.sax.ext.DefaultHandler2#comment(char[], int, int)
*/ */
@Override @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 { private void indent() throws IOException {
for (int i = 0; i < indent; i++) { for (int i = 0; i < indent; i++) {
out.write('\t'); out.write('\t');

View file

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

View file

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

View file

@ -48,6 +48,7 @@ public class MetaLanguageSiblingLoader implements ElementLanguageModuleLoaderSib
* Loads an ElementLanguageModule. * Loads an ElementLanguageModule.
* @param elementLanguage The ElementLanguage to load for. * @param elementLanguage The ElementLanguage to load for.
* @param elementLanguageModule The ElementLanguageModule to load into. * @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) * @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 { public void loadLanguageModule(ElementLanguage elementLanguage,ElementLanguageModule elementLanguageModule) throws ElementLanguageModuleLoaderException {