X4O: Formated x4o-driver module java classes
This commit is contained in:
parent
ed096a1427
commit
0b75d4e283
108 changed files with 2420 additions and 2248 deletions
|
|
@ -46,116 +46,109 @@ public abstract class X4ODriver<T> {
|
|||
|
||||
/** Defines the default version if none is defined. */
|
||||
public final static String DEFAULT_LANGUAGE_VERSION = "1.0";
|
||||
|
||||
|
||||
/**
|
||||
* marker constructor.
|
||||
*/
|
||||
public X4ODriver(/*X4ODriverManager.ConstructorMarker marker*/) {
|
||||
public X4ODriver(/* X4ODriverManager.ConstructorMarker marker */) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the langauge name of this driver.
|
||||
* @return Returns the langauge name of this driver.
|
||||
*/
|
||||
abstract public String getLanguageName();
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the supported language versions for this driver.
|
||||
* @return Returns the supported language versions for this driver.
|
||||
*/
|
||||
abstract public String[] getLanguageVersions();
|
||||
|
||||
|
||||
|
||||
|
||||
// =============== build methods to override
|
||||
|
||||
|
||||
protected X4OLanguage buildLanguage(String version) {
|
||||
return X4ODriverManager.getDefaultBuildLanguage(this, version);
|
||||
}
|
||||
|
||||
|
||||
protected X4OPhaseManager buildPhaseManager() {
|
||||
return X4ODriverManager.getDefaultBuildPhaseManager();
|
||||
}
|
||||
|
||||
|
||||
protected X4OLanguageConfiguration buildLanguageConfiguration() {
|
||||
return X4ODriverManager.getDefaultBuildLanguageConfiguration();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// =============== Reader
|
||||
|
||||
|
||||
public X4OReader<T> createReader() {
|
||||
return createReaderSession();
|
||||
}
|
||||
|
||||
|
||||
public X4OReader<T> createReader(String version) {
|
||||
return createReaderSession(version);
|
||||
}
|
||||
|
||||
|
||||
public X4OReaderSession<T> createReaderSession() {
|
||||
return createReaderSession(getLanguageVersionDefault());
|
||||
}
|
||||
|
||||
|
||||
public X4OReaderSession<T> createReaderSession(String version) {
|
||||
return new DefaultX4OReader<T>(createLanguage(version));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// =============== Writer
|
||||
|
||||
|
||||
public X4OWriter<T> createWriter() {
|
||||
return createWriterSession();
|
||||
}
|
||||
|
||||
|
||||
public X4OWriter<T> createWriter(String version) {
|
||||
return createWriterSession(version);
|
||||
}
|
||||
|
||||
|
||||
public X4OWriterSession<T> createWriterSession() {
|
||||
return createWriterSession(getLanguageVersionDefault());
|
||||
}
|
||||
|
||||
|
||||
public X4OWriterSession<T> createWriterSession(String version) {
|
||||
return new DefaultX4OWriter<T>(createLanguage(version));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// =============== Language
|
||||
|
||||
|
||||
/**
|
||||
* Returns the default language which is the latest version.
|
||||
* @return The default language version.
|
||||
*
|
||||
* @return The default language version.
|
||||
*/
|
||||
final public String getLanguageVersionDefault() {
|
||||
return X4ODriverManager.getDefaultLanguageVersion(getLanguageVersions());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the X4OLanguage for the specified version.
|
||||
* @param version The language version to create.
|
||||
* @return The created X4OLanguage.
|
||||
*
|
||||
* @param version The language version to create.
|
||||
* @return The created X4OLanguage.
|
||||
*/
|
||||
final public X4OLanguage createLanguage(String version) {
|
||||
return buildLanguage(version);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates the X4OLanguage for the default version.
|
||||
* @return The created X4OLanguage.
|
||||
*
|
||||
* @return The created X4OLanguage.
|
||||
*/
|
||||
final public X4OLanguage createLanguage() {
|
||||
return buildLanguage(getLanguageVersionDefault());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// =============== Language Tasks
|
||||
|
||||
final public X4OLanguageTask getLanguageTask(String taskId) {
|
||||
return X4ODriverManager.getX4OLanguageTask(taskId);
|
||||
}
|
||||
|
||||
|
||||
final public List<X4OLanguageTask> getLanguageTasks() {
|
||||
return X4ODriverManager.getX4OLanguageTasks();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,33 +34,35 @@ import java.util.Locale;
|
|||
*/
|
||||
@SuppressWarnings("serial")
|
||||
abstract public class AbstractObjectConverter implements ObjectConverter {
|
||||
|
||||
|
||||
protected List<ObjectConverter> converters = new ArrayList<ObjectConverter>(5);
|
||||
|
||||
abstract public Object convertAfterTo(Object obj, Locale locale) throws ObjectConverterException;
|
||||
|
||||
abstract public Object convertAfterBack(Object obj, Locale locale) throws ObjectConverterException;
|
||||
|
||||
abstract public ObjectConverter clone() throws CloneNotSupportedException;
|
||||
|
||||
|
||||
protected List<ObjectConverter> cloneConverters() throws CloneNotSupportedException {
|
||||
List<ObjectConverter> result = new ArrayList<ObjectConverter>(converters.size());
|
||||
for (ObjectConverter converter:converters) {
|
||||
for (ObjectConverter converter : converters) {
|
||||
result.add(converter.clone());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.conv.ObjectConverter#convertTo(java.lang.Object, java.util.Locale)
|
||||
*/
|
||||
public Object convertTo(Object obj, Locale locale) throws ObjectConverterException {
|
||||
if (converters.isEmpty()) {
|
||||
return convertAfterTo(obj,locale);
|
||||
return convertAfterTo(obj, locale);
|
||||
}
|
||||
Object result = null;
|
||||
for (ObjectConverter conv:converters) {
|
||||
for (ObjectConverter conv : converters) {
|
||||
result = conv.convertTo(obj, locale);
|
||||
}
|
||||
result = convertAfterTo(obj,locale);
|
||||
result = convertAfterTo(obj, locale);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -69,13 +71,13 @@ abstract public class AbstractObjectConverter implements ObjectConverter {
|
|||
*/
|
||||
public Object convertBack(Object obj, Locale locale) throws ObjectConverterException {
|
||||
if (converters.isEmpty()) {
|
||||
return convertAfterBack(obj,locale);
|
||||
return convertAfterBack(obj, locale);
|
||||
}
|
||||
Object result = null;
|
||||
for (ObjectConverter conv:converters) {
|
||||
for (ObjectConverter conv : converters) {
|
||||
result = conv.convertBack(obj, locale);
|
||||
}
|
||||
result = convertAfterBack(obj,locale);
|
||||
result = convertAfterBack(obj, locale);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,16 +42,17 @@ abstract public class AbstractStringObjectConverter extends AbstractObjectConver
|
|||
|
||||
public Object convertAfterTo(Object obj, Locale locale) throws ObjectConverterException {
|
||||
if (obj instanceof String) {
|
||||
return convertStringTo((String)obj,locale);
|
||||
return convertStringTo((String) obj, locale);
|
||||
} else {
|
||||
return convertStringTo(obj.toString(),locale);
|
||||
return convertStringTo(obj.toString(), locale);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Object convertAfterBack(Object obj, Locale locale) throws ObjectConverterException {
|
||||
return convertStringBack(obj,locale);
|
||||
return convertStringBack(obj, locale);
|
||||
}
|
||||
|
||||
abstract public Object convertStringTo(String str, Locale locale) throws ObjectConverterException;
|
||||
abstract public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException;
|
||||
|
||||
abstract public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,19 +43,20 @@ import org.x4o.xml.conv.text.URLConverter;
|
|||
* @version 1.0 Jan 20, 2012
|
||||
*/
|
||||
public class DefaultObjectConverterProvider implements ObjectConverterProvider {
|
||||
|
||||
private Map<Class<?>,ObjectConverter> converters = null;
|
||||
|
||||
|
||||
private Map<Class<?>, ObjectConverter> converters = null;
|
||||
|
||||
/**
|
||||
* Create new DefaultObjectConverterProvider.
|
||||
*/
|
||||
public DefaultObjectConverterProvider() {
|
||||
converters = new HashMap<Class<?>,ObjectConverter>(20);
|
||||
converters = new HashMap<Class<?>, ObjectConverter>(20);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create new DefaultObjectConverterProvider.
|
||||
* @param addDefaults When true do the addDefaults().
|
||||
*
|
||||
* @param addDefaults When true do the addDefaults().
|
||||
*/
|
||||
public DefaultObjectConverterProvider(boolean addDefaults) {
|
||||
this();
|
||||
|
|
@ -63,7 +64,7 @@ public class DefaultObjectConverterProvider implements ObjectConverterProvider {
|
|||
addDefaults();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds the default converters.
|
||||
*/
|
||||
|
|
@ -78,9 +79,9 @@ public class DefaultObjectConverterProvider implements ObjectConverterProvider {
|
|||
addObjectConverter(new URLConverter());
|
||||
addObjectConverter(new ClassConverter());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param converter The converter to add.
|
||||
* @param converter The converter to add.
|
||||
*/
|
||||
public void addObjectConverter(ObjectConverter converter) {
|
||||
converters.put(converter.getObjectClassTo(), converter);
|
||||
|
|
@ -89,14 +90,14 @@ public class DefaultObjectConverterProvider implements ObjectConverterProvider {
|
|||
/**
|
||||
* @see org.x4o.xml.conv.ObjectConverterProvider#getObjectConverterForClass(java.lang.Class)
|
||||
* @param clazz The Class to search an ObjectConverter for.
|
||||
* @return The ObjectConverter or null for the class.
|
||||
* @return The ObjectConverter or null for the class.
|
||||
*/
|
||||
public ObjectConverter getObjectConverterForClass(Class<?> clazz) {
|
||||
return converters.get(clazz);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns all ObjectConverted stored in this class.
|
||||
* @return Returns all ObjectConverted stored in this class.
|
||||
*/
|
||||
protected Collection<ObjectConverter> getObjectConverters() {
|
||||
return converters.values();
|
||||
|
|
|
|||
|
|
@ -32,56 +32,58 @@ import java.util.Locale;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 28, 2008
|
||||
*/
|
||||
public interface ObjectConverter extends Cloneable,Serializable {
|
||||
public interface ObjectConverter extends Cloneable, Serializable {
|
||||
|
||||
/**
|
||||
* @return Returns the class which we can convert to.
|
||||
* @return Returns the class which we can convert to.
|
||||
*/
|
||||
Class<?> getObjectClassTo();
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the class which we can convert from.
|
||||
* @return Returns the class which we can convert from.
|
||||
*/
|
||||
Class<?> getObjectClassBack();
|
||||
|
||||
|
||||
/**
|
||||
* Convert to the object.
|
||||
* @param obj The object to convert.
|
||||
* @param locale The Object convert locale if needed.
|
||||
*
|
||||
* @param obj The object to convert.
|
||||
* @param locale The Object convert locale if needed.
|
||||
* @return Returns the converted object.
|
||||
* @throws ObjectConverterException When the conversion failes.
|
||||
* @throws ObjectConverterException When the conversion failes.
|
||||
*/
|
||||
Object convertTo(Object obj,Locale locale) throws ObjectConverterException;
|
||||
|
||||
Object convertTo(Object obj, Locale locale) throws ObjectConverterException;
|
||||
|
||||
/**
|
||||
* Convert the object back.
|
||||
* @param obj The object to convert.
|
||||
* @param locale The Object convert locale if needed.
|
||||
*
|
||||
* @param obj The object to convert.
|
||||
* @param locale The Object convert locale if needed.
|
||||
* @return Returns the converted object.
|
||||
* @throws ObjectConverterException When the conversion failes.
|
||||
* @throws ObjectConverterException When the conversion failes.
|
||||
*/
|
||||
Object convertBack(Object obj,Locale locale) throws ObjectConverterException;
|
||||
|
||||
Object convertBack(Object obj, Locale locale) throws ObjectConverterException;
|
||||
|
||||
/**
|
||||
* @return Returns list of child converters.
|
||||
* @return Returns list of child converters.
|
||||
*/
|
||||
List<ObjectConverter> getObjectConverters();
|
||||
|
||||
|
||||
/**
|
||||
* @param converter Adds an child converter.
|
||||
* @param converter Adds an child converter.
|
||||
*/
|
||||
void addObjectConverter(ObjectConverter converter);
|
||||
|
||||
|
||||
/**
|
||||
* @param converter Removes this child converter.
|
||||
* @param converter Removes this child converter.
|
||||
*/
|
||||
void removeObjectConverter(ObjectConverter converter);
|
||||
|
||||
|
||||
/**
|
||||
* Force impl to have public clone method.
|
||||
*
|
||||
* @return An cloned ObjectConverter.
|
||||
* @throws CloneNotSupportedException If thrown when cloning is not supported.
|
||||
* @return An cloned ObjectConverter.
|
||||
* @throws CloneNotSupportedException If thrown when cloning is not supported.
|
||||
*/
|
||||
ObjectConverter clone() throws CloneNotSupportedException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,33 +29,35 @@ package org.x4o.xml.conv;
|
|||
* @version 1.0 Jan 20, 2012
|
||||
*/
|
||||
public class ObjectConverterException extends Exception {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final ObjectConverter converter;
|
||||
|
||||
/**
|
||||
* Creates an ObjectConverterException.
|
||||
* @param converter The converter which has the exception.
|
||||
* @param message The exception message.
|
||||
*
|
||||
* @param converter The converter which has the exception.
|
||||
* @param message The exception message.
|
||||
*/
|
||||
public ObjectConverterException(ObjectConverter converter,String message) {
|
||||
public ObjectConverterException(ObjectConverter converter, String message) {
|
||||
super(message);
|
||||
this.converter=converter;
|
||||
this.converter = converter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates an ObjectConverterException.
|
||||
* @param converter The converter which has the exception.
|
||||
* @param message The exception message.
|
||||
* @param exception The parent exception.
|
||||
*
|
||||
* @param converter The converter which has the exception.
|
||||
* @param message The exception message.
|
||||
* @param exception The parent exception.
|
||||
*/
|
||||
public ObjectConverterException(ObjectConverter converter,String message,Exception exception) {
|
||||
super(message,exception);
|
||||
this.converter=converter;
|
||||
public ObjectConverterException(ObjectConverter converter, String message, Exception exception) {
|
||||
super(message, exception);
|
||||
this.converter = converter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the ObjectConverter of this exception.
|
||||
* @return Returns the ObjectConverter of this exception.
|
||||
*/
|
||||
public ObjectConverter getObjectConverter() {
|
||||
return converter;
|
||||
|
|
|
|||
|
|
@ -29,11 +29,12 @@ package org.x4o.xml.conv;
|
|||
* @version 1.0 Jan 20, 2012
|
||||
*/
|
||||
public interface ObjectConverterProvider {
|
||||
|
||||
|
||||
/**
|
||||
* Provides an ObjectConvert based on the converted class result.
|
||||
* @param clazz The result class we want.
|
||||
* @return The ObjectConverter which can convert for us.
|
||||
*
|
||||
* @param clazz The result class we want.
|
||||
* @return The ObjectConverter which can convert for us.
|
||||
*/
|
||||
ObjectConverter getObjectConverterForClass(Class<?> clazz);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.conv.text;
|
||||
package org.x4o.xml.conv.text;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
|
@ -35,67 +35,66 @@ import org.x4o.xml.lang.X4OLanguageClassLoader;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 31, 2007
|
||||
*/
|
||||
@SuppressWarnings({"rawtypes","unchecked"})
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public class EnumConverter extends AbstractStringObjectConverter {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 8860785472427794548L;
|
||||
|
||||
|
||||
private String enumClass = 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() {
|
||||
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 str The string to convert to object.
|
||||
* @param locale The locale to convert the string from.
|
||||
* @return The object converted from the string.
|
||||
* @throws ObjectConverterException When conversion fails.
|
||||
*/
|
||||
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
||||
if (getEnumClass()==null) {
|
||||
throw new ObjectConverterException(this,"enumClass String attribute is not set.");
|
||||
if (getEnumClass() == null) {
|
||||
throw new ObjectConverterException(this, "enumClass String attribute is not set.");
|
||||
}
|
||||
//if (value instanceof Enum) {
|
||||
// return value;
|
||||
//}
|
||||
String v = str; //value.toString();
|
||||
// if (value instanceof Enum) {
|
||||
// return value;
|
||||
// }
|
||||
String v = str; // value.toString();
|
||||
try {
|
||||
if (enumObjectClass==null) {
|
||||
enumObjectClass = (Class<?>)X4OLanguageClassLoader.loadClass(getEnumClass());
|
||||
if (enumObjectClass == null) {
|
||||
enumObjectClass = (Class<?>) X4OLanguageClassLoader.loadClass(getEnumClass());
|
||||
}
|
||||
if (enumObjectClass==null) {
|
||||
throw new ObjectConverterException(this,"Could not load enumClass");
|
||||
if (enumObjectClass == null) {
|
||||
throw new ObjectConverterException(this, "Could not load enumClass");
|
||||
}
|
||||
return Enum.valueOf(enumObjectClass, v);
|
||||
} catch (Exception e) {
|
||||
throw new ObjectConverterException(this,e.getMessage(),e);
|
||||
throw new ObjectConverterException(this, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 obj The object to convert to string.
|
||||
* @param locale The locale to convert the object from.
|
||||
* @return The string converted from the object.
|
||||
* @throws ObjectConverterException When conversion fails.
|
||||
*/
|
||||
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
|
||||
return ((Enum<?>)obj).name();
|
||||
public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException {
|
||||
return ((Enum<?>) obj).name();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -105,16 +104,16 @@ public class EnumConverter extends AbstractStringObjectConverter {
|
|||
return enumClass;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param enumClass the enumClass to set
|
||||
*/
|
||||
public void setEnumClass(String enumClass) {
|
||||
this.enumClass = enumClass;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clone this ObjectConverter.
|
||||
*
|
||||
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
||||
* @return The cloned ObjectConverter.
|
||||
* @throws CloneNotSupportedException When cloning fails.
|
||||
|
|
@ -122,8 +121,8 @@ public class EnumConverter extends AbstractStringObjectConverter {
|
|||
@Override
|
||||
public ObjectConverter clone() throws CloneNotSupportedException {
|
||||
EnumConverter result = new EnumConverter();
|
||||
result.converters=cloneConverters();
|
||||
result.enumClass=enumClass;
|
||||
result.converters = cloneConverters();
|
||||
result.enumClass = enumClass;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,18 +40,19 @@ public class FloatConverter extends AbstractStringObjectConverter {
|
|||
|
||||
/**
|
||||
* Returns the convert to class.
|
||||
*
|
||||
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
||||
* @return The class to convert to.
|
||||
*/
|
||||
public Class<?> getObjectClassTo() {
|
||||
return Float.class;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts string into object.
|
||||
*
|
||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
||||
* @param str The string to convert to object.
|
||||
* @param 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.
|
||||
|
|
@ -59,22 +60,23 @@ public class FloatConverter extends AbstractStringObjectConverter {
|
|||
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
||||
return Float.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 obj The object to convert to string.
|
||||
* @param locale The locale to convert the object from.
|
||||
* @return The string converted from the object.
|
||||
* @throws ObjectConverterException When conversion fails.
|
||||
*/
|
||||
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
|
||||
return ((Float)obj).toString();
|
||||
public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException {
|
||||
return ((Float) obj).toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clone this ObjectConverter.
|
||||
*
|
||||
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
||||
* @return The cloned ObjectConverter.
|
||||
* @throws CloneNotSupportedException When cloning fails.
|
||||
|
|
@ -82,7 +84,7 @@ public class FloatConverter extends AbstractStringObjectConverter {
|
|||
@Override
|
||||
public ObjectConverter clone() throws CloneNotSupportedException {
|
||||
FloatConverter result = new FloatConverter();
|
||||
result.converters=cloneConverters();
|
||||
result.converters = cloneConverters();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,18 +40,19 @@ public class IntegerConverter extends AbstractStringObjectConverter {
|
|||
|
||||
/**
|
||||
* Returns the convert to class.
|
||||
*
|
||||
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
||||
* @return The class to convert to.
|
||||
*/
|
||||
public Class<?> getObjectClassTo() {
|
||||
return Integer.class;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts string into object.
|
||||
*
|
||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
||||
* @param str The string to convert to object.
|
||||
* @param 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.
|
||||
|
|
@ -59,22 +60,23 @@ public class IntegerConverter extends AbstractStringObjectConverter {
|
|||
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
||||
return Integer.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 obj The object to convert to string.
|
||||
* @param locale The locale to convert the object from.
|
||||
* @return The string converted from the object.
|
||||
* @throws ObjectConverterException When conversion fails.
|
||||
*/
|
||||
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
|
||||
return ((Integer)obj).toString();
|
||||
public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException {
|
||||
return ((Integer) obj).toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clone this ObjectConverter.
|
||||
*
|
||||
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
||||
* @return The cloned ObjectConverter.
|
||||
* @throws CloneNotSupportedException When cloning fails.
|
||||
|
|
@ -82,7 +84,7 @@ public class IntegerConverter extends AbstractStringObjectConverter {
|
|||
@Override
|
||||
public ObjectConverter clone() throws CloneNotSupportedException {
|
||||
IntegerConverter result = new IntegerConverter();
|
||||
result.converters=cloneConverters();
|
||||
result.converters = cloneConverters();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,18 +40,19 @@ public class LongConverter extends AbstractStringObjectConverter {
|
|||
|
||||
/**
|
||||
* Returns the convert to class.
|
||||
*
|
||||
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
||||
* @return The class to convert to.
|
||||
*/
|
||||
public Class<?> getObjectClassTo() {
|
||||
return Long.class;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts string into object.
|
||||
*
|
||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
||||
* @param str The string to convert to object.
|
||||
* @param 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.
|
||||
|
|
@ -59,22 +60,23 @@ public class LongConverter extends AbstractStringObjectConverter {
|
|||
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
||||
return Long.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 obj The object to convert to string.
|
||||
* @param locale The locale to convert the object from.
|
||||
* @return The string converted from the object.
|
||||
* @throws ObjectConverterException When conversion fails.
|
||||
*/
|
||||
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
|
||||
return ((Long)obj).toString();
|
||||
public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException {
|
||||
return ((Long) obj).toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clone this ObjectConverter.
|
||||
*
|
||||
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
||||
* @return The cloned ObjectConverter.
|
||||
* @throws CloneNotSupportedException When cloning fails.
|
||||
|
|
@ -82,7 +84,7 @@ public class LongConverter extends AbstractStringObjectConverter {
|
|||
@Override
|
||||
public ObjectConverter clone() throws CloneNotSupportedException {
|
||||
LongConverter result = new LongConverter();
|
||||
result.converters=cloneConverters();
|
||||
result.converters = cloneConverters();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,76 +49,77 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
|||
private String singleToMethod = null;
|
||||
private Boolean useNativeType = null;
|
||||
private List<StringSplitConverterStep> stringSplitConverterSteps = null;
|
||||
|
||||
|
||||
public StringSplitConverter() {
|
||||
stringSplitConverterSteps = new ArrayList<StringSplitConverterStep>(10);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the convert to class.
|
||||
*
|
||||
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
||||
* @return The class to convert to.
|
||||
*/
|
||||
public Class<?> getObjectClassTo() {
|
||||
return classTo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts string into object.
|
||||
*
|
||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
||||
* @param str The string to convert to object.
|
||||
* @param str The string to convert to object.
|
||||
* @param locale The locale to convert the string from.
|
||||
* @return The object converted from the string.
|
||||
* @throws ObjectConverterException When conversion fails.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
||||
if (split==null) {
|
||||
throw new ObjectConverterException(this,"split is not set.");
|
||||
if (split == null) {
|
||||
throw new ObjectConverterException(this, "split is not set.");
|
||||
}
|
||||
if (splitSize==null) {
|
||||
throw new ObjectConverterException(this,"splitSize is not set.");
|
||||
if (splitSize == null) {
|
||||
throw new ObjectConverterException(this, "splitSize is not set.");
|
||||
}
|
||||
if (classTo==null) {
|
||||
throw new ObjectConverterException(this,"classTo is not set.");
|
||||
if (classTo == null) {
|
||||
throw new ObjectConverterException(this, "classTo is not set.");
|
||||
}
|
||||
String[] strSplit = str.split(split);
|
||||
if(strSplit.length!=splitSize) {
|
||||
throw new ObjectConverterException(this,"Split size is wrong; "+strSplit.length+" need: "+splitSize);
|
||||
if (strSplit.length != splitSize) {
|
||||
throw new ObjectConverterException(this, "Split size is wrong; " + strSplit.length + " need: " + splitSize);
|
||||
}
|
||||
List<StringSplitConverterStep> steps = getOrderedSteps(true);
|
||||
if (steps.size()!=splitSize) {
|
||||
throw new ObjectConverterException(this,"Step size is wrong; "+steps.size()+" need: "+splitSize);
|
||||
if (steps.size() != splitSize) {
|
||||
throw new ObjectConverterException(this, "Step size is wrong; " + steps.size() + " need: " + splitSize);
|
||||
}
|
||||
try {
|
||||
Object[] singleMethodValues = new Object[splitSize];
|
||||
Object object = X4OLanguageClassLoader.newInstance(classTo);
|
||||
for (int i=0;i<steps.size();i++) {
|
||||
for (int i = 0; i < steps.size(); i++) {
|
||||
StringSplitConverterStep step = steps.get(i);
|
||||
Object stepObject = strSplit[i];
|
||||
Object stepValue = step.getObjectConverter().convertTo(stepObject, locale);
|
||||
if (singleToMethod==null) {
|
||||
Method m = classTo.getMethod(step.getToMethod(), new Class[] {stepValue.getClass()});
|
||||
if (singleToMethod == null) {
|
||||
Method m = classTo.getMethod(step.getToMethod(), new Class[] { stepValue.getClass() });
|
||||
m.invoke(object, stepValue);
|
||||
} else {
|
||||
singleMethodValues[i] = stepValue;
|
||||
}
|
||||
}
|
||||
if (singleToMethod!=null) {
|
||||
if (singleToMethod != null) {
|
||||
List<Class> arguClass = new ArrayList<Class>(singleMethodValues.length);
|
||||
for (int i=0;i<singleMethodValues.length;i++) {
|
||||
for (int i = 0; i < singleMethodValues.length; i++) {
|
||||
arguClass.add(singleMethodValues[i].getClass());
|
||||
}
|
||||
if (useNativeType!=null && useNativeType) {
|
||||
if (useNativeType != null && useNativeType) {
|
||||
arguClass = convertToNative(arguClass);
|
||||
}
|
||||
Class[] arguArray = new Class[arguClass.size()];
|
||||
arguArray = arguClass.toArray(arguArray);
|
||||
Method m = classTo.getMethod(singleToMethod, arguArray);
|
||||
|
||||
|
||||
List<Object> arguValue = new ArrayList<Object>(singleMethodValues.length);
|
||||
for (int i=0;i<singleMethodValues.length;i++) {
|
||||
for (int i = 0; i < singleMethodValues.length; i++) {
|
||||
arguValue.add(singleMethodValues[i]);
|
||||
}
|
||||
Object[] valueArray = new Object[arguValue.size()];
|
||||
|
|
@ -127,27 +128,27 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
|||
}
|
||||
return object;
|
||||
} catch (Exception e) {
|
||||
throw new ObjectConverterException(this,e.getMessage(),e);
|
||||
throw new ObjectConverterException(this, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts object into string.
|
||||
*
|
||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
||||
* @param object The object to convert to string.
|
||||
* @param object 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);
|
||||
if (steps.size()!=splitSize) {
|
||||
throw new ObjectConverterException(this,"Step size is wrong; "+steps.size()+" need: "+splitSize);
|
||||
if (steps.size() != splitSize) {
|
||||
throw new ObjectConverterException(this, "Step size is wrong; " + steps.size() + " need: " + splitSize);
|
||||
}
|
||||
try {
|
||||
StringBuilder buf = new StringBuilder(200);
|
||||
for (int i=0;i<steps.size();i++) {
|
||||
for (int i = 0; i < steps.size(); i++) {
|
||||
StringSplitConverterStep step = steps.get(i);
|
||||
Method m = classTo.getMethod(step.getFromMethod(), new Class[] {});
|
||||
Object stepValue = m.invoke(object, new Object[] {});
|
||||
|
|
@ -156,12 +157,13 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
|||
}
|
||||
return buf.toString();
|
||||
} catch (Exception e) {
|
||||
throw new ObjectConverterException(this,e.getMessage(),e);
|
||||
throw new ObjectConverterException(this, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clone this ObjectConverter.
|
||||
*
|
||||
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
||||
* @return The cloned ObjectConverter.
|
||||
* @throws CloneNotSupportedException When cloning fails.
|
||||
|
|
@ -169,20 +171,24 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
|||
@Override
|
||||
public ObjectConverter clone() throws CloneNotSupportedException {
|
||||
StringSplitConverter result = new StringSplitConverter();
|
||||
result.converters=cloneConverters();
|
||||
result.converters = cloneConverters();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private List<StringSplitConverterStep> getOrderedSteps(boolean isTo) {
|
||||
List<StringSplitConverterStep> result = new ArrayList<StringSplitConverterStep>(stringSplitConverterSteps.size());
|
||||
result.addAll(stringSplitConverterSteps);
|
||||
Collections.sort(stringSplitConverterSteps,new StringSplitConverterStepComparator(isTo));
|
||||
Collections.sort(stringSplitConverterSteps, new StringSplitConverterStepComparator(isTo));
|
||||
return result;
|
||||
}
|
||||
|
||||
public class StringSplitConverterStepComparator implements Comparator<StringSplitConverterStep> {
|
||||
boolean isTo = true;
|
||||
public StringSplitConverterStepComparator(boolean isTo) { this.isTo=isTo; }
|
||||
|
||||
public StringSplitConverterStepComparator(boolean isTo) {
|
||||
this.isTo = isTo;
|
||||
}
|
||||
|
||||
public int compare(StringSplitConverterStep e1, StringSplitConverterStep e2) {
|
||||
if (isTo) {
|
||||
return e1.getToOrder().compareTo(e2.getToOrder());
|
||||
|
|
@ -191,11 +197,11 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private List<Class> convertToNative(List<Class> types) throws ObjectConverterException {
|
||||
List<Class> result = new ArrayList<Class>(types.size());
|
||||
for (int i=0;i<types.size();i++) {
|
||||
for (int i = 0; i < types.size(); i++) {
|
||||
Class<?> clazz = types.get(i);
|
||||
if (clazz.isAssignableFrom(Integer.class)) {
|
||||
result.add(Integer.TYPE);
|
||||
|
|
@ -208,12 +214,12 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
|||
} else if (clazz.isAssignableFrom(Boolean.class)) {
|
||||
result.add(Boolean.TYPE);
|
||||
} else {
|
||||
throw new ObjectConverterException(this,"Can't convert type to native; "+clazz);
|
||||
throw new ObjectConverterException(this, "Can't convert type to native; " + clazz);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the classTo
|
||||
*/
|
||||
|
|
@ -269,7 +275,7 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
|||
public void setSingleToMethod(String singleToMethod) {
|
||||
this.singleToMethod = singleToMethod;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the useNativeType
|
||||
*/
|
||||
|
|
@ -287,9 +293,11 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
|||
public void addStringSplitConverterStep(StringSplitConverterStep stringSplitConverterStep) {
|
||||
stringSplitConverterSteps.add(stringSplitConverterStep);
|
||||
}
|
||||
|
||||
public void removeStringSplitConverterStep(StringSplitConverterStep stringSplitConverterStep) {
|
||||
stringSplitConverterSteps.remove(stringSplitConverterStep);
|
||||
}
|
||||
|
||||
public List<StringSplitConverterStep> getStringSplitConverterSteps() {
|
||||
return stringSplitConverterSteps;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,70 +37,70 @@ public class StringSplitConverterStep {
|
|||
private Integer fromOrder = null;
|
||||
private String toMethod = null;
|
||||
private Integer toOrder = null;
|
||||
|
||||
|
||||
/**
|
||||
* @return the objectConverter
|
||||
*/
|
||||
public ObjectConverter getObjectConverter() {
|
||||
return objectConverter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param objectConverter the objectConverter to set
|
||||
*/
|
||||
public void setObjectConverter(ObjectConverter objectConverter) {
|
||||
this.objectConverter = objectConverter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the fromMethod
|
||||
*/
|
||||
public String getFromMethod() {
|
||||
return fromMethod;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param fromMethod the fromMethod to set
|
||||
*/
|
||||
public void setFromMethod(String fromMethod) {
|
||||
this.fromMethod = fromMethod;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the fromOrder
|
||||
*/
|
||||
public Integer getFromOrder() {
|
||||
return fromOrder;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param fromOrder the fromOrder to set
|
||||
*/
|
||||
public void setFromOrder(Integer fromOrder) {
|
||||
this.fromOrder = fromOrder;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the toMethod
|
||||
*/
|
||||
public String getToMethod() {
|
||||
return toMethod;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param toMethod the toMethod to set
|
||||
*/
|
||||
public void setToMethod(String toMethod) {
|
||||
this.toMethod = toMethod;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the toOrder
|
||||
*/
|
||||
public Integer getToOrder() {
|
||||
return toOrder;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param toOrder the toOrder to set
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -42,18 +42,19 @@ public class URLConverter extends AbstractStringObjectConverter {
|
|||
|
||||
/**
|
||||
* Returns the convert to class.
|
||||
*
|
||||
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
||||
* @return The class to convert to.
|
||||
*/
|
||||
public Class<?> getObjectClassTo() {
|
||||
return URL.class;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts string into object.
|
||||
*
|
||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
||||
* @param str The string to convert to object.
|
||||
* @param 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.
|
||||
|
|
@ -62,25 +63,26 @@ public class URLConverter extends AbstractStringObjectConverter {
|
|||
try {
|
||||
return new URL(str);
|
||||
} catch (MalformedURLException e) {
|
||||
throw new ObjectConverterException(this,e.getMessage(),e);
|
||||
throw new ObjectConverterException(this, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 obj The object to convert to string.
|
||||
* @param locale The locale to convert the object from.
|
||||
* @return The string converted from the object.
|
||||
* @throws ObjectConverterException When conversion fails.
|
||||
*/
|
||||
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
|
||||
return ((URL)obj).toString();
|
||||
public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException {
|
||||
return ((URL) obj).toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clone this ObjectConverter.
|
||||
*
|
||||
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
||||
* @return The cloned ObjectConverter.
|
||||
* @throws CloneNotSupportedException When cloning fails.
|
||||
|
|
@ -88,7 +90,7 @@ public class URLConverter extends AbstractStringObjectConverter {
|
|||
@Override
|
||||
public ObjectConverter clone() throws CloneNotSupportedException {
|
||||
URLConverter result = new URLConverter();
|
||||
result.converters=cloneConverters();
|
||||
result.converters = cloneConverters();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,30 +41,31 @@ import javax.el.VariableMapper;
|
|||
* @version 1.0 Sep 14, 2010
|
||||
*/
|
||||
public class X4OELContext extends ELContext {
|
||||
|
||||
|
||||
private ELResolver elResolver = null;
|
||||
private FunctionMapper functionMapper = null;
|
||||
private VariableMapper variableMapper = null;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a X4OELContext.
|
||||
*/
|
||||
public X4OELContext() {
|
||||
|
||||
|
||||
CompositeELResolver compositeELResolver = new CompositeELResolver();
|
||||
compositeELResolver.add(new X4OELResolver(new HashMap<Object, Object>(100)));
|
||||
compositeELResolver.add(new ArrayELResolver());
|
||||
compositeELResolver.add(new ListELResolver());
|
||||
compositeELResolver.add(new BeanELResolver());
|
||||
compositeELResolver.add(new MapELResolver());
|
||||
|
||||
elResolver = compositeELResolver;
|
||||
|
||||
elResolver = compositeELResolver;
|
||||
functionMapper = new X4OELFunctionMapper();
|
||||
variableMapper = new X4OELVariableMapper();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ELResolver.
|
||||
*
|
||||
* @return The ELResolver.
|
||||
* @see javax.el.ELContext#getELResolver()
|
||||
*/
|
||||
|
|
@ -75,6 +76,7 @@ public class X4OELContext extends ELContext {
|
|||
|
||||
/**
|
||||
* Returns the FunctionMapper.
|
||||
*
|
||||
* @return The FunctionMapper.
|
||||
* @see javax.el.ELContext#getFunctionMapper()
|
||||
*/
|
||||
|
|
@ -85,6 +87,7 @@ public class X4OELContext extends ELContext {
|
|||
|
||||
/**
|
||||
* Returns the VariableMapper.
|
||||
*
|
||||
* @return The VariableMapper.
|
||||
* @see javax.el.ELContext#getVariableMapper()
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -36,53 +36,55 @@ import javax.el.FunctionMapper;
|
|||
* @version 1.0 Sep 14, 2010
|
||||
*/
|
||||
public class X4OELFunctionMapper extends FunctionMapper {
|
||||
|
||||
|
||||
/**
|
||||
* Stores the el to method function mapping.
|
||||
*/
|
||||
private Map<String,Method> functionMap = null;
|
||||
|
||||
private Map<String, Method> functionMap = null;
|
||||
|
||||
/**
|
||||
* Creates a X4OELFunctionMapper.
|
||||
*/
|
||||
public X4OELFunctionMapper() {
|
||||
functionMap = new HashMap<String,Method>(50);
|
||||
functionMap = new HashMap<String, Method>(50);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resolves method el functions.
|
||||
* @param prefix The function prefix.
|
||||
* @param localName The local name of function.
|
||||
* @return The resolved function or null is not found.
|
||||
*
|
||||
* @param prefix The function prefix.
|
||||
* @param localName The local name of function.
|
||||
* @return The resolved function or null is not found.
|
||||
*/
|
||||
@Override
|
||||
public Method resolveFunction(String prefix, String localName) {
|
||||
String key = prefix + ":" + localName;
|
||||
return functionMap.get(key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add an static method to the function mapper.
|
||||
* @param prefix The function prefix.
|
||||
* @param localName The local name of function.
|
||||
* @param method The method to execute on.
|
||||
*
|
||||
* @param prefix The function prefix.
|
||||
* @param localName The local name of function.
|
||||
* @param method The method to execute on.
|
||||
*/
|
||||
public void addFunction(String prefix, String localName, Method method) {
|
||||
if(prefix==null || localName==null || method==null) {
|
||||
if (prefix == null || localName == null || method == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
int modifiers = method.getModifiers();
|
||||
if(!Modifier.isPublic(modifiers)) {
|
||||
if (!Modifier.isPublic(modifiers)) {
|
||||
throw new IllegalArgumentException("method not public");
|
||||
}
|
||||
if(!Modifier.isStatic(modifiers)) {
|
||||
if (!Modifier.isStatic(modifiers)) {
|
||||
throw new IllegalArgumentException("method not static");
|
||||
}
|
||||
Class<?> retType = method.getReturnType();
|
||||
if(retType == Void.TYPE) {
|
||||
if (retType == Void.TYPE) {
|
||||
throw new IllegalArgumentException("method returns void");
|
||||
}
|
||||
|
||||
|
||||
String key = prefix + ":" + localName;
|
||||
functionMap.put(key, method);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import javax.el.ELContext;
|
|||
import javax.el.ELResolver;
|
||||
import javax.el.MapELResolver;
|
||||
|
||||
|
||||
/**
|
||||
* X4OELResolver simple EL resolver.
|
||||
*
|
||||
|
|
@ -37,37 +36,39 @@ import javax.el.MapELResolver;
|
|||
* @version 1.0 Sep 14, 2010
|
||||
*/
|
||||
public class X4OELResolver extends ELResolver {
|
||||
|
||||
|
||||
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.
|
||||
*
|
||||
* @param objectStore The objectStore.
|
||||
*/
|
||||
public X4OELResolver(Map<Object, Object> objectStore) {
|
||||
this.objectStore = objectStore;
|
||||
delegate = new MapELResolver();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if base object is null and else return objectStore.
|
||||
* @param base The base object to check.
|
||||
* @return Returns the base object or objectStore.
|
||||
*
|
||||
* @param base The base object to check.
|
||||
* @return Returns the base object or objectStore.
|
||||
*/
|
||||
private Object checkBase(Object base) {
|
||||
if (base==null) {
|
||||
if (base == null) {
|
||||
return objectStore;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getValue(ELContext context, Object base, Object property) {
|
||||
base = checkBase(base);
|
||||
return delegate.getValue(context, base, property);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<?> getCommonPropertyType(ELContext context, Object base) {
|
||||
base = checkBase(base);
|
||||
|
|
@ -76,7 +77,7 @@ public class X4OELResolver extends ELResolver {
|
|||
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public Iterator getFeatureDescriptors(ELContext context,Object base) {
|
||||
public Iterator getFeatureDescriptors(ELContext context, Object base) {
|
||||
base = checkBase(base);
|
||||
return delegate.getFeatureDescriptors(context, base);
|
||||
}
|
||||
|
|
@ -86,7 +87,7 @@ public class X4OELResolver extends ELResolver {
|
|||
base = checkBase(base);
|
||||
return delegate.getType(context, base, property);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly(ELContext context, Object base, Object property) {
|
||||
base = checkBase(base);
|
||||
|
|
|
|||
|
|
@ -35,17 +35,17 @@ import javax.el.VariableMapper;
|
|||
* @version 1.0 Sep 14, 2010
|
||||
*/
|
||||
public class X4OELVariableMapper extends VariableMapper {
|
||||
|
||||
|
||||
/** Map to hold all the expressions used. */
|
||||
private Map<String, ValueExpression> expressions = null;
|
||||
|
||||
|
||||
/**
|
||||
* Creates the X4OELVariableMapper.
|
||||
*/
|
||||
public X4OELVariableMapper() {
|
||||
expressions = new HashMap<String, ValueExpression>();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see javax.el.VariableMapper#resolveVariable(java.lang.String)
|
||||
* @param var Resolve this var to an ValueExpression.
|
||||
|
|
@ -58,7 +58,7 @@ public class X4OELVariableMapper extends VariableMapper {
|
|||
|
||||
/**
|
||||
* @see javax.el.VariableMapper#setVariable(java.lang.String, javax.el.ValueExpression)
|
||||
* @param var Resolve this var to an ValueExpression.
|
||||
* @param var Resolve this var to an ValueExpression.
|
||||
* @param expression The ValueExpression of the var.
|
||||
* @return The ValueExpression being set.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import javax.el.ExpressionFactory;
|
|||
import org.x4o.xml.lang.X4OLanguageClassLoader;
|
||||
|
||||
/**
|
||||
* X4OExpressionFactory finds and loads the needed impl.
|
||||
* X4OExpressionFactory finds and loads the needed impl.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 7, 2013
|
||||
|
|
@ -37,7 +37,7 @@ public class X4OExpressionFactory {
|
|||
|
||||
static public final String EL_FACTORY_IMPL_APACHE = "org.apache.el.ExpressionFactoryImpl";
|
||||
static public final String EL_FACTORY_IMPL_ODYSSEUS = "de.odysseus.el.ExpressionFactoryImpl";
|
||||
|
||||
|
||||
static public ExpressionFactory createExpressionFactory() {
|
||||
ExpressionFactory result = null;
|
||||
try {
|
||||
|
|
@ -48,17 +48,18 @@ public class X4OExpressionFactory {
|
|||
Class<?> expressionFactoryClass = X4OLanguageClassLoader.loadClass(EL_FACTORY_IMPL_ODYSSEUS);
|
||||
result = X4OLanguageClassLoader.newInstance(ExpressionFactory.class, expressionFactoryClass);
|
||||
} catch (ClassNotFoundException ee) {
|
||||
throw new RuntimeException("Could not load ExpressionFactory tried: "+EL_FACTORY_IMPL_APACHE+" and "+EL_FACTORY_IMPL_ODYSSEUS+" but could not load one of them.");
|
||||
throw new RuntimeException("Could not load ExpressionFactory tried: " + EL_FACTORY_IMPL_APACHE + " and " + EL_FACTORY_IMPL_ODYSSEUS
|
||||
+ " but could not load one of them.");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static public ELContext createELContext(Class<?> elContextClass) {
|
||||
|
||||
static public ELContext createELContext(Class<?> elContextClass) {
|
||||
try {
|
||||
return X4OLanguageClassLoader.newInstance(ELContext.class, elContextClass);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException("Could not create instance of ELContext: "+e.getMessage(),e);
|
||||
throw new RuntimeException("Could not create instance of ELContext: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.eld;
|
||||
package org.x4o.xml.eld;
|
||||
|
||||
import org.x4o.xml.X4ODriver;
|
||||
import org.x4o.xml.lang.X4OLanguageModule;
|
||||
|
|
@ -35,9 +35,9 @@ public class CelDriver extends X4ODriver<X4OLanguageModule> {
|
|||
|
||||
/** Defines the identifier of the 'Core Element Language' language. */
|
||||
public static final String LANGUAGE_NAME = "cel";
|
||||
|
||||
|
||||
/** Defines the versions this langauge knowns. */
|
||||
public static final String[] LANGUAGE_VERSIONS = new String[]{X4ODriver.DEFAULT_LANGUAGE_VERSION};
|
||||
public static final String[] LANGUAGE_VERSIONS = new String[] { X4ODriver.DEFAULT_LANGUAGE_VERSION };
|
||||
|
||||
@Override
|
||||
public String getLanguageName() {
|
||||
|
|
|
|||
|
|
@ -20,14 +20,13 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.eld;
|
||||
package org.x4o.xml.eld;
|
||||
|
||||
import org.x4o.xml.X4ODriver;
|
||||
import org.x4o.xml.lang.X4OLanguageModule;
|
||||
|
||||
/**
|
||||
* An Element Language Definition X4O parser.
|
||||
* This eld parser config parent x4o parser with the eld x4o parser.
|
||||
* An Element Language Definition X4O parser. This eld parser config parent x4o parser with the eld x4o parser.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 20, 2005
|
||||
|
|
@ -36,15 +35,15 @@ public class EldDriver extends X4ODriver<X4OLanguageModule> {
|
|||
|
||||
/** Defines the identifier of the 'Element Language Description' language. */
|
||||
public static final String LANGUAGE_NAME = "eld";
|
||||
|
||||
|
||||
/** Defines the identifier of the ELD x4o language. */
|
||||
public static final String[] LANGUAGE_VERSIONS = new String[]{X4ODriver.DEFAULT_LANGUAGE_VERSION};
|
||||
|
||||
public static final String[] LANGUAGE_VERSIONS = new String[] { X4ODriver.DEFAULT_LANGUAGE_VERSION };
|
||||
|
||||
@Override
|
||||
public String getLanguageName() {
|
||||
return LANGUAGE_NAME;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String[] getLanguageVersions() {
|
||||
return LANGUAGE_VERSIONS;
|
||||
|
|
|
|||
|
|
@ -52,19 +52,20 @@ public class EldModuleLoader implements X4OLanguageModuleLoader {
|
|||
private final Logger logger;
|
||||
private final String eldResource;
|
||||
private final boolean isEldCore;
|
||||
|
||||
|
||||
/** The EL key to access the parent language module. */
|
||||
public static final String EL_PARENT_LANGUAGE_MODULE = "parentLanguageModule";
|
||||
|
||||
|
||||
/** The EL key to access the parent language element langauge. */
|
||||
public static final String EL_PARENT_LANGUAGE = "parentLanguage";
|
||||
|
||||
|
||||
/**
|
||||
* Creates an ELD/CEL module loader.
|
||||
* @param eldResource The resource to load.
|
||||
* @param isEldCore If true then load CEL else load ELD.
|
||||
* Creates an ELD/CEL module loader.
|
||||
*
|
||||
* @param eldResource The resource to load.
|
||||
* @param isEldCore If true then load CEL else load ELD.
|
||||
*/
|
||||
public EldModuleLoader(String eldResource,boolean isEldCore) {
|
||||
public EldModuleLoader(String eldResource, boolean isEldCore) {
|
||||
if (eldResource == null) {
|
||||
throw new NullPointerException("Can't load null eld resource.");
|
||||
}
|
||||
|
|
@ -75,13 +76,15 @@ public class EldModuleLoader implements X4OLanguageModuleLoader {
|
|||
|
||||
/**
|
||||
* Loads the ELD language into the module.
|
||||
* @param session The session we run in.
|
||||
*
|
||||
* @param session The session we run in.
|
||||
* @param language The local Language to load for.
|
||||
* @param module The language module to load it into.
|
||||
* @param module The language module to load it into.
|
||||
* @throws X4OLanguageModuleLoaderException When eld language could not be loaded.
|
||||
* @see org.x4o.xml.lang.X4OLanguageModuleLoader#loadLanguageModule(org.x4o.xml.lang.X4OLanguageLocal, org.x4o.xml.lang.X4OLanguageModuleLocal)
|
||||
*/
|
||||
public void loadLanguageModule(X4OLanguageSession session, X4OLanguageLocal language, X4OLanguageModuleLocal module) throws X4OLanguageModuleLoaderException {
|
||||
public void loadLanguageModule(X4OLanguageSession session, X4OLanguageLocal language, X4OLanguageModuleLocal module)
|
||||
throws X4OLanguageModuleLoaderException {
|
||||
logger.fine("Loading name eld file from resource: " + eldResource);
|
||||
try {
|
||||
X4ODriver<?> driver = null;
|
||||
|
|
@ -98,21 +101,23 @@ public class EldModuleLoader implements X4OLanguageModuleLoader {
|
|||
}
|
||||
reader.readResource(eldResource);
|
||||
} catch (X4OConnectionException e) {
|
||||
throw new X4OLanguageModuleLoaderException(this,e.getMessage()+" while parsing: "+eldResource,e);
|
||||
throw new X4OLanguageModuleLoaderException(this, e.getMessage() + " while parsing: " + eldResource, e);
|
||||
} catch (SAXException e) {
|
||||
throw new X4OLanguageModuleLoaderException(this,e.getMessage()+" while parsing: "+eldResource,e);
|
||||
throw new X4OLanguageModuleLoaderException(this, e.getMessage() + " while parsing: " + eldResource, e);
|
||||
} catch (IOException e) {
|
||||
throw new X4OLanguageModuleLoaderException(this,e.getMessage()+" while parsing: "+eldResource,e);
|
||||
throw new X4OLanguageModuleLoaderException(this, e.getMessage() + " while parsing: " + eldResource, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static X4OLanguage getLanguage(X4OLanguageSession context) {
|
||||
ValueExpression ee = context.getExpressionLanguageFactory().createValueExpression(context.getExpressionLanguageContext(),"${"+EL_PARENT_LANGUAGE+"}", X4OLanguage.class);
|
||||
return (X4OLanguage)ee.getValue(context.getExpressionLanguageContext());
|
||||
ValueExpression ee = context.getExpressionLanguageFactory().createValueExpression(context.getExpressionLanguageContext(),
|
||||
"${" + EL_PARENT_LANGUAGE + "}", X4OLanguage.class);
|
||||
return (X4OLanguage) ee.getValue(context.getExpressionLanguageContext());
|
||||
}
|
||||
|
||||
|
||||
public static X4OLanguageModule getLanguageModule(X4OLanguageSession context) {
|
||||
ValueExpression ee = context.getExpressionLanguageFactory().createValueExpression(context.getExpressionLanguageContext(),"${"+EL_PARENT_LANGUAGE_MODULE+"}", X4OLanguageModule.class);
|
||||
return (X4OLanguageModule)ee.getValue(context.getExpressionLanguageContext());
|
||||
ValueExpression ee = context.getExpressionLanguageFactory().createValueExpression(context.getExpressionLanguageContext(),
|
||||
"${" + EL_PARENT_LANGUAGE_MODULE + "}", X4OLanguageModule.class);
|
||||
return (X4OLanguageModule) ee.getValue(context.getExpressionLanguageContext());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,8 +51,7 @@ import org.x4o.xml.lang.X4OLanguageModuleLocal;
|
|||
import org.x4o.xml.lang.X4OLanguageSession;
|
||||
|
||||
/**
|
||||
* EldModuleLoaderCore provides a few basic elements for the core eld x4o
|
||||
* language.
|
||||
* EldModuleLoaderCore provides a few basic elements for the core eld x4o language.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 11, 2009
|
||||
|
|
@ -89,11 +88,11 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
|||
* @param session The session to run in.
|
||||
* @param language The langauge to load for.
|
||||
* @param languageModule The module to load it in.
|
||||
* @see org.x4o.xml.lang.X4OLanguageModuleLoader#loadLanguageModule(org.x4o.xml.lang.X4OLanguageLocal,
|
||||
* org.x4o.xml.lang.X4OLanguageModuleLocald)
|
||||
* @see org.x4o.xml.lang.X4OLanguageModuleLoader#loadLanguageModule(org.x4o.xml.lang.X4OLanguageLocal, org.x4o.xml.lang.X4OLanguageModuleLocald)
|
||||
*/
|
||||
@Override
|
||||
public void loadLanguageModule(X4OLanguageSession session, X4OLanguageLocal language, X4OLanguageModuleLocal languageModule) throws X4OLanguageModuleLoaderException {
|
||||
public void loadLanguageModule(X4OLanguageSession session, X4OLanguageLocal language, X4OLanguageModuleLocal languageModule)
|
||||
throws X4OLanguageModuleLoaderException {
|
||||
|
||||
// Config module meta data
|
||||
configLanguageModule(languageModule);
|
||||
|
|
@ -113,7 +112,8 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
|||
// Create cel-root namespace in language for schema support
|
||||
ElementNamespace namespaceRoot = createNamespaceContext(language, CEL_ROOT, CEL_ROOT_URI, CEL_ROOT_XSD_URI, CEL_ROOT_XSD_FILE, CEL_ROOT);
|
||||
namespaceRoot.setLanguageRoot(true); // Only define single language root so xsd is (mostly) not cicle import.
|
||||
ElementClass rootElement = createElementClass(language, "module", language.getLanguageConfiguration().getDefaultElementLanguageModule(), ModuleElement.class, "The module tag is the root xml element for ELD language.");
|
||||
ElementClass rootElement = createElementClass(language, "module", language.getLanguageConfiguration().getDefaultElementLanguageModule(),
|
||||
ModuleElement.class, "The module tag is the root xml element for ELD language.");
|
||||
rootElement.addElementClassAttribute(createElementClassAttribute(language, "id", true, null));
|
||||
rootElement.addElementClassAttribute(createElementClassAttribute(language, "providerHost", true, null));
|
||||
namespaceRoot.addElementClass(rootElement);
|
||||
|
|
@ -130,14 +130,16 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
|||
private void configElementClasses(X4OLanguage language, ElementNamespace namespace) throws X4OLanguageModuleLoaderException {
|
||||
ElementClass ec = null;
|
||||
|
||||
namespace.addElementClass(createElementClass(language, "attribute", language.getLanguageConfiguration().getDefaultElementClassAttribute(), null, "Defines xml element attribute."));
|
||||
namespace.addElementClass(createElementClass(language, "attribute", language.getLanguageConfiguration().getDefaultElementClassAttribute(), null,
|
||||
"Defines xml element attribute."));
|
||||
|
||||
ec = createElementClass(language, "attributeAlias", null, AttributeAliasElement.class, "Adds an attribute alias.");
|
||||
ec.addElementClassAttribute(createElementClassAttribute(language, "name", true, null));
|
||||
ec.addElementParent(CEL_CORE_URI, "attribute");
|
||||
namespace.addElementClass(ec);
|
||||
|
||||
namespace.addElementClass(createElementClass(language, "classConverter", ClassConverter.class, null, "Converts string attribute to java class instance."));
|
||||
namespace.addElementClass(
|
||||
createElementClass(language, "classConverter", ClassConverter.class, null, "Converts string attribute to java class instance."));
|
||||
|
||||
ec = createElementClass(language, "namespace", language.getLanguageConfiguration().getDefaultElementNamespace(), null, "Defines an xml namespace.");
|
||||
ec.addElementClassAttribute(createElementClassAttribute(language, "uri", true, null));
|
||||
|
|
@ -148,7 +150,8 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
|||
ec.addElementClassAttribute(createElementClassAttribute(language, "elementClass", false, new ClassConverter()));
|
||||
namespace.addElementClass(ec);
|
||||
|
||||
ec = createElementClass(language, "elementInterface", language.getLanguageConfiguration().getDefaultElementInterface(), null, "Defines element interface class.");
|
||||
ec = createElementClass(language, "elementInterface", language.getLanguageConfiguration().getDefaultElementInterface(), null,
|
||||
"Defines element interface class.");
|
||||
ec.addElementClassAttribute(createElementClassAttribute(language, "interfaceClass", false, new ClassConverter()));
|
||||
namespace.addElementClass(ec);
|
||||
|
||||
|
|
@ -204,7 +207,8 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
|||
languageModule.setDescription("Core Element Language Module Loader");
|
||||
}
|
||||
|
||||
private void startAndAddNamespace(X4OLanguageLocal language, X4OLanguageModuleLocal languageModule, ElementNamespace namespace) throws X4OLanguageModuleLoaderException {
|
||||
private void startAndAddNamespace(X4OLanguageLocal language, X4OLanguageModuleLocal languageModule, ElementNamespace namespace)
|
||||
throws X4OLanguageModuleLoaderException {
|
||||
try {
|
||||
namespace.getElementNamespaceInstanceProvider().start(language, namespace);
|
||||
} catch (ElementNamespaceInstanceProviderException e) {
|
||||
|
|
@ -213,7 +217,8 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
|||
languageModule.addElementNamespace(namespace);
|
||||
}
|
||||
|
||||
private ElementNamespace createNamespaceContext(X4OLanguageLocal language, String id, String uri, String schemaUri, String schemaResource, String schemaPrefix) throws X4OLanguageModuleLoaderException {
|
||||
private ElementNamespace createNamespaceContext(X4OLanguageLocal language, String id, String uri, String schemaUri, String schemaResource,
|
||||
String schemaPrefix) throws X4OLanguageModuleLoaderException {
|
||||
logger.finer("Creating " + language.getLanguageName() + " namespace.");
|
||||
ElementNamespace namespace;
|
||||
try {
|
||||
|
|
@ -222,7 +227,8 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
|||
throw new X4OLanguageModuleLoaderException(this, e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
namespace.setElementNamespaceInstanceProvider(X4OLanguageClassLoader.newInstance(ElementNamespaceInstanceProvider.class, language.getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider()));
|
||||
namespace.setElementNamespaceInstanceProvider(X4OLanguageClassLoader.newInstance(ElementNamespaceInstanceProvider.class,
|
||||
language.getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider()));
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new X4OLanguageModuleLoaderException(this, e.getMessage(), e);
|
||||
}
|
||||
|
|
@ -234,7 +240,8 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
|||
return namespace;
|
||||
}
|
||||
|
||||
private ElementClass createElementClass(X4OLanguage language, String tag, Class<?> objectClass, Class<?> elementClass, String description) throws X4OLanguageModuleLoaderException {
|
||||
private ElementClass createElementClass(X4OLanguage language, String tag, Class<?> objectClass, Class<?> elementClass, String description)
|
||||
throws X4OLanguageModuleLoaderException {
|
||||
try {
|
||||
ElementClass result = X4OLanguageClassLoader.newInstance(ElementClass.class, language.getLanguageConfiguration().getDefaultElementClass());
|
||||
result.setId(tag);
|
||||
|
|
@ -257,9 +264,11 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
|||
* @return The new ElementClassAttribute instance.
|
||||
* @throws X4OLanguageModuleLoaderException When class could not be created.
|
||||
*/
|
||||
private ElementClassAttribute createElementClassAttribute(X4OLanguage language, String name, boolean required, ObjectConverter converter) throws X4OLanguageModuleLoaderException {
|
||||
private ElementClassAttribute createElementClassAttribute(X4OLanguage language, String name, boolean required, ObjectConverter converter)
|
||||
throws X4OLanguageModuleLoaderException {
|
||||
try {
|
||||
ElementClassAttribute result = X4OLanguageClassLoader.newInstance(ElementClassAttribute.class, language.getLanguageConfiguration().getDefaultElementClassAttribute());
|
||||
ElementClassAttribute result = X4OLanguageClassLoader.newInstance(ElementClassAttribute.class,
|
||||
language.getLanguageConfiguration().getDefaultElementClassAttribute());
|
||||
result.setId(name);
|
||||
if (required) {
|
||||
result.setRequired(required);
|
||||
|
|
|
|||
|
|
@ -37,14 +37,14 @@ import org.x4o.xml.lang.task.X4OLanguageTaskExecutor;
|
|||
*/
|
||||
public class EldDocLanguageTask extends AbstractX4OLanguageTask {
|
||||
|
||||
public static final String TASK_ID = "eld-doc";
|
||||
public static final String TASK_ID = "eld-doc";
|
||||
private static final String TASK_NAME = "ELD DOC Writer Task";
|
||||
private static final String TASK_DESC = "Writes out the documentation of the language elements.";
|
||||
|
||||
|
||||
public EldDocLanguageTask() {
|
||||
super(TASK_ID,TASK_NAME,TASK_DESC,EldDocWriter.DEFAULT_PROPERTY_CONFIG);
|
||||
super(TASK_ID, TASK_NAME, TASK_DESC, EldDocWriter.DEFAULT_PROPERTY_CONFIG);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Executes this language task.
|
||||
*/
|
||||
|
|
@ -52,9 +52,9 @@ public class EldDocLanguageTask extends AbstractX4OLanguageTask {
|
|||
return new X4OLanguageTaskExecutor() {
|
||||
public void execute(X4OLanguage language) throws X4OLanguageTaskException {
|
||||
try {
|
||||
new EldDocWriter(language,config).writeDocumentation();
|
||||
new EldDocWriter(language, config).writeDocumentation();
|
||||
} catch (ElementException e) {
|
||||
throw new X4OLanguageTaskException(config,e.getMessage(),e);
|
||||
throw new X4OLanguageTaskException(config, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -60,7 +60,8 @@ import org.x4o.xml.lang.X4OLanguageSession;
|
|||
* @version 1.0 Aug 26, 2010
|
||||
*/
|
||||
public class EldDocWriter {
|
||||
|
||||
|
||||
//@formatter:off
|
||||
private final static String DEFAULT_NAME = "X4O ELD DOC";
|
||||
private final static String DEFAULT_DESCRIPTION = "X4O Meta Language Documentation.";
|
||||
|
||||
|
|
@ -116,26 +117,29 @@ public class EldDocWriter {
|
|||
new PropertyConfigItem(PAGE_PRINT_HELP,Boolean.class,true)
|
||||
);
|
||||
}
|
||||
|
||||
//@formatter:on
|
||||
|
||||
/** The config of this writer. */
|
||||
private final SAX3PropertyConfig propertyConfig;
|
||||
|
||||
|
||||
/** The language to write doc over. */
|
||||
private final X4OLanguage language;
|
||||
|
||||
|
||||
/**
|
||||
* Creates an EldDocGenerator for this langauge context.
|
||||
* @param language The language to generate doc for.
|
||||
*
|
||||
* @param language The language to generate doc for.
|
||||
*/
|
||||
public EldDocWriter(X4OLanguage language,SAX3PropertyConfig parentConfig) {
|
||||
this.language=language;
|
||||
this.propertyConfig=new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG,PROPERTY_CONTEXT_PREFIX);
|
||||
public EldDocWriter(X4OLanguage language, SAX3PropertyConfig parentConfig) {
|
||||
this.language = language;
|
||||
this.propertyConfig = new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG, PROPERTY_CONTEXT_PREFIX);
|
||||
this.propertyConfig.copyParentProperties(parentConfig);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Writes the language documentation to the base path.
|
||||
* @throws ElementException Is thrown when error is done.
|
||||
*
|
||||
* @throws ElementException Is thrown when error is done.
|
||||
*/
|
||||
public void writeDocumentation() throws ElementException {
|
||||
try {
|
||||
|
|
@ -147,124 +151,163 @@ public class EldDocWriter {
|
|||
throw new ElementException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a fully configured ApiDco object.
|
||||
* @return The ApiDoc configured to write eld documentation.
|
||||
*
|
||||
* @return The ApiDoc configured to write eld documentation.
|
||||
*/
|
||||
private MaisDoc buildLanguageDoc() {
|
||||
|
||||
|
||||
// Generic config
|
||||
MaisDoc doc = new MaisDoc();
|
||||
List<String> javadocLinkList = propertyConfig.getPropertyList(JAVADOC_LINK);
|
||||
Map<String,String> javadocLinkOfflineMap = propertyConfig.getPropertyMap(JAVADOC_LINK_OFFLINE);
|
||||
if (javadocLinkList!=null) {
|
||||
for (String javadocUrl:javadocLinkList) {
|
||||
Map<String, String> javadocLinkOfflineMap = propertyConfig.getPropertyMap(JAVADOC_LINK_OFFLINE);
|
||||
if (javadocLinkList != null) {
|
||||
for (String javadocUrl : javadocLinkList) {
|
||||
doc.addRemoteClass(new MaisDocRemoteClass(javadocUrl));
|
||||
}
|
||||
}
|
||||
if (javadocLinkOfflineMap!=null) {
|
||||
for (Map.Entry<String,String> offlineLink:javadocLinkOfflineMap.entrySet()) {
|
||||
doc.addRemoteClass(new MaisDocRemoteClass(offlineLink.getKey(),offlineLink.getValue()));
|
||||
if (javadocLinkOfflineMap != null) {
|
||||
for (Map.Entry<String, String> offlineLink : javadocLinkOfflineMap.entrySet()) {
|
||||
doc.addRemoteClass(new MaisDocRemoteClass(offlineLink.getKey(), offlineLink.getValue()));
|
||||
}
|
||||
}
|
||||
doc.setName( propertyConfig.getPropertyString(DOC_NAME, DEFAULT_NAME));
|
||||
doc.setDescription( propertyConfig.getPropertyString(DOC_DESCRIPTION, DEFAULT_DESCRIPTION));
|
||||
doc.setDocAbout( propertyConfig.getPropertyString(DOC_ABOUT, createLanguageAbout()));
|
||||
doc.setDocCopyright( propertyConfig.getPropertyString(DOC_COPYRIGHT, createLanguageCopyright()));
|
||||
doc.setDocPageSubTitle( propertyConfig.getPropertyString(DOC_PAGE_SUB_TITLE, createPageSubTitle()));
|
||||
doc.setMetaStyleSheetThema( propertyConfig.getPropertyString(META_STYLESHEET_THEMA));
|
||||
doc.setMetaStyleSheet( propertyConfig.getPropertyFile(META_STYLESHEET));
|
||||
List<String> keywords = propertyConfig.getPropertyList(META_KEYWORDS);
|
||||
if (keywords==null) {
|
||||
doc.setName(propertyConfig.getPropertyString(DOC_NAME, DEFAULT_NAME));
|
||||
doc.setDescription(propertyConfig.getPropertyString(DOC_DESCRIPTION, DEFAULT_DESCRIPTION));
|
||||
doc.setDocAbout(propertyConfig.getPropertyString(DOC_ABOUT, createLanguageAbout()));
|
||||
doc.setDocCopyright(propertyConfig.getPropertyString(DOC_COPYRIGHT, createLanguageCopyright()));
|
||||
doc.setDocPageSubTitle(propertyConfig.getPropertyString(DOC_PAGE_SUB_TITLE, createPageSubTitle()));
|
||||
doc.setMetaStyleSheetThema(propertyConfig.getPropertyString(META_STYLESHEET_THEMA));
|
||||
doc.setMetaStyleSheet(propertyConfig.getPropertyFile(META_STYLESHEET));
|
||||
List<String> keywords = propertyConfig.getPropertyList(META_KEYWORDS);
|
||||
if (keywords == null) {
|
||||
keywords = createLanguageKeywords();
|
||||
}
|
||||
doc.addMetaKeywordAll(keywords);
|
||||
doc.setNoFrameAllName("All Elements");
|
||||
doc.setFrameNavPrintParent(true);
|
||||
doc.setFrameNavPrintParentId(true);
|
||||
doc.setGroupTypeName("summary", "Summary",1);
|
||||
doc.setGroupTypeName("overview", "Overview",2);
|
||||
doc.setGroupTypeName("summary", "Summary", 1);
|
||||
doc.setGroupTypeName("overview", "Overview", 2);
|
||||
doc.setFrameNavConceptClass(ElementClass.class);
|
||||
|
||||
|
||||
doc.addTreeNodePageModeClass(X4OLanguageSession.class);
|
||||
doc.addTreeNodePageModeClass(X4OLanguageModule.class);
|
||||
doc.addTreeNodePageModeClass(ElementInterface.class);
|
||||
doc.addTreeNodePageModeClass(ElementNamespace.class);
|
||||
|
||||
|
||||
doc.addAnnotatedClasses(EldDocWriterLanguage.class);
|
||||
doc.addAnnotatedClasses(EldDocWriterLanguageModule.class);
|
||||
doc.addAnnotatedClasses(EldDocWriterElementClass.class);
|
||||
doc.addAnnotatedClasses(EldDocWriterElementNamespace.class);
|
||||
doc.addAnnotatedClasses(EldDocWriterElementInterface.class);
|
||||
|
||||
MaisDocConcept adcRoot = doc.addConcept(new MaisDocConcept(null,C_CONTEXT,X4OLanguage.class));
|
||||
MaisDocConcept adcMod = doc.addConcept(new MaisDocConcept(adcRoot,C_MODULE,X4OLanguageModule.class));
|
||||
MaisDocConcept adcIface = doc.addConcept(new MaisDocConcept(adcMod,C_INTERFACE,ElementInterface.class));
|
||||
MaisDocConcept adcNs = doc.addConcept(new MaisDocConcept(adcMod,C_NAMESPACE,ElementNamespace.class));
|
||||
MaisDocConcept adcEc = doc.addConcept(new MaisDocConcept(adcNs,C_ELEMENT,ElementClass.class));
|
||||
|
||||
|
||||
MaisDocConcept adcRoot = doc.addConcept(new MaisDocConcept(null, C_CONTEXT, X4OLanguage.class));
|
||||
MaisDocConcept adcMod = doc.addConcept(new MaisDocConcept(adcRoot, C_MODULE, X4OLanguageModule.class));
|
||||
MaisDocConcept adcIface = doc.addConcept(new MaisDocConcept(adcMod, C_INTERFACE, ElementInterface.class));
|
||||
MaisDocConcept adcNs = doc.addConcept(new MaisDocConcept(adcMod, C_NAMESPACE, ElementNamespace.class));
|
||||
MaisDocConcept adcEc = doc.addConcept(new MaisDocConcept(adcNs, C_ELEMENT, ElementClass.class));
|
||||
|
||||
// mm maybe redo something here
|
||||
adcMod.addChildConcept(new MaisDocConcept(adcMod,CC_ATTRIBUTE_H,ElementNamespaceAttribute.class));
|
||||
adcMod.addChildConcept(new MaisDocConcept(adcMod,CC_CONFIGURATOR_G,ElementConfiguratorGlobal.class));
|
||||
adcMod.addChildConcept(new MaisDocConcept(adcMod,CC_BINDING,ElementBindingHandler.class));
|
||||
adcIface.addChildConcept(new MaisDocConcept(adcMod,CC_ATTRIBUTE,ElementClassAttribute.class));
|
||||
adcIface.addChildConcept(new MaisDocConcept(adcMod,CC_CONFIGURATOR,ElementConfigurator.class));
|
||||
adcEc.addChildConcept(new MaisDocConcept(adcEc,CC_CONFIGURATOR,ElementConfigurator.class));
|
||||
adcEc.addChildConcept(new MaisDocConcept(adcEc,CC_ATTRIBUTE,ElementClassAttribute.class));
|
||||
|
||||
adcMod.addChildConcept(new MaisDocConcept(adcMod, CC_ATTRIBUTE_H, ElementNamespaceAttribute.class));
|
||||
adcMod.addChildConcept(new MaisDocConcept(adcMod, CC_CONFIGURATOR_G, ElementConfiguratorGlobal.class));
|
||||
adcMod.addChildConcept(new MaisDocConcept(adcMod, CC_BINDING, ElementBindingHandler.class));
|
||||
adcIface.addChildConcept(new MaisDocConcept(adcMod, CC_ATTRIBUTE, ElementClassAttribute.class));
|
||||
adcIface.addChildConcept(new MaisDocConcept(adcMod, CC_CONFIGURATOR, ElementConfigurator.class));
|
||||
adcEc.addChildConcept(new MaisDocConcept(adcEc, CC_CONFIGURATOR, ElementConfigurator.class));
|
||||
adcEc.addChildConcept(new MaisDocConcept(adcEc, CC_ATTRIBUTE, ElementClassAttribute.class));
|
||||
|
||||
// Non-tree pages config
|
||||
if (propertyConfig.getPropertyBoolean(PAGE_PRINT_XTREE)) { doc.addDocPage(EldDocXTreePageWriter.createDocPage()); }
|
||||
if (propertyConfig.getPropertyBoolean(PAGE_PRINT_TREE)) { doc.addDocPage(DefaultPageWriterTree.createDocPage()); }
|
||||
if (propertyConfig.getPropertyBoolean(PAGE_PRINT_INDEX_ALL)) { doc.addDocPage(DefaultPageWriterIndexAll.createDocPage()); }
|
||||
if (propertyConfig.getPropertyBoolean(PAGE_PRINT_HELP)) { doc.addDocPage(DefaultPageWriterHelp.createDocPage()); }
|
||||
|
||||
if (propertyConfig.getPropertyBoolean(PAGE_PRINT_XTREE)) {
|
||||
doc.addDocPage(EldDocXTreePageWriter.createDocPage());
|
||||
}
|
||||
if (propertyConfig.getPropertyBoolean(PAGE_PRINT_TREE)) {
|
||||
doc.addDocPage(DefaultPageWriterTree.createDocPage());
|
||||
}
|
||||
if (propertyConfig.getPropertyBoolean(PAGE_PRINT_INDEX_ALL)) {
|
||||
doc.addDocPage(DefaultPageWriterIndexAll.createDocPage());
|
||||
}
|
||||
if (propertyConfig.getPropertyBoolean(PAGE_PRINT_HELP)) {
|
||||
doc.addDocPage(DefaultPageWriterHelp.createDocPage());
|
||||
}
|
||||
|
||||
// Doc tree config
|
||||
MaisDocNode rootNode = new MaisDocNode(language,"language",getLanguageNameUpperCase()+" Language","The X4O "+getLanguageNameUpperCase()+" Language");
|
||||
MaisDocNode rootNode = new MaisDocNode(language, "language", getLanguageNameUpperCase() + " Language",
|
||||
"The X4O " + getLanguageNameUpperCase() + " Language");
|
||||
doc.setRootNode(rootNode);
|
||||
for (X4OLanguageModule mod:language.getLanguageModules()) { MaisDocNode modNode = rootNode.addNode(createNodeLanguageModule(mod));
|
||||
for (ElementBindingHandler bind:mod.getElementBindingHandlers()) { modNode.addNode(createNodeElementBindingHandler(bind)); }
|
||||
for (ElementConfiguratorGlobal conf:mod.getElementConfiguratorGlobals()) { modNode.addNode(createNodeElementConfiguratorGlobal(conf)); }
|
||||
for (ElementInterface iface:mod.getElementInterfaces()) { MaisDocNode ifaceNode = modNode.addNode(createNodeElementInterface(iface));
|
||||
for (ElementClassAttribute eca:iface.getElementClassAttributes()) { ifaceNode.addNode(createNodeElementClassAttribute(eca)); }
|
||||
for (ElementConfigurator conf:iface.getElementConfigurators()) { ifaceNode.addNode(createNodeElementConfigurator(conf)); } }
|
||||
for (ElementNamespace ns:mod.getElementNamespaces()) { MaisDocNode nsNode = modNode.addNode(createNodeElementNamespace(ns));
|
||||
for (ElementNamespaceAttribute attr:ns.getElementNamespaceAttributes()) { nsNode.addNode(createNodeElementNamespaceAttribute(attr)); }
|
||||
for (ElementClass ec:ns.getElementClasses()) { MaisDocNode ecNode = nsNode.addNode(createNodeElementClass(ec));
|
||||
for (ElementClassAttribute eca:ec.getElementClassAttributes()) { ecNode.addNode(createNodeElementClassAttribute(eca)); }
|
||||
for (ElementConfigurator conf:ec.getElementConfigurators()) { ecNode.addNode(createNodeElementConfigurator(conf)); } } }
|
||||
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||
MaisDocNode modNode = rootNode.addNode(createNodeLanguageModule(mod));
|
||||
for (ElementBindingHandler bind : mod.getElementBindingHandlers()) {
|
||||
modNode.addNode(createNodeElementBindingHandler(bind));
|
||||
}
|
||||
for (ElementConfiguratorGlobal conf : mod.getElementConfiguratorGlobals()) {
|
||||
modNode.addNode(createNodeElementConfiguratorGlobal(conf));
|
||||
}
|
||||
for (ElementInterface iface : mod.getElementInterfaces()) {
|
||||
MaisDocNode ifaceNode = modNode.addNode(createNodeElementInterface(iface));
|
||||
for (ElementClassAttribute eca : iface.getElementClassAttributes()) {
|
||||
ifaceNode.addNode(createNodeElementClassAttribute(eca));
|
||||
}
|
||||
for (ElementConfigurator conf : iface.getElementConfigurators()) {
|
||||
ifaceNode.addNode(createNodeElementConfigurator(conf));
|
||||
}
|
||||
}
|
||||
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||
MaisDocNode nsNode = modNode.addNode(createNodeElementNamespace(ns));
|
||||
for (ElementNamespaceAttribute attr : ns.getElementNamespaceAttributes()) {
|
||||
nsNode.addNode(createNodeElementNamespaceAttribute(attr));
|
||||
}
|
||||
for (ElementClass ec : ns.getElementClasses()) {
|
||||
MaisDocNode ecNode = nsNode.addNode(createNodeElementClass(ec));
|
||||
for (ElementClassAttribute eca : ec.getElementClassAttributes()) {
|
||||
ecNode.addNode(createNodeElementClassAttribute(eca));
|
||||
}
|
||||
for (ElementConfigurator conf : ec.getElementConfigurators()) {
|
||||
ecNode.addNode(createNodeElementConfigurator(conf));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
||||
private MaisDocNode createNodeElementBindingHandler(ElementBindingHandler bind) {
|
||||
return new MaisDocNode(bind,bind.getId(),bind.getId(),bind.getDescription());
|
||||
return new MaisDocNode(bind, bind.getId(), bind.getId(), bind.getDescription());
|
||||
}
|
||||
|
||||
private MaisDocNode createNodeElementNamespaceAttribute(ElementNamespaceAttribute attr) {
|
||||
return new MaisDocNode(attr,attr.getId(),attr.getId(),attr.getDescription());
|
||||
return new MaisDocNode(attr, attr.getId(), attr.getId(), attr.getDescription());
|
||||
}
|
||||
|
||||
private MaisDocNode createNodeElementConfiguratorGlobal(ElementConfiguratorGlobal conf) {
|
||||
return new MaisDocNode(conf,conf.getId(),conf.getId(),conf.getDescription());
|
||||
return new MaisDocNode(conf, conf.getId(), conf.getId(), conf.getDescription());
|
||||
}
|
||||
|
||||
private MaisDocNode createNodeElementConfigurator(ElementConfigurator conf) {
|
||||
return new MaisDocNode(conf,conf.getId(),conf.getId(),conf.getDescription());
|
||||
return new MaisDocNode(conf, conf.getId(), conf.getId(), conf.getDescription());
|
||||
}
|
||||
|
||||
private MaisDocNode createNodeLanguageModule(X4OLanguageModule mod) {
|
||||
return new MaisDocNode(mod,mod.getId(),mod.getId(),mod.getDescription());
|
||||
return new MaisDocNode(mod, mod.getId(), mod.getId(), mod.getDescription());
|
||||
}
|
||||
|
||||
private MaisDocNode createNodeElementInterface(ElementInterface iface) {
|
||||
return new MaisDocNode(iface,iface.getId(),iface.getId(),iface.getDescription());
|
||||
return new MaisDocNode(iface, iface.getId(), iface.getId(), iface.getDescription());
|
||||
}
|
||||
|
||||
private MaisDocNode createNodeElementNamespace(ElementNamespace ns) {
|
||||
return new MaisDocNode(ns,ns.getId(),ns.getUri(),ns.getDescription());
|
||||
return new MaisDocNode(ns, ns.getId(), ns.getUri(), ns.getDescription());
|
||||
}
|
||||
|
||||
private MaisDocNode createNodeElementClass(ElementClass ec) {
|
||||
return new MaisDocNode(ec,ec.getId(),ec.getId(),ec.getDescription());
|
||||
return new MaisDocNode(ec, ec.getId(), ec.getId(), ec.getDescription());
|
||||
}
|
||||
|
||||
private MaisDocNode createNodeElementClassAttribute(ElementClassAttribute eca) {
|
||||
return new MaisDocNode(eca,eca.getId(),eca.getId(),eca.getDescription());
|
||||
return new MaisDocNode(eca, eca.getId(), eca.getId(), eca.getDescription());
|
||||
}
|
||||
|
||||
|
||||
private String createPageSubTitle() {
|
||||
StringBuilder buf = new StringBuilder(100);
|
||||
buf.append(language.getLanguageName());
|
||||
|
|
@ -273,7 +316,7 @@ public class EldDocWriter {
|
|||
buf.append(" API");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
||||
private String createLanguageAbout() {
|
||||
StringBuilder buf = new StringBuilder(100);
|
||||
buf.append("XML X4O Language\n");
|
||||
|
|
@ -282,7 +325,7 @@ public class EldDocWriter {
|
|||
buf.append(language.getLanguageVersion());
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
||||
private String createLanguageCopyright() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
StringBuilder buf = new StringBuilder(100);
|
||||
|
|
@ -294,7 +337,7 @@ public class EldDocWriter {
|
|||
buf.append("All Rights Reserved.");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
||||
private List<String> createLanguageKeywords() {
|
||||
List<String> keywords = new ArrayList<String>(10);
|
||||
keywords.add(language.getLanguageName());
|
||||
|
|
@ -307,7 +350,7 @@ public class EldDocWriter {
|
|||
keywords.add("documentation");
|
||||
return keywords;
|
||||
}
|
||||
|
||||
|
||||
private String getLanguageNameUpperCase() {
|
||||
return language.getLanguageName().toUpperCase();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,15 +50,17 @@ import org.x4o.xml.lang.X4OLanguageModule;
|
|||
* @version 1.0 May 29, 2013
|
||||
*/
|
||||
public class EldDocWriterElementClass implements MaisDocContentPrinter {
|
||||
|
||||
@MaisDocNodeDataConfiguratorMethod(targetClasses={ElementClass.class})
|
||||
public void configNavBar(MaisDoc doc,MaisDocNode node,MaisDocNodeData data) {
|
||||
|
||||
@MaisDocNodeDataConfiguratorMethod(targetClasses = { ElementClass.class })
|
||||
public void configNavBar(MaisDoc doc, MaisDocNode node, MaisDocNodeData data) {
|
||||
/*
|
||||
//@formatter:off
|
||||
ElementClass ec = (ElementClass)node.getUserData();
|
||||
Collection<ElementClassAttribute> list = ec.getElementClassAttributes();
|
||||
if (list.isEmpty()) {
|
||||
clearHrefContentGroupAlways(doc,"summary","attribute");
|
||||
}
|
||||
//@formatter:om
|
||||
*/
|
||||
clearHrefContentGroup(doc,node,"summary","attribute",ElementClassAttribute.class);
|
||||
clearHrefContentGroup(doc,node,"summary","configurator",ElementConfigurator.class);
|
||||
|
|
@ -80,6 +82,7 @@ public class EldDocWriterElementClass implements MaisDocContentPrinter {
|
|||
}
|
||||
|
||||
/*
|
||||
//@formatter:off
|
||||
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementClass.class},nodeBodyOrders={2},contentGroup="attribute",contentGroupType="summary")
|
||||
public void writeElementX4OAttributeSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||
ElementClass ec = (ElementClass)event.getEventObject().getUserData();
|
||||
|
|
@ -95,77 +98,79 @@ public class EldDocWriterElementClass implements MaisDocContentPrinter {
|
|||
}
|
||||
writer.docTableEnd();
|
||||
}
|
||||
//@formatter:on
|
||||
*/
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementClass.class},nodeBodyOrders={10},contentGroup="bean",contentGroupType="summary")
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementClass.class }, nodeBodyOrders = {
|
||||
10 }, contentGroup = "bean", contentGroupType = "summary")
|
||||
public void writeElementObjectPropertiesSummary(MaisDocWriteEvent<MaisDocNode> event) throws IOException {
|
||||
ElementClass ec = (ElementClass)event.getEventObject().getUserData();
|
||||
ElementClass ec = (ElementClass) event.getEventObject().getUserData();
|
||||
Class<?> beanClass = ec.getObjectClass();
|
||||
if (beanClass==null) {
|
||||
if (beanClass == null) {
|
||||
return;
|
||||
}
|
||||
printApiTableBeanClass(event, beanClass, "Object");
|
||||
}
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.DESCRIPTION_LINKS,targetClasses={ElementClass.class})
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.DESCRIPTION_LINKS, targetClasses = { ElementClass.class })
|
||||
public void writeElementRelationLinks(MaisDocWriteEvent<MaisDocNode> event) throws IOException {
|
||||
MaisDocContentWriter writer = event.getWriter();
|
||||
ElementClass ec = (ElementClass)event.getEventObject().getUserData();
|
||||
ElementNamespace ns = (ElementNamespace)event.getEventObject().getParent().getUserData();
|
||||
X4OLanguageModule mod = (X4OLanguageModule)event.getEventObject().getParent().getParent().getUserData();
|
||||
X4OLanguage language = (X4OLanguage)event.getEventObject().getParent().getParent().getParent().getUserData();
|
||||
|
||||
ElementClass ec = (ElementClass) event.getEventObject().getUserData();
|
||||
ElementNamespace ns = (ElementNamespace) event.getEventObject().getParent().getUserData();
|
||||
X4OLanguageModule mod = (X4OLanguageModule) event.getEventObject().getParent().getParent().getUserData();
|
||||
X4OLanguage language = (X4OLanguage) event.getEventObject().getParent().getParent().getParent().getUserData();
|
||||
|
||||
// TODO: this is hacky
|
||||
EldDocXTreePageWriter xtree = (EldDocXTreePageWriter)event.getDoc().findDocPageById("overview-xtree").getPageWriters().get(0);
|
||||
|
||||
EldDocXTreePageWriter xtree = (EldDocXTreePageWriter) event.getDoc().findDocPageById("overview-xtree").getPageWriters().get(0);
|
||||
|
||||
TreeNode node = xtree.new TreeNode();
|
||||
node.language=language;
|
||||
node.module=mod;
|
||||
node.namespace=ns;
|
||||
node.elementClass=ec;
|
||||
|
||||
node.language = language;
|
||||
node.module = mod;
|
||||
node.namespace = ns;
|
||||
node.elementClass = ec;
|
||||
|
||||
String pathPrefix = "../../../../language/";
|
||||
|
||||
|
||||
List<TreeNode> parents = xtree.findParents(node);
|
||||
writer.printTagStart(Tag.dl);
|
||||
writer.printTagCharacters(Tag.dt,"All Element Parents:");
|
||||
writer.printTagStart(Tag.dd);
|
||||
if (parents.isEmpty()) {
|
||||
writer.printCharacters("No parent.");
|
||||
}
|
||||
for (int i=0;i<parents.size();i++) {
|
||||
TreeNode n = parents.get(i);
|
||||
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
|
||||
writer.printHref(uri, n.namespace.getId()+":"+n.elementClass.getId());
|
||||
if (i<parents.size()-1) {
|
||||
writer.printCharacters(", ");
|
||||
}
|
||||
}
|
||||
writer.printTagEnd(Tag.dd);
|
||||
writer.printTagCharacters(Tag.dt, "All Element Parents:");
|
||||
writer.printTagStart(Tag.dd);
|
||||
if (parents.isEmpty()) {
|
||||
writer.printCharacters("No parent.");
|
||||
}
|
||||
for (int i = 0; i < parents.size(); i++) {
|
||||
TreeNode n = parents.get(i);
|
||||
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
|
||||
writer.printHref(uri, n.namespace.getId() + ":" + n.elementClass.getId());
|
||||
if (i < parents.size() - 1) {
|
||||
writer.printCharacters(", ");
|
||||
}
|
||||
}
|
||||
writer.printTagEnd(Tag.dd);
|
||||
writer.printTagEnd(Tag.dl);
|
||||
|
||||
|
||||
List<TreeNode> childs = xtree.findChilderen(node);
|
||||
writer.printTagStart(Tag.dl);
|
||||
writer.printTagCharacters(Tag.dt,"All Element Childeren:");
|
||||
writer.printTagStart(Tag.dd);
|
||||
if (childs.isEmpty()) {
|
||||
writer.printCharacters("No childeren.");
|
||||
}
|
||||
for (int i=0;i<childs.size();i++) {
|
||||
TreeNode n = childs.get(i);
|
||||
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
|
||||
writer.printHref(uri, n.namespace.getId()+":"+n.elementClass.getId());
|
||||
if (i<childs.size()-1) {
|
||||
writer.printCharacters(", ");
|
||||
}
|
||||
}
|
||||
writer.printTagEnd(Tag.dd);
|
||||
writer.printTagCharacters(Tag.dt, "All Element Childeren:");
|
||||
writer.printTagStart(Tag.dd);
|
||||
if (childs.isEmpty()) {
|
||||
writer.printCharacters("No childeren.");
|
||||
}
|
||||
for (int i = 0; i < childs.size(); i++) {
|
||||
TreeNode n = childs.get(i);
|
||||
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
|
||||
writer.printHref(uri, n.namespace.getId() + ":" + n.elementClass.getId());
|
||||
if (i < childs.size() - 1) {
|
||||
writer.printCharacters(", ");
|
||||
}
|
||||
}
|
||||
writer.printTagEnd(Tag.dd);
|
||||
writer.printTagEnd(Tag.dl);
|
||||
}
|
||||
|
||||
private String toElementUri(String pathPrefix,X4OLanguageModule mod,ElementNamespace namespace,ElementClass ec) {
|
||||
|
||||
private String toElementUri(String pathPrefix, X4OLanguageModule mod, ElementNamespace namespace, ElementClass ec) {
|
||||
StringBuilder buf = new StringBuilder(100);
|
||||
if (pathPrefix!=null) {
|
||||
if (pathPrefix != null) {
|
||||
buf.append(pathPrefix);
|
||||
}
|
||||
buf.append(MaisDocContentWriter.toSafeUri(mod.getId()));
|
||||
|
|
|
|||
|
|
@ -45,32 +45,35 @@ import org.xml.sax.SAXException;
|
|||
* @version 1.0 Aug 17, 2013
|
||||
*/
|
||||
public class EldDocWriterElementInterface implements MaisDocContentPrinter {
|
||||
|
||||
@MaisDocNodeDataConfiguratorMethod(targetClasses={ElementInterface.class})
|
||||
public void configNavBar(MaisDoc doc,MaisDocNode node,MaisDocNodeData data) {
|
||||
clearHrefContentGroup(doc,node,"summary","attribute",ElementClassAttribute.class);
|
||||
clearHrefContentGroup(doc,node,"summary","binding",ElementBindingHandler.class);
|
||||
clearHrefContentGroup(doc,node,"summary","configurator",ElementConfigurator.class);
|
||||
|
||||
@MaisDocNodeDataConfiguratorMethod(targetClasses = { ElementInterface.class })
|
||||
public void configNavBar(MaisDoc doc, MaisDocNode node, MaisDocNodeData data) {
|
||||
clearHrefContentGroup(doc, node, "summary", "attribute", ElementClassAttribute.class);
|
||||
clearHrefContentGroup(doc, node, "summary", "binding", ElementBindingHandler.class);
|
||||
clearHrefContentGroup(doc, node, "summary", "configurator", ElementConfigurator.class);
|
||||
}
|
||||
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementInterface.class},nodeBodyOrders={1},contentGroup="interface",contentGroupType="summary")
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementInterface.class }, nodeBodyOrders = {
|
||||
1 }, contentGroup = "interface", contentGroupType = "summary")
|
||||
public void writeElementNamespaceBeanProperties(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||
printApiTableBean(event,"Interface","description");
|
||||
printApiTableBean(event, "Interface", "description");
|
||||
}
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementInterface.class},nodeBodyOrders={2},contentGroup="attribute",contentGroupType="summary")
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementInterface.class }, nodeBodyOrders = {
|
||||
2 }, contentGroup = "attribute", contentGroupType = "summary")
|
||||
public void writeElementClassAttribute(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||
printApiTable(event,"Element Class Attribute Summary",ElementClassAttribute.class);
|
||||
printApiTable(event, "Element Class Attribute Summary", ElementClassAttribute.class);
|
||||
}
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementInterface.class},nodeBodyOrders={3},contentGroup="binding",contentGroupType="summary")
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementInterface.class }, nodeBodyOrders = {
|
||||
3 }, contentGroup = "binding", contentGroupType = "summary")
|
||||
public void writeElementBindingHandler(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||
printApiTable(event,"Element Binding Handler Summary",ElementBindingHandler.class);
|
||||
printApiTable(event, "Element Binding Handler Summary", ElementBindingHandler.class);
|
||||
}
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementInterface.class},nodeBodyOrders={4},contentGroup="configurator",contentGroupType="summary")
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementInterface.class }, nodeBodyOrders = {
|
||||
4 }, contentGroup = "configurator", contentGroupType = "summary")
|
||||
public void writeElementConfigurator(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||
printApiTable(event,"Element Configurator Summary",ElementConfigurator.class);
|
||||
printApiTable(event, "Element Configurator Summary", ElementConfigurator.class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,24 +43,26 @@ import org.xml.sax.SAXException;
|
|||
* @version 1.0 Aug 14, 2013
|
||||
*/
|
||||
public class EldDocWriterElementNamespace implements MaisDocContentPrinter {
|
||||
|
||||
@MaisDocNodeDataConfiguratorMethod(targetClasses={ElementNamespace.class})
|
||||
public void configNavBar(MaisDoc doc,MaisDocNode node,MaisDocNodeData data) {
|
||||
clearHrefContentGroup(doc,node,"summary","element",ElementClass.class);
|
||||
|
||||
@MaisDocNodeDataConfiguratorMethod(targetClasses = { ElementNamespace.class })
|
||||
public void configNavBar(MaisDoc doc, MaisDocNode node, MaisDocNodeData data) {
|
||||
clearHrefContentGroup(doc, node, "summary", "element", ElementClass.class);
|
||||
}
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementNamespace.class},nodeBodyOrders={1},contentGroup="namespace",contentGroupType="summary")
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementNamespace.class }, nodeBodyOrders = {
|
||||
1 }, contentGroup = "namespace", contentGroupType = "summary")
|
||||
public void writeElementNamespaceBeanProperties(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||
printApiTableBean(event,"Namespace","description","elementClasses","elementNamespaceInstanceProvider","prefixMapping");
|
||||
printApiTableBean(event, "Namespace", "description", "elementClasses", "elementNamespaceInstanceProvider", "prefixMapping");
|
||||
}
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementNamespace.class},nodeBodyOrders={2},contentGroup="element",contentGroupType="summary")
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementNamespace.class }, nodeBodyOrders = {
|
||||
2 }, contentGroup = "element", contentGroupType = "summary")
|
||||
public void writeElementNamespaceElements(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||
printApiTable(event,"Element Summary",ElementClass.class);
|
||||
printApiTable(event, "Element Summary", ElementClass.class);
|
||||
}
|
||||
|
||||
//@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY_PAGE,targetClasses={ElementNamespace.class},nodeBodyOrders={2})
|
||||
//public void writeElementNamespaceAttributes(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||
// printApiTable(event,"Element Summary",ElementClass.class);
|
||||
//}
|
||||
|
||||
// @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY_PAGE,targetClasses={ElementNamespace.class},nodeBodyOrders={2})
|
||||
// public void writeElementNamespaceAttributes(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||
// printApiTable(event,"Element Summary",ElementClass.class);
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,47 +47,47 @@ import org.xml.sax.SAXException;
|
|||
*/
|
||||
public class EldDocWriterLanguage implements MaisDocContentPrinter {
|
||||
|
||||
// TODO move
|
||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementBindingHandler.class})
|
||||
// TODO move
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementBindingHandler.class })
|
||||
public void writeElementBindingHandlerBean(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||
printApiTableBean(event,"BindingHandler","description");
|
||||
printApiTableBean(event, "BindingHandler", "description");
|
||||
}
|
||||
|
||||
// TODO move
|
||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementConfigurator.class})
|
||||
// TODO move
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementConfigurator.class })
|
||||
public void writeElementConfiguratorBean(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||
printApiTableBean(event,"Configurator","description");
|
||||
printApiTableBean(event, "Configurator", "description");
|
||||
}
|
||||
|
||||
// TODO move
|
||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementClassAttribute.class})
|
||||
|
||||
// TODO move
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementClassAttribute.class })
|
||||
public void writeElementClassAttributeBean(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||
printApiTableBean(event,"Element Class Attribute","description");
|
||||
printApiTableBean(event, "Element Class Attribute", "description");
|
||||
}
|
||||
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={X4OLanguage.class},nodeBodyOrders={1})
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { X4OLanguage.class }, nodeBodyOrders = { 1 })
|
||||
public void writeLanguageSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||
MaisDocContentWriter writer = event.getWriter();
|
||||
MaisDocNode node = event.getEventObject();
|
||||
X4OLanguage language = (X4OLanguage)node.getUserData();
|
||||
X4OLanguage language = (X4OLanguage) node.getUserData();
|
||||
int attrHandlers = 0;
|
||||
int bindHandlers = 0;
|
||||
int interFaces = 0;
|
||||
int eleConfigs = 0;
|
||||
int elements = 0;
|
||||
int namespaces = 0;
|
||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
||||
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||
bindHandlers += mod.getElementBindingHandlers().size();
|
||||
interFaces += mod.getElementInterfaces().size();
|
||||
eleConfigs += mod.getElementConfiguratorGlobals().size();
|
||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
||||
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||
namespaces++;
|
||||
elements += ns.getElementClasses().size();
|
||||
attrHandlers += ns.getElementNamespaceAttributes().size();
|
||||
}
|
||||
}
|
||||
writer.docTableStart("Language Summary", "Language Stats Summary.",MaisDocContentCss.overviewSummary);
|
||||
writer.docTableStart("Language Summary", "Language Stats Summary.", MaisDocContentCss.overviewSummary);
|
||||
//@formatter:off
|
||||
writer.docTableHeader("Name", "Value");
|
||||
writer.docTableRow("LanguageName:", ""+language.getLanguageName(), null);
|
||||
writer.docTableRow("LanguageVersion:",""+language.getLanguageVersion(),null);
|
||||
|
|
@ -99,23 +99,26 @@ public class EldDocWriterLanguage implements MaisDocContentPrinter {
|
|||
writer.docTableRow("ElementBindingHandlers:",""+bindHandlers,null);
|
||||
writer.docTableRow("ElementConfigurators:",""+eleConfigs,null);
|
||||
writer.docTableEnd();
|
||||
//@formatter:on
|
||||
}
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={X4OLanguage.class},nodeBodyOrders={2})
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { X4OLanguage.class }, nodeBodyOrders = { 2 })
|
||||
public void writeModulesSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||
printApiTable(event,"Module Summary",X4OLanguageModule.class);
|
||||
printApiTable(event, "Module Summary", X4OLanguageModule.class);
|
||||
}
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={X4OLanguage.class},nodeBodyOrders={3})
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { X4OLanguage.class }, nodeBodyOrders = { 3 })
|
||||
public void writeNamespaceSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||
MaisDocContentWriter writer = event.getWriter();
|
||||
MaisDocNode node = event.getEventObject();
|
||||
X4OLanguage language = (X4OLanguage)node.getUserData();
|
||||
writer.docTableStart("Namespace Summary", "All Language Namespaces Overview",MaisDocContentCss.overviewSummary);
|
||||
X4OLanguage language = (X4OLanguage) node.getUserData();
|
||||
writer.docTableStart("Namespace Summary", "All Language Namespaces Overview", MaisDocContentCss.overviewSummary);
|
||||
writer.docTableHeader("ID", "URI");
|
||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
||||
writer.docTableRowLink("language/"+MaisDocContentWriter.toSafeUri(mod.getId())+"/"+MaisDocContentWriter.toSafeUri(ns.getId())+"/index.html",ns.getId(),ns.getUri());
|
||||
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||
writer.docTableRowLink(
|
||||
"language/" + MaisDocContentWriter.toSafeUri(mod.getId()) + "/" + MaisDocContentWriter.toSafeUri(ns.getId()) + "/index.html",
|
||||
ns.getId(), ns.getUri());
|
||||
}
|
||||
}
|
||||
writer.docTableEnd();
|
||||
|
|
|
|||
|
|
@ -48,38 +48,43 @@ import org.xml.sax.SAXException;
|
|||
* @version 1.0 Aug 10, 2013
|
||||
*/
|
||||
public class EldDocWriterLanguageModule implements MaisDocContentPrinter {
|
||||
|
||||
@MaisDocNodeDataConfiguratorMethod(targetClasses={X4OLanguageModule.class})
|
||||
public void configNavBar(MaisDoc doc,MaisDocNode node,MaisDocNodeData data) {
|
||||
clearHrefContentGroup(doc,node,"summary","interface",ElementInterface.class);
|
||||
clearHrefContentGroup(doc,node,"summary","binding",ElementBindingHandler.class);
|
||||
clearHrefContentGroup(doc,node,"summary","attribute",ElementNamespaceAttribute.class);
|
||||
clearHrefContentGroup(doc,node,"summary","configurator",ElementConfigurator.class);
|
||||
clearHrefContentGroup(doc,node,"summary","namespace",ElementNamespace.class);
|
||||
|
||||
@MaisDocNodeDataConfiguratorMethod(targetClasses = { X4OLanguageModule.class })
|
||||
public void configNavBar(MaisDoc doc, MaisDocNode node, MaisDocNodeData data) {
|
||||
clearHrefContentGroup(doc, node, "summary", "interface", ElementInterface.class);
|
||||
clearHrefContentGroup(doc, node, "summary", "binding", ElementBindingHandler.class);
|
||||
clearHrefContentGroup(doc, node, "summary", "attribute", ElementNamespaceAttribute.class);
|
||||
clearHrefContentGroup(doc, node, "summary", "configurator", ElementConfigurator.class);
|
||||
clearHrefContentGroup(doc, node, "summary", "namespace", ElementNamespace.class);
|
||||
}
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={X4OLanguageModule.class},nodeBodyOrders={1},contentGroup="interface",contentGroupType="summary")
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { X4OLanguageModule.class }, nodeBodyOrders = {
|
||||
1 }, contentGroup = "interface", contentGroupType = "summary")
|
||||
public void writeInterfaceSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||
printApiTable(event,"Interface Summary",ElementInterface.class);
|
||||
printApiTable(event, "Interface Summary", ElementInterface.class);
|
||||
}
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={X4OLanguageModule.class},nodeBodyOrders={2},contentGroup="binding",contentGroupType="summary")
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { X4OLanguageModule.class }, nodeBodyOrders = {
|
||||
2 }, contentGroup = "binding", contentGroupType = "summary")
|
||||
public void writeBindingSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||
printApiTable(event,"Binding Summary",ElementBindingHandler.class);
|
||||
printApiTable(event, "Binding Summary", ElementBindingHandler.class);
|
||||
}
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={X4OLanguageModule.class},nodeBodyOrders={3},contentGroup="attribute",contentGroupType="summary")
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { X4OLanguageModule.class }, nodeBodyOrders = {
|
||||
3 }, contentGroup = "attribute", contentGroupType = "summary")
|
||||
public void writeAttributeSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||
printApiTable(event,"Attribute Summary",ElementNamespaceAttribute.class);
|
||||
printApiTable(event, "Attribute Summary", ElementNamespaceAttribute.class);
|
||||
}
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={X4OLanguageModule.class},nodeBodyOrders={4},contentGroup="configurator",contentGroupType="summary")
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { X4OLanguageModule.class }, nodeBodyOrders = {
|
||||
4 }, contentGroup = "configurator", contentGroupType = "summary")
|
||||
public void writeConfigutorSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||
printApiTable(event,"Configurator Summary",ElementConfigurator.class);
|
||||
printApiTable(event, "Configurator Summary", ElementConfigurator.class);
|
||||
}
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={X4OLanguageModule.class},nodeBodyOrders={5},contentGroup="namespace",contentGroupType="summary")
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { X4OLanguageModule.class }, nodeBodyOrders = {
|
||||
5 }, contentGroup = "namespace", contentGroupType = "summary")
|
||||
public void writeNamespaceSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||
printApiTable(event,"Namespace Summary",ElementNamespace.class);
|
||||
printApiTable(event, "Namespace Summary", ElementNamespace.class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,66 +50,68 @@ import org.x4o.xml.lang.X4OLanguageModule;
|
|||
* @version 1.0 May 29, 2013
|
||||
*/
|
||||
public class EldDocXTreePageWriter extends DefaultPageWriterTree implements MaisDocPageWriter {
|
||||
|
||||
|
||||
public static MaisDocPage createDocPage() {
|
||||
return new MaisDocPage("overview-xtree","XTree","XTree of dom elements.",new EldDocXTreePageWriter());
|
||||
return new MaisDocPage("overview-xtree", "XTree", "XTree of dom elements.", new EldDocXTreePageWriter());
|
||||
}
|
||||
|
||||
|
||||
// TODO: rm this old tree code;
|
||||
private void walkTree(TreeNode node,MaisDocContentWriter writer,String pathPrefix) throws IOException {
|
||||
String href = toElementUri(pathPrefix,node.module,node.namespace,node.elementClass);
|
||||
|
||||
private void walkTree(TreeNode node, MaisDocContentWriter writer, String pathPrefix) throws IOException {
|
||||
String href = toElementUri(pathPrefix, node.module, node.namespace, node.elementClass);
|
||||
|
||||
writer.printTagStart(Tag.ul);
|
||||
writer.printTagStart(Tag.li,"",null,"circle");
|
||||
writer.printTagStart(Tag.li, "", null, "circle");
|
||||
writer.printCharacters(node.namespace.getId());
|
||||
writer.printCharacters(":");
|
||||
writer.printHref(href, node.elementClass.getId(), node.elementClass.getId(), "strong");
|
||||
writer.printTagEnd(Tag.li);
|
||||
|
||||
|
||||
List<TreeNode> childs = findChilderen(node);
|
||||
for (TreeNode child:childs) {
|
||||
walkTree(child,writer,pathPrefix);
|
||||
for (TreeNode child : childs) {
|
||||
walkTree(child, writer, pathPrefix);
|
||||
}
|
||||
writer.printTagEnd(Tag.ul);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TODO: remove this
|
||||
*
|
||||
* @see org.x4o.maisdoc.flake.DefaultPageWriterTree#writePageContent(org.x4o.maisdoc.model.MaisDocWriteEvent)
|
||||
*/
|
||||
@Override
|
||||
public void writePageContent(MaisDocWriteEvent<MaisDocPage> e) throws IOException {
|
||||
//selectRootNode(e.getDoc()); // create
|
||||
// selectRootNode(e.getDoc()); // create
|
||||
MaisDoc doc = e.getDoc();
|
||||
X4OLanguage language = (X4OLanguage)doc.getRootNode().getUserData();
|
||||
|
||||
X4OLanguage language = (X4OLanguage) doc.getRootNode().getUserData();
|
||||
|
||||
String pathPrefix = "language/";
|
||||
|
||||
|
||||
// temp print old way
|
||||
List<TreeNode> rootNodes = new ArrayList<TreeNode>(3);
|
||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
||||
if (ns.getLanguageRoot()!=null && ns.getLanguageRoot()) {
|
||||
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||
if (ns.getLanguageRoot() != null && ns.getLanguageRoot()) {
|
||||
// found language root elements.
|
||||
for (ElementClass ec:ns.getElementClasses()) {
|
||||
for (ElementClass ec : ns.getElementClasses()) {
|
||||
TreeNode node = new TreeNode();
|
||||
node.language=language;
|
||||
node.module=mod;
|
||||
node.namespace=ns;
|
||||
node.elementClass=ec;
|
||||
node.language = language;
|
||||
node.module = mod;
|
||||
node.namespace = ns;
|
||||
node.elementClass = ec;
|
||||
rootNodes.add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(rootNodes,new TreeNodeComparator());
|
||||
for (TreeNode rootNode:rootNodes) {
|
||||
walkTree(rootNode,e.getWriter(),pathPrefix);
|
||||
Collections.sort(rootNodes, new TreeNodeComparator());
|
||||
for (TreeNode rootNode : rootNodes) {
|
||||
walkTree(rootNode, e.getWriter(), pathPrefix);
|
||||
}
|
||||
}
|
||||
private String toElementUri(String pathPrefix,X4OLanguageModule mod,ElementNamespace namespace,ElementClass ec) {
|
||||
|
||||
private String toElementUri(String pathPrefix, X4OLanguageModule mod, ElementNamespace namespace, ElementClass ec) {
|
||||
StringBuilder buf = new StringBuilder(100);
|
||||
if (pathPrefix!=null) {
|
||||
if (pathPrefix != null) {
|
||||
buf.append(pathPrefix);
|
||||
}
|
||||
buf.append(MaisDocContentWriter.toSafeUri(mod.getId()));
|
||||
|
|
@ -121,9 +123,9 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements Mais
|
|||
return buf.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Overrided to select the dom view of the tree.
|
||||
*
|
||||
* @see org.x4o.maisdoc.flake.DefaultPageWriterTree#selectRootNode(org.x4o.maisdoc.model.MaisDoc)
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -131,49 +133,47 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements Mais
|
|||
try {
|
||||
return createXTree(doc);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("Could not create XTree for: "+doc.getName()+" error: "+e.getMessage(),e);
|
||||
throw new IllegalStateException("Could not create XTree for: " + doc.getName() + " error: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private MaisDocNode createXTree(MaisDoc doc) throws IOException {
|
||||
|
||||
X4OLanguage language = (X4OLanguage)doc.getRootNode().getUserData();
|
||||
MaisDocNode root = new MaisDocNode(language,"root","Root","Language root");
|
||||
|
||||
|
||||
X4OLanguage language = (X4OLanguage) doc.getRootNode().getUserData();
|
||||
MaisDocNode root = new MaisDocNode(language, "root", "Root", "Language root");
|
||||
|
||||
List<TreeNode> rootNodes = new ArrayList<TreeNode>(3);
|
||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
||||
if (ns.getLanguageRoot()!=null && ns.getLanguageRoot()) {
|
||||
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||
if (ns.getLanguageRoot() != null && ns.getLanguageRoot()) {
|
||||
// found language root elements.
|
||||
for (ElementClass ec:ns.getElementClasses()) {
|
||||
for (ElementClass ec : ns.getElementClasses()) {
|
||||
TreeNode node = new TreeNode();
|
||||
node.language=language;
|
||||
node.module=mod;
|
||||
node.namespace=ns;
|
||||
node.elementClass=ec;
|
||||
node.language = language;
|
||||
node.module = mod;
|
||||
node.namespace = ns;
|
||||
node.elementClass = ec;
|
||||
rootNodes.add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(rootNodes,new TreeNodeComparator());
|
||||
for (TreeNode rootNode:rootNodes) {
|
||||
walkTree(rootNode,"../");
|
||||
Collections.sort(rootNodes, new TreeNodeComparator());
|
||||
for (TreeNode rootNode : rootNodes) {
|
||||
walkTree(rootNode, "../");
|
||||
}
|
||||
|
||||
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
private void walkTree(TreeNode node,String pathPrefix) throws IOException {
|
||||
//String href = toElementUri(pathPrefix,node.module,node.namespace,node.elementClass);
|
||||
|
||||
private void walkTree(TreeNode node, String pathPrefix) throws IOException {
|
||||
// String href = toElementUri(pathPrefix,node.module,node.namespace,node.elementClass);
|
||||
List<TreeNode> childs = findChilderen(node);
|
||||
for (TreeNode child:childs) {
|
||||
walkTree(child,pathPrefix);
|
||||
for (TreeNode child : childs) {
|
||||
walkTree(child, pathPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class TreeNode {
|
||||
X4OLanguage language;
|
||||
X4OLanguageModule module;
|
||||
|
|
@ -182,150 +182,148 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements Mais
|
|||
TreeNode parent;
|
||||
int indent = 0;
|
||||
}
|
||||
|
||||
|
||||
public List<TreeNode> findChilderen(TreeNode node) {
|
||||
List<TreeNode> result = new ArrayList<TreeNode>(10);
|
||||
|
||||
if (node.indent>20) {
|
||||
|
||||
if (node.indent > 20) {
|
||||
return result; // hard fail limit
|
||||
}
|
||||
for (X4OLanguageModule mod:node.language.getLanguageModules()) {
|
||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
||||
for (ElementClass ec:ns.getElementClasses()) {
|
||||
TreeNode n=null;
|
||||
for (X4OLanguageModule mod : node.language.getLanguageModules()) {
|
||||
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||
for (ElementClass ec : ns.getElementClasses()) {
|
||||
TreeNode n = null;
|
||||
List<String> tags = ec.getElementParents(node.namespace.getUri());
|
||||
if (tags!=null && tags.contains(node.elementClass.getId())) {
|
||||
if (tags != null && tags.contains(node.elementClass.getId())) {
|
||||
n = new TreeNode();
|
||||
n.language=node.language;
|
||||
n.module=mod;
|
||||
n.namespace=ns;
|
||||
n.elementClass=ec;
|
||||
n.indent=node.indent+1;
|
||||
n.parent=node;
|
||||
n.language = node.language;
|
||||
n.module = mod;
|
||||
n.namespace = ns;
|
||||
n.elementClass = ec;
|
||||
n.indent = node.indent + 1;
|
||||
n.parent = node;
|
||||
} else {
|
||||
if (ec.getObjectClass()==null) {
|
||||
if (ec.getObjectClass() == null) {
|
||||
continue;
|
||||
}
|
||||
// Check interfaces of parent , and see if child tag is there.
|
||||
for (ElementInterface ei:node.language.findElementInterfaces(ec.getObjectClass())) {
|
||||
for (ElementInterface ei : node.language.findElementInterfaces(ec.getObjectClass())) {
|
||||
List<String> eiTags = ei.getElementParents(node.namespace.getUri());
|
||||
if (eiTags!=null && eiTags.contains(node.elementClass.getId())) {
|
||||
if (eiTags != null && eiTags.contains(node.elementClass.getId())) {
|
||||
n = new TreeNode();
|
||||
n.language=node.language;
|
||||
n.module=mod;
|
||||
n.namespace=ns;
|
||||
n.elementClass=ec;
|
||||
n.indent=node.indent+1;
|
||||
n.parent=node;
|
||||
n.language = node.language;
|
||||
n.module = mod;
|
||||
n.namespace = ns;
|
||||
n.elementClass = ec;
|
||||
n.indent = node.indent + 1;
|
||||
n.parent = node;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (node.elementClass.getObjectClass()==null) {
|
||||
|
||||
if (node.elementClass.getObjectClass() == null) {
|
||||
continue;
|
||||
}
|
||||
List<ElementBindingHandler> binds = node.language.findElementBindingHandlers(node.elementClass.getObjectClass(), ec.getObjectClass());
|
||||
if (binds.isEmpty()==false) {
|
||||
if (binds.isEmpty() == false) {
|
||||
n = new TreeNode();
|
||||
n.language=node.language;
|
||||
n.module=mod;
|
||||
n.namespace=ns;
|
||||
n.elementClass=ec;
|
||||
n.indent=node.indent+1;
|
||||
n.parent=node;
|
||||
n.language = node.language;
|
||||
n.module = mod;
|
||||
n.namespace = ns;
|
||||
n.elementClass = ec;
|
||||
n.indent = node.indent + 1;
|
||||
n.parent = node;
|
||||
}
|
||||
}
|
||||
if (n!=null && isInTree(node,n)==false) {
|
||||
if (n != null && isInTree(node, n) == false) {
|
||||
result.add(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(result,new TreeNodeComparator());
|
||||
Collections.sort(result, new TreeNodeComparator());
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isInTree(TreeNode node,TreeNode checkNode) {
|
||||
|
||||
if ( node.namespace.getUri().equals(checkNode.namespace.getUri()) &&
|
||||
node.elementClass.getId().equals(checkNode.elementClass.getId())
|
||||
) {
|
||||
|
||||
private boolean isInTree(TreeNode node, TreeNode checkNode) {
|
||||
|
||||
if (node.namespace.getUri().equals(checkNode.namespace.getUri()) && node.elementClass.getId().equals(checkNode.elementClass.getId())) {
|
||||
return true;
|
||||
}
|
||||
if (node.parent!=null) {
|
||||
return isInTree(node.parent,checkNode);
|
||||
if (node.parent != null) {
|
||||
return isInTree(node.parent, checkNode);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public List<TreeNode> findParents(TreeNode node) {
|
||||
List<TreeNode> result = new ArrayList<TreeNode>(10);
|
||||
TreeNode n=null;
|
||||
for (X4OLanguageModule mod:node.language.getLanguageModules()) {
|
||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
||||
|
||||
TreeNode n = null;
|
||||
for (X4OLanguageModule mod : node.language.getLanguageModules()) {
|
||||
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||
|
||||
List<String> tags = node.elementClass.getElementParents(ns.getUri());
|
||||
if (tags!=null) {
|
||||
for (ElementClass ec:ns.getElementClasses()) {
|
||||
if (tags != null) {
|
||||
for (ElementClass ec : ns.getElementClasses()) {
|
||||
if (tags.contains(ec.getId())) {
|
||||
n = new TreeNode();
|
||||
n.language=node.language;
|
||||
n.module=mod;
|
||||
n.namespace=ns;
|
||||
n.elementClass=ec;
|
||||
n.indent=node.indent+1;
|
||||
n.parent=node;
|
||||
n.language = node.language;
|
||||
n.module = mod;
|
||||
n.namespace = ns;
|
||||
n.elementClass = ec;
|
||||
n.indent = node.indent + 1;
|
||||
n.parent = node;
|
||||
result.add(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ElementClass ec:ns.getElementClasses()) {
|
||||
for (ElementClass ec : ns.getElementClasses()) {
|
||||
|
||||
// Check interfaces of parent , and see if child tag is there.
|
||||
if (node.elementClass.getObjectClass()!=null) {
|
||||
for (ElementInterface ei:node.language.findElementInterfaces(node.elementClass.getObjectClass())) {
|
||||
if (node.elementClass.getObjectClass() != null) {
|
||||
for (ElementInterface ei : node.language.findElementInterfaces(node.elementClass.getObjectClass())) {
|
||||
List<String> eiTags = ei.getElementParents(ns.getUri());
|
||||
if (eiTags!=null && eiTags.contains(ec.getId())) {
|
||||
if (eiTags != null && eiTags.contains(ec.getId())) {
|
||||
n = new TreeNode();
|
||||
n.language=node.language;
|
||||
n.module=mod;
|
||||
n.namespace=ns;
|
||||
n.elementClass=ec;
|
||||
n.indent=node.indent+1;
|
||||
n.parent=node;
|
||||
n.language = node.language;
|
||||
n.module = mod;
|
||||
n.namespace = ns;
|
||||
n.elementClass = ec;
|
||||
n.indent = node.indent + 1;
|
||||
n.parent = node;
|
||||
result.add(n);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ec.getObjectClass()==null) {
|
||||
if (ec.getObjectClass() == null) {
|
||||
continue;
|
||||
}
|
||||
if (node.elementClass.getObjectClass()==null) {
|
||||
if (node.elementClass.getObjectClass() == null) {
|
||||
continue;
|
||||
}
|
||||
List<ElementBindingHandler> binds = node.language.findElementBindingHandlers(ec.getObjectClass(),node.elementClass.getObjectClass());
|
||||
if (binds.isEmpty()==false) {
|
||||
List<ElementBindingHandler> binds = node.language.findElementBindingHandlers(ec.getObjectClass(), node.elementClass.getObjectClass());
|
||||
if (binds.isEmpty() == false) {
|
||||
n = new TreeNode();
|
||||
n.language=node.language;
|
||||
n.module=mod;
|
||||
n.namespace=ns;
|
||||
n.elementClass=ec;
|
||||
n.indent=node.indent+1;
|
||||
n.parent=node;
|
||||
if (isInTree(node,n)==false) {
|
||||
n.language = node.language;
|
||||
n.module = mod;
|
||||
n.namespace = ns;
|
||||
n.elementClass = ec;
|
||||
n.indent = node.indent + 1;
|
||||
n.parent = node;
|
||||
if (isInTree(node, n) == false) {
|
||||
result.add(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(result,new TreeNodeComparator());
|
||||
Collections.sort(result, new TreeNodeComparator());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
class TreeNodeComparator implements Comparator<TreeNode> {
|
||||
public int compare(TreeNode o1,TreeNode o2) {
|
||||
public int compare(TreeNode o1, TreeNode o2) {
|
||||
return o1.elementClass.getId().compareTo(o2.elementClass.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,19 +36,20 @@ public class AttributeAliasElement extends AbstractElement {
|
|||
|
||||
/**
|
||||
* Add the xml attribute 'name' to ElementClassAttribute as attribute alias.
|
||||
*
|
||||
* @see org.x4o.xml.element.AbstractElement#doElementEnd()
|
||||
* @throws ElementException When name attribute is not set or when parent element object is not ElementClassAttribute interface.
|
||||
*/
|
||||
@Override
|
||||
public void doElementEnd() throws ElementException {
|
||||
String alias = getAttributes().get("name");
|
||||
if (alias==null) {
|
||||
throw new ElementException("'name' attribute is not set on: "+getElementClass().getId());
|
||||
if (alias == null) {
|
||||
throw new ElementException("'name' attribute is not set on: " + getElementClass().getId());
|
||||
}
|
||||
if (getParent().getElementObject() instanceof ElementClassAttribute) {
|
||||
((ElementClassAttribute)getParent().getElementObject()).addAttributeAlias(alias);
|
||||
((ElementClassAttribute) getParent().getElementObject()).addAttributeAlias(alias);
|
||||
} else {
|
||||
throw new ElementException("Wrong parent class is not ElementClassAttribute but: "+getParent().getElementObject());
|
||||
throw new ElementException("Wrong parent class is not ElementClassAttribute but: " + getParent().getElementObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,33 +38,36 @@ import org.x4o.xml.lang.X4OLanguageClassLoader;
|
|||
* @version 1.0 Jan 21, 2007
|
||||
*/
|
||||
public class BeanElement extends AbstractElement {
|
||||
|
||||
|
||||
private List<Object> constructorArguments = null;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a BeanElement.
|
||||
*/
|
||||
public BeanElement() {
|
||||
constructorArguments = new ArrayList<Object>(3);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* On start of element create the element object, filled from the bean.class attribute.
|
||||
*
|
||||
* @throws ElementException When bean could not be created.
|
||||
*/
|
||||
@Override
|
||||
public void doElementStart() throws ElementException {
|
||||
String className = getAttributes().get("bean.class");
|
||||
if("".equals(className) | className==null) { throw new ElementException("Set the bean.class attribute"); }
|
||||
if ("".equals(className) | className == null) {
|
||||
throw new ElementException("Set the bean.class attribute");
|
||||
}
|
||||
try {
|
||||
Class<?> beanClass = X4OLanguageClassLoader.loadClass(className);
|
||||
Class<?> beanClass = X4OLanguageClassLoader.loadClass(className);
|
||||
if (constructorArguments.isEmpty()) {
|
||||
setElementObject(X4OLanguageClassLoader.newInstance(beanClass));
|
||||
} else {
|
||||
Class<?>[] arguClass = new Class<?>[constructorArguments.size()];
|
||||
constructorArguments.toArray(arguClass);
|
||||
Constructor<?> c = beanClass.getConstructor(arguClass);
|
||||
setElementObject(c.newInstance(constructorArguments));
|
||||
setElementObject(c.newInstance(constructorArguments));
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new ElementException(e);
|
||||
|
|
@ -79,14 +82,15 @@ public class BeanElement extends AbstractElement {
|
|||
} catch (InvocationTargetException e) {
|
||||
throw new ElementException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add bean constructor arguments.
|
||||
* @param argu The argument to add to constructor.
|
||||
*
|
||||
* @param argu The argument to add to constructor.
|
||||
*/
|
||||
public void addConstuctorArgument(Object argu) {
|
||||
if (argu==null) {
|
||||
if (argu == null) {
|
||||
throw new NullPointerException("Can't add null argument for constructor.");
|
||||
}
|
||||
constructorArguments.add(argu);
|
||||
|
|
|
|||
|
|
@ -33,15 +33,16 @@ import org.x4o.xml.element.ElementException;
|
|||
* @version 1.0 Jan 13, 2009
|
||||
*/
|
||||
public class DescriptionElement extends AbstractElement {
|
||||
|
||||
|
||||
/**
|
||||
* Starts the description element and validates that it is not root and parent is meta base.
|
||||
* @throws ElementException When parent element object is not meta base object.
|
||||
*
|
||||
* @throws ElementException When parent element object is not meta base object.
|
||||
* @see org.x4o.xml.element.AbstractElement#doElementStart()
|
||||
*/
|
||||
@Override
|
||||
public void doElementStart() throws ElementException {
|
||||
if (getParent()==null) {
|
||||
if (getParent() == null) {
|
||||
throw new ElementException("can't be a root tag");
|
||||
}
|
||||
if (getParent().getElementObject() instanceof ElementMetaBase == false) {
|
||||
|
|
@ -51,8 +52,9 @@ public class DescriptionElement extends AbstractElement {
|
|||
|
||||
/**
|
||||
* The description elememt body characters are stored as element object.
|
||||
* @param characters The text of the description.
|
||||
* @throws ElementException When super has error.
|
||||
*
|
||||
* @param characters The text of the description.
|
||||
* @throws ElementException When super has error.
|
||||
* @see org.x4o.xml.element.AbstractElement#doCharacters(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -63,16 +65,17 @@ public class DescriptionElement extends AbstractElement {
|
|||
|
||||
/**
|
||||
* Ends the description element and sets the description on the parent.
|
||||
* @throws ElementException When parent element object is not meta base object.
|
||||
*
|
||||
* @throws ElementException When parent element object is not meta base object.
|
||||
* @see org.x4o.xml.element.AbstractElement#doElementEnd()
|
||||
*/
|
||||
@Override
|
||||
public void doElementEnd() throws ElementException {
|
||||
if (getElementObject()==null) {
|
||||
if (getElementObject() == null) {
|
||||
throw new ElementException("description is not set.");
|
||||
}
|
||||
if (getParent().getElementObject() instanceof ElementMetaBase) {
|
||||
((ElementMetaBase)getParent().getElementObject()).setDescription(getElementObject().toString());
|
||||
((ElementMetaBase) getParent().getElementObject()).setDescription(getElementObject().toString());
|
||||
} else {
|
||||
throw new ElementException("Wrong parent class is not ElementClass");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,17 +41,17 @@ public class ElementClassAddParentElement extends AbstractElement {
|
|||
@Override
|
||||
public void doElementEnd() throws ElementException {
|
||||
String tag = getAttributes().get("tag");
|
||||
if (tag==null) {
|
||||
throw new ElementException("'tag' attribute is not set on: "+getElementClass().getId());
|
||||
if (tag == null) {
|
||||
throw new ElementException("'tag' attribute is not set on: " + getElementClass().getId());
|
||||
}
|
||||
String namespaceUri = getAttributes().get("uri");
|
||||
if (namespaceUri==null) {
|
||||
if (namespaceUri == null) {
|
||||
namespaceUri = getParent().getParent().getAttributes().get("uri"); // copy uri from namespace element.
|
||||
}
|
||||
if (getParent().getElementObject() instanceof ElementClassBase) {
|
||||
((ElementClassBase)getParent().getElementObject()).addElementParent(namespaceUri,tag);
|
||||
((ElementClassBase) getParent().getElementObject()).addElementParent(namespaceUri, tag);
|
||||
} else {
|
||||
throw new ElementException("Wrong parent class is not ElementClassBase but: "+getParent().getElementObject());
|
||||
throw new ElementException("Wrong parent class is not ElementClassBase but: " + getParent().getElementObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.eld.lang;
|
||||
package org.x4o.xml.eld.lang;
|
||||
|
||||
import org.x4o.xml.conv.ObjectConverter;
|
||||
import org.x4o.xml.element.AbstractElementBindingHandler;
|
||||
|
|
@ -36,11 +36,8 @@ import org.x4o.xml.element.ElementClassAttribute;
|
|||
*/
|
||||
public class ElementClassAttributeBindingHandler extends AbstractElementBindingHandler<ElementClassAttribute> {
|
||||
|
||||
|
||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
||||
ObjectConverter.class
|
||||
};
|
||||
|
||||
private final static Class<?>[] CLASSES_CHILD = new Class[] { ObjectConverter.class };
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||
*/
|
||||
|
|
@ -58,16 +55,16 @@ public class ElementClassAttributeBindingHandler extends AbstractElementBindingH
|
|||
/**
|
||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public void bindChild(Element childElement,ElementClassAttribute parentObject,Object childObject) throws ElementBindingHandlerException {
|
||||
if (childObject instanceof ObjectConverter) {
|
||||
parentObject.setObjectConverter((ObjectConverter)childObject);
|
||||
public void bindChild(Element childElement, ElementClassAttribute parentObject, Object childObject) throws ElementBindingHandlerException {
|
||||
if (childObject instanceof ObjectConverter) {
|
||||
parentObject.setObjectConverter((ObjectConverter) childObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||
*/
|
||||
public void createChilderen(Element parentElement,ElementClassAttribute parentObject) throws ElementBindingHandlerException {
|
||||
public void createChilderen(Element parentElement, ElementClassAttribute parentObject) throws ElementBindingHandlerException {
|
||||
createChild(parentElement, parentObject.getObjectConverter());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.eld.lang;
|
||||
package org.x4o.xml.eld.lang;
|
||||
|
||||
import org.x4o.xml.element.AbstractElementBindingHandler;
|
||||
import org.x4o.xml.element.Element;
|
||||
|
|
@ -30,19 +30,15 @@ import org.x4o.xml.element.ElementClassAttribute;
|
|||
import org.x4o.xml.element.ElementConfigurator;
|
||||
|
||||
/**
|
||||
* This ElementBindingHandler adds the ElementClassAttributeConverter and the
|
||||
* ElementConfigurator to the ElementClass.
|
||||
* This ElementBindingHandler adds the ElementClassAttributeConverter and the ElementConfigurator to the ElementClass.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 31, 2007
|
||||
*/
|
||||
public class ElementClassBindingHandler extends AbstractElementBindingHandler<ElementClass> {
|
||||
|
||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
||||
ElementClassAttribute.class,
|
||||
ElementConfigurator.class
|
||||
};
|
||||
|
||||
private final static Class<?>[] CLASSES_CHILD = new Class[] { ElementClassAttribute.class, ElementConfigurator.class };
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||
*/
|
||||
|
|
@ -60,23 +56,23 @@ public class ElementClassBindingHandler extends AbstractElementBindingHandler<El
|
|||
/**
|
||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public void bindChild(Element childElement,ElementClass parent, Object childObject) throws ElementBindingHandlerException {
|
||||
public void bindChild(Element childElement, ElementClass parent, Object childObject) throws ElementBindingHandlerException {
|
||||
if (childObject instanceof ElementClassAttribute) {
|
||||
parent.addElementClassAttribute((ElementClassAttribute)childObject);
|
||||
parent.addElementClassAttribute((ElementClassAttribute) childObject);
|
||||
}
|
||||
if (childObject instanceof ElementConfigurator) {
|
||||
parent.addElementConfigurators((ElementConfigurator)childObject);
|
||||
if (childObject instanceof ElementConfigurator) {
|
||||
parent.addElementConfigurators((ElementConfigurator) childObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||
*/
|
||||
public void createChilderen(Element parentElement,ElementClass parent) throws ElementBindingHandlerException {
|
||||
for (ElementClassAttribute child:parent.getElementClassAttributes()) {
|
||||
public void createChilderen(Element parentElement, ElementClass parent) throws ElementBindingHandlerException {
|
||||
for (ElementClassAttribute child : parent.getElementClassAttributes()) {
|
||||
createChild(parentElement, child);
|
||||
}
|
||||
for (ElementConfigurator child:parent.getElementConfigurators()) {
|
||||
for (ElementConfigurator child : parent.getElementConfigurators()) {
|
||||
createChild(parentElement, child);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.eld.lang;
|
||||
package org.x4o.xml.eld.lang;
|
||||
|
||||
import org.x4o.xml.element.AbstractElementBindingHandler;
|
||||
import org.x4o.xml.element.Element;
|
||||
|
|
@ -36,12 +36,9 @@ import org.x4o.xml.element.ElementInterface;
|
|||
* @version 1.0 Aug 21, 2012
|
||||
*/
|
||||
public class ElementInterfaceBindingHandler extends AbstractElementBindingHandler<ElementInterface> {
|
||||
|
||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
||||
ElementClassAttribute.class,
|
||||
ElementConfigurator.class
|
||||
};
|
||||
|
||||
|
||||
private final static Class<?>[] CLASSES_CHILD = new Class[] { ElementClassAttribute.class, ElementConfigurator.class };
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||
*/
|
||||
|
|
@ -59,23 +56,23 @@ public class ElementInterfaceBindingHandler extends AbstractElementBindingHandle
|
|||
/**
|
||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public void bindChild(Element childElement,ElementInterface parent, Object childObject) throws ElementBindingHandlerException {
|
||||
public void bindChild(Element childElement, ElementInterface parent, Object childObject) throws ElementBindingHandlerException {
|
||||
if (childObject instanceof ElementClassAttribute) {
|
||||
parent.addElementClassAttribute((ElementClassAttribute)childObject);
|
||||
parent.addElementClassAttribute((ElementClassAttribute) childObject);
|
||||
}
|
||||
if (childObject instanceof ElementConfigurator) {
|
||||
parent.addElementConfigurators((ElementConfigurator)childObject);
|
||||
if (childObject instanceof ElementConfigurator) {
|
||||
parent.addElementConfigurators((ElementConfigurator) childObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||
*/
|
||||
public void createChilderen(Element parentElement,ElementInterface parent) throws ElementBindingHandlerException {
|
||||
for (ElementClassAttribute child:parent.getElementClassAttributes()) {
|
||||
public void createChilderen(Element parentElement, ElementInterface parent) throws ElementBindingHandlerException {
|
||||
for (ElementClassAttribute child : parent.getElementClassAttributes()) {
|
||||
createChild(parentElement, child);
|
||||
}
|
||||
for (ElementConfigurator child:parent.getElementConfigurators()) {
|
||||
for (ElementConfigurator child : parent.getElementConfigurators()) {
|
||||
createChild(parentElement, child);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.eld.lang;
|
||||
package org.x4o.xml.eld.lang;
|
||||
|
||||
import org.x4o.xml.eld.EldModuleLoader;
|
||||
import org.x4o.xml.element.AbstractElementBindingHandler;
|
||||
|
|
@ -44,16 +44,11 @@ import org.x4o.xml.lang.X4OLanguageModuleLocal;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 19, 2007
|
||||
*/
|
||||
public class ElementModuleBindingHandler extends AbstractElementBindingHandler<X4OLanguageModuleLocal> {
|
||||
|
||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
||||
ElementInterface.class,
|
||||
ElementNamespace.class,
|
||||
ElementBindingHandler.class,
|
||||
ElementConfiguratorGlobal.class,
|
||||
};
|
||||
|
||||
|
||||
public class ElementModuleBindingHandler extends AbstractElementBindingHandler<X4OLanguageModuleLocal> {
|
||||
|
||||
private final static Class<?>[] CLASSES_CHILD = new Class[] { ElementInterface.class, ElementNamespace.class, ElementBindingHandler.class,
|
||||
ElementConfiguratorGlobal.class, };
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||
*/
|
||||
|
|
@ -71,105 +66,101 @@ public class ElementModuleBindingHandler extends AbstractElementBindingHandler<
|
|||
/**
|
||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public void bindChild(Element childElement,X4OLanguageModuleLocal languageModule, Object childObject) throws ElementBindingHandlerException {
|
||||
|
||||
public void bindChild(Element childElement, X4OLanguageModuleLocal languageModule, Object childObject) throws ElementBindingHandlerException {
|
||||
|
||||
X4OLanguage x4oParsingContext = EldModuleLoader.getLanguage(childElement.getLanguageSession());
|
||||
if (x4oParsingContext==null) {
|
||||
if (x4oParsingContext == null) {
|
||||
return;
|
||||
}
|
||||
if (languageModule==null) {
|
||||
if (languageModule == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (childObject instanceof ElementInterface) {
|
||||
ElementInterface elementInterface = (ElementInterface)childObject;
|
||||
ElementInterface elementInterface = (ElementInterface) childObject;
|
||||
languageModule.addElementInterface(elementInterface);
|
||||
return;
|
||||
}
|
||||
if (childObject instanceof ElementNamespace) {
|
||||
ElementNamespace elementNamespace = (ElementNamespace)childObject;
|
||||
|
||||
if (elementNamespace.getId()==null) {
|
||||
ElementNamespace elementNamespace = (ElementNamespace) childObject;
|
||||
|
||||
if (elementNamespace.getId() == null) {
|
||||
throw new NullPointerException("Can add elementNamespace without id.");
|
||||
}
|
||||
// TODO: no language here so move to EL default on eld attribute tag
|
||||
if (elementNamespace.getId()!=null) {
|
||||
if (elementNamespace.getId() != null) {
|
||||
StringBuilder buf = new StringBuilder(30);
|
||||
for (char c:elementNamespace.getId().toLowerCase().toCharArray()) {
|
||||
if (Character.isLetter(c)) {buf.append(c);}
|
||||
if (Character.isDigit(c)) {buf.append(c);}
|
||||
if ('-'==c) {buf.append(c);}
|
||||
for (char c : elementNamespace.getId().toLowerCase().toCharArray()) {
|
||||
if (Character.isLetter(c)) {
|
||||
buf.append(c);
|
||||
}
|
||||
if (Character.isDigit(c)) {
|
||||
buf.append(c);
|
||||
}
|
||||
if ('-' == c) {
|
||||
buf.append(c);
|
||||
}
|
||||
}
|
||||
String id = buf.toString();
|
||||
elementNamespace.setId(id);
|
||||
}
|
||||
if (elementNamespace.getUri()==null) {
|
||||
if (elementNamespace.getUri() == null) {
|
||||
elementNamespace.setUri(
|
||||
"http://"+languageModule.getProviderHost()+
|
||||
"/xml/ns/"+x4oParsingContext.getLanguageName()+
|
||||
"-"+elementNamespace.getId());
|
||||
"http://" + languageModule.getProviderHost() + "/xml/ns/" + x4oParsingContext.getLanguageName() + "-" + elementNamespace.getId());
|
||||
}
|
||||
if (elementNamespace.getSchemaUri()==null) {
|
||||
elementNamespace.setSchemaUri(
|
||||
"http://"+languageModule.getProviderHost()+
|
||||
"/xml/ns/"+x4oParsingContext.getLanguageName()+
|
||||
"-"+elementNamespace.getId()+
|
||||
"-"+x4oParsingContext.getLanguageVersion()+
|
||||
".xsd"
|
||||
);
|
||||
if (elementNamespace.getSchemaUri() == null) {
|
||||
elementNamespace.setSchemaUri("http://" + languageModule.getProviderHost() + "/xml/ns/" + x4oParsingContext.getLanguageName() + "-"
|
||||
+ elementNamespace.getId() + "-" + x4oParsingContext.getLanguageVersion() + ".xsd");
|
||||
}
|
||||
if (elementNamespace.getSchemaResource()==null) {
|
||||
if (elementNamespace.getSchemaResource() == null) {
|
||||
elementNamespace.setSchemaResource(
|
||||
x4oParsingContext.getLanguageName()+
|
||||
"-"+elementNamespace.getId()+
|
||||
"-"+x4oParsingContext.getLanguageVersion()+
|
||||
".xsd"
|
||||
);
|
||||
x4oParsingContext.getLanguageName() + "-" + elementNamespace.getId() + "-" + x4oParsingContext.getLanguageVersion() + ".xsd");
|
||||
}
|
||||
if (elementNamespace.getSchemaPrefix()==null) {
|
||||
if (elementNamespace.getSchemaPrefix() == null) {
|
||||
elementNamespace.setSchemaPrefix(elementNamespace.getId());
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
elementNamespace.setElementNamespaceInstanceProvider(X4OLanguageClassLoader.newInstance(ElementNamespaceInstanceProvider.class, childElement.getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider()));
|
||||
elementNamespace.setElementNamespaceInstanceProvider(X4OLanguageClassLoader.newInstance(ElementNamespaceInstanceProvider.class,
|
||||
childElement.getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider()));
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new ElementBindingHandlerException("Error loading: "+e.getMessage(),e);
|
||||
throw new ElementBindingHandlerException("Error loading: " + e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
|
||||
|
||||
elementNamespace.getElementNamespaceInstanceProvider().start(x4oParsingContext, elementNamespace);
|
||||
} catch (ElementNamespaceInstanceProviderException e) {
|
||||
throw new ElementBindingHandlerException("Error starting: "+e.getMessage(),e);
|
||||
throw new ElementBindingHandlerException("Error starting: " + e.getMessage(), e);
|
||||
}
|
||||
languageModule.addElementNamespace(elementNamespace);
|
||||
return;
|
||||
}
|
||||
if (childObject instanceof ElementBindingHandler) {
|
||||
ElementBindingHandler elementBindingHandler = (ElementBindingHandler)childObject;
|
||||
ElementBindingHandler elementBindingHandler = (ElementBindingHandler) childObject;
|
||||
languageModule.addElementBindingHandler(elementBindingHandler);
|
||||
return;
|
||||
}
|
||||
if (childObject instanceof ElementConfiguratorGlobal) {
|
||||
ElementConfiguratorGlobal elementConfigurator = (ElementConfiguratorGlobal)childObject;
|
||||
ElementConfiguratorGlobal elementConfigurator = (ElementConfiguratorGlobal) childObject;
|
||||
languageModule.addElementConfiguratorGlobal(elementConfigurator);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||
*/
|
||||
public void createChilderen(Element parentElement,X4OLanguageModuleLocal parent) throws ElementBindingHandlerException {
|
||||
for (ElementInterface child:parent.getElementInterfaces()) {
|
||||
public void createChilderen(Element parentElement, X4OLanguageModuleLocal parent) throws ElementBindingHandlerException {
|
||||
for (ElementInterface child : parent.getElementInterfaces()) {
|
||||
createChild(parentElement, child);
|
||||
}
|
||||
for (ElementNamespace child:parent.getElementNamespaces()) {
|
||||
for (ElementNamespace child : parent.getElementNamespaces()) {
|
||||
createChild(parentElement, child);
|
||||
}
|
||||
for (ElementBindingHandler child:parent.getElementBindingHandlers()) {
|
||||
for (ElementBindingHandler child : parent.getElementBindingHandlers()) {
|
||||
createChild(parentElement, child);
|
||||
}
|
||||
for (ElementConfiguratorGlobal child:parent.getElementConfiguratorGlobals()) {
|
||||
for (ElementConfiguratorGlobal child : parent.getElementConfiguratorGlobals()) {
|
||||
createChild(parentElement, child);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.eld.lang;
|
||||
package org.x4o.xml.eld.lang;
|
||||
|
||||
import org.x4o.xml.element.AbstractElementBindingHandler;
|
||||
import org.x4o.xml.element.Element;
|
||||
|
|
@ -37,11 +37,8 @@ import org.x4o.xml.element.ElementNamespaceAttribute;
|
|||
*/
|
||||
public class ElementNamespaceBindingHandler extends AbstractElementBindingHandler<ElementNamespace> {
|
||||
|
||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
||||
ElementClass.class,
|
||||
ElementNamespaceAttribute.class
|
||||
};
|
||||
|
||||
private final static Class<?>[] CLASSES_CHILD = new Class[] { ElementClass.class, ElementNamespaceAttribute.class };
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||
*/
|
||||
|
|
@ -59,29 +56,29 @@ public class ElementNamespaceBindingHandler extends AbstractElementBindingHandle
|
|||
/**
|
||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public void bindChild(Element childElement,ElementNamespace parent, Object childObject) throws ElementBindingHandlerException {
|
||||
public void bindChild(Element childElement, ElementNamespace parent, Object childObject) throws ElementBindingHandlerException {
|
||||
if (childObject instanceof ElementClass) {
|
||||
ElementClass elementClass = (ElementClass)childObject;
|
||||
if (elementClass.getId()==null && elementClass.getObjectClass()!=null) {
|
||||
ElementClass elementClass = (ElementClass) childObject;
|
||||
if (elementClass.getId() == null && elementClass.getObjectClass() != null) {
|
||||
elementClass.setId(elementClass.getObjectClass().getSimpleName()); // TODO: move to defaults layer
|
||||
}
|
||||
parent.addElementClass(elementClass);
|
||||
}
|
||||
if (childObject instanceof ElementNamespaceAttribute) {
|
||||
ElementNamespaceAttribute elementNamespaceAttribute = (ElementNamespaceAttribute)childObject;
|
||||
ElementNamespaceAttribute elementNamespaceAttribute = (ElementNamespaceAttribute) childObject;
|
||||
parent.addElementNamespaceAttribute(elementNamespaceAttribute);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||
*/
|
||||
public void createChilderen(Element parentElement,ElementNamespace parent) throws ElementBindingHandlerException {
|
||||
for (ElementClass child:parent.getElementClasses()) {
|
||||
public void createChilderen(Element parentElement, ElementNamespace parent) throws ElementBindingHandlerException {
|
||||
for (ElementClass child : parent.getElementClasses()) {
|
||||
createChild(parentElement, child);
|
||||
}
|
||||
for (ElementNamespaceAttribute child:parent.getElementNamespaceAttributes()) {
|
||||
for (ElementNamespaceAttribute child : parent.getElementNamespaceAttributes()) {
|
||||
createChild(parentElement, child);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.eld.lang;
|
||||
package org.x4o.xml.eld.lang;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -46,32 +46,32 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
|||
private String addMethod = null;
|
||||
private String getMethod = null;
|
||||
private String skipChilderenClassRegex = null;
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||
*/
|
||||
public Class<?> getBindParentClass() {
|
||||
return parentClass;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindChildClasses()
|
||||
*/
|
||||
public Class<?>[] getBindChildClasses() {
|
||||
return new Class[] {childClass};
|
||||
return new Class[] { childClass };
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
@SuppressWarnings(value = {"unchecked", "rawtypes"})
|
||||
@SuppressWarnings(value = { "unchecked", "rawtypes" })
|
||||
public void bindChild(Element childElement, Object parentObject, Object childObject) throws ElementBindingHandlerException {
|
||||
if (parentClass==null | childClass==null) {
|
||||
throw new IllegalStateException("Missing property: parentClass="+parentClass+" childClass="+childClass+" addMethod="+addMethod+".");
|
||||
if (parentClass == null | childClass == null) {
|
||||
throw new IllegalStateException("Missing property: parentClass=" + parentClass + " childClass=" + childClass + " addMethod=" + addMethod + ".");
|
||||
}
|
||||
if (property != null) { // Tmp hanky code here...
|
||||
try {
|
||||
String pop = property.substring(0,1).toUpperCase() + property.substring(1);
|
||||
String pop = property.substring(0, 1).toUpperCase() + property.substring(1);
|
||||
Method propType = parentObject.getClass().getMethod("get" + pop);
|
||||
if (List.class.isAssignableFrom(propType.getReturnType())) {
|
||||
Object data = childElement.getLanguageSession().getElementObjectPropertyValue().getProperty(parentObject, property);
|
||||
|
|
@ -81,22 +81,23 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
|||
data = childElement.getLanguageSession().getElementObjectPropertyValue().getProperty(parentObject, property);
|
||||
}
|
||||
if (data instanceof Collection) {
|
||||
Collection dataCollection = (Collection)data;
|
||||
Collection dataCollection = (Collection) data;
|
||||
dataCollection.add(childObject);
|
||||
return;
|
||||
}
|
||||
throw new ElementBindingHandlerException("Unhandled property collection type: "+data.getClass()+" on: "+parentObject.getClass()+" id:"+getId());
|
||||
throw new ElementBindingHandlerException(
|
||||
"Unhandled property collection type: " + data.getClass() + " on: " + parentObject.getClass() + " id:" + getId());
|
||||
}
|
||||
|
||||
|
||||
childElement.getLanguageSession().getElementObjectPropertyValue().setProperty(parentObject, property, childObject);
|
||||
return;
|
||||
} catch (/*ElementObjectPropertyValueException |*/ Exception e) {
|
||||
} catch (/* ElementObjectPropertyValueException | */ Exception e) {
|
||||
throw new ElementBindingHandlerException(getId() + " error " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
// TODO: remove old...
|
||||
Method[] ms = parentObject.getClass().getMethods();
|
||||
for (Method m:ms) {
|
||||
for (Method m : ms) {
|
||||
Class<?>[] types = m.getParameterTypes();
|
||||
if (types.length == 0) {
|
||||
continue;
|
||||
|
|
@ -104,28 +105,28 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
|||
if (types.length > 1) {
|
||||
continue;
|
||||
}
|
||||
if (addMethod.equalsIgnoreCase(m.getName())==false) {
|
||||
if (addMethod.equalsIgnoreCase(m.getName()) == false) {
|
||||
continue;
|
||||
}
|
||||
if (types[0].isAssignableFrom(childClass)) {
|
||||
try {
|
||||
m.invoke(parentObject, childObject);
|
||||
} catch (Exception e) {
|
||||
throw new ElementBindingHandlerException("Error invoke binding method of: "+getId()+" error: "+e.getMessage(),e);
|
||||
throw new ElementBindingHandlerException("Error invoke binding method of: " + getId() + " error: " + e.getMessage(), e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new ElementBindingHandlerException("Could not find method: "+addMethod+" on: "+parentObject.getClass()+" id:"+getId());
|
||||
throw new ElementBindingHandlerException("Could not find method: " + addMethod + " on: " + parentObject.getClass() + " id:" + getId());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||
*/
|
||||
|
||||
public void createChilderen(Element parentElement,Object parentObject) throws ElementBindingHandlerException {
|
||||
if (parentClass==null | childClass==null) {
|
||||
throw new IllegalStateException("Missing property: parentClass="+parentClass+" childClass="+childClass+" getMethod="+getMethod+".");
|
||||
|
||||
public void createChilderen(Element parentElement, Object parentObject) throws ElementBindingHandlerException {
|
||||
if (parentClass == null | childClass == null) {
|
||||
throw new IllegalStateException("Missing property: parentClass=" + parentClass + " childClass=" + childClass + " getMethod=" + getMethod + ".");
|
||||
}
|
||||
if (property != null) {
|
||||
try {
|
||||
|
|
@ -137,43 +138,44 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
|||
return;
|
||||
}
|
||||
Method[] ms = parentObject.getClass().getMethods();
|
||||
for (Method m:ms) {
|
||||
for (Method m : ms) {
|
||||
Class<?>[] types = m.getParameterTypes();
|
||||
if (types.length != 0) {
|
||||
continue;
|
||||
}
|
||||
if (getMethod.equalsIgnoreCase(m.getName())==false) {
|
||||
if (getMethod.equalsIgnoreCase(m.getName()) == false) {
|
||||
continue;
|
||||
}
|
||||
Object result;
|
||||
try {
|
||||
result = m.invoke(parentObject, new Object[]{});
|
||||
result = m.invoke(parentObject, new Object[] {});
|
||||
} catch (Exception e) {
|
||||
throw new ElementBindingHandlerException("Invoke error: "+e.getMessage()+" from: "+getMethod+" on: "+parentObject+" id:"+getId(),e);
|
||||
}
|
||||
throw new ElementBindingHandlerException("Invoke error: " + e.getMessage() + " from: " + getMethod + " on: " + parentObject + " id:" + getId(),
|
||||
e);
|
||||
}
|
||||
createSafeChildLoop(parentElement, result);
|
||||
return;
|
||||
}
|
||||
throw new ElementBindingHandlerException("Could not find method: "+getMethod+" on: "+parentObject.getClass()+" id:"+getId());
|
||||
throw new ElementBindingHandlerException("Could not find method: " + getMethod + " on: " + parentObject.getClass() + " id:" + getId());
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected void createSafeChildLoop(Element parentElement,Object result) throws ElementBindingHandlerException {
|
||||
if (result==null) {
|
||||
protected void createSafeChildLoop(Element parentElement, Object result) throws ElementBindingHandlerException {
|
||||
if (result == null) {
|
||||
return; // null is no childeren
|
||||
}
|
||||
if (result instanceof List) {
|
||||
for (Object o:(List)result) {
|
||||
for (Object o : (List) result) {
|
||||
createSafeChild(parentElement, o);
|
||||
}
|
||||
return;
|
||||
} else if (result instanceof Collection) {
|
||||
for (Object o:(Collection)result) {
|
||||
for (Object o : (Collection) result) {
|
||||
createSafeChild(parentElement, o);
|
||||
}
|
||||
return;
|
||||
} else if (result.getClass().isArray()) {
|
||||
for (Object o:(Object[])result) {
|
||||
for (Object o : (Object[]) result) {
|
||||
createSafeChild(parentElement, o);
|
||||
}
|
||||
return;
|
||||
|
|
@ -181,102 +183,104 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
|||
createSafeChild(parentElement, result);
|
||||
return;
|
||||
} else {
|
||||
throw new ElementBindingHandlerException("Unsupported return type: "+result.getClass()+" need: "+childClass+" from: "+getMethod+" on: "+parentElement.getElementObject().getClass()+" id:"+getId());
|
||||
throw new ElementBindingHandlerException("Unsupported return type: " + result.getClass() + " need: " + childClass + " from: " + getMethod + " on: "
|
||||
+ parentElement.getElementObject().getClass() + " id:" + getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Only create child when class matches and regex doesn't exclude it.
|
||||
* @param parentElement The element to create childeren for.
|
||||
* @param childObject The childObject.
|
||||
*
|
||||
* @param parentElement The element to create childeren for.
|
||||
* @param childObject The childObject.
|
||||
*/
|
||||
protected void createSafeChild(Element parentElement,Object childObject) {
|
||||
if (childClass.isAssignableFrom(childObject.getClass())==false) {
|
||||
protected void createSafeChild(Element parentElement, Object childObject) {
|
||||
if (childClass.isAssignableFrom(childObject.getClass()) == false) {
|
||||
return;
|
||||
}
|
||||
if (skipChilderenClassRegex!=null && childObject.getClass().getName().matches(skipChilderenClassRegex)) {
|
||||
if (skipChilderenClassRegex != null && childObject.getClass().getName().matches(skipChilderenClassRegex)) {
|
||||
return; // skip
|
||||
}
|
||||
createChild(parentElement,childObject);
|
||||
createChild(parentElement, childObject);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the parentClass
|
||||
*/
|
||||
public Class<?> getParentClass() {
|
||||
return parentClass;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param parentClass the parentClass to set
|
||||
*/
|
||||
public void setParentClass(Class<?> parentClass) {
|
||||
this.parentClass = parentClass;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the childClass
|
||||
*/
|
||||
public Class<?> getChildClass() {
|
||||
return childClass;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param childClass the childClass to set
|
||||
*/
|
||||
public void setChildClass(Class<?> childClass) {
|
||||
this.childClass = childClass;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the addMethod
|
||||
*/
|
||||
public String getAddMethod() {
|
||||
return addMethod;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param addMethod the addMethod to set
|
||||
*/
|
||||
public void setAddMethod(String addMethod) {
|
||||
this.addMethod = addMethod;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the getMethod
|
||||
*/
|
||||
public String getGetMethod() {
|
||||
return getMethod;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param getMethod the getMethod to set
|
||||
*/
|
||||
public void setGetMethod(String getMethod) {
|
||||
this.getMethod = getMethod;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the property
|
||||
*/
|
||||
public String getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param property the property to set
|
||||
*/
|
||||
public void setProperty(String property) {
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the skipChilderenClassRegex
|
||||
*/
|
||||
public String getSkipChilderenClassRegex() {
|
||||
return skipChilderenClassRegex;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param skipChilderenClassRegex the skipChilderenClassRegex to set
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -35,14 +35,14 @@ import org.x4o.xml.lang.X4OLanguageModule;
|
|||
* @version 1.0 Aug 20, 2012
|
||||
*/
|
||||
public class ModuleElement extends AbstractElement {
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.AbstractElement#doElementStart()
|
||||
* @throws ElementException When module element is used and non-root element.
|
||||
*/
|
||||
@Override
|
||||
public void doElementStart() throws ElementException {
|
||||
if (getParent()!=null) {
|
||||
if (getParent() != null) {
|
||||
throw new ElementException("Need to be root tag");
|
||||
}
|
||||
X4OLanguageModule elementLanguageModule = EldModuleLoader.getLanguageModule(getLanguageSession());
|
||||
|
|
|
|||
|
|
@ -38,14 +38,14 @@ public class NextAttributeElement extends AbstractElement {
|
|||
@Override
|
||||
public void doElementRun() throws ElementException {
|
||||
String param = getAttributes().get("attributeName");
|
||||
if (param==null) {
|
||||
if (param == null) {
|
||||
throw new ElementException("attributeName may not be null");
|
||||
}
|
||||
if (getParent()==null) {
|
||||
if (getParent() == null) {
|
||||
throw new ElementException("can't be a root tag");
|
||||
}
|
||||
if (getParent().getElementObject() instanceof ElementNamespaceAttribute) {
|
||||
((ElementNamespaceAttribute)getParent().getElementObject()).addNextAttribute(param);
|
||||
((ElementNamespaceAttribute) getParent().getElementObject()).addNextAttribute(param);
|
||||
} else {
|
||||
throw new ElementException("Wrong parent class");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,13 +41,13 @@ public class SkipPhaseElement extends AbstractElement {
|
|||
@Override
|
||||
public void doElementEnd() throws ElementException {
|
||||
String phase = getAttributes().get("name");
|
||||
if (phase==null) {
|
||||
throw new ElementException("'name' attribute is not set on: "+getElementClass().getId());
|
||||
if (phase == null) {
|
||||
throw new ElementException("'name' attribute is not set on: " + getElementClass().getId());
|
||||
}
|
||||
if (getParent().getElementObject() instanceof ElementClass) {
|
||||
((ElementClass)getParent().getElementObject()).addSkipPhase(phase);
|
||||
((ElementClass) getParent().getElementObject()).addSkipPhase(phase);
|
||||
} else {
|
||||
throw new ElementException("Wrong parent class is not ElementClassAttribute but: "+getParent().getElementObject());
|
||||
throw new ElementException("Wrong parent class is not ElementClassAttribute but: " + getParent().getElementObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.eld.lang;
|
||||
package org.x4o.xml.eld.lang;
|
||||
|
||||
import org.x4o.xml.conv.text.StringSplitConverter;
|
||||
import org.x4o.xml.conv.text.StringSplitConverterStep;
|
||||
|
|
@ -36,11 +36,8 @@ import org.x4o.xml.element.ElementBindingHandlerException;
|
|||
*/
|
||||
public class StringSplitConverterBindingHandler extends AbstractElementBindingHandler<StringSplitConverter> {
|
||||
|
||||
|
||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
||||
StringSplitConverterStep.class
|
||||
};
|
||||
|
||||
private final static Class<?>[] CLASSES_CHILD = new Class[] { StringSplitConverterStep.class };
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||
*/
|
||||
|
|
@ -58,9 +55,9 @@ public class StringSplitConverterBindingHandler extends AbstractElementBindingHa
|
|||
/**
|
||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public void bindChild(Element childElement,StringSplitConverter parent, Object childObject) throws ElementBindingHandlerException {
|
||||
if (childObject instanceof StringSplitConverterStep) {
|
||||
parent.addStringSplitConverterStep((StringSplitConverterStep)childObject);
|
||||
public void bindChild(Element childElement, StringSplitConverter parent, Object childObject) throws ElementBindingHandlerException {
|
||||
if (childObject instanceof StringSplitConverterStep) {
|
||||
parent.addStringSplitConverterStep((StringSplitConverterStep) childObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -68,8 +65,8 @@ public class StringSplitConverterBindingHandler extends AbstractElementBindingHa
|
|||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void createChilderen(Element parentElement,StringSplitConverter parentObject) throws ElementBindingHandlerException {
|
||||
for (StringSplitConverterStep child:parentObject.getStringSplitConverterSteps()) {
|
||||
public void createChilderen(Element parentElement, StringSplitConverter parentObject) throws ElementBindingHandlerException {
|
||||
for (StringSplitConverterStep child : parentObject.getStringSplitConverterSteps()) {
|
||||
createChild(parentElement, child);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.eld.lang;
|
||||
package org.x4o.xml.eld.lang;
|
||||
|
||||
import org.x4o.xml.conv.ObjectConverter;
|
||||
import org.x4o.xml.conv.text.StringSplitConverterStep;
|
||||
|
|
@ -36,11 +36,8 @@ import org.x4o.xml.element.ElementBindingHandlerException;
|
|||
*/
|
||||
public class StringSplitConverterStepBindingHandler extends AbstractElementBindingHandler<StringSplitConverterStep> {
|
||||
|
||||
|
||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
||||
ObjectConverter.class
|
||||
};
|
||||
|
||||
private final static Class<?>[] CLASSES_CHILD = new Class[] { ObjectConverter.class };
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||
*/
|
||||
|
|
@ -58,17 +55,17 @@ public class StringSplitConverterStepBindingHandler extends AbstractElementBindi
|
|||
/**
|
||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public void bindChild(Element childElement,StringSplitConverterStep parent, Object childObject) throws ElementBindingHandlerException {
|
||||
if (childObject instanceof ObjectConverter) {
|
||||
parent.setObjectConverter((ObjectConverter)childObject);
|
||||
public void bindChild(Element childElement, StringSplitConverterStep parent, Object childObject) throws ElementBindingHandlerException {
|
||||
if (childObject instanceof ObjectConverter) {
|
||||
parent.setObjectConverter((ObjectConverter) childObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void createChilderen(Element parentElement,StringSplitConverterStep parentObject) throws ElementBindingHandlerException {
|
||||
public void createChilderen(Element parentElement, StringSplitConverterStep parentObject) throws ElementBindingHandlerException {
|
||||
createChild(parentElement, parentObject.getObjectConverter());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,15 +38,15 @@ import org.xml.sax.SAXException;
|
|||
* @version 1.0 Aug 22, 2012
|
||||
*/
|
||||
public class EldXsdLanguageTask extends AbstractX4OLanguageTask {
|
||||
|
||||
public static final String TASK_ID = "eld-xsd";
|
||||
|
||||
public static final String TASK_ID = "eld-xsd";
|
||||
private static final String TASK_NAME = "ELD XSD Writer Task";
|
||||
private static final String TASK_DESC = "Writes out the schema of the language elements.";
|
||||
|
||||
|
||||
public EldXsdLanguageTask() {
|
||||
super(TASK_ID,TASK_NAME,TASK_DESC,EldXsdWriter.DEFAULT_PROPERTY_CONFIG);
|
||||
super(TASK_ID, TASK_NAME, TASK_DESC, EldXsdWriter.DEFAULT_PROPERTY_CONFIG);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Executes this language task.
|
||||
*/
|
||||
|
|
@ -54,11 +54,11 @@ public class EldXsdLanguageTask extends AbstractX4OLanguageTask {
|
|||
return new X4OLanguageTaskExecutor() {
|
||||
public void execute(X4OLanguage language) throws X4OLanguageTaskException {
|
||||
try {
|
||||
new EldXsdWriter(language,config).writeSchema();
|
||||
new EldXsdWriter(language, config).writeSchema();
|
||||
} catch (SAXException e) {
|
||||
throw new X4OLanguageTaskException(config,e.getMessage(),e);
|
||||
throw new X4OLanguageTaskException(config, e.getMessage(), e);
|
||||
} catch (IOException e) {
|
||||
throw new X4OLanguageTaskException(config,e.getMessage(),e);
|
||||
throw new X4OLanguageTaskException(config, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -39,16 +39,17 @@ import org.x4o.xml.lang.X4OLanguage;
|
|||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* EldXsdWriter creates XML Schema files from a x4o language.
|
||||
* EldXsdWriter creates XML Schema files from a x4o language.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 8, 2012
|
||||
*/
|
||||
public class EldXsdWriter {
|
||||
|
||||
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"eld-xsd/";
|
||||
|
||||
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX + "eld-xsd/";
|
||||
public final static SAX3PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
||||
|
||||
|
||||
//@formatter:off
|
||||
public final static String OUTPUT_PATH = PROPERTY_CONTEXT_PREFIX+"output/path";
|
||||
public final static String OUTPUT_DOCUMENTATION = PROPERTY_CONTEXT_PREFIX+"output/documentation";
|
||||
public final static String FILTER_NAMESPACE = PROPERTY_CONTEXT_PREFIX+"filter/namespace";
|
||||
|
|
@ -78,59 +79,60 @@ public class EldXsdWriter {
|
|||
new PropertyConfigItem(PROLOG_XMLNS_DESC_ENABLE, Boolean.class, true)
|
||||
);
|
||||
}
|
||||
|
||||
//@formatter:on
|
||||
|
||||
private final X4OLanguage language;
|
||||
private final SAX3PropertyConfig propertyConfig;
|
||||
|
||||
public EldXsdWriter(X4OLanguage language,SAX3PropertyConfig parentConfig) {
|
||||
this.language=language;
|
||||
this.propertyConfig=new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG,PROPERTY_CONTEXT_PREFIX);
|
||||
|
||||
public EldXsdWriter(X4OLanguage language, SAX3PropertyConfig parentConfig) {
|
||||
this.language = language;
|
||||
this.propertyConfig = new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG, PROPERTY_CONTEXT_PREFIX);
|
||||
this.propertyConfig.copyParentProperties(parentConfig);
|
||||
}
|
||||
|
||||
|
||||
private void checkNamespace(ElementNamespace ns) {
|
||||
if (ns.getSchemaResource()==null) {
|
||||
throw new NullPointerException("Can't generate xsd for namespace without schemaResource uri: "+ns.getUri());
|
||||
if (ns.getSchemaResource() == null) {
|
||||
throw new NullPointerException("Can't generate xsd for namespace without schemaResource uri: " + ns.getUri());
|
||||
}
|
||||
if (ns.getSchemaResource().length()==0) {
|
||||
throw new NullPointerException("Can't generate xsd for namespace with empty schemaResource uri: "+ns.getUri());
|
||||
if (ns.getSchemaResource().length() == 0) {
|
||||
throw new NullPointerException("Can't generate xsd for namespace with empty schemaResource uri: " + ns.getUri());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void writeSchema() throws SAXException, IOException {
|
||||
File basePath = propertyConfig.getPropertyFile(OUTPUT_PATH);
|
||||
String encoding = propertyConfig.getPropertyString(SAX3WriterXml.OUTPUT_ENCODING);
|
||||
String namespace = propertyConfig.getPropertyString(FILTER_NAMESPACE);
|
||||
if (basePath==null) {
|
||||
if (basePath == null) {
|
||||
throw new NullPointerException("Can't write schema to null output path.");
|
||||
}
|
||||
if (!basePath.exists()) {
|
||||
basePath.mkdirs();
|
||||
}
|
||||
if (namespace!=null) {
|
||||
if (namespace != null) {
|
||||
ElementNamespace ns = language.findElementNamespace(namespace);
|
||||
if (ns==null) {
|
||||
throw new NullPointerException("Could not find namespace: "+namespace);
|
||||
if (ns == null) {
|
||||
throw new NullPointerException("Could not find namespace: " + namespace);
|
||||
}
|
||||
checkNamespace(ns);
|
||||
File outputFile = new File(basePath.getAbsolutePath()+File.separatorChar+ns.getSchemaResource());
|
||||
File outputFile = new File(basePath.getAbsolutePath() + File.separatorChar + ns.getSchemaResource());
|
||||
Writer wr = new OutputStreamWriter(new FileOutputStream(outputFile), encoding);
|
||||
try {
|
||||
SAX3WriterXsd xsdWriter = new SAX3WriterXsd(wr,encoding);
|
||||
SAX3WriterXsd xsdWriter = new SAX3WriterXsd(wr, encoding);
|
||||
xsdWriter.getPropertyConfig().copyParentProperties(propertyConfig);
|
||||
generateSchema(ns.getUri(), xsdWriter);
|
||||
} finally {
|
||||
wr.close();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
||||
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||
checkNamespace(ns);
|
||||
File outputFile = new File(basePath.getAbsolutePath()+File.separatorChar+ns.getSchemaResource());
|
||||
File outputFile = new File(basePath.getAbsolutePath() + File.separatorChar + ns.getSchemaResource());
|
||||
Writer wr = new OutputStreamWriter(new FileOutputStream(outputFile), encoding);
|
||||
try {
|
||||
SAX3WriterXsd xsdWriter = new SAX3WriterXsd(wr,encoding);
|
||||
SAX3WriterXsd xsdWriter = new SAX3WriterXsd(wr, encoding);
|
||||
xsdWriter.getPropertyConfig().copyParentProperties(propertyConfig);
|
||||
generateSchema(ns.getUri(), xsdWriter);
|
||||
} finally {
|
||||
|
|
@ -139,27 +141,27 @@ public class EldXsdWriter {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void generateSchema(String namespaceUri,SAX3WriterXsd xsdWriter) throws IOException {
|
||||
|
||||
private void generateSchema(String namespaceUri, SAX3WriterXsd xsdWriter) throws IOException {
|
||||
ElementNamespace ns = language.findElementNamespace(namespaceUri);
|
||||
if (ns==null) {
|
||||
throw new NullPointerException("Could not find namespace: "+namespaceUri);
|
||||
if (ns == null) {
|
||||
throw new NullPointerException("Could not find namespace: " + namespaceUri);
|
||||
}
|
||||
String filterElement = propertyConfig.getPropertyString(FILTER_ELEMENT);
|
||||
EldXsdWriterElement xsdWriterElement = new EldXsdWriterElement(xsdWriter,language,propertyConfig);
|
||||
EldXsdWriterElement xsdWriterElement = new EldXsdWriterElement(xsdWriter, language, propertyConfig);
|
||||
xsdWriterElement.startNamespaces(namespaceUri);
|
||||
xsdWriterElement.startSchema(ns);
|
||||
for (ElementClass ec:ns.getElementClasses()) {
|
||||
if (filterElement!=null && !ec.getId().equals(filterElement)) {
|
||||
for (ElementClass ec : ns.getElementClasses()) {
|
||||
if (filterElement != null && !ec.getId().equals(filterElement)) {
|
||||
continue;
|
||||
}
|
||||
xsdWriterElement.writeElementClass(ec,ns);
|
||||
xsdWriterElement.writeElementClass(ec, ns);
|
||||
}
|
||||
for (ElementClass ec:ns.getElementClasses()) {
|
||||
if (filterElement!=null && !ec.getId().equals(filterElement)) {
|
||||
for (ElementClass ec : ns.getElementClasses()) {
|
||||
if (filterElement != null && !ec.getId().equals(filterElement)) {
|
||||
continue;
|
||||
}
|
||||
xsdWriterElement.writeElement(ec,ns);
|
||||
xsdWriterElement.writeElement(ec, ns);
|
||||
}
|
||||
xsdWriterElement.endSchema();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.eld.xsd;
|
||||
package org.x4o.xml.eld.xsd;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
|
@ -59,35 +59,35 @@ import org.xml.sax.helpers.AttributesImpl;
|
|||
* @version 1.0 Aug 8, 2012
|
||||
*/
|
||||
public class EldXsdWriterElement {
|
||||
|
||||
|
||||
private SAX3PropertyConfig propertyConfig;
|
||||
protected X4OLanguage language = null;
|
||||
protected SAX3WriterXsd xsdWriter = null;
|
||||
protected String writeNamespace = null;
|
||||
protected Map<String, String> namespaces = null;
|
||||
|
||||
public EldXsdWriterElement(SAX3WriterXsd xsdWriter,X4OLanguage language,SAX3PropertyConfig propertyConfig) {
|
||||
this.xsdWriter=xsdWriter;
|
||||
this.language=language;
|
||||
this.propertyConfig=propertyConfig;
|
||||
this.namespaces=new HashMap<String,String>(10);
|
||||
|
||||
public EldXsdWriterElement(SAX3WriterXsd xsdWriter, X4OLanguage language, SAX3PropertyConfig propertyConfig) {
|
||||
this.xsdWriter = xsdWriter;
|
||||
this.language = language;
|
||||
this.propertyConfig = propertyConfig;
|
||||
this.namespaces = new HashMap<String, String>(10);
|
||||
}
|
||||
|
||||
private void startNamespace(String uri,String prefixNamespace) {
|
||||
|
||||
private void startNamespace(String uri, String prefixNamespace) {
|
||||
String prefix = namespaces.get(uri);
|
||||
if (prefix!=null) {
|
||||
if (prefix != null) {
|
||||
return;
|
||||
}
|
||||
if (uri.equals(writeNamespace)) {
|
||||
namespaces.put(uri, "this");
|
||||
return;
|
||||
}
|
||||
if (prefixNamespace!=null) {
|
||||
if (prefixNamespace != null) {
|
||||
namespaces.put(uri, prefixNamespace); // let user define it
|
||||
return;
|
||||
}
|
||||
StringBuilder buf = new StringBuilder(20);
|
||||
for (char c:uri.toLowerCase().toCharArray()) {
|
||||
for (char c : uri.toLowerCase().toCharArray()) {
|
||||
if (Character.isLetter(c)) {
|
||||
buf.append(c);
|
||||
}
|
||||
|
|
@ -107,37 +107,37 @@ public class EldXsdWriterElement {
|
|||
}
|
||||
namespaces.put(uri, prefix);
|
||||
}
|
||||
|
||||
|
||||
public void startNamespaces(String namespaceUri) {
|
||||
|
||||
this.writeNamespace=namespaceUri;
|
||||
|
||||
this.writeNamespace = namespaceUri;
|
||||
this.namespaces.clear();
|
||||
|
||||
|
||||
// redo this mess, add nice find for binding handlers
|
||||
for (X4OLanguageModule modContext:language.getLanguageModules()) {
|
||||
for (ElementNamespace nsContext:modContext.getElementNamespaces()) {
|
||||
for (ElementClass ec:nsContext.getElementClasses()) {
|
||||
for (X4OLanguageModule modContext : language.getLanguageModules()) {
|
||||
for (ElementNamespace nsContext : modContext.getElementNamespaces()) {
|
||||
for (ElementClass ec : nsContext.getElementClasses()) {
|
||||
Class<?> objectClass = null;
|
||||
if (ec.getObjectClass()!=null) {
|
||||
if (ec.getObjectClass() != null) {
|
||||
objectClass = ec.getObjectClass();
|
||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
||||
for (ElementClass checkClass:ns.getElementClasses()) {
|
||||
if (checkClass.getObjectClass()==null) {
|
||||
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||
for (ElementClass checkClass : ns.getElementClasses()) {
|
||||
if (checkClass.getObjectClass() == null) {
|
||||
continue;
|
||||
}
|
||||
Class<?> checkObjectClass = checkClass.getObjectClass();
|
||||
List<ElementBindingHandler> b = language.findElementBindingHandlers(objectClass,checkObjectClass);
|
||||
if (b.isEmpty()==false) {
|
||||
startNamespace(ns.getUri(),ns.getSchemaPrefix());
|
||||
List<ElementBindingHandler> b = language.findElementBindingHandlers(objectClass, checkObjectClass);
|
||||
if (b.isEmpty() == false) {
|
||||
startNamespace(ns.getUri(), ns.getSchemaPrefix());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ElementInterface ei:language.findElementInterfaces(objectClass)) {
|
||||
for (ElementInterface ei : language.findElementInterfaces(objectClass)) {
|
||||
List<String> eiTags = ei.getElementParents(namespaceUri);
|
||||
if (eiTags!=null) {
|
||||
startNamespace(nsContext.getUri(),nsContext.getSchemaPrefix());
|
||||
if (eiTags != null) {
|
||||
startNamespace(nsContext.getUri(), nsContext.getSchemaPrefix());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -145,10 +145,9 @@ public class EldXsdWriterElement {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static final String COMMENT_FORMAT = "%1$-20s %2$s";
|
||||
|
||||
|
||||
private void prologWriteGenerator() throws IOException {
|
||||
if (propertyConfig.getPropertyBoolean(EldXsdWriter.PROLOG_SEPERATOR_ENABLE)) {
|
||||
xsdWriter.printComment(propertyConfig.getPropertyString(EldXsdWriter.PROLOG_SEPERATOR_LINE));
|
||||
|
|
@ -161,26 +160,26 @@ public class EldXsdWriterElement {
|
|||
String generatedBy = propertyConfig.getPropertyString(EldXsdWriter.PROLOG_GENERATED_BY, EldXsdWriter.class.getSimpleName());
|
||||
String generatedVersion = propertyConfig.getPropertyString(EldXsdWriter.PROLOG_GENERATED_VERSION);
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"GeneratedBy:",generatedBy));
|
||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"GeneratedDate:",new Date()));
|
||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT, "GeneratedBy:", generatedBy));
|
||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT, "GeneratedDate:", new Date()));
|
||||
if (generatedVersion != null && !generatedVersion.isEmpty()) {
|
||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"GeneratedVersion:",generatedVersion));
|
||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT, "GeneratedVersion:", generatedVersion));
|
||||
}
|
||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"LanguageName:",language.getLanguageName()));
|
||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"LanguageVersion:",language.getLanguageVersion()));
|
||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT, "LanguageName:", language.getLanguageName()));
|
||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT, "LanguageVersion:", language.getLanguageVersion()));
|
||||
b.append(chEnter);
|
||||
xsdWriter.printComment(b.toString());
|
||||
}
|
||||
|
||||
|
||||
private void prologWriteNSMeta(ElementNamespace ns) throws IOException {
|
||||
String chEnter = propertyConfig.getPropertyString(SAX3WriterXml.OUTPUT_CHAR_NEWLINE);
|
||||
String chTab = propertyConfig.getPropertyString(SAX3WriterXml.OUTPUT_CHAR_TAB);
|
||||
if (propertyConfig.getPropertyBoolean(EldXsdWriter.PROLOG_XMLNS_INFO_ENABLE)) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"NSId:",ns.getId()));
|
||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"NSName:",ns.getName()));
|
||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"NSUri:",ns.getUri()));
|
||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"NSUriSchema:",ns.getSchemaUri()));
|
||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT, "NSId:", ns.getId()));
|
||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT, "NSName:", ns.getName()));
|
||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT, "NSUri:", ns.getUri()));
|
||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT, "NSUriSchema:", ns.getSchemaUri()));
|
||||
b.append(chEnter);
|
||||
xsdWriter.printComment(b.toString());
|
||||
}
|
||||
|
|
@ -204,15 +203,15 @@ public class EldXsdWriterElement {
|
|||
xsdWriter.printComment(buf.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void startSchema(ElementNamespace ns) throws IOException {
|
||||
|
||||
|
||||
xsdWriter.startDocument();
|
||||
|
||||
|
||||
prologWriteGenerator();
|
||||
prologWriteNSMeta(ns);
|
||||
|
||||
for (String uri:namespaces.keySet()) {
|
||||
|
||||
for (String uri : namespaces.keySet()) {
|
||||
String prefix = namespaces.get(uri);
|
||||
try {
|
||||
xsdWriter.getContentWriterWrapped().startPrefixMapping(prefix, uri);
|
||||
|
|
@ -220,25 +219,25 @@ public class EldXsdWriterElement {
|
|||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "version", "", "", "1.0");
|
||||
atts.addAttribute ("", "elementFormDefault", "", "", "qualified");
|
||||
atts.addAttribute ("", "attributeFormDefault", "", "", "unqualified");
|
||||
atts.addAttribute ("", "targetNamespace", "", "", ns.getUri());
|
||||
atts.addAttribute("", "version", "", "", "1.0");
|
||||
atts.addAttribute("", "elementFormDefault", "", "", "qualified");
|
||||
atts.addAttribute("", "attributeFormDefault", "", "", "unqualified");
|
||||
atts.addAttribute("", "targetNamespace", "", "", ns.getUri());
|
||||
xsdWriter.printTagStart(Tag.schema, atts);
|
||||
|
||||
for (String uri:namespaces.keySet()) {
|
||||
|
||||
for (String uri : namespaces.keySet()) {
|
||||
if (ns.getUri().equals(uri)) {
|
||||
continue;
|
||||
}
|
||||
ElementNamespace nsContext = language.findElementNamespace(uri);
|
||||
xsdWriter.printXsdImport(nsContext.getUri(), nsContext.getSchemaResource());
|
||||
}
|
||||
|
||||
|
||||
writeNamespaceAttributes(ns);
|
||||
}
|
||||
|
||||
|
||||
public void endSchema() throws IOException {
|
||||
xsdWriter.printTagEnd(Tag.schema);
|
||||
try {
|
||||
|
|
@ -248,122 +247,122 @@ public class EldXsdWriterElement {
|
|||
}
|
||||
xsdWriter.endDocument();
|
||||
}
|
||||
|
||||
|
||||
private void writeNamespaceAttributes(ElementNamespace ns) throws IOException {
|
||||
for (ElementNamespaceAttribute eah:ns.getElementNamespaceAttributes()) {
|
||||
for (ElementNamespaceAttribute eah : ns.getElementNamespaceAttributes()) {
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "name", "", "", eah.getAttributeName());
|
||||
atts.addAttribute ("", "type", "", "", "string");
|
||||
writeElementAttribute(eah,atts);
|
||||
atts.addAttribute("", "name", "", "", eah.getAttributeName());
|
||||
atts.addAttribute("", "type", "", "", "string");
|
||||
writeElementAttribute(eah, atts);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeElementClass(ElementClass ec,ElementNamespace nsWrite) throws IOException {
|
||||
|
||||
|
||||
public void writeElementClass(ElementClass ec, ElementNamespace nsWrite) throws IOException {
|
||||
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) {
|
||||
atts.addAttribute ("", "name", "", "", ec.getId());
|
||||
if (nsWrite.getLanguageRoot() != null && nsWrite.getLanguageRoot()) {
|
||||
atts.addAttribute("", "name", "", "", ec.getId());
|
||||
xsdWriter.printTagStart(Tag.element, atts);// Only in the language root xsd there is an element.
|
||||
|
||||
|
||||
atts = new AttributesImpl();
|
||||
xsdWriter.printTagStart(Tag.complexType, atts);
|
||||
} else {
|
||||
atts.addAttribute ("", "name", "", "", ec.getId()+"Type");
|
||||
atts.addAttribute("", "name", "", "", ec.getId() + "Type");
|
||||
xsdWriter.printTagStart(Tag.complexType, atts);
|
||||
}
|
||||
|
||||
if (ec.getSchemaContentBase()!=null) {
|
||||
|
||||
if (ec.getSchemaContentBase() != null) {
|
||||
atts = new AttributesImpl();
|
||||
if (ec.getSchemaContentComplex()!=null && ec.getSchemaContentComplex()) {
|
||||
if (ec.getSchemaContentMixed()!=null && ec.getSchemaContentMixed()) {
|
||||
atts.addAttribute ("", "mixed", "", "", "true");
|
||||
if (ec.getSchemaContentComplex() != null && ec.getSchemaContentComplex()) {
|
||||
if (ec.getSchemaContentMixed() != null && ec.getSchemaContentMixed()) {
|
||||
atts.addAttribute("", "mixed", "", "", "true");
|
||||
}
|
||||
xsdWriter.printTagStart(Tag.complexContent, atts);
|
||||
} else {
|
||||
xsdWriter.printTagStart(Tag.simpleContent, atts);
|
||||
}
|
||||
atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "base", "", "", ec.getSchemaContentBase());
|
||||
atts.addAttribute("", "base", "", "", ec.getSchemaContentBase());
|
||||
xsdWriter.printTagStart(Tag.extension, atts);
|
||||
}
|
||||
|
||||
if (ec.getSchemaContentBase()==null) {
|
||||
|
||||
if (ec.getSchemaContentBase() == null) {
|
||||
atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "minOccurs", "", "", "0"); // TODO: make unordered elements
|
||||
atts.addAttribute ("", "maxOccurs", "", "", "unbounded");
|
||||
atts.addAttribute("", "minOccurs", "", "", "0"); // TODO: make unordered elements
|
||||
atts.addAttribute("", "maxOccurs", "", "", "unbounded");
|
||||
xsdWriter.printTagStart(Tag.choice, atts);
|
||||
|
||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
||||
writeElementClassNamespaces(ec,nsWrite,ns);
|
||||
|
||||
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||
writeElementClassNamespaces(ec, nsWrite, ns);
|
||||
}
|
||||
}
|
||||
xsdWriter.printTagEnd(Tag.choice);
|
||||
}
|
||||
|
||||
|
||||
List<String> attrNames = new ArrayList<String>(30);
|
||||
for (ElementClassAttribute eca:ec.getElementClassAttributes()) {
|
||||
for (ElementClassAttribute eca : ec.getElementClassAttributes()) {
|
||||
attrNames.add(eca.getId());
|
||||
atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "name", "", "", eca.getId());
|
||||
atts.addAttribute ("", "type", "", "", "string");
|
||||
if (eca.getRequired()!=null && eca.getRequired()) {
|
||||
atts.addAttribute ("", "use", "", "", "required");
|
||||
atts.addAttribute("", "name", "", "", eca.getId());
|
||||
atts.addAttribute("", "type", "", "", "string");
|
||||
if (eca.getRequired() != null && eca.getRequired()) {
|
||||
atts.addAttribute("", "use", "", "", "required");
|
||||
}
|
||||
writeElementAttribute(eca,atts);
|
||||
|
||||
for (String alias:eca.getAttributeAliases()) {
|
||||
writeElementAttribute(eca, atts);
|
||||
|
||||
for (String alias : eca.getAttributeAliases()) {
|
||||
attrNames.add(alias);
|
||||
atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "name", "", "", alias);
|
||||
atts.addAttribute ("", "type", "", "", "string");
|
||||
writeElementAttribute(null,atts);
|
||||
atts.addAttribute("", "name", "", "", alias);
|
||||
atts.addAttribute("", "type", "", "", "string");
|
||||
writeElementAttribute(null, atts);
|
||||
}
|
||||
}
|
||||
|
||||
if (ec.getAutoAttributes()!=null && ec.getAutoAttributes()==false) {
|
||||
|
||||
if (ec.getAutoAttributes() != null && ec.getAutoAttributes() == false) {
|
||||
// oke, reverse this if and rm whitespace.
|
||||
try {
|
||||
xsdWriter.getContentWriterWrapped().ignorableWhitespace(' ');
|
||||
} catch (SAXException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
if (ec.getObjectClass()!=null) {
|
||||
for (Method m:ec.getObjectClass().getMethods()) {
|
||||
|
||||
if (ec.getObjectClass() != null) {
|
||||
for (Method m : ec.getObjectClass().getMethods()) {
|
||||
if (m.getName().startsWith("set")) {
|
||||
String n = m.getName().substring(3);
|
||||
if (m.getParameterTypes().length==0) {
|
||||
if (m.getParameterTypes().length == 0) {
|
||||
continue; // set without parameters
|
||||
}
|
||||
if (n.length()<2) {
|
||||
if (n.length() < 2) {
|
||||
continue;
|
||||
}
|
||||
n = n.substring(0,1).toLowerCase()+n.substring(1,n.length());
|
||||
n = n.substring(0, 1).toLowerCase() + n.substring(1, n.length());
|
||||
if (attrNames.contains(n)) {
|
||||
continue;
|
||||
}
|
||||
attrNames.add(n);
|
||||
atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "name", "", "", n);
|
||||
|
||||
atts.addAttribute("", "name", "", "", n);
|
||||
|
||||
Class<?> type = m.getParameterTypes()[0]; // TODO make full list for auto attribute type resolving.
|
||||
if (type.equals(Object.class)) {
|
||||
atts.addAttribute ("", "type", "", "", "string");// object is always string because is always assignable
|
||||
atts.addAttribute("", "type", "", "", "string");// object is always string because is always assignable
|
||||
} else if (type.isAssignableFrom(Boolean.class) | type.isAssignableFrom(Boolean.TYPE)) {
|
||||
atts.addAttribute ("", "type", "", "", "boolean");
|
||||
atts.addAttribute("", "type", "", "", "boolean");
|
||||
} else if (type.isAssignableFrom(Integer.class) | type.isAssignableFrom(Integer.TYPE)) {
|
||||
atts.addAttribute ("", "type", "", "", "integer");
|
||||
atts.addAttribute("", "type", "", "", "integer");
|
||||
} else if (type.isAssignableFrom(Long.class) | type.isAssignableFrom(Long.TYPE)) {
|
||||
atts.addAttribute ("", "type", "", "", "long");
|
||||
atts.addAttribute("", "type", "", "", "long");
|
||||
} else if (type.isAssignableFrom(Float.class) | type.isAssignableFrom(Float.TYPE)) {
|
||||
atts.addAttribute ("", "type", "", "", "float");
|
||||
atts.addAttribute("", "type", "", "", "float");
|
||||
} else if (type.isAssignableFrom(Double.class) | type.isAssignableFrom(Double.TYPE)) {
|
||||
atts.addAttribute ("", "type", "", "", "double");
|
||||
atts.addAttribute("", "type", "", "", "double");
|
||||
} else {
|
||||
atts.addAttribute ("", "type", "", "", "string");
|
||||
atts.addAttribute("", "type", "", "", "string");
|
||||
}
|
||||
xsdWriter.printTagStartEnd(Tag.attribute, atts);
|
||||
}
|
||||
|
|
@ -373,97 +372,96 @@ public class EldXsdWriterElement {
|
|||
xsdWriter.printTagStartEnd(Tag.anyAttribute, atts);
|
||||
}
|
||||
}
|
||||
if (ec.getSchemaContentBase()!=null) {
|
||||
if (ec.getSchemaContentBase() != null) {
|
||||
xsdWriter.printTagEnd(Tag.extension);
|
||||
if (ec.getSchemaContentComplex()!=null && ec.getSchemaContentComplex()) {
|
||||
if (ec.getSchemaContentComplex() != null && ec.getSchemaContentComplex()) {
|
||||
xsdWriter.printTagEnd(Tag.complexContent);
|
||||
} else {
|
||||
xsdWriter.printTagEnd(Tag.simpleContent);
|
||||
}
|
||||
}
|
||||
xsdWriter.printTagEnd(Tag.complexType);
|
||||
if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) {
|
||||
if (nsWrite.getLanguageRoot() != null && nsWrite.getLanguageRoot()) {
|
||||
xsdWriter.printTagEnd(Tag.element);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeElementClassNamespaces(ElementClass ecWrite,ElementNamespace nsWrite,ElementNamespace ns) throws IOException {
|
||||
|
||||
private void writeElementClassNamespaces(ElementClass ecWrite, ElementNamespace nsWrite, ElementNamespace ns) throws IOException {
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
List<String> refElements = new ArrayList<String>(20);
|
||||
for (ElementClass checkClass:ns.getElementClasses()) {
|
||||
for (ElementClass checkClass : ns.getElementClasses()) {
|
||||
List<String> parents = checkClass.getElementParents(nsWrite.getUri());
|
||||
if (parents!=null && parents.contains(ecWrite.getId())) {
|
||||
if (parents != null && parents.contains(ecWrite.getId())) {
|
||||
refElements.add(checkClass.getId());
|
||||
continue;
|
||||
}
|
||||
if (checkClass.getObjectClass()==null) {
|
||||
if (checkClass.getObjectClass() == null) {
|
||||
continue;
|
||||
}
|
||||
for (ElementInterface ei:language.findElementInterfaces(checkClass.getObjectClass())) {
|
||||
for (ElementInterface ei : language.findElementInterfaces(checkClass.getObjectClass())) {
|
||||
parents = ei.getElementParents(nsWrite.getUri());
|
||||
if (parents!=null && parents.contains(ecWrite.getId())) {
|
||||
if (parents != null && parents.contains(ecWrite.getId())) {
|
||||
refElements.add(checkClass.getId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ecWrite.getObjectClass()==null) {
|
||||
if (ecWrite.getObjectClass() == null) {
|
||||
continue;
|
||||
}
|
||||
Class<?> objectClass = ecWrite.getObjectClass();
|
||||
Class<?> checkObjectClass = checkClass.getObjectClass();
|
||||
List<ElementBindingHandler> b = language.findElementBindingHandlers(objectClass,checkObjectClass);
|
||||
if (b.isEmpty()==false) {
|
||||
List<ElementBindingHandler> b = language.findElementBindingHandlers(objectClass, checkObjectClass);
|
||||
if (b.isEmpty() == false) {
|
||||
refElements.add(checkClass.getId());
|
||||
}
|
||||
}
|
||||
|
||||
if (refElements.isEmpty()==false) {
|
||||
|
||||
if (refElements.isEmpty() == false) {
|
||||
Set<String> s = new HashSet<String>(refElements.size());
|
||||
s.addAll(refElements);
|
||||
List<String> r = new ArrayList<String>(s.size());
|
||||
r.addAll(s);
|
||||
Collections.sort(r);
|
||||
|
||||
|
||||
String prefix = namespaces.get(ns.getUri());
|
||||
for (String refElement:r) {
|
||||
for (String refElement : r) {
|
||||
atts = new AttributesImpl();
|
||||
if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) {
|
||||
atts.addAttribute ("", "ref", "", "", prefix+":"+refElement);
|
||||
} else if (nsWrite.getUri().equals(ns.getUri())==false) {
|
||||
atts.addAttribute ("", "ref", "", "", prefix+":"+refElement);
|
||||
if (nsWrite.getLanguageRoot() != null && nsWrite.getLanguageRoot()) {
|
||||
atts.addAttribute("", "ref", "", "", prefix + ":" + refElement);
|
||||
} else if (nsWrite.getUri().equals(ns.getUri()) == false) {
|
||||
atts.addAttribute("", "ref", "", "", prefix + ":" + refElement);
|
||||
} else {
|
||||
atts.addAttribute ("", "name", "", "", refElement);
|
||||
atts.addAttribute ("", "type", "", "", prefix+":"+refElement+"Type");
|
||||
atts.addAttribute("", "name", "", "", refElement);
|
||||
atts.addAttribute("", "type", "", "", prefix + ":" + refElement + "Type");
|
||||
}
|
||||
xsdWriter.printTagStartEnd(Tag.element,atts);
|
||||
xsdWriter.printTagStartEnd(Tag.element, atts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void writeElement(ElementClass ec,ElementNamespace nsWrite) throws IOException {
|
||||
if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) {
|
||||
|
||||
public void writeElement(ElementClass ec, ElementNamespace nsWrite) throws IOException {
|
||||
if (nsWrite.getLanguageRoot() != null && nsWrite.getLanguageRoot()) {
|
||||
return; // is done in writeElementClass
|
||||
}
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "name", "", "", ec.getId());
|
||||
atts.addAttribute ("", "type", "", "", "this:"+ec.getId()+"Type");
|
||||
xsdWriter.printTagStart(Tag.element,atts);
|
||||
atts.addAttribute("", "name", "", "", ec.getId());
|
||||
atts.addAttribute("", "type", "", "", "this:" + ec.getId() + "Type");
|
||||
xsdWriter.printTagStart(Tag.element, atts);
|
||||
writeElementMetaBase(ec);
|
||||
xsdWriter.printTagEnd(Tag.element);
|
||||
}
|
||||
|
||||
private void writeElementAttribute(ElementMetaBase base,AttributesImpl atts) throws IOException {
|
||||
xsdWriter.printTagStart(Tag.attribute,atts);
|
||||
|
||||
private void writeElementAttribute(ElementMetaBase base, AttributesImpl atts) throws IOException {
|
||||
xsdWriter.printTagStart(Tag.attribute, atts);
|
||||
writeElementMetaBase(base);
|
||||
xsdWriter.printTagEnd(Tag.attribute);
|
||||
}
|
||||
|
||||
private void writeElementMetaBase(ElementMetaBase base) throws IOException {
|
||||
if (base==null) {
|
||||
|
||||
private void writeElementMetaBase(ElementMetaBase base) throws IOException {
|
||||
if (base == null) {
|
||||
return;
|
||||
}
|
||||
if (base.getDescription()==null) {
|
||||
if (base.getDescription() == null) {
|
||||
return;
|
||||
}
|
||||
if (!propertyConfig.getPropertyBoolean(EldXsdWriter.OUTPUT_DOCUMENTATION)) {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
package org.x4o.xml.element;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -47,46 +47,47 @@ public abstract class AbstractElement implements Element {
|
|||
/** The ElementClass */
|
||||
private ElementClass elementClass = null;
|
||||
/** The attributes */
|
||||
private Map<String,String> attributes = new HashMap<String,String>(10);
|
||||
private Map<String, String> attributes = new HashMap<String, String>(10);
|
||||
/** The Childeren */
|
||||
private List<Element> childeren = new ArrayList<Element>(10);
|
||||
/** All Childeren */
|
||||
private List<Element> allChilderen = new ArrayList<Element>(10);
|
||||
|
||||
|
||||
/**
|
||||
* @see Element#doElementStart()
|
||||
*/
|
||||
public void doElementStart() throws ElementException {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see Element#doElementEnd()
|
||||
*/
|
||||
public void doElementEnd() throws ElementException {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see Element#doElementRun()
|
||||
*/
|
||||
public void doElementRun() throws ElementException {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see Element#setParent(Element)
|
||||
*/
|
||||
public void setParent(Element element) {
|
||||
parent = element;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see Element#getParent()
|
||||
*/
|
||||
public Element getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cleans the attributes and elements(class) and context.
|
||||
*
|
||||
* @see Element#release()
|
||||
*/
|
||||
public void release() throws ElementException {
|
||||
|
|
@ -98,28 +99,28 @@ public abstract class AbstractElement implements Element {
|
|||
childeren.clear(); // we do not release childeren, x4o does that
|
||||
allChilderen.clear();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see Element#getElementObject()
|
||||
*/
|
||||
public Object getElementObject() {
|
||||
return elementObject;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see Element#setElementObject(Object)
|
||||
*/
|
||||
public void setElementObject(Object object) {
|
||||
elementObject=object;
|
||||
elementObject = object;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see Element#setLanguageSession(X4OLanguageSession)
|
||||
*/
|
||||
public void setLanguageSession(X4OLanguageSession languageSession) {
|
||||
this.languageSession=languageSession;
|
||||
this.languageSession = languageSession;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see Element#getLanguageSession()
|
||||
*/
|
||||
|
|
@ -132,7 +133,8 @@ public abstract class AbstractElement implements Element {
|
|||
*/
|
||||
public void doCharacters(String characters) throws ElementException {
|
||||
try {
|
||||
Element e = X4OLanguageClassLoader.newInstance(Element.class, getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyCharacters());
|
||||
Element e = X4OLanguageClassLoader.newInstance(Element.class,
|
||||
getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyCharacters());
|
||||
e.setElementObject(characters);
|
||||
addChild(e);
|
||||
} catch (ClassNotFoundException exception) {
|
||||
|
|
@ -145,7 +147,8 @@ public abstract class AbstractElement implements Element {
|
|||
*/
|
||||
public void doComment(String comment) throws ElementException {
|
||||
try {
|
||||
Element e = X4OLanguageClassLoader.newInstance(Element.class, getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyComment());
|
||||
Element e = X4OLanguageClassLoader.newInstance(Element.class,
|
||||
getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyComment());
|
||||
e.setElementObject(comment);
|
||||
addChild(e);
|
||||
} catch (ClassNotFoundException exception) {
|
||||
|
|
@ -158,7 +161,8 @@ public abstract class AbstractElement implements Element {
|
|||
*/
|
||||
public void doIgnorableWhitespace(String space) throws ElementException {
|
||||
try {
|
||||
Element e = X4OLanguageClassLoader.newInstance(Element.class, getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyWhitespace());
|
||||
Element e = X4OLanguageClassLoader.newInstance(Element.class,
|
||||
getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyWhitespace());
|
||||
e.setElementObject(space);
|
||||
addChild(e);
|
||||
} catch (ClassNotFoundException exception) {
|
||||
|
|
@ -170,9 +174,9 @@ public abstract class AbstractElement implements Element {
|
|||
* @see org.x4o.xml.element.Element#setElementClass(ElementClass)
|
||||
*/
|
||||
public void setElementClass(ElementClass elementClass) {
|
||||
this.elementClass=elementClass;
|
||||
this.elementClass = elementClass;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.Element#getElementClass()
|
||||
*/
|
||||
|
|
@ -188,9 +192,9 @@ public abstract class AbstractElement implements Element {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.Element#setAttribute(java.lang.String, java.lang.String)
|
||||
* @see org.x4o.xml.element.Element#setAttribute(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void setAttribute(String name,String value) {
|
||||
public void setAttribute(String name, String value) {
|
||||
attributes.put(name, value);
|
||||
}
|
||||
|
||||
|
|
@ -200,7 +204,7 @@ public abstract class AbstractElement implements Element {
|
|||
public List<Element> getChilderen() {
|
||||
return childeren;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.Element#addChild(Element)
|
||||
*/
|
||||
|
|
@ -210,7 +214,7 @@ public abstract class AbstractElement implements Element {
|
|||
childeren.add(element);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.Element#removeChild(Element)
|
||||
*/
|
||||
|
|
@ -235,6 +239,7 @@ public abstract class AbstractElement implements Element {
|
|||
|
||||
/**
|
||||
* Defaults to false.
|
||||
*
|
||||
* @see org.x4o.xml.element.Element#isTransformingTree()
|
||||
*/
|
||||
public boolean isTransformingTree() {
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
|
||||
package org.x4o.xml.element;
|
||||
|
||||
/**
|
||||
* An AbstractElementBindingHandler.<br>
|
||||
|
|
@ -33,30 +32,31 @@ package org.x4o.xml.element;
|
|||
*/
|
||||
public abstract class AbstractElementBindingHandler<T> extends AbstractElementMetaBase implements ElementBindingHandler {
|
||||
|
||||
abstract public void bindChild(Element childElement,T parentObject,Object childObject) throws ElementBindingHandlerException;
|
||||
|
||||
abstract public void createChilderen(Element parentElement,T parentObject) throws ElementBindingHandlerException;
|
||||
|
||||
abstract public void bindChild(Element childElement, T parentObject, Object childObject) throws ElementBindingHandlerException;
|
||||
|
||||
abstract public void createChilderen(Element parentElement, T parentObject) throws ElementBindingHandlerException;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void bindChild(Element childElement) throws ElementBindingHandlerException {
|
||||
bindChild(childElement,(T)childElement.getParent().getElementObject(), childElement.getElementObject());
|
||||
bindChild(childElement, (T) childElement.getParent().getElementObject(), childElement.getElementObject());
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void createChilderen(Element parentElement) throws ElementBindingHandlerException {
|
||||
createChilderen(parentElement,(T)parentElement.getElementObject());
|
||||
createChilderen(parentElement, (T) parentElement.getElementObject());
|
||||
}
|
||||
|
||||
protected void createChild(Element parentElement,Object childObject) {
|
||||
if (childObject==null) {
|
||||
|
||||
protected void createChild(Element parentElement, Object childObject) {
|
||||
if (childObject == null) {
|
||||
return;
|
||||
}
|
||||
if (parentElement==null) {
|
||||
if (parentElement == null) {
|
||||
throw new NullPointerException("Can't create child with null parent.");
|
||||
}
|
||||
Element childElement = parentElement.getLanguageSession().getLanguage().createElementInstance(parentElement.getLanguageSession(), childObject.getClass());
|
||||
if (childElement==null) {
|
||||
throw new NullPointerException("Could not find Element for child: "+childObject.getClass());
|
||||
Element childElement = parentElement.getLanguageSession().getLanguage().createElementInstance(parentElement.getLanguageSession(),
|
||||
childObject.getClass());
|
||||
if (childElement == null) {
|
||||
throw new NullPointerException("Could not find Element for child: " + childObject.getClass());
|
||||
}
|
||||
childElement.setElementObject(childObject);
|
||||
childElement.setParent(parentElement);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
package org.x4o.xml.element;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -40,11 +40,11 @@ public abstract class AbstractElementClass extends AbstractElementClassBase impl
|
|||
private Boolean schemaContentComplex = null;
|
||||
private Boolean schemaContentMixed = null;
|
||||
private List<String> skipPhases = null;
|
||||
|
||||
|
||||
public AbstractElementClass() {
|
||||
skipPhases = new ArrayList<String>(3);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see ElementClass#getElementClass()
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -40,11 +40,11 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
|
|||
private List<String> attributeAliases = null;
|
||||
private Boolean required = null;
|
||||
private Boolean runResolveEL = null;
|
||||
//private Boolean runInterfaces = null;
|
||||
// private Boolean runInterfaces = null;
|
||||
private Boolean runConverters = null;
|
||||
private Boolean runBeanValue = null;
|
||||
private Integer writeOrder = null;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a AbstractElementClassAttribute.
|
||||
*/
|
||||
|
|
@ -54,6 +54,7 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
|
|||
|
||||
/**
|
||||
* Returns the objectConverter.
|
||||
*
|
||||
* @return The objectConverter.
|
||||
*/
|
||||
public ObjectConverter getObjectConverter() {
|
||||
|
|
@ -62,6 +63,7 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
|
|||
|
||||
/**
|
||||
* Sets the objectConverter.
|
||||
*
|
||||
* @param objectConverter The objectConverter to set.
|
||||
*/
|
||||
public void setObjectConverter(ObjectConverter objectConverter) {
|
||||
|
|
@ -70,15 +72,17 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
|
|||
|
||||
/**
|
||||
* Sets the default value.
|
||||
* @param defaultValue The defaultValue to set.
|
||||
*
|
||||
* @param defaultValue The defaultValue to set.
|
||||
* @see org.x4o.xml.element.ElementClassAttribute#setDefaultValue(java.lang.Object)
|
||||
*/
|
||||
public void setDefaultValue(Object defaultValue) {
|
||||
this.defaultValue=defaultValue;
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default value.
|
||||
*
|
||||
* @return The default value.
|
||||
* @see org.x4o.xml.element.ElementClassAttribute#getDefaultValue()
|
||||
*/
|
||||
|
|
@ -88,7 +92,8 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
|
|||
|
||||
/**
|
||||
* Adds an alias of this attribute.
|
||||
* @param alias The alias to add.
|
||||
*
|
||||
* @param alias The alias to add.
|
||||
* @see org.x4o.xml.element.ElementClassAttribute#addAttributeAlias(java.lang.String)
|
||||
*/
|
||||
public void addAttributeAlias(String alias) {
|
||||
|
|
@ -97,7 +102,8 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
|
|||
|
||||
/**
|
||||
* Removes an alias of this attribute.
|
||||
* @param alias The alias to remove.
|
||||
*
|
||||
* @param alias The alias to remove.
|
||||
* @see org.x4o.xml.element.ElementClassAttribute#removeAttributeAlias(java.lang.String)
|
||||
*/
|
||||
public void removeAttributeAlias(String alias) {
|
||||
|
|
@ -106,7 +112,8 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
|
|||
|
||||
/**
|
||||
* Returns all aliases of this attribute.
|
||||
* @return An list of aliases.
|
||||
*
|
||||
* @return An list of aliases.
|
||||
* @see org.x4o.xml.element.ElementClassAttribute#getAttributeAliases()
|
||||
*/
|
||||
public List<String> getAttributeAliases() {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
package org.x4o.xml.element;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
|
@ -36,22 +36,23 @@ import java.util.Map;
|
|||
*/
|
||||
public abstract class AbstractElementClassBase extends AbstractElementMetaBase implements ElementClassBase {
|
||||
|
||||
private Map<String,ElementClassAttribute> elementClassAttributes = null;
|
||||
private Map<String, ElementClassAttribute> elementClassAttributes = null;
|
||||
private List<ElementConfigurator> elementConfigurators = null;
|
||||
private Map<String,List<String>> elementParents = null;
|
||||
|
||||
private Map<String, List<String>> elementParents = null;
|
||||
|
||||
/**
|
||||
* Creates a AbstractElementClassBase.
|
||||
*/
|
||||
public AbstractElementClassBase() {
|
||||
elementConfigurators = new ArrayList<ElementConfigurator>(5);
|
||||
elementClassAttributes = new HashMap<String,ElementClassAttribute>(15);
|
||||
elementParents = new HashMap<String,List<String>>(5);
|
||||
elementClassAttributes = new HashMap<String, ElementClassAttribute>(15);
|
||||
elementParents = new HashMap<String, List<String>>(5);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a list of ElementConfigurators.
|
||||
* @return List of ElementConfigurators.
|
||||
*
|
||||
* @return List of ElementConfigurators.
|
||||
* @see ElementClass#getElementConfigurators()
|
||||
*/
|
||||
public List<ElementConfigurator> getElementConfigurators() {
|
||||
|
|
@ -70,40 +71,42 @@ public abstract class AbstractElementClassBase extends AbstractElementMetaBase i
|
|||
* @param elementClassAttribute The ElementClassAttribute to add.
|
||||
*/
|
||||
public void addElementClassAttribute(ElementClassAttribute elementClassAttribute) {
|
||||
elementClassAttributes.put(elementClassAttribute.getId(),elementClassAttribute);
|
||||
elementClassAttributes.put(elementClassAttribute.getId(), elementClassAttribute);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return All the element attributes.
|
||||
*/
|
||||
public Collection<ElementClassAttribute> getElementClassAttributes() {
|
||||
return elementClassAttributes.values();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the ElementClassAttribute from its name.
|
||||
* Get the ElementClassAttribute from its name.
|
||||
*
|
||||
* @param attributeName The attribute name.
|
||||
* @return The element class attribute for the name.
|
||||
*/
|
||||
public ElementClassAttribute getElementClassAttributeByName(String attributeName) {
|
||||
return elementClassAttributes.get(attributeName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds parent tag.
|
||||
*
|
||||
* @see org.x4o.xml.element.ElementClassBase#addElementParent(java.lang.String,java.lang.String)
|
||||
* @param namespaceUri The namespace uri of the parent tag.
|
||||
* @param tag The tag of the parent of this tag.
|
||||
* @param tag The tag of the parent of this tag.
|
||||
*/
|
||||
public void addElementParent(String namespaceUri,String tag) {
|
||||
if (namespaceUri==null) {
|
||||
public void addElementParent(String namespaceUri, String tag) {
|
||||
if (namespaceUri == null) {
|
||||
throw new NullPointerException("Can't add parent tag with null namespace uri.");
|
||||
}
|
||||
if (namespaceUri.length()==0) {
|
||||
if (namespaceUri.length() == 0) {
|
||||
throw new IllegalArgumentException("Can't add parent tag with empty namespace uri.");
|
||||
}
|
||||
List<String> tags = elementParents.get(namespaceUri);
|
||||
if (tags==null) {
|
||||
if (tags == null) {
|
||||
tags = new ArrayList<String>(5);
|
||||
elementParents.put(namespaceUri, tags);
|
||||
}
|
||||
|
|
@ -112,13 +115,14 @@ public abstract class AbstractElementClassBase extends AbstractElementMetaBase i
|
|||
|
||||
/**
|
||||
* Removes parent tag.
|
||||
*
|
||||
* @see org.x4o.xml.element.ElementClassBase#removeElementParent(java.lang.String,java.lang.String)
|
||||
* @param namespaceUri The namespace uri of the parent tag.
|
||||
* @param tag The tag of the parent of this tag.
|
||||
* @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);
|
||||
if (tags==null) {
|
||||
if (tags == null) {
|
||||
return;
|
||||
}
|
||||
tags.remove(tag);
|
||||
|
|
@ -126,6 +130,7 @@ public abstract class AbstractElementClassBase extends AbstractElementMetaBase i
|
|||
|
||||
/**
|
||||
* Returns the parent per namespace uri.
|
||||
*
|
||||
* @see org.x4o.xml.element.ElementClassBase#getElementParents(java.lang.String)
|
||||
* @param namespaceUri The namespace uri to gets the parents of.
|
||||
* @return List of parent tags of requested parent namespace uri.
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
package org.x4o.xml.element;
|
||||
|
||||
/**
|
||||
* An AbstractElementConfigurator.<br>
|
||||
|
|
@ -33,21 +33,23 @@ public abstract class AbstractElementConfigurator extends AbstractElementMetaBas
|
|||
|
||||
/** Flag indicating that this is an config action and should run in runPhase */
|
||||
private boolean configAction = false;
|
||||
|
||||
|
||||
/**
|
||||
* Defaults to false.
|
||||
*
|
||||
* @see org.x4o.xml.element.ElementConfigurator#isConfigAction()
|
||||
* @return True if set to configAction
|
||||
*/
|
||||
public boolean isConfigAction() {
|
||||
return configAction;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the configAction.
|
||||
* @param configAction The configAction to set.
|
||||
*
|
||||
* @param configAction The configAction to set.
|
||||
*/
|
||||
public void setConfigAction(boolean configAction) {
|
||||
this.configAction=configAction;
|
||||
this.configAction = configAction;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
package org.x4o.xml.element;
|
||||
|
||||
/**
|
||||
* AbstractElementInterface extends base support with element interface support.
|
||||
|
|
@ -31,13 +31,13 @@ package org.x4o.xml.element;
|
|||
public abstract class AbstractElementInterface extends AbstractElementClassBase implements ElementInterface {
|
||||
|
||||
private Class<?> interfaceClass = null;
|
||||
|
||||
|
||||
/**
|
||||
* Creates AbstractElementInterface.
|
||||
*/
|
||||
public AbstractElementInterface() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementInterface#getInterfaceClass()
|
||||
* @return The interface class
|
||||
|
|
@ -45,12 +45,12 @@ public abstract class AbstractElementInterface extends AbstractElementClassBase
|
|||
public Class<?> getInterfaceClass() {
|
||||
return interfaceClass;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementInterface#setInterfaceClass(java.lang.Class)
|
||||
* @param interfaceClass The interface class to set.
|
||||
*/
|
||||
public void setInterfaceClass(Class<?> interfaceClass) {
|
||||
this.interfaceClass=interfaceClass;
|
||||
this.interfaceClass = interfaceClass;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
package org.x4o.xml.element;
|
||||
|
||||
/**
|
||||
* AbstractElementMetaBase stores the id and description.
|
||||
|
|
@ -30,46 +30,50 @@ package org.x4o.xml.element;
|
|||
* @version 1.0 Jan 18, 2009
|
||||
*/
|
||||
public abstract class AbstractElementMetaBase implements ElementMetaBase {
|
||||
|
||||
|
||||
/** The id */
|
||||
private String id = null;
|
||||
|
||||
|
||||
/** The description */
|
||||
private String description = null;
|
||||
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
*
|
||||
* @see org.x4o.xml.element.ElementMetaBase#getId()
|
||||
* @return The id.
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the id.
|
||||
*
|
||||
* @see org.x4o.xml.element.ElementMetaBase#setId(java.lang.String)
|
||||
* @param id The id to set.
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id=id;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the description.
|
||||
*
|
||||
* @see org.x4o.xml.element.ElementConfigurator#getDescription()
|
||||
* @return The description.
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the description.
|
||||
*
|
||||
* @see org.x4o.xml.element.ElementConfigurator#setDescription(java.lang.String)
|
||||
* @param description The description to set.
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description=description;
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public abstract class AbstractElementNamespace extends AbstractElementMetaBase i
|
|||
|
||||
private ElementNamespaceInstanceProvider elementNamespaceInstanceProvider = null;
|
||||
private String prefixMapping = null;
|
||||
private Map<String,ElementClass> elementClasses = null;
|
||||
private Map<String, ElementClass> elementClasses = null;
|
||||
private String uri = null;
|
||||
private String name = null;
|
||||
private String schemaUri = null;
|
||||
|
|
@ -45,9 +45,9 @@ public abstract class AbstractElementNamespace extends AbstractElementMetaBase i
|
|||
private String schemaPrefix = null;
|
||||
private Boolean languageRoot = null;
|
||||
private List<ElementNamespaceAttribute> elementNamespaceAttributes = null;
|
||||
|
||||
|
||||
public AbstractElementNamespace() {
|
||||
elementClasses = new HashMap<String,ElementClass>(60);
|
||||
elementClasses = new HashMap<String, ElementClass>(60);
|
||||
elementNamespaceAttributes = new ArrayList<ElementNamespaceAttribute>(5);
|
||||
}
|
||||
|
||||
|
|
@ -76,14 +76,14 @@ public abstract class AbstractElementNamespace extends AbstractElementMetaBase i
|
|||
* @see org.x4o.xml.element.ElementNamespace#setPrefixMapping(java.lang.String)
|
||||
*/
|
||||
public void setPrefixMapping(String prefixMapping) {
|
||||
this.prefixMapping=prefixMapping;
|
||||
this.prefixMapping = prefixMapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementNamespace#addElementClass(org.x4o.xml.element.ElementClass)
|
||||
*/
|
||||
public void addElementClass(ElementClass elementClass) {
|
||||
if (elementClass.getId()==null) {
|
||||
if (elementClass.getId() == null) {
|
||||
throw new NullPointerException("ElementClass not correctly configured getId is null.");
|
||||
}
|
||||
elementClasses.put(elementClass.getId(), elementClass);
|
||||
|
|
@ -186,16 +186,15 @@ public abstract class AbstractElementNamespace extends AbstractElementMetaBase i
|
|||
public void setSchemaPrefix(String schemaPrefix) {
|
||||
this.schemaPrefix = schemaPrefix;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void addElementNamespaceAttribute(ElementNamespaceAttribute elementNamespaceAttribute) {
|
||||
if (elementNamespaceAttribute==null) {
|
||||
if (elementNamespaceAttribute == null) {
|
||||
throw new NullPointerException("Can't add null object");
|
||||
}
|
||||
if (elementNamespaceAttribute.getId()==null) {
|
||||
if (elementNamespaceAttribute.getId() == null) {
|
||||
throw new NullPointerException("Can't add with null id property.");
|
||||
}
|
||||
//logger.finer("Adding elementNamespaceAttribute: "+elementNamespaceAttribute.getAttributeName());
|
||||
// logger.finer("Adding elementNamespaceAttribute: "+elementNamespaceAttribute.getAttributeName());
|
||||
elementNamespaceAttributes.add(elementNamespaceAttribute);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,15 +32,15 @@ import java.util.List;
|
|||
* @version 1.0 Aug 10, 2006
|
||||
*/
|
||||
public abstract class AbstractElementNamespaceAttribute extends AbstractElementConfigurator implements ElementNamespaceAttribute {
|
||||
|
||||
|
||||
private String attributeName = null;
|
||||
private List<String> nextAttributes = new ArrayList<String>(2);
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementNamespaceAttribute#addNextAttribute(java.lang.String)
|
||||
*/
|
||||
public void addNextAttribute(String attribute) {
|
||||
if (attribute==null) {
|
||||
if (attribute == null) {
|
||||
throw new NullPointerException("Can add null attribute for loading.");
|
||||
}
|
||||
nextAttributes.add(attribute);
|
||||
|
|
@ -48,9 +48,9 @@ public abstract class AbstractElementNamespaceAttribute extends AbstractElementC
|
|||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementNamespaceAttribute#removeNextAttribute(java.lang.String)
|
||||
*/
|
||||
*/
|
||||
public void removeNextAttribute(String attribute) {
|
||||
if (attribute==null) {
|
||||
if (attribute == null) {
|
||||
throw new NullPointerException("Can remove null attribute for loading.");
|
||||
}
|
||||
nextAttributes.remove(attribute);
|
||||
|
|
@ -74,6 +74,6 @@ public abstract class AbstractElementNamespaceAttribute extends AbstractElementC
|
|||
* @see org.x4o.xml.element.ElementNamespaceAttribute#setAttributeName(java.lang.String)
|
||||
*/
|
||||
public void setAttributeName(String attributeName) {
|
||||
this.attributeName=attributeName;
|
||||
this.attributeName = attributeName;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
|
||||
package org.x4o.xml.element;
|
||||
|
||||
/**
|
||||
* The default element to handle the xml events.
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
package org.x4o.xml.element;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Logger;
|
||||
|
|
@ -29,7 +29,6 @@ import javax.el.ValueExpression;
|
|||
|
||||
import org.x4o.xml.conv.ObjectConverterException;
|
||||
|
||||
|
||||
/**
|
||||
* An DefaultElementAttributeValueParser.
|
||||
*
|
||||
|
|
@ -38,18 +37,16 @@ import org.x4o.xml.conv.ObjectConverterException;
|
|||
*/
|
||||
public class DefaultElementAttributeValueParser implements ElementAttributeValueParser {
|
||||
|
||||
|
||||
private Logger logger = null;
|
||||
|
||||
|
||||
public DefaultElementAttributeValueParser() {
|
||||
logger = Logger.getLogger(DefaultElementAttributeValueParser.class.getName());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementAttributeValueParser#getParameterValue(java.lang.String, java.lang.String, org.x4o.xml.element.Element)
|
||||
*/
|
||||
public Object getParameterValue(String name, String valueString, Element element) throws ElementAttributeValueParserException,ObjectConverterException {
|
||||
public Object getParameterValue(String name, String valueString, Element element) throws ElementAttributeValueParserException, ObjectConverterException {
|
||||
Object value = valueString;
|
||||
|
||||
if (isELParameter(name, valueString, element)) {
|
||||
|
|
@ -58,55 +55,53 @@ public class DefaultElementAttributeValueParser implements ElementAttributeValue
|
|||
return getConvertedParameterValue(name, value, element);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @throws ObjectConverterException
|
||||
* @throws ObjectConverterException
|
||||
* @see org.x4o.xml.element.ElementAttributeValueParser#getConvertedParameterValue(java.lang.String, java.lang.Object, org.x4o.xml.element.Element)
|
||||
*/
|
||||
public Object getConvertedParameterValue(String name,Object value, Element element) throws ElementAttributeValueParserException, ObjectConverterException {
|
||||
//bit slow here
|
||||
if (value==null) {
|
||||
public Object getConvertedParameterValue(String name, Object value, Element element) throws ElementAttributeValueParserException, ObjectConverterException {
|
||||
// bit slow here
|
||||
if (value == null) {
|
||||
return null; // TODO: make setting for null
|
||||
}
|
||||
|
||||
|
||||
// do converts for ElementClass
|
||||
ElementClassAttribute attr = element.getElementClass().getElementClassAttributeByName(name);
|
||||
if (attr!=null && attr.getObjectConverter()!=null && value.getClass().isAssignableFrom(attr.getObjectConverter().getObjectClassTo())==false) {
|
||||
logger.finer("attr conv: "+attr.getObjectConverter()+" for name: "+name);
|
||||
if (attr != null && attr.getObjectConverter() != null && value.getClass().isAssignableFrom(attr.getObjectConverter().getObjectClassTo()) == false) {
|
||||
logger.finer("attr conv: " + attr.getObjectConverter() + " for name: " + name);
|
||||
Object result = attr.getObjectConverter().convertTo(value.toString(), Locale.getDefault());
|
||||
return result;
|
||||
}
|
||||
// check interfaces
|
||||
if (element.getElementObject()==null) {
|
||||
if (element.getElementObject() == null) {
|
||||
return value;
|
||||
}
|
||||
for (ElementInterface ei:element.getLanguageSession().getLanguage().findElementInterfaces(element.getElementObject())) {
|
||||
for (ElementInterface ei : element.getLanguageSession().getLanguage().findElementInterfaces(element.getElementObject())) {
|
||||
logger.finer("Found interface match executing converter.");
|
||||
for (ElementClassAttribute attrClass:ei.getElementClassAttributes()) {
|
||||
if (name.equals(attrClass.getId())==false) {
|
||||
for (ElementClassAttribute attrClass : ei.getElementClassAttributes()) {
|
||||
if (name.equals(attrClass.getId()) == false) {
|
||||
continue;
|
||||
}
|
||||
if (attrClass.getObjectConverter()==null) {
|
||||
if (attrClass.getObjectConverter() == null) {
|
||||
continue;
|
||||
}
|
||||
if (value.getClass().isAssignableFrom(attrClass.getObjectConverter().getObjectClassTo())) {
|
||||
continue; // make flag ?
|
||||
}
|
||||
logger.finest("attr conv interface: "+attrClass.getObjectConverter()+" for name: "+name);
|
||||
logger.finest("attr conv interface: " + attrClass.getObjectConverter() + " for name: " + name);
|
||||
Object result = attrClass.getObjectConverter().convertTo(value.toString(), Locale.getDefault());
|
||||
return result; // ??
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementAttributeValueParser#getELParameterValue(java.lang.String, org.x4o.xml.element.Element)
|
||||
*/
|
||||
public Object getELParameterValue(String value, Element element) throws ElementAttributeValueParserException {
|
||||
ValueExpression e = element.getLanguageSession().getExpressionLanguageFactory().createValueExpression(element.getLanguageSession().getExpressionLanguageContext(), (String)value,Object.class);
|
||||
ValueExpression e = element.getLanguageSession().getExpressionLanguageFactory()
|
||||
.createValueExpression(element.getLanguageSession().getExpressionLanguageContext(), (String) value, Object.class);
|
||||
return e.getValue(element.getLanguageSession().getExpressionLanguageContext());
|
||||
}
|
||||
|
||||
|
|
@ -114,27 +109,27 @@ public class DefaultElementAttributeValueParser implements ElementAttributeValue
|
|||
* @see org.x4o.xml.element.ElementAttributeValueParser#isELParameter(java.lang.String, java.lang.String, org.x4o.xml.element.Element)
|
||||
*/
|
||||
public boolean isELParameter(String name, String value, Element element) {
|
||||
if (value==null) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
if (value.startsWith("${")==false) {
|
||||
if (value.startsWith("${") == false) {
|
||||
return false;
|
||||
}
|
||||
if (element==null) {
|
||||
return true; // null element disables checks
|
||||
if (element == null) {
|
||||
return true; // null element disables checks
|
||||
}
|
||||
ElementClassAttribute attr = element.getElementClass().getElementClassAttributeByName(name);
|
||||
if (attr!=null && attr.getRunResolveEL()!=null && attr.getRunResolveEL()==false) {
|
||||
logger.finest("Skipping EL parsing for: "+name);
|
||||
if (attr != null && attr.getRunResolveEL() != null && attr.getRunResolveEL() == false) {
|
||||
logger.finest("Skipping EL parsing for: " + name);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (ElementInterface ei:element.getLanguageSession().getLanguage().findElementInterfaces(element.getElementObject())) {
|
||||
|
||||
for (ElementInterface ei : element.getLanguageSession().getLanguage().findElementInterfaces(element.getElementObject())) {
|
||||
logger.finest("Found interface match checking disables el parameters.");
|
||||
|
||||
|
||||
attr = ei.getElementClassAttributeByName(name);
|
||||
if (attr!=null && attr.getRunResolveEL()!=null && attr.getRunResolveEL()==false) {
|
||||
logger.finest("Skipping EL parsing for: "+name+" in interface element.");
|
||||
if (attr != null && attr.getRunResolveEL() != null && attr.getRunResolveEL() == false) {
|
||||
logger.finest("Skipping EL parsing for: " + name + " in interface element.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
package org.x4o.xml.element;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -29,7 +29,6 @@ import java.util.Map;
|
|||
|
||||
import org.x4o.xml.lang.X4OLanguageSession;
|
||||
|
||||
|
||||
/**
|
||||
* DefaultElementBodyCharacters the default characters element.
|
||||
*
|
||||
|
|
@ -42,9 +41,9 @@ public class DefaultElementBodyCharacters implements Element {
|
|||
private Element parent = null;
|
||||
/** The config object */
|
||||
private Object elementObject = null;
|
||||
|
||||
|
||||
/**
|
||||
* @return The ElementType for characters.
|
||||
* @return The ElementType for characters.
|
||||
* @see org.x4o.xml.element.Element#getElementType()
|
||||
*/
|
||||
public ElementType getElementType() {
|
||||
|
|
@ -106,7 +105,7 @@ public class DefaultElementBodyCharacters implements Element {
|
|||
* @see org.x4o.xml.element.Element#getAttributes()
|
||||
*/
|
||||
public Map<String, String> getAttributes() {
|
||||
return new HashMap<String,String>(0);
|
||||
return new HashMap<String, String>(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -160,7 +159,7 @@ public class DefaultElementBodyCharacters implements Element {
|
|||
/**
|
||||
* @see org.x4o.xml.element.Element#removeChild(org.x4o.xml.element.Element)
|
||||
*/
|
||||
public void removeChild(Element element) {
|
||||
public void removeChild(Element element) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -185,13 +184,13 @@ public class DefaultElementBodyCharacters implements Element {
|
|||
* @see org.x4o.xml.element.Element#setElementObject(java.lang.Object)
|
||||
*/
|
||||
public void setElementObject(Object elementObject) {
|
||||
this.elementObject=elementObject;
|
||||
this.elementObject = elementObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.Element#setParent(org.x4o.xml.element.Element)
|
||||
*/
|
||||
public void setParent(Element parent) {
|
||||
this.parent=parent;
|
||||
this.parent = parent;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
|
||||
package org.x4o.xml.element;
|
||||
|
||||
/**
|
||||
* DefaultElementBodyComment the default comment element.
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
|
||||
package org.x4o.xml.element;
|
||||
|
||||
/**
|
||||
* DefaultElementBodyWhitespace the default white space element.
|
||||
|
|
@ -32,7 +31,7 @@ package org.x4o.xml.element;
|
|||
public class DefaultElementBodyWhitespace extends AbstractElement {
|
||||
|
||||
/**
|
||||
* @return Returns the whitespace element type.
|
||||
* @return Returns the whitespace element type.
|
||||
* @see org.x4o.xml.element.AbstractElement#getElementType()
|
||||
*/
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
|
||||
package org.x4o.xml.element;
|
||||
|
||||
/**
|
||||
* DefaultElementClass stores the XML Element information.
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
|
||||
package org.x4o.xml.element;
|
||||
|
||||
/**
|
||||
* The default ElementClassAttribute.
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
|
||||
package org.x4o.xml.element;
|
||||
|
||||
/**
|
||||
* The default ElementInterface to store config based on class interface.
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
*/
|
||||
package org.x4o.xml.element;
|
||||
|
||||
|
||||
/**
|
||||
* DefaultElementNamespace is the default element namespace implementation.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ package org.x4o.xml.element;
|
|||
|
||||
import java.util.Comparator;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The DefaultElementNamespaceAttributeComparator.<br>
|
||||
* This Comparator compares the NextAttribute names with the attributeName of the ElementNamespaceAttribute.<br>
|
||||
|
|
@ -36,20 +34,20 @@ import java.util.Comparator;
|
|||
public class DefaultElementNamespaceAttributeComparator implements Comparator<ElementNamespaceAttribute> {
|
||||
|
||||
/**
|
||||
* @param e1 The first ElementNamespaceAttribute to compare.
|
||||
* @param e2 The second ElementNamespaceAttribute to compare.
|
||||
* @return 0 is same.
|
||||
* @param e1 The first ElementNamespaceAttribute to compare.
|
||||
* @param e2 The second ElementNamespaceAttribute to compare.
|
||||
* @return 0 is same.
|
||||
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public int compare(ElementNamespaceAttribute e1, ElementNamespaceAttribute e2) {
|
||||
|
||||
for (String param:e1.getNextAttributes()) {
|
||||
if(param.equals(e2.getAttributeName())) {
|
||||
for (String param : e1.getNextAttributes()) {
|
||||
if (param.equals(e2.getAttributeName())) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
for (String param:e2.getNextAttributes()) {
|
||||
if(param.equals(e1.getAttributeName())) {
|
||||
for (String param : e2.getNextAttributes()) {
|
||||
if (param.equals(e1.getAttributeName())) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class DefaultElementNamespaceInstanceProvider implements ElementNamespace
|
|||
|
||||
private Logger logger = null;
|
||||
private ElementNamespace elementNamespace = null;
|
||||
|
||||
|
||||
/**
|
||||
* Creates new DefaultElementNamespaceInstanceProvider.
|
||||
*/
|
||||
|
|
@ -47,47 +47,47 @@ public class DefaultElementNamespaceInstanceProvider implements ElementNamespace
|
|||
}
|
||||
|
||||
/**
|
||||
* @param language The elementLanguage of this provider.
|
||||
* @param elementNamespace The elementNamespace for this provider.
|
||||
* @param language The elementLanguage of this provider.
|
||||
* @param elementNamespace The elementNamespace for this provider.
|
||||
* @see org.x4o.xml.element.ElementNamespaceInstanceProvider#start(org.x4o.xml.lang.X4OLanguage, org.x4o.xml.element.ElementNamespace)
|
||||
*/
|
||||
public void start(X4OLanguage language,ElementNamespace elementNamespace) {
|
||||
this.elementNamespace=elementNamespace;
|
||||
logger.finer("Starting DefaultElementNamespaceInstanceProvider for: "+elementNamespace.getUri());
|
||||
public void start(X4OLanguage language, ElementNamespace elementNamespace) {
|
||||
this.elementNamespace = elementNamespace;
|
||||
logger.finer("Starting DefaultElementNamespaceInstanceProvider for: " + elementNamespace.getUri());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param languageSession The language context for which we create the Element instance.
|
||||
* @param tag The xml tag to create an Element instance for.
|
||||
* @return The Element to handle the given tag.
|
||||
* @throws ElementNamespaceInstanceProviderException
|
||||
* @param languageSession The language context for which we create the Element instance.
|
||||
* @param tag The xml tag to create an Element instance for.
|
||||
* @return The Element to handle the given tag.
|
||||
* @throws ElementNamespaceInstanceProviderException
|
||||
* @see org.x4o.xml.element.ElementNamespaceInstanceProvider#createElementInstance(org.x4o.xml.lang.X4OLanguageSession,java.lang.String)
|
||||
*/
|
||||
public Element createElementInstance(X4OLanguageSession languageSession,String tag) throws ElementNamespaceInstanceProviderException {
|
||||
ElementClass elementClass = elementNamespace.getElementClass(tag);
|
||||
Element element = null;
|
||||
|
||||
if (elementClass==null) {
|
||||
throw new ElementNamespaceInstanceProviderException(this,"Tag: " + tag + " unknown in: " + elementNamespace.getUri());
|
||||
public Element createElementInstance(X4OLanguageSession languageSession, String tag) throws ElementNamespaceInstanceProviderException {
|
||||
ElementClass elementClass = elementNamespace.getElementClass(tag);
|
||||
Element element = null;
|
||||
|
||||
if (elementClass == null) {
|
||||
throw new ElementNamespaceInstanceProviderException(this, "Tag: " + tag + " unknown in: " + elementNamespace.getUri());
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
if (elementClass.getElementClass()!=null) {
|
||||
if (elementClass.getElementClass() != null) {
|
||||
Object obj = X4OLanguageClassLoader.newInstance(elementClass.getElementClass());
|
||||
if (obj instanceof Element) {
|
||||
element = (Element) obj;
|
||||
} else {
|
||||
throw new ElementNamespaceInstanceProviderException(this,"Provided elementClassName is not an Element: "+obj.getClass());
|
||||
throw new ElementNamespaceInstanceProviderException(this, "Provided elementClassName is not an Element: " + obj.getClass());
|
||||
}
|
||||
} else {
|
||||
element = (Element)X4OLanguageClassLoader.newInstance((languageSession.getLanguage().getLanguageConfiguration().getDefaultElement()));
|
||||
element = (Element) X4OLanguageClassLoader.newInstance((languageSession.getLanguage().getLanguageConfiguration().getDefaultElement()));
|
||||
}
|
||||
|
||||
if (elementClass.getObjectClass()!=null) {
|
||||
|
||||
if (elementClass.getObjectClass() != null) {
|
||||
element.setElementObject(X4OLanguageClassLoader.newInstance(elementClass.getObjectClass()));
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new ElementNamespaceInstanceProviderException(this,"Error while providing Element: "+e.getMessage(),e);
|
||||
throw new ElementNamespaceInstanceProviderException(this, "Error while providing Element: " + e.getMessage(), e);
|
||||
}
|
||||
element.setElementClass(elementClass);
|
||||
element.setLanguageSession(languageSession);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
package org.x4o.xml.element;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Method;
|
||||
|
|
@ -39,24 +39,24 @@ import org.x4o.xml.conv.ObjectConverterException;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 16, 2007
|
||||
*/
|
||||
public class DefaultElementObjectPropertyValue implements ElementObjectPropertyValue,Serializable {
|
||||
public class DefaultElementObjectPropertyValue implements ElementObjectPropertyValue, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
private Logger logger = Logger.getLogger(DefaultElementObjectPropertyValue.class.getName());
|
||||
|
||||
private Method findMethod(Object object,String parameterName,Object parameter) {
|
||||
|
||||
|
||||
private Method findMethod(Object object, String parameterName, Object parameter) {
|
||||
|
||||
// Get class but can be null.
|
||||
Class<?> parameterClass = null;
|
||||
if(parameter!=null) {
|
||||
parameterClass=parameter.getClass();
|
||||
if (parameter != null) {
|
||||
parameterClass = parameter.getClass();
|
||||
}
|
||||
logger.finer("Trying value: pn="+parameterName+" o="+object+" p="+parameter+"("+parameterClass+")");
|
||||
String parameterNameSet = "set"+parameterName;
|
||||
logger.finer("Trying value: pn=" + parameterName + " o=" + object + " p=" + parameter + "(" + parameterClass + ")");
|
||||
String parameterNameSet = "set" + parameterName;
|
||||
Method[] methodes = object.getClass().getMethods();
|
||||
Method lastMethodFall = null;
|
||||
for (int i=0;i<methodes.length;i++) {
|
||||
for (int i = 0; i < methodes.length; i++) {
|
||||
Method method = methodes[i];
|
||||
Class<?>[] types = method.getParameterTypes();
|
||||
if (types.length == 0) {
|
||||
|
|
@ -67,32 +67,32 @@ public class DefaultElementObjectPropertyValue implements ElementObjectPropertyV
|
|||
}
|
||||
if (method.getName().equalsIgnoreCase(parameterNameSet)) {
|
||||
lastMethodFall = method;
|
||||
if (parameterClass!=null) {
|
||||
if (parameterClass != null) {
|
||||
// Check for class based parameters.
|
||||
if (types[0].isAssignableFrom(parameterClass)) {
|
||||
logger.finest("Found method type: "+method.getParameterTypes()[0]+" for parameter: "+parameterName);
|
||||
logger.finest("Found method type: " + method.getParameterTypes()[0] + " for parameter: " + parameterName);
|
||||
return method;
|
||||
}
|
||||
// Check the native parameter types.
|
||||
if (parameterClass.isAssignableFrom(Boolean.class) && types[0].isAssignableFrom(Boolean.TYPE) ) {
|
||||
if (parameterClass.isAssignableFrom(Boolean.class) && types[0].isAssignableFrom(Boolean.TYPE)) {
|
||||
return method;
|
||||
}
|
||||
if (parameterClass.isAssignableFrom(Integer.class) && types[0].isAssignableFrom(Integer.TYPE) ) {
|
||||
if (parameterClass.isAssignableFrom(Integer.class) && types[0].isAssignableFrom(Integer.TYPE)) {
|
||||
return method;
|
||||
}
|
||||
if (parameterClass.isAssignableFrom(Long.class) && types[0].isAssignableFrom(Long.TYPE) ) {
|
||||
if (parameterClass.isAssignableFrom(Long.class) && types[0].isAssignableFrom(Long.TYPE)) {
|
||||
return method;
|
||||
}
|
||||
if (parameterClass.isAssignableFrom(Double.class) && types[0].isAssignableFrom(Double.TYPE) ) {
|
||||
if (parameterClass.isAssignableFrom(Double.class) && types[0].isAssignableFrom(Double.TYPE)) {
|
||||
return method;
|
||||
}
|
||||
if (parameterClass.isAssignableFrom(Float.class) && types[0].isAssignableFrom(Float.TYPE) ) {
|
||||
if (parameterClass.isAssignableFrom(Float.class) && types[0].isAssignableFrom(Float.TYPE)) {
|
||||
return method;
|
||||
}
|
||||
if (parameterClass.isAssignableFrom(Byte.class) && types[0].isAssignableFrom(Byte.TYPE) ) {
|
||||
if (parameterClass.isAssignableFrom(Byte.class) && types[0].isAssignableFrom(Byte.TYPE)) {
|
||||
return method;
|
||||
}
|
||||
if (parameterClass.isAssignableFrom(Character.class) && types[0].isAssignableFrom(Character.TYPE) ) {
|
||||
if (parameterClass.isAssignableFrom(Character.class) && types[0].isAssignableFrom(Character.TYPE)) {
|
||||
return method;
|
||||
}
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ public class DefaultElementObjectPropertyValue implements ElementObjectPropertyV
|
|||
}
|
||||
return lastMethodFall;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TODO: this function is not completed !!
|
||||
*
|
||||
|
|
@ -111,222 +111,212 @@ public class DefaultElementObjectPropertyValue implements ElementObjectPropertyV
|
|||
* @param parameter
|
||||
* @throws ElementObjectPropertyValueException
|
||||
*/
|
||||
public void setProperty(Object object,String parameterName,Object parameter) throws ElementObjectPropertyValueException {
|
||||
|
||||
public void setProperty(Object object, String parameterName, Object parameter) throws ElementObjectPropertyValueException {
|
||||
|
||||
// find the method for the parameter
|
||||
Method lastMethod = findMethod(object,parameterName,parameter);
|
||||
if (lastMethod==null) {
|
||||
logger.finest("No method found, aborting parameter: "+parameterName);
|
||||
Method lastMethod = findMethod(object, parameterName, parameter);
|
||||
if (lastMethod == null) {
|
||||
logger.finest("No method found, aborting parameter: " + parameterName);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Special case for null value.
|
||||
if (parameter==null) {
|
||||
logger.finest("Found parameter is null Setting method: "+lastMethod.getParameterTypes()[0]+" for parameter: "+parameterName);
|
||||
if (parameter == null) {
|
||||
logger.finest("Found parameter is null Setting method: " + lastMethod.getParameterTypes()[0] + " for parameter: " + parameterName);
|
||||
try {
|
||||
lastMethod.invoke(object,new Object[]{parameter});
|
||||
lastMethod.invoke(object, new Object[] { parameter });
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
throw new ElementObjectPropertyValueException(e.getMessage(),e);
|
||||
throw new ElementObjectPropertyValueException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Invoke for class based parameters
|
||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(parameter.getClass())) {
|
||||
logger.finest("Found parameter type: "+lastMethod.getParameterTypes()[0]+" for parameter: "+parameterName+" setting value: "+parameter);
|
||||
logger.finest("Found parameter type: " + lastMethod.getParameterTypes()[0] + " for parameter: " + parameterName + " setting value: " + parameter);
|
||||
try {
|
||||
lastMethod.invoke(object,new Object[]{parameter});
|
||||
lastMethod.invoke(object, new Object[] { parameter });
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
throw new ElementObjectPropertyValueException(e.getMessage(),e);
|
||||
throw new ElementObjectPropertyValueException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Invoke for native based types
|
||||
|
||||
|
||||
|
||||
// not found 2sec try
|
||||
logger.finest("No corresoning class is found, trying convert manualy");
|
||||
|
||||
|
||||
// special case for object.
|
||||
if (lastMethod.getParameterTypes()[0].equals(Object.class) ) {
|
||||
logger.finest("Set Special object value: "+parameterName+" parm2: "+parameter+" on2="+lastMethod.getName()+" with="+object);
|
||||
if (lastMethod.getParameterTypes()[0].equals(Object.class)) {
|
||||
logger.finest("Set Special object value: " + parameterName + " parm2: " + parameter + " on2=" + lastMethod.getName() + " with=" + object);
|
||||
try {
|
||||
lastMethod.invoke(object,new Object[]{parameter});
|
||||
lastMethod.invoke(object, new Object[] { parameter });
|
||||
} catch (Exception e) {
|
||||
throw new ElementObjectPropertyValueException(e.getMessage(),e);
|
||||
throw new ElementObjectPropertyValueException(e.getMessage(), e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// all below creates from string
|
||||
if (parameter.toString().length()==0) {
|
||||
if (parameter.toString().length() == 0) {
|
||||
return; // can't set value from string with empty size.
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// JAVA OBJECT TYPES:
|
||||
//
|
||||
Object parameter2 = null;
|
||||
|
||||
|
||||
try {
|
||||
DefaultObjectConverterProvider convProvider = new DefaultObjectConverterProvider();
|
||||
convProvider.addDefaults();
|
||||
ObjectConverter conv = convProvider.getObjectConverterForClass(lastMethod.getParameterTypes()[0]);
|
||||
if (conv!=null) {
|
||||
if (conv != null) {
|
||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* JAVA NATIVE TYPES:
|
||||
*
|
||||
* TYPE: Size in bits:
|
||||
* boolean 8, unsigned
|
||||
* byte 8
|
||||
* char 16, unsigned
|
||||
* short 16
|
||||
* int 32
|
||||
* long 64
|
||||
* float 32
|
||||
* double 64
|
||||
* void n/a
|
||||
* TYPE: Size in bits: boolean 8, unsigned byte 8 char 16, unsigned short 16 int 32 long 64 float 32 double 64 void n/a
|
||||
*/
|
||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Boolean.TYPE) ) {
|
||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Boolean.TYPE)) {
|
||||
conv = convProvider.getObjectConverterForClass(Boolean.class);
|
||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
||||
}
|
||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Integer.TYPE) ) {
|
||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Integer.TYPE)) {
|
||||
conv = convProvider.getObjectConverterForClass(Integer.class);
|
||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
||||
}
|
||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Long.TYPE) ) {
|
||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Long.TYPE)) {
|
||||
conv = convProvider.getObjectConverterForClass(Long.class);
|
||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
||||
}
|
||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Double.TYPE) ) {
|
||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Double.TYPE)) {
|
||||
conv = convProvider.getObjectConverterForClass(Double.class);
|
||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
||||
}
|
||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Float.TYPE) ) {
|
||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Float.TYPE)) {
|
||||
conv = convProvider.getObjectConverterForClass(Float.class);
|
||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
||||
}
|
||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Byte.TYPE) ) {
|
||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Byte.TYPE)) {
|
||||
conv = convProvider.getObjectConverterForClass(Byte.class);
|
||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
||||
}
|
||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Character.TYPE) ) {
|
||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Character.TYPE)) {
|
||||
conv = convProvider.getObjectConverterForClass(Character.class);
|
||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
||||
}
|
||||
|
||||
|
||||
} catch (ObjectConverterException oce) {
|
||||
throw new ElementObjectPropertyValueException(oce.getMessage(),oce);
|
||||
throw new ElementObjectPropertyValueException(oce.getMessage(), oce);
|
||||
}
|
||||
|
||||
if (parameter2==null) {
|
||||
throw new ElementObjectPropertyValueException("Could not convert to type for parameter: '"+parameterName+"' value: '"+parameter+"'");
|
||||
|
||||
if (parameter2 == null) {
|
||||
throw new ElementObjectPropertyValueException("Could not convert to type for parameter: '" + parameterName + "' value: '" + parameter + "'");
|
||||
}
|
||||
|
||||
logger.finest("Set value: "+parameterName+" parm2: "+parameter2+" on2="+lastMethod.getName()+" with="+object);
|
||||
|
||||
logger.finest("Set value: " + parameterName + " parm2: " + parameter2 + " on2=" + lastMethod.getName() + " with=" + object);
|
||||
try {
|
||||
lastMethod.invoke(object,new Object[]{parameter2});
|
||||
lastMethod.invoke(object, new Object[] { parameter2 });
|
||||
} catch (Exception e) {
|
||||
throw new ElementObjectPropertyValueException(e.getMessage(),e);
|
||||
throw new ElementObjectPropertyValueException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the property of an bean.
|
||||
*
|
||||
* @param object The object to get from.
|
||||
* @param parameterName The parameter name of the property to get.
|
||||
* @param object The object to get from.
|
||||
* @param parameterName The parameter name of the property to get.
|
||||
* @throws ElementObjectPropertyValueException
|
||||
*/
|
||||
public Object getProperty(Object object,String parameterName) throws ElementObjectPropertyValueException {
|
||||
public Object getProperty(Object object, String parameterName) throws ElementObjectPropertyValueException {
|
||||
|
||||
if (object==null) {
|
||||
if (object == null) {
|
||||
throw new NullPointerException("Can't get property of null object.");
|
||||
}
|
||||
if (parameterName==null) {
|
||||
if (parameterName == null) {
|
||||
throw new NullPointerException("Can't get property is the name is null.");
|
||||
}
|
||||
|
||||
|
||||
Logger logger = Logger.getLogger(DefaultElementObjectPropertyValue.class.getName());
|
||||
|
||||
|
||||
String propRest = null;
|
||||
int index = parameterName.indexOf(".");
|
||||
if(index>0) {
|
||||
propRest = parameterName.substring(index+1);
|
||||
parameterName = parameterName.substring(0,index);
|
||||
logger.finest("slit property into: '"+propRest+"' and '"+parameterName+"'");
|
||||
if (index > 0) {
|
||||
propRest = parameterName.substring(index + 1);
|
||||
parameterName = parameterName.substring(0, index);
|
||||
logger.finest("slit property into: '" + propRest + "' and '" + parameterName + "'");
|
||||
}
|
||||
|
||||
logger.finer("Trying value: pn="+parameterName+" o="+object);
|
||||
String parameterNameSet = "get"+parameterName;
|
||||
logger.finer("Trying value: pn=" + parameterName + " o=" + object);
|
||||
String parameterNameSet = "get" + parameterName;
|
||||
Method[] methodes = object.getClass().getMethods();
|
||||
Method lastMethod = null;
|
||||
|
||||
|
||||
// a bit hackie
|
||||
for(int i=0;i<methodes.length;i++) {
|
||||
for (int i = 0; i < methodes.length; i++) {
|
||||
Method method = methodes[i];
|
||||
Class<?>[] types = method.getParameterTypes();
|
||||
if (types.length != 0) {
|
||||
continue;
|
||||
}
|
||||
if(method.getName().equalsIgnoreCase(parameterNameSet)) {
|
||||
logger.finest("Found method: "+method.getName());
|
||||
if (method.getName().equalsIgnoreCase(parameterNameSet)) {
|
||||
logger.finest("Found method: " + method.getName());
|
||||
lastMethod = method;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastMethod==null) {
|
||||
for(int i=0;i<methodes.length;i++) {
|
||||
|
||||
if (lastMethod == null) {
|
||||
for (int i = 0; i < methodes.length; i++) {
|
||||
Method method = methodes[i];
|
||||
if(method.getName().equalsIgnoreCase("is"+parameterName)) {
|
||||
logger.finest("Found is method: "+method.getName());
|
||||
if (method.getName().equalsIgnoreCase("is" + parameterName)) {
|
||||
logger.finest("Found is method: " + method.getName());
|
||||
lastMethod = method;
|
||||
break;
|
||||
}
|
||||
if(method.getName().equalsIgnoreCase("has"+parameterName)) {
|
||||
logger.finest("Found has method: "+method.getName());
|
||||
if (method.getName().equalsIgnoreCase("has" + parameterName)) {
|
||||
logger.finest("Found has method: " + method.getName());
|
||||
lastMethod = method;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lastMethod==null) {
|
||||
throw new ElementObjectPropertyValueException("Could not find method for parameter: '"+parameterName+"' object: '"+object+"'");
|
||||
|
||||
if (lastMethod == null) {
|
||||
throw new ElementObjectPropertyValueException("Could not find method for parameter: '" + parameterName + "' object: '" + object + "'");
|
||||
}
|
||||
|
||||
Object result = null;
|
||||
try {
|
||||
result = lastMethod.invoke(object,new Object[]{});
|
||||
result = lastMethod.invoke(object, new Object[] {});
|
||||
} catch (Exception e) {
|
||||
throw new ElementObjectPropertyValueException(e.getMessage(),e);
|
||||
throw new ElementObjectPropertyValueException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (propRest!=null) {
|
||||
if (result==null) {
|
||||
|
||||
if (propRest != null) {
|
||||
if (result == null) {
|
||||
return null; // no need to go deeper into a null value.
|
||||
}
|
||||
// recursif function:
|
||||
return getProperty(result,propRest);
|
||||
return getProperty(result, propRest);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementObjectPropertyValue#setPropertyMap(java.lang.Object, java.util.Map)
|
||||
*/
|
||||
public void setPropertyMap(Object object, Map<String, Object> attributes) throws ElementObjectPropertyValueException {
|
||||
Iterator<String> keyIterator = attributes.keySet().iterator();
|
||||
while(keyIterator.hasNext()) {
|
||||
while (keyIterator.hasNext()) {
|
||||
String key = keyIterator.next();
|
||||
setProperty(object,key,attributes.get(key));
|
||||
setProperty(object, key, attributes.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
package org.x4o.xml.element;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -32,43 +32,43 @@ import org.x4o.xml.lang.X4OLanguageSession;
|
|||
* Defines an XML element with an object.<br>
|
||||
* <br>
|
||||
* The main function is to store the ElementObject.<br>
|
||||
* Also we can configure the ElementObject from differted events hooks.
|
||||
* from the attibutes or parent (object)element.
|
||||
* Also we can configure the ElementObject from differted events hooks. from the attibutes or parent (object)element.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 01, 2005
|
||||
*/
|
||||
public interface Element {
|
||||
|
||||
|
||||
/**
|
||||
* The ElementTypes which are possible.
|
||||
*/
|
||||
public enum ElementType {
|
||||
|
||||
|
||||
/** The normale ElementType, which is mostly bound to an object. */
|
||||
element,
|
||||
|
||||
|
||||
/** Extra meta characters in xml. */
|
||||
characters,
|
||||
|
||||
|
||||
/** The xml comments in xml. */
|
||||
comment,
|
||||
|
||||
|
||||
/** ignorableWhitespace in xml. */
|
||||
ignorableWhitespace,
|
||||
|
||||
|
||||
/** Receive raw sax event on elementObject. */
|
||||
overrideSax;
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @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) {
|
||||
public static List<Element> filterElements(List<Element> elements, ElementType elementType) {
|
||||
List<Element> result = new ArrayList<Element>(3);
|
||||
for (int i=0;i<elements.size();i++) {
|
||||
for (int i = 0; i < elements.size(); i++) {
|
||||
Element element = elements.get(i);
|
||||
if (elementType == element.getElementType()) {
|
||||
result.add(element);
|
||||
|
|
@ -77,151 +77,170 @@ public interface Element {
|
|||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is fired when the end xml tag is parsed.
|
||||
*
|
||||
* @throws ElementException Can be thrown when structure is not correct.
|
||||
*/
|
||||
void doElementEnd() throws ElementException;
|
||||
|
||||
|
||||
/**
|
||||
* This method is fired when the start of xml tag is parsed.
|
||||
*
|
||||
* @throws ElementException Can be thrown when structure is not correct.
|
||||
*/
|
||||
void doElementStart() throws ElementException;
|
||||
|
||||
|
||||
/**
|
||||
* This method is fired only once in the run phase.
|
||||
*
|
||||
* @throws ElementException Can be thrown when structure is not correct.
|
||||
*/
|
||||
void doElementRun() throws ElementException;
|
||||
|
||||
|
||||
/**
|
||||
* Set the parent Element.
|
||||
* @param element The paraent Element to set.
|
||||
*
|
||||
* @param element The paraent Element to set.
|
||||
*/
|
||||
void setParent(Element element);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the parent Element.<br>
|
||||
* Or null when there is no parent Element.
|
||||
*
|
||||
* @return Returns the parent Element
|
||||
* @return Returns the parent Element
|
||||
*/
|
||||
Element getParent();
|
||||
|
||||
|
||||
/**
|
||||
* This method get called when this Element object is not needed anymore.<br>
|
||||
* Can be used to close resources.
|
||||
*
|
||||
* @throws ElementException Can be thrown when structure is not correct.
|
||||
*/
|
||||
void release() throws ElementException;
|
||||
|
||||
|
||||
/**
|
||||
* Gives back the object this Element has made and configed.<br>
|
||||
* So other elements can do stuff to that object.<br>
|
||||
*
|
||||
* @return An Object.
|
||||
* @return An Object.
|
||||
*/
|
||||
Object getElementObject();
|
||||
|
||||
|
||||
/**
|
||||
* Sets the object which we control.
|
||||
* @param object The object to configed by this element.
|
||||
*
|
||||
* @param object The object to configed by this element.
|
||||
*/
|
||||
void setElementObject(Object object);
|
||||
|
||||
|
||||
/**
|
||||
* Sets the X4OLanguageSession.
|
||||
* @param languageSession The X4OLanguageSession to set.
|
||||
*
|
||||
* @param languageSession The X4OLanguageSession to set.
|
||||
*/
|
||||
void setLanguageSession(X4OLanguageSession languageSession);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the X4OLanguageSession.
|
||||
* @return Returns the X4OLanguageSession.
|
||||
*
|
||||
* @return Returns the X4OLanguageSession.
|
||||
*/
|
||||
X4OLanguageSession getLanguageSession();
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
||||
/**
|
||||
* Is called when there is whitespace in xml.
|
||||
* @param space The space.
|
||||
*
|
||||
* @param space The space.
|
||||
* @throws ElementException Can be thrown when structure is not correct.
|
||||
*/
|
||||
void doIgnorableWhitespace(String space) throws ElementException;
|
||||
|
||||
void doIgnorableWhitespace(String space) throws ElementException;
|
||||
|
||||
/**
|
||||
* Sets the ElementClass.
|
||||
* @param elementClass The ElementClass to set.
|
||||
*
|
||||
* @param elementClass The ElementClass to set.
|
||||
*/
|
||||
void setElementClass(ElementClass elementClass);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the ElementClass.
|
||||
* @return Returns the ElementClass.
|
||||
*
|
||||
* @return Returns the ElementClass.
|
||||
*/
|
||||
ElementClass getElementClass();
|
||||
|
||||
|
||||
/**
|
||||
* Sets the xml attributes.
|
||||
* @param name The name to set.
|
||||
* @param value The value to set.
|
||||
*
|
||||
* @param name The name to set.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
void setAttribute(String name,String value);
|
||||
|
||||
void setAttribute(String name, String value);
|
||||
|
||||
/**
|
||||
* Gets the xml attributes.
|
||||
* @return Returns the xml attributes.
|
||||
*
|
||||
* @return Returns the xml attributes.
|
||||
*/
|
||||
Map<String,String> getAttributes();
|
||||
|
||||
Map<String, String> getAttributes();
|
||||
|
||||
/**
|
||||
* Gets the childeren elements.
|
||||
* @return Returns the childeren.
|
||||
*
|
||||
* @return Returns the childeren.
|
||||
*/
|
||||
List<Element> getChilderen();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the childeren elements including those which are comment and white space. (text)
|
||||
* @return Returns all the childeren.
|
||||
*
|
||||
* @return Returns all the childeren.
|
||||
*/
|
||||
List<Element> getAllChilderen();
|
||||
|
||||
|
||||
/**
|
||||
* Adds an Elment as child of this element.
|
||||
* @param element The child to add.
|
||||
*
|
||||
* @param element The child to add.
|
||||
*/
|
||||
void addChild(Element element);
|
||||
|
||||
|
||||
/**
|
||||
* Removes an Elment as child of this element.
|
||||
* @param element The child to remove.
|
||||
*
|
||||
* @param element The child to remove.
|
||||
*/
|
||||
void removeChild(Element element);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the Element type.
|
||||
* @return Returns the ElementType.
|
||||
*
|
||||
* @return Returns the ElementType.
|
||||
*/
|
||||
ElementType getElementType();
|
||||
|
||||
|
||||
/**
|
||||
* Returns if this elements transforms the tree.
|
||||
* if true the the doElementRun is runned in the transform phase insteat of the run phase.
|
||||
* Returns if this elements transforms the tree. if true the the doElementRun is runned in the transform phase insteat of the run phase.
|
||||
*
|
||||
* You need to add those new or modified Elements to the DirtyElement for reparsering.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
package org.x4o.xml.element;
|
||||
|
||||
import org.x4o.xml.conv.ObjectConverterException;
|
||||
|
||||
|
|
@ -31,46 +31,49 @@ import org.x4o.xml.conv.ObjectConverterException;
|
|||
* @version 1.0 Aug 20, 2005
|
||||
*/
|
||||
public interface ElementAttributeValueParser {
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the value is an EL parameter.
|
||||
* @param name The name of the attribute.
|
||||
* @param value The value of the attribute.
|
||||
* @param element The element of the attribute.
|
||||
* @return Returns true if value is EL parameter.
|
||||
*
|
||||
* @param name The name of the attribute.
|
||||
* @param value The value of the attribute.
|
||||
* @param element The element of the attribute.
|
||||
* @return Returns true if value is EL parameter.
|
||||
*/
|
||||
boolean isELParameter(String name,String value,Element element);
|
||||
|
||||
boolean isELParameter(String name, String value, Element element);
|
||||
|
||||
/**
|
||||
* Returns the object which is stored in the ELContext
|
||||
* @param value The attribute value.
|
||||
* @param element The element of the attribute.
|
||||
* @return Returns the resolved el parameter value.
|
||||
*
|
||||
* @param value The attribute value.
|
||||
* @param element The element of the attribute.
|
||||
* @return Returns the resolved el parameter value.
|
||||
* @throws ElementAttributeValueParserException
|
||||
* @throws ObjectConverterException
|
||||
*/
|
||||
Object getELParameterValue(String value,Element element) throws ElementAttributeValueParserException,ObjectConverterException;
|
||||
|
||||
Object getELParameterValue(String value, Element element) throws ElementAttributeValueParserException, ObjectConverterException;
|
||||
|
||||
/**
|
||||
* Convert the value into a new value genereted by parameterConverters.
|
||||
* @param name The name of the attribute.
|
||||
* @param value The value of the attribute.
|
||||
* @param element The element of the attribute.
|
||||
* @return Returns the converted attribute value.
|
||||
*
|
||||
* @param name The name of the attribute.
|
||||
* @param value The value of the attribute.
|
||||
* @param element The element of the attribute.
|
||||
* @return Returns the converted attribute value.
|
||||
* @throws ElementAttributeValueParserException
|
||||
* @throws ObjectConverterException
|
||||
*/
|
||||
Object getConvertedParameterValue(String name,Object value,Element element) throws ElementAttributeValueParserException,ObjectConverterException;
|
||||
|
||||
Object getConvertedParameterValue(String name, Object value, Element element) throws ElementAttributeValueParserException, ObjectConverterException;
|
||||
|
||||
/**
|
||||
* Does is all, Checks if value is EL parameter and lookups the object.
|
||||
* and converts to new object via parameter converter and return value.
|
||||
* @param name The name of the attribute.
|
||||
* @param value The value of the attribute.
|
||||
* @param element The element of the attribute.
|
||||
* @return Returns the attribute value.
|
||||
* Does is all, Checks if value is EL parameter and lookups the object. and converts to new object via parameter converter and return value.
|
||||
*
|
||||
* @param name The name of the attribute.
|
||||
* @param value The value of the attribute.
|
||||
* @param element The element of the attribute.
|
||||
* @return Returns the attribute value.
|
||||
* @throws ElementAttributeValueParserException
|
||||
* @throws ObjectConverterException
|
||||
*/
|
||||
Object getParameterValue(String name,String value,Element element) throws ElementAttributeValueParserException,ObjectConverterException;
|
||||
Object getParameterValue(String name, String value, Element element) throws ElementAttributeValueParserException, ObjectConverterException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
|
||||
package org.x4o.xml.element;
|
||||
|
||||
/**
|
||||
* ElementAttributeValueParserException.<br>
|
||||
|
|
@ -33,14 +32,10 @@ package org.x4o.xml.element;
|
|||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ElementAttributeValueParserException extends ElementException {
|
||||
|
||||
|
||||
/*
|
||||
public ElementAttributeValueParserException(ElementAttributeConverter converter,String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ElementAttributeValueParserException(ElementAttributeConverter converter,String message,Exception exception) {
|
||||
super(message,exception);
|
||||
}
|
||||
*/
|
||||
* public ElementAttributeValueParserException(ElementAttributeConverter converter,String message) { super(message); }
|
||||
*
|
||||
* public ElementAttributeValueParserException(ElementAttributeConverter converter,String message,Exception exception) { super(message,exception); }
|
||||
*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,42 +20,42 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
|
||||
package org.x4o.xml.element;
|
||||
|
||||
/**
|
||||
* Bind ElementObjects together.
|
||||
*
|
||||
* This interface is used to bind a parent and child ElementObject together.
|
||||
* For example; when both objects are an JComponent then we can add the child to the parent
|
||||
* with the method: ((JComponent)parent).add((JComponent)child);
|
||||
* This interface is used to bind a parent and child ElementObject together. For example; when both objects are an JComponent then we can add the child to the
|
||||
* parent with the method: ((JComponent)parent).add((JComponent)child);
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 17, 2005
|
||||
*/
|
||||
public interface ElementBindingHandler extends ElementMetaBase {
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the parent classes which this binding handler can do.
|
||||
* @return Returns the parent classes which this binding handler can do.
|
||||
*/
|
||||
Class<?> getBindParentClass();
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns array of child classes which this binding handler can do.
|
||||
* @return Returns array of child classes which this binding handler can do.
|
||||
*/
|
||||
Class<?>[] getBindChildClasses();
|
||||
|
||||
|
||||
/**
|
||||
* Do the binding of this child to the parent object.
|
||||
* @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 bindChild(Element childElement) throws ElementBindingHandlerException;
|
||||
|
||||
|
||||
/**
|
||||
* Creates the childeren of the parent object.
|
||||
* @param parentElement The parent element to create the childeren from.'
|
||||
*
|
||||
* @param parentElement The parent element to create the childeren from.'
|
||||
* @throws ElementBindingHandlerException When binding could not happen.
|
||||
*/
|
||||
void createChilderen(Element parentElement) throws ElementBindingHandlerException;
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
|
||||
package org.x4o.xml.element;
|
||||
|
||||
/**
|
||||
* ElementBindingException.<br>
|
||||
|
|
@ -33,21 +32,23 @@ package org.x4o.xml.element;
|
|||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ElementBindingHandlerException extends ElementException {
|
||||
|
||||
|
||||
/**
|
||||
* Creates binding exception.
|
||||
* @param message The error message.
|
||||
*
|
||||
* @param message The error message.
|
||||
*/
|
||||
public ElementBindingHandlerException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates binding exception.
|
||||
* @param message The error message.
|
||||
* @param exception The error exception.
|
||||
*
|
||||
* @param message The error message.
|
||||
* @param exception The error exception.
|
||||
*/
|
||||
public ElementBindingHandlerException(String message,Exception exception) {
|
||||
super(message,exception);
|
||||
public ElementBindingHandlerException(String message, Exception exception) {
|
||||
super(message, exception);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
package org.x4o.xml.element;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -32,15 +32,17 @@ import java.util.List;
|
|||
* @version 1.0 Aug 11, 2005
|
||||
*/
|
||||
public interface ElementClass extends ElementClassBase {
|
||||
|
||||
|
||||
/**
|
||||
* Gets the ElementClass.
|
||||
*
|
||||
* @return the elementClass
|
||||
*/
|
||||
Class<?> getElementClass();
|
||||
|
||||
/**
|
||||
* Sets the ElementClass.
|
||||
*
|
||||
* @param elementClass the elementClass to set.
|
||||
*/
|
||||
void setElementClass(Class<?> elementClass);
|
||||
|
|
@ -54,7 +56,7 @@ public interface ElementClass extends ElementClassBase {
|
|||
* @param objectClass the objectClass to set.
|
||||
*/
|
||||
void setObjectClass(Class<?> objectClass);
|
||||
|
||||
|
||||
/**
|
||||
* @return the autoAttributes.
|
||||
*/
|
||||
|
|
@ -64,7 +66,7 @@ public interface ElementClass extends ElementClassBase {
|
|||
* @param autoAttributes the autoAttributes to set.
|
||||
*/
|
||||
void setAutoAttributes(Boolean autoAttributes);
|
||||
|
||||
|
||||
/**
|
||||
* @return the schemaContentBase
|
||||
*/
|
||||
|
|
@ -74,7 +76,7 @@ public interface ElementClass extends ElementClassBase {
|
|||
* @param schemaContentBase the schemaContentBase to set
|
||||
*/
|
||||
void setSchemaContentBase(String schemaContentBase);
|
||||
|
||||
|
||||
/**
|
||||
* @return the schemaContentComplex
|
||||
*/
|
||||
|
|
@ -94,22 +96,25 @@ public interface ElementClass extends ElementClassBase {
|
|||
* @param schemaContentMixed the schemaContentMixed to set
|
||||
*/
|
||||
void setSchemaContentMixed(Boolean schemaContentMixed);
|
||||
|
||||
|
||||
/**
|
||||
* Add an skip phase for this element.
|
||||
* @param phase The phase name.
|
||||
*
|
||||
* @param phase The phase name.
|
||||
*/
|
||||
void addSkipPhase(String phase);
|
||||
|
||||
|
||||
/**
|
||||
* Removes an skip phase for this element.
|
||||
* @param phase The phase name.
|
||||
*
|
||||
* @param phase The phase name.
|
||||
*/
|
||||
void removeSkipPhase(String phase);
|
||||
|
||||
|
||||
/**
|
||||
* Get all the skip phases for this element.
|
||||
* @return The defined phases.
|
||||
*
|
||||
* @return The defined phases.
|
||||
*/
|
||||
List<String> getSkipPhases();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
package org.x4o.xml.element;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -34,61 +34,70 @@ import org.x4o.xml.conv.ObjectConverter;
|
|||
* @version 1.0 Aug 11, 2005
|
||||
*/
|
||||
public interface ElementClassAttribute extends ElementMetaBase {
|
||||
|
||||
|
||||
/**
|
||||
* Gets the ObjectConverter.
|
||||
*
|
||||
* @return The ObjectConverter.
|
||||
*/
|
||||
ObjectConverter getObjectConverter();
|
||||
|
||||
|
||||
/**
|
||||
* Add the ObjectConverter whichs converts.
|
||||
* @param objectConverter The objectConverter to set for this attribute.
|
||||
*
|
||||
* @param objectConverter The objectConverter to set for this attribute.
|
||||
*/
|
||||
void setObjectConverter(ObjectConverter objectConverter);
|
||||
|
||||
|
||||
/**
|
||||
* Sets the defaultValue of this attribute.
|
||||
* @param defaultValue The defaultValue to set.
|
||||
*
|
||||
* @param defaultValue The defaultValue to set.
|
||||
*/
|
||||
void setDefaultValue(Object defaultValue);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the default value.
|
||||
* @return Returns the default value if any.
|
||||
*
|
||||
* @return Returns the default value if any.
|
||||
*/
|
||||
Object getDefaultValue();
|
||||
|
||||
|
||||
/**
|
||||
* Add an attribute alias for this attribute.
|
||||
* @param alias The alias.
|
||||
*
|
||||
* @param alias The alias.
|
||||
*/
|
||||
void addAttributeAlias(String alias);
|
||||
|
||||
|
||||
/**
|
||||
* Removes an attribute alias.
|
||||
* @param alias The alias.
|
||||
*
|
||||
* @param alias The alias.
|
||||
*/
|
||||
void removeAttributeAlias(String alias);
|
||||
|
||||
|
||||
/**
|
||||
* Get all the aliases for this attribute.
|
||||
* @return The defined aliases.
|
||||
*
|
||||
* @return The defined aliases.
|
||||
*/
|
||||
List<String> getAttributeAliases();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the required state of this attribute.
|
||||
*
|
||||
* @return If true then attribute is required.
|
||||
*/
|
||||
Boolean getRequired();
|
||||
|
||||
/**
|
||||
* Sets the required state of this attribute.
|
||||
*
|
||||
* @param required the required to set.
|
||||
*/
|
||||
void setRequired(Boolean required);
|
||||
|
||||
|
||||
/**
|
||||
* @return the runResolveEL.
|
||||
*/
|
||||
|
|
@ -118,7 +127,7 @@ public interface ElementClassAttribute extends ElementMetaBase {
|
|||
* @param runBeanValue the runBeanValue to set.
|
||||
*/
|
||||
void setRunBeanValue(Boolean runBeanValue);
|
||||
|
||||
|
||||
/**
|
||||
* @return the writeOrder
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
package org.x4o.xml.element;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
|
@ -33,35 +33,38 @@ import java.util.List;
|
|||
* @version 1.0 Jan 19, 2012
|
||||
*/
|
||||
public interface ElementClassBase extends ElementMetaBase {
|
||||
|
||||
|
||||
List<ElementConfigurator> getElementConfigurators();
|
||||
|
||||
void addElementConfigurators(ElementConfigurator elementConfigurator);
|
||||
|
||||
|
||||
Collection<ElementClassAttribute> getElementClassAttributes();
|
||||
|
||||
ElementClassAttribute getElementClassAttributeByName(String attributeName);
|
||||
|
||||
void addElementClassAttribute(ElementClassAttribute elementClassAttribute);
|
||||
|
||||
|
||||
/**
|
||||
* Add an parent element tag.
|
||||
* Used: for xsd/doc only.
|
||||
* Add an parent element tag. Used: for xsd/doc only.
|
||||
*
|
||||
* @param namespaceUri The namespace uri of this tag relation.
|
||||
* @param tag The parent element tag.
|
||||
* @param tag The parent element tag.
|
||||
*/
|
||||
void addElementParent(String namespaceUri,String tag);
|
||||
|
||||
void addElementParent(String namespaceUri, String tag);
|
||||
|
||||
/**
|
||||
* Remove and parent element
|
||||
* Used: for xsd/doc only.
|
||||
* Remove and parent element Used: for xsd/doc only.
|
||||
*
|
||||
* @param namespaceUri The namespace uri of this tag relation.
|
||||
* @param tag The parent element tag.
|
||||
* @param tag The parent element tag.
|
||||
*/
|
||||
void removeElementParent(String namespaceUri,String tag);
|
||||
|
||||
void removeElementParent(String namespaceUri, String tag);
|
||||
|
||||
/**
|
||||
* Returns list of parent element tags.
|
||||
* Used: for xsd/doc only.
|
||||
* Returns list of parent element tags. Used: for xsd/doc only.
|
||||
*
|
||||
* @param namespaceUri The namespace uri of this tag relation.
|
||||
* @return The list of tags.
|
||||
* @return The list of tags.
|
||||
*/
|
||||
List<String> getElementParents(String namespaceUri);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
|
||||
package org.x4o.xml.element;
|
||||
|
||||
/**
|
||||
* Provides an Interface to configure Element(Object).
|
||||
|
|
@ -31,19 +30,20 @@ package org.x4o.xml.element;
|
|||
* @version 1.0 Jan 18, 2007
|
||||
*/
|
||||
public interface ElementConfigurator extends ElementMetaBase {
|
||||
|
||||
|
||||
/**
|
||||
* Gets called for configuring the given Element.
|
||||
* @param element The element to config.
|
||||
* @throws ElementConfiguratorException Is thrown which error is done.
|
||||
*
|
||||
* @param element The element to config.
|
||||
* @throws ElementConfiguratorException Is thrown which error is done.
|
||||
*/
|
||||
void doConfigElement(Element element) throws ElementConfiguratorException;
|
||||
|
||||
|
||||
/**
|
||||
* Return if this ElementConfigurator is an Action.
|
||||
* which means is is executed in the runPhase in the end.
|
||||
* So all magic is done, and we can access the fully finnisched object and toss it around.
|
||||
* @return Returns true if need to run in config phase.
|
||||
* Return if this ElementConfigurator is an Action. which means is is executed in the runPhase in the end. So all magic is done, and we can access the fully
|
||||
* finnisched object and toss it around.
|
||||
*
|
||||
* @return Returns true if need to run in config phase.
|
||||
*/
|
||||
boolean isConfigAction();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
|
||||
package org.x4o.xml.element;
|
||||
|
||||
/**
|
||||
* ElementConfiguratorException.<br>
|
||||
|
|
@ -31,44 +30,48 @@ package org.x4o.xml.element;
|
|||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ElementConfiguratorException extends ElementException {
|
||||
|
||||
|
||||
private ElementConfigurator elementConfigurator = null;
|
||||
|
||||
|
||||
/**
|
||||
* Creates an configurator exception.
|
||||
* @param config The ElementConfigurator.
|
||||
* @param message The error message.
|
||||
*
|
||||
* @param config The ElementConfigurator.
|
||||
* @param message The error message.
|
||||
*/
|
||||
public ElementConfiguratorException(ElementConfigurator config,String message) {
|
||||
public ElementConfiguratorException(ElementConfigurator config, String message) {
|
||||
super(message);
|
||||
this.elementConfigurator=config;
|
||||
this.elementConfigurator = config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates an configurator exception.
|
||||
* @param config The ElementConfigurator.
|
||||
* @param message The error message.
|
||||
* @param exception The error exception.
|
||||
*
|
||||
* @param config The ElementConfigurator.
|
||||
* @param message The error message.
|
||||
* @param exception The error exception.
|
||||
*/
|
||||
public ElementConfiguratorException(ElementConfigurator config,String message,Exception exception) {
|
||||
super(message,exception);
|
||||
this.elementConfigurator=config;
|
||||
public ElementConfiguratorException(ElementConfigurator config, String message, Exception exception) {
|
||||
super(message, exception);
|
||||
this.elementConfigurator = config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates an configurator exception.
|
||||
* @param config The ElementConfigurator.
|
||||
* @param message The error message.
|
||||
* @param exception The wrapped element error exception.
|
||||
*
|
||||
* @param config The ElementConfigurator.
|
||||
* @param message The error message.
|
||||
* @param exception The wrapped element error exception.
|
||||
*/
|
||||
public ElementConfiguratorException(ElementConfigurator config,String message,ElementException exception) {
|
||||
super(message,exception);
|
||||
this.elementConfigurator=config;
|
||||
public ElementConfiguratorException(ElementConfigurator config, String message, ElementException exception) {
|
||||
super(message, exception);
|
||||
this.elementConfigurator = config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the ElementConfigurator which has thrown this exception.
|
||||
* @return The ElementConfigurator.
|
||||
*
|
||||
* @return The ElementConfigurator.
|
||||
*/
|
||||
public ElementConfigurator getElementConfigurator() {
|
||||
return elementConfigurator;
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
|
||||
package org.x4o.xml.element;
|
||||
|
||||
/**
|
||||
* Provides an Interface to configure Element(Object) global.
|
||||
|
|
@ -30,5 +29,5 @@ package org.x4o.xml.element;
|
|||
* @version 1.0 Nov 18, 2012
|
||||
*/
|
||||
public interface ElementConfiguratorGlobal extends ElementConfigurator {
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
package org.x4o.xml.element;
|
||||
|
||||
/**
|
||||
* Is throw when there is en Exception within an Element.
|
||||
|
|
@ -29,7 +29,7 @@ package org.x4o.xml.element;
|
|||
* @version 1.0 Aug 8, 2005
|
||||
*/
|
||||
public class ElementException extends Exception {
|
||||
|
||||
|
||||
/** The serial version uid */
|
||||
static final long serialVersionUID = 10L;
|
||||
|
||||
|
|
@ -42,26 +42,29 @@ public class ElementException extends Exception {
|
|||
|
||||
/**
|
||||
* Constructs an ElementException with a detail message.
|
||||
* @param message The message of this Exception
|
||||
*
|
||||
* @param message The message of this Exception
|
||||
*/
|
||||
public ElementException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates an ElementException from a parent exception.
|
||||
* @param e The error exception.
|
||||
*
|
||||
* @param e The error exception.
|
||||
*/
|
||||
public ElementException(Exception e) {
|
||||
super(e);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs an ElementException with a detail message.
|
||||
* @param message The message of this Exception
|
||||
* @param e The error exception.
|
||||
*
|
||||
* @param message The message of this Exception
|
||||
* @param e The error exception.
|
||||
*/
|
||||
public ElementException(String message,Exception e) {
|
||||
super(message,e);
|
||||
public ElementException(String message, Exception e) {
|
||||
super(message, e);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
package org.x4o.xml.element;
|
||||
|
||||
/**
|
||||
* Defines an ElementInterface.
|
||||
|
|
@ -29,15 +29,17 @@ package org.x4o.xml.element;
|
|||
* @version 1.0 Apr 15, 2008
|
||||
*/
|
||||
public interface ElementInterface extends ElementClassBase {
|
||||
|
||||
|
||||
/**
|
||||
* Gets this class of the interface to match this converters/etc/ to.
|
||||
*
|
||||
* @return the tag.
|
||||
*/
|
||||
Class<?> getInterfaceClass();
|
||||
|
||||
|
||||
/**
|
||||
* Sets the interface class.
|
||||
*
|
||||
* @param interfaceClass the interfaceClass to set.
|
||||
*/
|
||||
void setInterfaceClass(Class<?> interfaceClass);
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
|
||||
package org.x4o.xml.element;
|
||||
|
||||
/**
|
||||
* ElementMetaBase provides a base interface describe meta information.
|
||||
|
|
@ -31,28 +30,32 @@ package org.x4o.xml.element;
|
|||
* @version 1.0 Jan 13, 2009
|
||||
*/
|
||||
public interface ElementMetaBase {
|
||||
|
||||
|
||||
/**
|
||||
* Sets the id of the ElementMetaBase.
|
||||
* @param id The id to set.
|
||||
*
|
||||
* @param id The id to set.
|
||||
*/
|
||||
void setId(String id);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the id of the ElementMetaBase.
|
||||
* @return Returns the id.
|
||||
*
|
||||
* @return Returns the id.
|
||||
*/
|
||||
String getId();
|
||||
|
||||
|
||||
/**
|
||||
* Sets the description of the ElementMetaBase.
|
||||
* @param description The description to set.
|
||||
*
|
||||
* @param description The description to set.
|
||||
*/
|
||||
void setDescription(String description);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the description of the ElementMetaBase.
|
||||
* @return Returns the description.
|
||||
*
|
||||
* @return Returns the description.
|
||||
*/
|
||||
String getDescription();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,50 +31,57 @@ import java.util.List;
|
|||
* @version 1.0 Oct 28, 2009
|
||||
*/
|
||||
public interface ElementNamespace extends ElementMetaBase {
|
||||
|
||||
|
||||
/**
|
||||
* Sets the prefix mapping.
|
||||
* @param prefixMapping The prefix mapping to set.
|
||||
*
|
||||
* @param prefixMapping The prefix mapping to set.
|
||||
*/
|
||||
void setPrefixMapping(String prefixMapping);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the set prefix mapping of this namespace.
|
||||
*
|
||||
* @return Returns the prefix mapping.
|
||||
*/
|
||||
String getPrefixMapping();
|
||||
|
||||
|
||||
/**
|
||||
* Sets the elememen instance provider which creates the elements objects.
|
||||
* @param elementNamespaceInstanceProvider The ElementNamespaceInstanceProvider to set.
|
||||
*
|
||||
* @param elementNamespaceInstanceProvider The ElementNamespaceInstanceProvider to set.
|
||||
*/
|
||||
void setElementNamespaceInstanceProvider(ElementNamespaceInstanceProvider elementNamespaceInstanceProvider);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the ElementProvider.
|
||||
* @return Returns the ElementNamespaceInstanceProvider for this namespace.
|
||||
*
|
||||
* @return Returns the ElementNamespaceInstanceProvider for this namespace.
|
||||
*/
|
||||
ElementNamespaceInstanceProvider getElementNamespaceInstanceProvider();
|
||||
|
||||
|
||||
/**
|
||||
* Adds an ElementClass.
|
||||
* @param elementClass The elementClass to add to this context.
|
||||
*
|
||||
* @param elementClass The elementClass to add to this context.
|
||||
*/
|
||||
void addElementClass(ElementClass elementClass);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the ElementClass for an namespace and tag.
|
||||
* @param tag The tag to get the ElementClass for.
|
||||
* @return Returns the ElementClass for a tag in an namespace.
|
||||
*
|
||||
* @param tag The tag to get the ElementClass for.
|
||||
* @return Returns the ElementClass for a tag in an namespace.
|
||||
*/
|
||||
ElementClass getElementClass(String tag);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the loaded ElementClass'es in an namespace in this context.
|
||||
* @return Returns all ElementClasses handled by this namespace.
|
||||
*
|
||||
* @return Returns all ElementClasses handled by this namespace.
|
||||
*/
|
||||
List<ElementClass> getElementClasses();
|
||||
|
||||
|
||||
/**
|
||||
* @return the uri of this namespace.
|
||||
*/
|
||||
|
|
@ -114,7 +121,7 @@ public interface ElementNamespace extends ElementMetaBase {
|
|||
* @param schemaResource the schemaResource to set.
|
||||
*/
|
||||
void setSchemaResource(String schemaResource);
|
||||
|
||||
|
||||
/**
|
||||
* @return the description.
|
||||
*/
|
||||
|
|
@ -124,7 +131,7 @@ public interface ElementNamespace extends ElementMetaBase {
|
|||
* @param description the description to set.
|
||||
*/
|
||||
void setDescription(String description);
|
||||
|
||||
|
||||
/**
|
||||
* @return the languageRoot
|
||||
*/
|
||||
|
|
@ -134,7 +141,7 @@ public interface ElementNamespace extends ElementMetaBase {
|
|||
* @param languageRoot the languageRoot to set
|
||||
*/
|
||||
void setLanguageRoot(Boolean languageRoot);
|
||||
|
||||
|
||||
/**
|
||||
* @return the schemaPrefix
|
||||
*/
|
||||
|
|
@ -144,15 +151,17 @@ public interface ElementNamespace extends ElementMetaBase {
|
|||
* @param schemaPrefix the schemaPrefix to set
|
||||
*/
|
||||
void setSchemaPrefix(String schemaPrefix);
|
||||
|
||||
|
||||
/**
|
||||
* Adds an ElementNamespaceAttribute.
|
||||
* @param elementNamespaceAttribute Adds an ElementNamespaceAttribute.
|
||||
*
|
||||
* @param elementNamespaceAttribute Adds an ElementNamespaceAttribute.
|
||||
*/
|
||||
void addElementNamespaceAttribute(ElementNamespaceAttribute elementNamespaceAttribute);
|
||||
|
||||
/**
|
||||
* Geta All ElementNamespaceAttributes.
|
||||
*
|
||||
* @return Returns an List of ElementNamespaceAttributes.
|
||||
*/
|
||||
List<ElementNamespaceAttribute> getElementNamespaceAttributes();
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
package org.x4o.xml.element;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -31,35 +31,39 @@ import java.util.List;
|
|||
* @version 1.0 Aug 20, 2005
|
||||
*/
|
||||
public interface ElementNamespaceAttribute extends ElementConfigurator {
|
||||
|
||||
|
||||
/**
|
||||
* Gets the attribute name this attribute handler handles.
|
||||
* @return Returns the attributes name of this attribute handler.
|
||||
*
|
||||
* @return Returns the attributes name of this attribute handler.
|
||||
*/
|
||||
String getAttributeName();
|
||||
|
||||
|
||||
/**
|
||||
* Sets the attribute name this attribute handler handles.
|
||||
* @param attributeName The attribute to handle.
|
||||
*
|
||||
* @param attributeName The attribute to handle.
|
||||
*/
|
||||
void setAttributeName(String attributeName);
|
||||
|
||||
|
||||
/**
|
||||
* Adds an NextAttribute.
|
||||
* There next attributes will defines the order in which the ElementNamespaceAttribute are executed.
|
||||
* @param attribute Add attribute which be will processed after this one.
|
||||
* Adds an NextAttribute. There next attributes will defines the order in which the ElementNamespaceAttribute are executed.
|
||||
*
|
||||
* @param attribute Add attribute which be will processed after this one.
|
||||
*/
|
||||
void addNextAttribute(String attribute);
|
||||
|
||||
/**
|
||||
* Removes an next attribute.
|
||||
* @param attribute Removes this next attribute.
|
||||
*
|
||||
* @param attribute Removes this next attribute.
|
||||
*/
|
||||
void removeNextAttribute(String attribute);
|
||||
|
||||
void removeNextAttribute(String attribute);
|
||||
|
||||
/**
|
||||
* Get all next attributes.
|
||||
* @return Returns the list of all next attributes.
|
||||
*
|
||||
* @return Returns the list of all next attributes.
|
||||
*/
|
||||
List<String> getNextAttributes();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,21 +32,23 @@ import org.x4o.xml.lang.X4OLanguage;
|
|||
* @version 1.0 Jul 8, 2006
|
||||
*/
|
||||
public interface ElementNamespaceInstanceProvider {
|
||||
|
||||
|
||||
/**
|
||||
* Starts the ElementProvider.
|
||||
* @param language The X4OLanguage to start in.
|
||||
*
|
||||
* @param language The X4OLanguage to start in.
|
||||
* @param elementNamespace The elementNamespace to start for.
|
||||
* @throws ElementNamespaceInstanceProviderException Thrown when error happened in language.
|
||||
* @throws ElementNamespaceInstanceProviderException Thrown when error happened in language.
|
||||
*/
|
||||
void start(X4OLanguage language,ElementNamespace elementNamespace) throws ElementNamespaceInstanceProviderException;
|
||||
|
||||
void start(X4OLanguage language, ElementNamespace elementNamespace) throws ElementNamespaceInstanceProviderException;
|
||||
|
||||
/**
|
||||
* Provide an Element for an xml tag.
|
||||
*
|
||||
* @param languageSession The languageSession to create element for.
|
||||
* @param tag The xml tag to create instance for.
|
||||
* @param tag The xml tag to create instance for.
|
||||
* @return An new Element instance.
|
||||
* @throws ElementNamespaceInstanceProviderException Thrown when error happened in language.
|
||||
* @throws ElementNamespaceInstanceProviderException Thrown when error happened in language.
|
||||
*/
|
||||
Element createElementInstance(X4OLanguageSession languageSession,String tag) throws ElementNamespaceInstanceProviderException;
|
||||
Element createElementInstance(X4OLanguageSession languageSession, String tag) throws ElementNamespaceInstanceProviderException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
|
||||
package org.x4o.xml.element;
|
||||
|
||||
/**
|
||||
* ElementNamespaceInstanceProviderException holds the ElementNamespaceInstanceProvider which created this Exception.<br>
|
||||
|
|
@ -31,33 +30,36 @@ package org.x4o.xml.element;
|
|||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ElementNamespaceInstanceProviderException extends ElementException {
|
||||
|
||||
|
||||
private ElementNamespaceInstanceProvider elementNamespaceInstanceProvider = null;
|
||||
|
||||
|
||||
/**
|
||||
* Creates provider instance exception.
|
||||
* @param elementNamespaceInstanceProvider The provider which creates this exception.
|
||||
* @param message The message of this exception.
|
||||
* 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);
|
||||
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.
|
||||
* Creates provider instance exception.
|
||||
*
|
||||
* @param elementNamespaceInstanceProvider The provider which creates this exception.
|
||||
* @param message The message of this exception.
|
||||
* @param exception The root cause of this exception.
|
||||
*/
|
||||
public ElementNamespaceInstanceProviderException(ElementNamespaceInstanceProvider elementNamespaceInstanceProvider,String message,Exception exception) {
|
||||
super(message,exception);
|
||||
this.elementNamespaceInstanceProvider=elementNamespaceInstanceProvider;
|
||||
public ElementNamespaceInstanceProviderException(ElementNamespaceInstanceProvider elementNamespaceInstanceProvider, String message, Exception exception) {
|
||||
super(message, exception);
|
||||
this.elementNamespaceInstanceProvider = elementNamespaceInstanceProvider;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the ElementNamespaceInstanceProvider which created this exception.
|
||||
* @return The provider which created the exception.
|
||||
*
|
||||
* @return The provider which created the exception.
|
||||
*/
|
||||
public ElementNamespaceInstanceProvider getElementNamespaceInstanceProvider() {
|
||||
return elementNamespaceInstanceProvider;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
package org.x4o.xml.element;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -34,27 +34,30 @@ public interface ElementObjectPropertyValue {
|
|||
|
||||
/**
|
||||
* Sets an bean property of the object.
|
||||
*
|
||||
* @param object
|
||||
* @param propertyName
|
||||
* @param value
|
||||
* @throws ElementObjectPropertyValueException
|
||||
*/
|
||||
void setProperty(Object object,String propertyName,Object value) throws ElementObjectPropertyValueException;
|
||||
|
||||
void setProperty(Object object, String propertyName, Object value) throws ElementObjectPropertyValueException;
|
||||
|
||||
/**
|
||||
* Get the value of a properterie of a bean,
|
||||
* @param object The object to get the properties from
|
||||
* @param propertyName The name of the property to get.
|
||||
* @return Returns the value of the property.
|
||||
*
|
||||
* @param object The object to get the properties from
|
||||
* @param propertyName The name of the property to get.
|
||||
* @return Returns the value of the property.
|
||||
* @throws ElementObjectPropertyValueException
|
||||
*/
|
||||
Object getProperty(Object object,String propertyName) throws ElementObjectPropertyValueException;
|
||||
|
||||
Object getProperty(Object object, String propertyName) throws ElementObjectPropertyValueException;
|
||||
|
||||
/**
|
||||
* Sets all bean properties.
|
||||
* @param object To object to set all the properties to.
|
||||
* @param propertyMap A Map with the keys as properties names and the valua as value to set.
|
||||
*
|
||||
* @param object To object to set all the properties to.
|
||||
* @param propertyMap A Map with the keys as properties names and the valua as value to set.
|
||||
* @throws ElementObjectPropertyValueException
|
||||
*/
|
||||
void setPropertyMap(Object object,Map<String,Object> propertyMap) throws ElementObjectPropertyValueException;
|
||||
void setPropertyMap(Object object, Map<String, Object> propertyMap) throws ElementObjectPropertyValueException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.element;
|
||||
|
||||
package org.x4o.xml.element;
|
||||
|
||||
/**
|
||||
* ElementObjectPropertyValueException.<br>
|
||||
|
|
@ -36,18 +35,20 @@ public class ElementObjectPropertyValueException extends ElementException {
|
|||
|
||||
/**
|
||||
* Creates ElementObjectPropertyValueException with message.
|
||||
* @param message The error message.
|
||||
*
|
||||
* @param message The error message.
|
||||
*/
|
||||
public ElementObjectPropertyValueException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates ElementObjectPropertyValueException with message and exception.
|
||||
* @param message The error message.
|
||||
* @param exception The error exception.
|
||||
*
|
||||
* @param message The error message.
|
||||
* @param exception The error exception.
|
||||
*/
|
||||
public ElementObjectPropertyValueException(String message,Exception exception) {
|
||||
super(message,exception);
|
||||
public ElementObjectPropertyValueException(String message, Exception exception) {
|
||||
super(message, exception);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,11 +37,11 @@ import org.x4o.xml.lang.X4OLanguageSession;
|
|||
* @version 1.0 Apr 6, 2013
|
||||
*/
|
||||
public abstract class AbstractX4OConnection extends AbstractX4OConnectionDebug {
|
||||
|
||||
|
||||
private final X4OLanguage language;
|
||||
protected String phaseStop = null;
|
||||
protected List<String> phaseSkip = null;
|
||||
|
||||
|
||||
public AbstractX4OConnection(X4OLanguage language) {
|
||||
if (language == null) {
|
||||
throw new NullPointerException("Can't create X4O connection for null language.");
|
||||
|
|
@ -49,44 +49,45 @@ public abstract class AbstractX4OConnection extends AbstractX4OConnectionDebug {
|
|||
this.language = language;
|
||||
this.phaseSkip = new ArrayList<String>(2);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final X4OLanguage getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final X4OLanguageSession createLanguageSession() {
|
||||
return language.createLanguageSession();
|
||||
}
|
||||
|
||||
|
||||
abstract SAX3PropertyConfig getPropertyConfig();
|
||||
|
||||
|
||||
/**
|
||||
* Sets an X4O Language property.
|
||||
* @param key The key of the property to set.
|
||||
* @param value The vlue of the property to set.
|
||||
*
|
||||
* @param key The key of the property to set.
|
||||
* @param value The vlue of the property to set.
|
||||
*/
|
||||
@Override
|
||||
public final void setProperty(String key,Object value) {
|
||||
public final void setProperty(String key, Object value) {
|
||||
getPropertyConfig().setProperty(key, value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final Object getProperty(String key) {
|
||||
return getPropertyConfig().getProperty(key);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final Collection<String> getPropertyKeys() {
|
||||
return getPropertyConfig().getPropertyKeys();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final void setPhaseStop(String phaseId) {
|
||||
phaseStop = phaseId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final void addPhaseSkip(String phaseId) {
|
||||
phaseSkip.add(phaseId);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@ public abstract class AbstractX4OConnectionDebug implements X4OConnection {
|
|||
protected final static String ABSTRACT_DEBUG_OUTPUT_HANDLER = "debug/output-handler";
|
||||
protected final static String ABSTRACT_DEBUG_OUTPUT_STREAM = "debug/output-stream";
|
||||
|
||||
protected void debugStart(X4OLanguageSession languageSession, String debugHandlerKey, String debugStreamKey) throws UnsupportedEncodingException, SAXException {
|
||||
protected void debugStart(X4OLanguageSession languageSession, String debugHandlerKey, String debugStreamKey)
|
||||
throws UnsupportedEncodingException, SAXException {
|
||||
Object debugOutputHandler = getProperty(debugHandlerKey);
|
||||
Object debugOutputStream = getProperty(debugStreamKey);
|
||||
// init debug infra
|
||||
|
|
|
|||
|
|
@ -120,8 +120,7 @@ abstract public class AbstractX4OReader<T> extends AbstractX4OReaderSession<T> i
|
|||
}
|
||||
|
||||
/**
|
||||
* Fetched the data direct from remote url to a InputStream to is can me readd
|
||||
* by SAX.
|
||||
* Fetched the data direct from remote url to a InputStream to is can me readd by SAX.
|
||||
*
|
||||
* @param url The url to read.
|
||||
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||
|
|
|
|||
|
|
@ -34,16 +34,16 @@ public class DefaultX4ODriver<T> extends X4ODriver<T> {
|
|||
|
||||
private final String languageName;
|
||||
private final String languageVersion;
|
||||
|
||||
|
||||
public DefaultX4ODriver(String languageName) {
|
||||
this(languageName,X4ODriver.DEFAULT_LANGUAGE_VERSION);
|
||||
this(languageName, X4ODriver.DEFAULT_LANGUAGE_VERSION);
|
||||
}
|
||||
|
||||
public DefaultX4ODriver(String languageName,String languageVersion) {
|
||||
this.languageName=languageName;
|
||||
this.languageVersion=languageVersion;
|
||||
|
||||
public DefaultX4ODriver(String languageName, String languageVersion) {
|
||||
this.languageName = languageName;
|
||||
this.languageVersion = languageVersion;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getLanguageName() {
|
||||
return languageName;
|
||||
|
|
@ -51,6 +51,6 @@ public class DefaultX4ODriver<T> extends X4ODriver<T> {
|
|||
|
||||
@Override
|
||||
public String[] getLanguageVersions() {
|
||||
return new String[]{languageVersion};
|
||||
return new String[] { languageVersion };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,10 +55,11 @@ import org.xml.sax.SAXException;
|
|||
* @param <T> The root element object type.
|
||||
*/
|
||||
public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
|
||||
|
||||
|
||||
private final SAX3PropertyConfig propertyConfig;
|
||||
private final Map<String, Object> elBeans = new HashMap<>();
|
||||
|
||||
|
||||
//@formatter:off
|
||||
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"reader/x4o/";
|
||||
public final static SAX3PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
||||
public final static String SAX_ERROR_HANDLER = PROPERTY_CONTEXT_PREFIX + "sax/error-handler";
|
||||
|
|
@ -96,12 +97,13 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
|
|||
new PropertyConfigItem(DEBUG_OUTPUT_STREAM,OutputStream.class)
|
||||
);
|
||||
}
|
||||
|
||||
//@formatter:on
|
||||
|
||||
public DefaultX4OReader(X4OLanguage language) {
|
||||
super(language);
|
||||
propertyConfig = new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG, PROPERTY_CONTEXT_PREFIX);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.io.AbstractX4OConnection#getPropertyConfig()
|
||||
*/
|
||||
|
|
@ -109,20 +111,22 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
|
|||
public SAX3PropertyConfig getPropertyConfig() {
|
||||
return propertyConfig;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readSession(X4OLanguageSession languageSession, InputStream input, String systemId, URL basePath) throws X4OConnectionException, SAXException, IOException {
|
||||
public void readSession(X4OLanguageSession languageSession, InputStream input, String systemId, URL basePath)
|
||||
throws X4OConnectionException, SAXException, IOException {
|
||||
setProperty(INPUT_STREAM, input);
|
||||
setProperty(INPUT_SYSTEM_ID, systemId);
|
||||
setProperty(INPUT_BASE_PATH, basePath);
|
||||
for (String name : elBeans.keySet()) {
|
||||
Object bean = elBeans.get(name);
|
||||
ValueExpression ve = languageSession.getExpressionLanguageFactory().createValueExpression(languageSession.getExpressionLanguageContext(),"${"+name+"}", bean.getClass());
|
||||
ValueExpression ve = languageSession.getExpressionLanguageFactory().createValueExpression(languageSession.getExpressionLanguageContext(),
|
||||
"${" + name + "}", bean.getClass());
|
||||
ve.setValue(languageSession.getExpressionLanguageContext(), bean);
|
||||
}
|
||||
readSession(languageSession);
|
||||
}
|
||||
|
||||
|
||||
public void addELBeanInstance(String name, Object bean) {
|
||||
if (name == null) {
|
||||
throw new NullPointerException("Can't add null name.");
|
||||
|
|
@ -135,19 +139,19 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
|
|||
}
|
||||
elBeans.put(name, bean);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parses the input stream as a X4O document.
|
||||
*/
|
||||
protected void readSession(X4OLanguageSession languageSession) throws X4OConnectionException, SAXException, IOException {
|
||||
// Extra check if we have a language
|
||||
if (languageSession.getLanguage() == null) {
|
||||
throw new X4OConnectionException("languageSession is broken getLanguage() returns null.");
|
||||
throw new X4OConnectionException("languageSession is broken getLanguage() returns null.");
|
||||
}
|
||||
|
||||
|
||||
// Insert stop/skip phase if we allowed to. TODO: move layer ?
|
||||
if (languageSession instanceof X4OLanguageSessionLocal) {
|
||||
X4OLanguageSessionLocal ll = (X4OLanguageSessionLocal)languageSession;
|
||||
X4OLanguageSessionLocal ll = (X4OLanguageSessionLocal) languageSession;
|
||||
if (phaseStop != null) {
|
||||
ll.setPhaseStop(phaseStop);
|
||||
}
|
||||
|
|
@ -155,39 +159,39 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
|
|||
ll.addPhaseSkip(phaseId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// init debug
|
||||
debugStart(languageSession, DEBUG_OUTPUT_HANDLER, DEBUG_OUTPUT_STREAM);
|
||||
|
||||
|
||||
try {
|
||||
// Run init (auto once)
|
||||
X4OLanguageLocal.class.cast(languageSession.getLanguage()).init(languageSession);
|
||||
|
||||
|
||||
// Run document parsing
|
||||
X4OContentParser parser = new X4OContentParser(propertyConfig);
|
||||
parser.parse(languageSession);
|
||||
|
||||
|
||||
// Run phases to build object tree
|
||||
getLanguage().getPhaseManager().runPhases(languageSession, X4OPhaseType.XML_READ);
|
||||
} catch (Exception e) {
|
||||
// also debug exceptions
|
||||
debugException(languageSession, e);
|
||||
|
||||
// unwrap exception
|
||||
|
||||
// unwrap exception
|
||||
// TODO: cleanup exceptions a bit more see X4OConnectionException
|
||||
if (e.getCause() instanceof ParserConfigurationException) {
|
||||
throw new X4OConnectionException((ParserConfigurationException)e.getCause());
|
||||
throw new X4OConnectionException((ParserConfigurationException) e.getCause());
|
||||
}
|
||||
if (e.getCause() instanceof SAXException) {
|
||||
throw (SAXException)e.getCause();
|
||||
throw (SAXException) e.getCause();
|
||||
}
|
||||
if (e.getCause() instanceof IOException) {
|
||||
throw (IOException)e.getCause();
|
||||
throw (IOException) e.getCause();
|
||||
}
|
||||
if (e.getCause()==null) {
|
||||
if (e.getCause() == null) {
|
||||
throw new SAXException(e);
|
||||
} else {
|
||||
throw new SAXException((Exception)e.getCause());
|
||||
throw new SAXException((Exception) e.getCause());
|
||||
}
|
||||
} finally {
|
||||
debugStop(languageSession);
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
|
|||
private boolean schemaUriPrint;
|
||||
private String schemaUriRoot;
|
||||
|
||||
//@formatter:off
|
||||
private final static AttributeEntryComparator ATTR_ENTRY_COMPARATOR = new AttributeEntryComparator();
|
||||
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"writer/x4o/";
|
||||
public final static SAX3PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
||||
|
|
@ -88,6 +89,7 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
|
|||
new PropertyConfigItem(DEBUG_OUTPUT_STREAM,OutputStream.class)
|
||||
);
|
||||
}
|
||||
//@formatter:on
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
|
|
|
|||
|
|
@ -34,23 +34,24 @@ import org.x4o.xml.lang.X4OLanguageSession;
|
|||
* @version 1.0 Apr 6, 2013
|
||||
*/
|
||||
public interface X4OConnection {
|
||||
|
||||
|
||||
X4OLanguage getLanguage();
|
||||
|
||||
|
||||
X4OLanguageSession createLanguageSession();
|
||||
|
||||
|
||||
/**
|
||||
* Sets an X4O Language property.
|
||||
* @param key The key of the property to set.
|
||||
* @param value The value of the property to set.
|
||||
*
|
||||
* @param key The key of the property to set.
|
||||
* @param value The value of the property to set.
|
||||
*/
|
||||
void setProperty(String key, Object value);
|
||||
|
||||
|
||||
Object getProperty(String key);
|
||||
|
||||
|
||||
Collection<String> getPropertyKeys();
|
||||
|
||||
|
||||
void setPhaseStop(String phaseId);
|
||||
|
||||
|
||||
void addPhaseSkip(String phaseId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.x4o.xml.io;
|
||||
package org.x4o.xml.io;
|
||||
|
||||
/**
|
||||
* X4OConnectionException is top level exception for io connections.
|
||||
|
|
@ -29,7 +29,7 @@ package org.x4o.xml.io;
|
|||
* @version 1.0 28 Apr, 2013
|
||||
*/
|
||||
public class X4OConnectionException extends Exception {
|
||||
|
||||
|
||||
/** The serial version uid */
|
||||
static final long serialVersionUID = 10L;
|
||||
|
||||
|
|
@ -42,26 +42,29 @@ public class X4OConnectionException extends Exception {
|
|||
|
||||
/**
|
||||
* Constructs an X4OConnectionException with a detail message.
|
||||
* @param message The message of this Exception
|
||||
*
|
||||
* @param message The message of this Exception
|
||||
*/
|
||||
public X4OConnectionException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates an X4OConnectionException from a parent exception.
|
||||
* @param e The error exception.
|
||||
*
|
||||
* @param e The error exception.
|
||||
*/
|
||||
public X4OConnectionException(Exception e) {
|
||||
super(e);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs an X4OConnectionException with a detail message.
|
||||
* @param message The message of this Exception
|
||||
* @param e The error exception.
|
||||
*
|
||||
* @param message The message of this Exception
|
||||
* @param e The error exception.
|
||||
*/
|
||||
public X4OConnectionException(String message,Exception e) {
|
||||
super(message,e);
|
||||
public X4OConnectionException(String message, Exception e) {
|
||||
super(message, e);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,33 +48,32 @@ import java.util.logging.Logger;
|
|||
* @version 1.0 Aug 20, 2005
|
||||
*/
|
||||
public class X4OContentHandler extends DefaultHandler2 {
|
||||
|
||||
|
||||
/** The logger to log to */
|
||||
private Logger logger = null;
|
||||
private boolean loggerFinest = false;
|
||||
|
||||
|
||||
/** The Locator for parse errors */
|
||||
private Locator locator = null;
|
||||
|
||||
|
||||
/** The element Stack */
|
||||
private Stack<Element> elementStack = null;
|
||||
|
||||
|
||||
/** The elememtContext */
|
||||
private X4OLanguageSession elementLanguage = null;
|
||||
|
||||
|
||||
/** Store the override element */
|
||||
private Element overrideSaxElement = null;
|
||||
|
||||
|
||||
/** Store the override element handler */
|
||||
private DefaultHandler2 overrideSaxHandler = null;
|
||||
|
||||
|
||||
private final SAX3PropertyConfig propertyConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Creates an X4OTagHandler
|
||||
* which can receice sax xml events and converts them into the Element* interfaces events.
|
||||
* Creates an X4OTagHandler which can receice sax xml events and converts them into the Element* interfaces events.
|
||||
*/
|
||||
public X4OContentHandler(X4OLanguageSession elementLanguage,SAX3PropertyConfig propertyConfig) {
|
||||
public X4OContentHandler(X4OLanguageSession elementLanguage, SAX3PropertyConfig propertyConfig) {
|
||||
logger = Logger.getLogger(X4OContentHandler.class.getName());
|
||||
loggerFinest = logger.isLoggable(Level.FINEST);
|
||||
elementStack = new Stack<Element>();
|
||||
|
|
@ -87,15 +86,15 @@ public class X4OContentHandler extends DefaultHandler2 {
|
|||
*/
|
||||
@Override
|
||||
public void setDocumentLocator(Locator locator) {
|
||||
this.locator=locator;
|
||||
this.locator = locator;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.helpers.DefaultHandler#startPrefixMapping(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void startPrefixMapping(String prefix, String namespaceUri) throws SAXException {
|
||||
if (overrideSaxHandler!=null) {
|
||||
if (overrideSaxHandler != null) {
|
||||
overrideSaxHandler.startPrefixMapping(prefix, namespaceUri);
|
||||
return;
|
||||
}
|
||||
|
|
@ -106,8 +105,8 @@ public class X4OContentHandler extends DefaultHandler2 {
|
|||
return; // skip xinclude ns.
|
||||
}
|
||||
ElementNamespace enc = elementLanguage.getLanguage().findElementNamespace(namespaceUri);
|
||||
if (enc==null) {
|
||||
throw new SAXException("Can't find namespace uri: "+namespaceUri+" in language: "+elementLanguage.getLanguage().getLanguageName());
|
||||
if (enc == null) {
|
||||
throw new SAXException("Can't find namespace uri: " + namespaceUri + " in language: " + elementLanguage.getLanguage().getLanguageName());
|
||||
}
|
||||
enc.setPrefixMapping(prefix);
|
||||
}
|
||||
|
|
@ -116,41 +115,41 @@ public class X4OContentHandler extends DefaultHandler2 {
|
|||
* @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
|
||||
*/
|
||||
@Override
|
||||
public void startElement(String namespaceUri, String tag, String qName,Attributes attributes) throws SAXException {
|
||||
public void startElement(String namespaceUri, String tag, String qName, Attributes attributes) throws SAXException {
|
||||
if (loggerFinest) {
|
||||
logger.finest("XMLTAG-START: "+namespaceUri+":"+tag);
|
||||
logger.finest("XMLTAG-START: " + namespaceUri + ":" + tag);
|
||||
}
|
||||
if (overrideSaxHandler!=null) {
|
||||
if (overrideSaxHandler != null) {
|
||||
overrideSaxHandler.startElement(namespaceUri, tag, qName, attributes);
|
||||
return;
|
||||
}
|
||||
ElementNamespace enc = elementLanguage.getLanguage().findElementNamespace(namespaceUri);
|
||||
if (enc==null) {
|
||||
if (enc == null) {
|
||||
if ("".equals(namespaceUri)) {
|
||||
String configEmptryUri = propertyConfig.getPropertyString(DefaultX4OReader.DOC_EMPTY_NAMESPACE_URI);
|
||||
if (configEmptryUri!=null) {
|
||||
if (configEmptryUri != null) {
|
||||
namespaceUri = configEmptryUri;
|
||||
enc = elementLanguage.getLanguage().findElementNamespace(namespaceUri);
|
||||
}
|
||||
if (enc==null) {
|
||||
throw new SAXParseException("No ElementNamespace found for empty namespace.",locator);
|
||||
if (enc == null) {
|
||||
throw new SAXParseException("No ElementNamespace found for empty namespace.", locator);
|
||||
}
|
||||
enc.setPrefixMapping("");
|
||||
}
|
||||
if (enc==null) {
|
||||
throw new SAXParseException("No ElementProvider found for namespace: "+namespaceUri,locator);
|
||||
if (enc == null) {
|
||||
throw new SAXParseException("No ElementProvider found for namespace: " + namespaceUri, locator);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ElementNamespaceInstanceProvider eip = enc.getElementNamespaceInstanceProvider();
|
||||
Element element = null;
|
||||
try {
|
||||
element = eip.createElementInstance(elementLanguage,tag);
|
||||
element = eip.createElementInstance(elementLanguage, tag);
|
||||
} catch (Exception e) {
|
||||
throw new SAXParseException("Error while creating element: "+e.getMessage(),locator,e);
|
||||
throw new SAXParseException("Error while creating element: " + e.getMessage(), locator, e);
|
||||
}
|
||||
enc.addElementClass(element.getElementClass());
|
||||
|
||||
|
||||
// next bind them togeter.
|
||||
if (elementStack.empty()) {
|
||||
elementLanguage.setRootElement(element); // root element !!
|
||||
|
|
@ -159,32 +158,32 @@ public class X4OContentHandler extends DefaultHandler2 {
|
|||
element.setParent(parent); // set parent element
|
||||
parent.addChild(element);
|
||||
}
|
||||
|
||||
|
||||
// create attribute map
|
||||
Map<String,String> map = new AttributeMap<String,String>(attributes);
|
||||
Map<String, String> map = new AttributeMap<String, String>(attributes);
|
||||
element.getAttributes().putAll(map);
|
||||
|
||||
|
||||
elementStack.push(element);
|
||||
try {
|
||||
element.doElementStart();
|
||||
} catch (ElementException ee) {
|
||||
throw new SAXParseException("Error while configing element: "+ee.getMessage(),locator,ee);
|
||||
throw new SAXParseException("Error while configing element: " + ee.getMessage(), locator, ee);
|
||||
}
|
||||
if (ElementType.overrideSax.equals(element.getElementType())) {
|
||||
overrideSaxElement = element;
|
||||
overrideSaxHandler = (DefaultHandler2)element.getElementObject();
|
||||
overrideSaxHandler = (DefaultHandler2) element.getElementObject();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void endElement(String namespaceUri, String tag,String qName) throws SAXException {
|
||||
public void endElement(String namespaceUri, String tag, String qName) throws SAXException {
|
||||
if (loggerFinest) {
|
||||
logger.finest("XMLTAG-END: "+namespaceUri+":"+tag);
|
||||
logger.finest("XMLTAG-END: " + namespaceUri + ":" + tag);
|
||||
}
|
||||
if (overrideSaxHandler!=null) {
|
||||
if (overrideSaxHandler != null) {
|
||||
if (overrideSaxElement.getElementClass().getId().equals(tag)) {
|
||||
overrideSaxHandler.endDocument();
|
||||
overrideSaxHandler = null;
|
||||
|
|
@ -201,38 +200,37 @@ public class X4OContentHandler extends DefaultHandler2 {
|
|||
try {
|
||||
element.doElementEnd();
|
||||
} catch (ElementException ee) {
|
||||
throw new SAXParseException("Error while configing element: '"+tag+"' "+ee.getMessage(),locator,ee);
|
||||
throw new SAXParseException("Error while configing element: '" + tag + "' " + ee.getMessage(), locator, ee);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets called to pass the text between XML-tags and converts it to a String.
|
||||
* When this string is 0 length then nothing is done.
|
||||
* If there are no element on the stact noting is done.
|
||||
* Gets called to pass the text between XML-tags and converts it to a String. When this string is 0 length then nothing is done. If there are no element on
|
||||
* the stact noting is done.
|
||||
*
|
||||
* @see org.xml.sax.helpers.DefaultHandler#characters(char[],int,int)
|
||||
*/
|
||||
@Override
|
||||
public void characters(char[] ch, int start, int length) throws SAXException {
|
||||
if (overrideSaxHandler!=null) {
|
||||
if (overrideSaxHandler != null) {
|
||||
overrideSaxHandler.characters(ch, start, length);
|
||||
return;
|
||||
}
|
||||
if (length==0) {
|
||||
if (length == 0) {
|
||||
return; // no text
|
||||
}
|
||||
String text = new String(ch,start,length);
|
||||
if (text.length()==0) {
|
||||
String text = new String(ch, start, length);
|
||||
if (text.length() == 0) {
|
||||
return; // no text
|
||||
}
|
||||
if (elementStack.isEmpty()) {
|
||||
return; // no element
|
||||
return; // no element
|
||||
}
|
||||
Element e = elementStack.peek();
|
||||
try {
|
||||
e.doCharacters(text);
|
||||
} catch (ElementException ee) {
|
||||
throw new SAXParseException("Error while doCharacters element: '"+e.getElementClass().getId()+"' "+ee.getMessage(),locator,ee);
|
||||
throw new SAXParseException("Error while doCharacters element: '" + e.getElementClass().getId() + "' " + ee.getMessage(), locator, ee);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -241,23 +239,23 @@ public class X4OContentHandler extends DefaultHandler2 {
|
|||
*/
|
||||
@Override
|
||||
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
|
||||
if (overrideSaxHandler!=null) {
|
||||
if (overrideSaxHandler != null) {
|
||||
overrideSaxHandler.ignorableWhitespace(ch, start, length);
|
||||
return;
|
||||
}
|
||||
String text = new String(ch);
|
||||
text = text.substring(start, start + length);
|
||||
if (text.length()==0) {
|
||||
if (text.length() == 0) {
|
||||
return; // no text
|
||||
}
|
||||
if (elementStack.empty()) {
|
||||
return; // no element
|
||||
return; // no element
|
||||
}
|
||||
Element e = elementStack.peek();
|
||||
try {
|
||||
e.doIgnorableWhitespace(text);
|
||||
} catch (ElementException ee) {
|
||||
throw new SAXParseException("Error while doIgnorableWhitespace element: '"+e.getElementClass().getId()+"' "+ee.getMessage(),locator,ee);
|
||||
throw new SAXParseException("Error while doIgnorableWhitespace element: '" + e.getElementClass().getId() + "' " + ee.getMessage(), locator, ee);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -266,31 +264,31 @@ public class X4OContentHandler extends DefaultHandler2 {
|
|||
*/
|
||||
@Override
|
||||
public void comment(char[] ch, int start, int length) throws SAXException {
|
||||
if (overrideSaxHandler!=null) {
|
||||
if (overrideSaxHandler != null) {
|
||||
overrideSaxHandler.comment(ch, start, length);
|
||||
return;
|
||||
}
|
||||
String text = new String(ch);
|
||||
text = text.substring(start, start + length);
|
||||
if (text.length()==0) {
|
||||
if (text.length() == 0) {
|
||||
return; // no text
|
||||
}
|
||||
if (elementStack.empty()) {
|
||||
return; // no element
|
||||
return; // no element
|
||||
}
|
||||
Element e = elementStack.peek();
|
||||
try {
|
||||
e.doComment(text);
|
||||
} catch (ElementException ee) {
|
||||
throw new SAXParseException("Error while doComment element: '"+e.getElementClass().getId()+"' "+ee.getMessage(),locator,ee);
|
||||
throw new SAXParseException("Error while doComment element: '" + e.getElementClass().getId() + "' " + ee.getMessage(), locator, ee);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.helpers.DefaultHandler#processingInstruction(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void processingInstruction(String target, String data) throws SAXException {
|
||||
logger.fine("Skipping process instuctions: "+target+" data: "+data);
|
||||
logger.fine("Skipping process instuctions: " + target + " data: " + data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue