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
|
|
@ -50,21 +50,19 @@ public abstract class X4ODriver<T> {
|
||||||
/**
|
/**
|
||||||
* marker constructor.
|
* 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();
|
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();
|
abstract public String[] getLanguageVersions();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// =============== build methods to override
|
// =============== build methods to override
|
||||||
|
|
||||||
protected X4OLanguage buildLanguage(String version) {
|
protected X4OLanguage buildLanguage(String version) {
|
||||||
|
|
@ -79,8 +77,6 @@ public abstract class X4ODriver<T> {
|
||||||
return X4ODriverManager.getDefaultBuildLanguageConfiguration();
|
return X4ODriverManager.getDefaultBuildLanguageConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// =============== Reader
|
// =============== Reader
|
||||||
|
|
||||||
public X4OReader<T> createReader() {
|
public X4OReader<T> createReader() {
|
||||||
|
|
@ -99,8 +95,6 @@ public abstract class X4ODriver<T> {
|
||||||
return new DefaultX4OReader<T>(createLanguage(version));
|
return new DefaultX4OReader<T>(createLanguage(version));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// =============== Writer
|
// =============== Writer
|
||||||
|
|
||||||
public X4OWriter<T> createWriter() {
|
public X4OWriter<T> createWriter() {
|
||||||
|
|
@ -119,13 +113,12 @@ public abstract class X4ODriver<T> {
|
||||||
return new DefaultX4OWriter<T>(createLanguage(version));
|
return new DefaultX4OWriter<T>(createLanguage(version));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// =============== Language
|
// =============== Language
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the default language which is the latest version.
|
* Returns the default language which is the latest version.
|
||||||
* @return The default language version.
|
*
|
||||||
|
* @return The default language version.
|
||||||
*/
|
*/
|
||||||
final public String getLanguageVersionDefault() {
|
final public String getLanguageVersionDefault() {
|
||||||
return X4ODriverManager.getDefaultLanguageVersion(getLanguageVersions());
|
return X4ODriverManager.getDefaultLanguageVersion(getLanguageVersions());
|
||||||
|
|
@ -133,8 +126,9 @@ public abstract class X4ODriver<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the X4OLanguage for the specified version.
|
* 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) {
|
final public X4OLanguage createLanguage(String version) {
|
||||||
return buildLanguage(version);
|
return buildLanguage(version);
|
||||||
|
|
@ -142,14 +136,13 @@ public abstract class X4ODriver<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the X4OLanguage for the default version.
|
* Creates the X4OLanguage for the default version.
|
||||||
* @return The created X4OLanguage.
|
*
|
||||||
|
* @return The created X4OLanguage.
|
||||||
*/
|
*/
|
||||||
final public X4OLanguage createLanguage() {
|
final public X4OLanguage createLanguage() {
|
||||||
return buildLanguage(getLanguageVersionDefault());
|
return buildLanguage(getLanguageVersionDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// =============== Language Tasks
|
// =============== Language Tasks
|
||||||
|
|
||||||
final public X4OLanguageTask getLanguageTask(String taskId) {
|
final public X4OLanguageTask getLanguageTask(String taskId) {
|
||||||
|
|
|
||||||
|
|
@ -38,12 +38,14 @@ abstract public class AbstractObjectConverter implements ObjectConverter {
|
||||||
protected List<ObjectConverter> converters = new ArrayList<ObjectConverter>(5);
|
protected List<ObjectConverter> converters = new ArrayList<ObjectConverter>(5);
|
||||||
|
|
||||||
abstract public Object convertAfterTo(Object obj, Locale locale) throws ObjectConverterException;
|
abstract public Object convertAfterTo(Object obj, Locale locale) throws ObjectConverterException;
|
||||||
|
|
||||||
abstract public Object convertAfterBack(Object obj, Locale locale) throws ObjectConverterException;
|
abstract public Object convertAfterBack(Object obj, Locale locale) throws ObjectConverterException;
|
||||||
|
|
||||||
abstract public ObjectConverter clone() throws CloneNotSupportedException;
|
abstract public ObjectConverter clone() throws CloneNotSupportedException;
|
||||||
|
|
||||||
protected List<ObjectConverter> cloneConverters() throws CloneNotSupportedException {
|
protected List<ObjectConverter> cloneConverters() throws CloneNotSupportedException {
|
||||||
List<ObjectConverter> result = new ArrayList<ObjectConverter>(converters.size());
|
List<ObjectConverter> result = new ArrayList<ObjectConverter>(converters.size());
|
||||||
for (ObjectConverter converter:converters) {
|
for (ObjectConverter converter : converters) {
|
||||||
result.add(converter.clone());
|
result.add(converter.clone());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -54,13 +56,13 @@ abstract public class AbstractObjectConverter implements ObjectConverter {
|
||||||
*/
|
*/
|
||||||
public Object convertTo(Object obj, Locale locale) throws ObjectConverterException {
|
public Object convertTo(Object obj, Locale locale) throws ObjectConverterException {
|
||||||
if (converters.isEmpty()) {
|
if (converters.isEmpty()) {
|
||||||
return convertAfterTo(obj,locale);
|
return convertAfterTo(obj, locale);
|
||||||
}
|
}
|
||||||
Object result = null;
|
Object result = null;
|
||||||
for (ObjectConverter conv:converters) {
|
for (ObjectConverter conv : converters) {
|
||||||
result = conv.convertTo(obj, locale);
|
result = conv.convertTo(obj, locale);
|
||||||
}
|
}
|
||||||
result = convertAfterTo(obj,locale);
|
result = convertAfterTo(obj, locale);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,13 +71,13 @@ abstract public class AbstractObjectConverter implements ObjectConverter {
|
||||||
*/
|
*/
|
||||||
public Object convertBack(Object obj, Locale locale) throws ObjectConverterException {
|
public Object convertBack(Object obj, Locale locale) throws ObjectConverterException {
|
||||||
if (converters.isEmpty()) {
|
if (converters.isEmpty()) {
|
||||||
return convertAfterBack(obj,locale);
|
return convertAfterBack(obj, locale);
|
||||||
}
|
}
|
||||||
Object result = null;
|
Object result = null;
|
||||||
for (ObjectConverter conv:converters) {
|
for (ObjectConverter conv : converters) {
|
||||||
result = conv.convertBack(obj, locale);
|
result = conv.convertBack(obj, locale);
|
||||||
}
|
}
|
||||||
result = convertAfterBack(obj,locale);
|
result = convertAfterBack(obj, locale);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,16 +42,17 @@ abstract public class AbstractStringObjectConverter extends AbstractObjectConver
|
||||||
|
|
||||||
public Object convertAfterTo(Object obj, Locale locale) throws ObjectConverterException {
|
public Object convertAfterTo(Object obj, Locale locale) throws ObjectConverterException {
|
||||||
if (obj instanceof String) {
|
if (obj instanceof String) {
|
||||||
return convertStringTo((String)obj,locale);
|
return convertStringTo((String) obj, locale);
|
||||||
} else {
|
} else {
|
||||||
return convertStringTo(obj.toString(),locale);
|
return convertStringTo(obj.toString(), locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object convertAfterBack(Object obj, Locale locale) throws ObjectConverterException {
|
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 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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,18 +44,19 @@ import org.x4o.xml.conv.text.URLConverter;
|
||||||
*/
|
*/
|
||||||
public class DefaultObjectConverterProvider implements ObjectConverterProvider {
|
public class DefaultObjectConverterProvider implements ObjectConverterProvider {
|
||||||
|
|
||||||
private Map<Class<?>,ObjectConverter> converters = null;
|
private Map<Class<?>, ObjectConverter> converters = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new DefaultObjectConverterProvider.
|
* Create new DefaultObjectConverterProvider.
|
||||||
*/
|
*/
|
||||||
public DefaultObjectConverterProvider() {
|
public DefaultObjectConverterProvider() {
|
||||||
converters = new HashMap<Class<?>,ObjectConverter>(20);
|
converters = new HashMap<Class<?>, ObjectConverter>(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new DefaultObjectConverterProvider.
|
* Create new DefaultObjectConverterProvider.
|
||||||
* @param addDefaults When true do the addDefaults().
|
*
|
||||||
|
* @param addDefaults When true do the addDefaults().
|
||||||
*/
|
*/
|
||||||
public DefaultObjectConverterProvider(boolean addDefaults) {
|
public DefaultObjectConverterProvider(boolean addDefaults) {
|
||||||
this();
|
this();
|
||||||
|
|
@ -80,7 +81,7 @@ public class DefaultObjectConverterProvider implements ObjectConverterProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param converter The converter to add.
|
* @param converter The converter to add.
|
||||||
*/
|
*/
|
||||||
public void addObjectConverter(ObjectConverter converter) {
|
public void addObjectConverter(ObjectConverter converter) {
|
||||||
converters.put(converter.getObjectClassTo(), 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)
|
* @see org.x4o.xml.conv.ObjectConverterProvider#getObjectConverterForClass(java.lang.Class)
|
||||||
* @param clazz The Class to search an ObjectConverter for.
|
* @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) {
|
public ObjectConverter getObjectConverterForClass(Class<?> clazz) {
|
||||||
return converters.get(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() {
|
protected Collection<ObjectConverter> getObjectConverters() {
|
||||||
return converters.values();
|
return converters.values();
|
||||||
|
|
|
||||||
|
|
@ -32,56 +32,58 @@ import java.util.Locale;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Aug 28, 2008
|
* @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();
|
Class<?> getObjectClassTo();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the class which we can convert from.
|
* @return Returns the class which we can convert from.
|
||||||
*/
|
*/
|
||||||
Class<?> getObjectClassBack();
|
Class<?> getObjectClassBack();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert to the object.
|
* 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.
|
* @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.
|
* 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.
|
* @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();
|
List<ObjectConverter> getObjectConverters();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param converter Adds an child converter.
|
* @param converter Adds an child converter.
|
||||||
*/
|
*/
|
||||||
void addObjectConverter(ObjectConverter converter);
|
void addObjectConverter(ObjectConverter converter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param converter Removes this child converter.
|
* @param converter Removes this child converter.
|
||||||
*/
|
*/
|
||||||
void removeObjectConverter(ObjectConverter converter);
|
void removeObjectConverter(ObjectConverter converter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force impl to have public clone method.
|
* Force impl to have public clone method.
|
||||||
*
|
*
|
||||||
* @return An cloned ObjectConverter.
|
* @return An cloned ObjectConverter.
|
||||||
* @throws CloneNotSupportedException If thrown when cloning is not supported.
|
* @throws CloneNotSupportedException If thrown when cloning is not supported.
|
||||||
*/
|
*/
|
||||||
ObjectConverter clone() throws CloneNotSupportedException;
|
ObjectConverter clone() throws CloneNotSupportedException;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,27 +35,29 @@ public class ObjectConverterException extends Exception {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an ObjectConverterException.
|
* 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);
|
super(message);
|
||||||
this.converter=converter;
|
this.converter = converter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an ObjectConverterException.
|
* 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 exception The parent exception.
|
* @param message The exception message.
|
||||||
|
* @param exception The parent exception.
|
||||||
*/
|
*/
|
||||||
public ObjectConverterException(ObjectConverter converter,String message,Exception exception) {
|
public ObjectConverterException(ObjectConverter converter, String message, Exception exception) {
|
||||||
super(message,exception);
|
super(message, exception);
|
||||||
this.converter=converter;
|
this.converter = converter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the ObjectConverter of this exception.
|
* @return Returns the ObjectConverter of this exception.
|
||||||
*/
|
*/
|
||||||
public ObjectConverter getObjectConverter() {
|
public ObjectConverter getObjectConverter() {
|
||||||
return converter;
|
return converter;
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,9 @@ public interface ObjectConverterProvider {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an ObjectConvert based on the converted class result.
|
* 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);
|
ObjectConverter getObjectConverterForClass(Class<?> clazz);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
@ -35,19 +35,18 @@ import org.x4o.xml.lang.X4OLanguageClassLoader;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Aug 31, 2007
|
* @version 1.0 Aug 31, 2007
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"rawtypes","unchecked"})
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
public class EnumConverter extends AbstractStringObjectConverter {
|
public class EnumConverter extends AbstractStringObjectConverter {
|
||||||
|
|
||||||
private static final long serialVersionUID = 8860785472427794548L;
|
private static final long serialVersionUID = 8860785472427794548L;
|
||||||
|
|
||||||
|
|
||||||
private String enumClass = null;
|
private String enumClass = null;
|
||||||
|
|
||||||
|
|
||||||
private Class enumObjectClass = null;
|
private Class enumObjectClass = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the convert to class.
|
* Returns the convert to class.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
||||||
* @return The class to convert to.
|
* @return The class to convert to.
|
||||||
*/
|
*/
|
||||||
|
|
@ -59,29 +58,29 @@ public class EnumConverter extends AbstractStringObjectConverter {
|
||||||
* Converts string into object.
|
* Converts string into object.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
||||||
* @param str The string to convert to object.
|
* @param str The string to convert to object.
|
||||||
* @param locale The locale to convert the string from.
|
* @param locale The locale to convert the string from.
|
||||||
* @return The object converted from the string.
|
* @return The object converted from the string.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
||||||
if (getEnumClass()==null) {
|
if (getEnumClass() == null) {
|
||||||
throw new ObjectConverterException(this,"enumClass String attribute is not set.");
|
throw new ObjectConverterException(this, "enumClass String attribute is not set.");
|
||||||
}
|
}
|
||||||
//if (value instanceof Enum) {
|
// if (value instanceof Enum) {
|
||||||
// return value;
|
// return value;
|
||||||
//}
|
// }
|
||||||
String v = str; //value.toString();
|
String v = str; // value.toString();
|
||||||
try {
|
try {
|
||||||
if (enumObjectClass==null) {
|
if (enumObjectClass == null) {
|
||||||
enumObjectClass = (Class<?>)X4OLanguageClassLoader.loadClass(getEnumClass());
|
enumObjectClass = (Class<?>) X4OLanguageClassLoader.loadClass(getEnumClass());
|
||||||
}
|
}
|
||||||
if (enumObjectClass==null) {
|
if (enumObjectClass == null) {
|
||||||
throw new ObjectConverterException(this,"Could not load enumClass");
|
throw new ObjectConverterException(this, "Could not load enumClass");
|
||||||
}
|
}
|
||||||
return Enum.valueOf(enumObjectClass, v);
|
return Enum.valueOf(enumObjectClass, v);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ObjectConverterException(this,e.getMessage(),e);
|
throw new ObjectConverterException(this, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,13 +88,13 @@ public class EnumConverter extends AbstractStringObjectConverter {
|
||||||
* Converts object into string.
|
* Converts object into string.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
||||||
* @param obj The object to convert to string.
|
* @param obj The object to convert to string.
|
||||||
* @param locale The locale to convert the object from.
|
* @param locale The locale to convert the object from.
|
||||||
* @return The string converted from the object.
|
* @return The string converted from the object.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
|
public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException {
|
||||||
return ((Enum<?>)obj).name();
|
return ((Enum<?>) obj).name();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -105,7 +104,6 @@ public class EnumConverter extends AbstractStringObjectConverter {
|
||||||
return enumClass;
|
return enumClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param enumClass the enumClass to set
|
* @param enumClass the enumClass to set
|
||||||
*/
|
*/
|
||||||
|
|
@ -115,6 +113,7 @@ public class EnumConverter extends AbstractStringObjectConverter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone this ObjectConverter.
|
* Clone this ObjectConverter.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
||||||
* @return The cloned ObjectConverter.
|
* @return The cloned ObjectConverter.
|
||||||
* @throws CloneNotSupportedException When cloning fails.
|
* @throws CloneNotSupportedException When cloning fails.
|
||||||
|
|
@ -122,8 +121,8 @@ public class EnumConverter extends AbstractStringObjectConverter {
|
||||||
@Override
|
@Override
|
||||||
public ObjectConverter clone() throws CloneNotSupportedException {
|
public ObjectConverter clone() throws CloneNotSupportedException {
|
||||||
EnumConverter result = new EnumConverter();
|
EnumConverter result = new EnumConverter();
|
||||||
result.converters=cloneConverters();
|
result.converters = cloneConverters();
|
||||||
result.enumClass=enumClass;
|
result.enumClass = enumClass;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ public class FloatConverter extends AbstractStringObjectConverter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the convert to class.
|
* Returns the convert to class.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
||||||
* @return The class to convert to.
|
* @return The class to convert to.
|
||||||
*/
|
*/
|
||||||
|
|
@ -51,7 +52,7 @@ public class FloatConverter extends AbstractStringObjectConverter {
|
||||||
* Converts string into object.
|
* Converts string into object.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
||||||
* @param str The string to convert to object.
|
* @param str The string to convert to object.
|
||||||
* @param locale The locale to convert the string from.
|
* @param locale The locale to convert the string from.
|
||||||
* @return The object converted from the string.
|
* @return The object converted from the string.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
|
|
@ -64,17 +65,18 @@ public class FloatConverter extends AbstractStringObjectConverter {
|
||||||
* Converts object into string.
|
* Converts object into string.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
||||||
* @param obj The object to convert to string.
|
* @param obj The object to convert to string.
|
||||||
* @param locale The locale to convert the object from.
|
* @param locale The locale to convert the object from.
|
||||||
* @return The string converted from the object.
|
* @return The string converted from the object.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
|
public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException {
|
||||||
return ((Float)obj).toString();
|
return ((Float) obj).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone this ObjectConverter.
|
* Clone this ObjectConverter.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
||||||
* @return The cloned ObjectConverter.
|
* @return The cloned ObjectConverter.
|
||||||
* @throws CloneNotSupportedException When cloning fails.
|
* @throws CloneNotSupportedException When cloning fails.
|
||||||
|
|
@ -82,7 +84,7 @@ public class FloatConverter extends AbstractStringObjectConverter {
|
||||||
@Override
|
@Override
|
||||||
public ObjectConverter clone() throws CloneNotSupportedException {
|
public ObjectConverter clone() throws CloneNotSupportedException {
|
||||||
FloatConverter result = new FloatConverter();
|
FloatConverter result = new FloatConverter();
|
||||||
result.converters=cloneConverters();
|
result.converters = cloneConverters();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ public class IntegerConverter extends AbstractStringObjectConverter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the convert to class.
|
* Returns the convert to class.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
||||||
* @return The class to convert to.
|
* @return The class to convert to.
|
||||||
*/
|
*/
|
||||||
|
|
@ -51,7 +52,7 @@ public class IntegerConverter extends AbstractStringObjectConverter {
|
||||||
* Converts string into object.
|
* Converts string into object.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
||||||
* @param str The string to convert to object.
|
* @param str The string to convert to object.
|
||||||
* @param locale The locale to convert the string from.
|
* @param locale The locale to convert the string from.
|
||||||
* @return The object converted from the string.
|
* @return The object converted from the string.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
|
|
@ -64,17 +65,18 @@ public class IntegerConverter extends AbstractStringObjectConverter {
|
||||||
* Converts object into string.
|
* Converts object into string.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
||||||
* @param obj The object to convert to string.
|
* @param obj The object to convert to string.
|
||||||
* @param locale The locale to convert the object from.
|
* @param locale The locale to convert the object from.
|
||||||
* @return The string converted from the object.
|
* @return The string converted from the object.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
|
public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException {
|
||||||
return ((Integer)obj).toString();
|
return ((Integer) obj).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone this ObjectConverter.
|
* Clone this ObjectConverter.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
||||||
* @return The cloned ObjectConverter.
|
* @return The cloned ObjectConverter.
|
||||||
* @throws CloneNotSupportedException When cloning fails.
|
* @throws CloneNotSupportedException When cloning fails.
|
||||||
|
|
@ -82,7 +84,7 @@ public class IntegerConverter extends AbstractStringObjectConverter {
|
||||||
@Override
|
@Override
|
||||||
public ObjectConverter clone() throws CloneNotSupportedException {
|
public ObjectConverter clone() throws CloneNotSupportedException {
|
||||||
IntegerConverter result = new IntegerConverter();
|
IntegerConverter result = new IntegerConverter();
|
||||||
result.converters=cloneConverters();
|
result.converters = cloneConverters();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ public class LongConverter extends AbstractStringObjectConverter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the convert to class.
|
* Returns the convert to class.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
||||||
* @return The class to convert to.
|
* @return The class to convert to.
|
||||||
*/
|
*/
|
||||||
|
|
@ -51,7 +52,7 @@ public class LongConverter extends AbstractStringObjectConverter {
|
||||||
* Converts string into object.
|
* Converts string into object.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
||||||
* @param str The string to convert to object.
|
* @param str The string to convert to object.
|
||||||
* @param locale The locale to convert the string from.
|
* @param locale The locale to convert the string from.
|
||||||
* @return The object converted from the string.
|
* @return The object converted from the string.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
|
|
@ -64,17 +65,18 @@ public class LongConverter extends AbstractStringObjectConverter {
|
||||||
* Converts object into string.
|
* Converts object into string.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
||||||
* @param obj The object to convert to string.
|
* @param obj The object to convert to string.
|
||||||
* @param locale The locale to convert the object from.
|
* @param locale The locale to convert the object from.
|
||||||
* @return The string converted from the object.
|
* @return The string converted from the object.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
|
public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException {
|
||||||
return ((Long)obj).toString();
|
return ((Long) obj).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone this ObjectConverter.
|
* Clone this ObjectConverter.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
||||||
* @return The cloned ObjectConverter.
|
* @return The cloned ObjectConverter.
|
||||||
* @throws CloneNotSupportedException When cloning fails.
|
* @throws CloneNotSupportedException When cloning fails.
|
||||||
|
|
@ -82,7 +84,7 @@ public class LongConverter extends AbstractStringObjectConverter {
|
||||||
@Override
|
@Override
|
||||||
public ObjectConverter clone() throws CloneNotSupportedException {
|
public ObjectConverter clone() throws CloneNotSupportedException {
|
||||||
LongConverter result = new LongConverter();
|
LongConverter result = new LongConverter();
|
||||||
result.converters=cloneConverters();
|
result.converters = cloneConverters();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the convert to class.
|
* Returns the convert to class.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
||||||
* @return The class to convert to.
|
* @return The class to convert to.
|
||||||
*/
|
*/
|
||||||
|
|
@ -67,50 +68,50 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
||||||
* Converts string into object.
|
* Converts string into object.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
||||||
* @param str The string to convert to object.
|
* @param str The string to convert to object.
|
||||||
* @param locale The locale to convert the string from.
|
* @param locale The locale to convert the string from.
|
||||||
* @return The object converted from the string.
|
* @return The object converted from the string.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
||||||
if (split==null) {
|
if (split == null) {
|
||||||
throw new ObjectConverterException(this,"split is not set.");
|
throw new ObjectConverterException(this, "split is not set.");
|
||||||
}
|
}
|
||||||
if (splitSize==null) {
|
if (splitSize == null) {
|
||||||
throw new ObjectConverterException(this,"splitSize is not set.");
|
throw new ObjectConverterException(this, "splitSize is not set.");
|
||||||
}
|
}
|
||||||
if (classTo==null) {
|
if (classTo == null) {
|
||||||
throw new ObjectConverterException(this,"classTo is not set.");
|
throw new ObjectConverterException(this, "classTo is not set.");
|
||||||
}
|
}
|
||||||
String[] strSplit = str.split(split);
|
String[] strSplit = str.split(split);
|
||||||
if(strSplit.length!=splitSize) {
|
if (strSplit.length != splitSize) {
|
||||||
throw new ObjectConverterException(this,"Split size is wrong; "+strSplit.length+" need: "+splitSize);
|
throw new ObjectConverterException(this, "Split size is wrong; " + strSplit.length + " need: " + splitSize);
|
||||||
}
|
}
|
||||||
List<StringSplitConverterStep> steps = getOrderedSteps(true);
|
List<StringSplitConverterStep> steps = getOrderedSteps(true);
|
||||||
if (steps.size()!=splitSize) {
|
if (steps.size() != splitSize) {
|
||||||
throw new ObjectConverterException(this,"Step size is wrong; "+steps.size()+" need: "+splitSize);
|
throw new ObjectConverterException(this, "Step size is wrong; " + steps.size() + " need: " + splitSize);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Object[] singleMethodValues = new Object[splitSize];
|
Object[] singleMethodValues = new Object[splitSize];
|
||||||
Object object = X4OLanguageClassLoader.newInstance(classTo);
|
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);
|
StringSplitConverterStep step = steps.get(i);
|
||||||
Object stepObject = strSplit[i];
|
Object stepObject = strSplit[i];
|
||||||
Object stepValue = step.getObjectConverter().convertTo(stepObject, locale);
|
Object stepValue = step.getObjectConverter().convertTo(stepObject, locale);
|
||||||
if (singleToMethod==null) {
|
if (singleToMethod == null) {
|
||||||
Method m = classTo.getMethod(step.getToMethod(), new Class[] {stepValue.getClass()});
|
Method m = classTo.getMethod(step.getToMethod(), new Class[] { stepValue.getClass() });
|
||||||
m.invoke(object, stepValue);
|
m.invoke(object, stepValue);
|
||||||
} else {
|
} else {
|
||||||
singleMethodValues[i] = stepValue;
|
singleMethodValues[i] = stepValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (singleToMethod!=null) {
|
if (singleToMethod != null) {
|
||||||
List<Class> arguClass = new ArrayList<Class>(singleMethodValues.length);
|
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());
|
arguClass.add(singleMethodValues[i].getClass());
|
||||||
}
|
}
|
||||||
if (useNativeType!=null && useNativeType) {
|
if (useNativeType != null && useNativeType) {
|
||||||
arguClass = convertToNative(arguClass);
|
arguClass = convertToNative(arguClass);
|
||||||
}
|
}
|
||||||
Class[] arguArray = new Class[arguClass.size()];
|
Class[] arguArray = new Class[arguClass.size()];
|
||||||
|
|
@ -118,7 +119,7 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
||||||
Method m = classTo.getMethod(singleToMethod, arguArray);
|
Method m = classTo.getMethod(singleToMethod, arguArray);
|
||||||
|
|
||||||
List<Object> arguValue = new ArrayList<Object>(singleMethodValues.length);
|
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]);
|
arguValue.add(singleMethodValues[i]);
|
||||||
}
|
}
|
||||||
Object[] valueArray = new Object[arguValue.size()];
|
Object[] valueArray = new Object[arguValue.size()];
|
||||||
|
|
@ -127,7 +128,7 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
||||||
}
|
}
|
||||||
return object;
|
return object;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ObjectConverterException(this,e.getMessage(),e);
|
throw new ObjectConverterException(this, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,19 +136,19 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
||||||
* Converts object into string.
|
* Converts object into string.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
||||||
* @param object The object to convert to string.
|
* @param object The object to convert to string.
|
||||||
* @param locale The locale to convert the object from.
|
* @param locale The locale to convert the object from.
|
||||||
* @return The string converted from the object.
|
* @return The string converted from the object.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
public String convertStringBack(Object object,Locale locale) throws ObjectConverterException {
|
public String convertStringBack(Object object, Locale locale) throws ObjectConverterException {
|
||||||
List<StringSplitConverterStep> steps = getOrderedSteps(false);
|
List<StringSplitConverterStep> steps = getOrderedSteps(false);
|
||||||
if (steps.size()!=splitSize) {
|
if (steps.size() != splitSize) {
|
||||||
throw new ObjectConverterException(this,"Step size is wrong; "+steps.size()+" need: "+splitSize);
|
throw new ObjectConverterException(this, "Step size is wrong; " + steps.size() + " need: " + splitSize);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
StringBuilder buf = new StringBuilder(200);
|
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);
|
StringSplitConverterStep step = steps.get(i);
|
||||||
Method m = classTo.getMethod(step.getFromMethod(), new Class[] {});
|
Method m = classTo.getMethod(step.getFromMethod(), new Class[] {});
|
||||||
Object stepValue = m.invoke(object, new Object[] {});
|
Object stepValue = m.invoke(object, new Object[] {});
|
||||||
|
|
@ -156,12 +157,13 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
||||||
}
|
}
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ObjectConverterException(this,e.getMessage(),e);
|
throw new ObjectConverterException(this, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone this ObjectConverter.
|
* Clone this ObjectConverter.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
||||||
* @return The cloned ObjectConverter.
|
* @return The cloned ObjectConverter.
|
||||||
* @throws CloneNotSupportedException When cloning fails.
|
* @throws CloneNotSupportedException When cloning fails.
|
||||||
|
|
@ -169,20 +171,24 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
||||||
@Override
|
@Override
|
||||||
public ObjectConverter clone() throws CloneNotSupportedException {
|
public ObjectConverter clone() throws CloneNotSupportedException {
|
||||||
StringSplitConverter result = new StringSplitConverter();
|
StringSplitConverter result = new StringSplitConverter();
|
||||||
result.converters=cloneConverters();
|
result.converters = cloneConverters();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<StringSplitConverterStep> getOrderedSteps(boolean isTo) {
|
private List<StringSplitConverterStep> getOrderedSteps(boolean isTo) {
|
||||||
List<StringSplitConverterStep> result = new ArrayList<StringSplitConverterStep>(stringSplitConverterSteps.size());
|
List<StringSplitConverterStep> result = new ArrayList<StringSplitConverterStep>(stringSplitConverterSteps.size());
|
||||||
result.addAll(stringSplitConverterSteps);
|
result.addAll(stringSplitConverterSteps);
|
||||||
Collections.sort(stringSplitConverterSteps,new StringSplitConverterStepComparator(isTo));
|
Collections.sort(stringSplitConverterSteps, new StringSplitConverterStepComparator(isTo));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class StringSplitConverterStepComparator implements Comparator<StringSplitConverterStep> {
|
public class StringSplitConverterStepComparator implements Comparator<StringSplitConverterStep> {
|
||||||
boolean isTo = true;
|
boolean isTo = true;
|
||||||
public StringSplitConverterStepComparator(boolean isTo) { this.isTo=isTo; }
|
|
||||||
|
public StringSplitConverterStepComparator(boolean isTo) {
|
||||||
|
this.isTo = isTo;
|
||||||
|
}
|
||||||
|
|
||||||
public int compare(StringSplitConverterStep e1, StringSplitConverterStep e2) {
|
public int compare(StringSplitConverterStep e1, StringSplitConverterStep e2) {
|
||||||
if (isTo) {
|
if (isTo) {
|
||||||
return e1.getToOrder().compareTo(e2.getToOrder());
|
return e1.getToOrder().compareTo(e2.getToOrder());
|
||||||
|
|
@ -195,7 +201,7 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private List<Class> convertToNative(List<Class> types) throws ObjectConverterException {
|
private List<Class> convertToNative(List<Class> types) throws ObjectConverterException {
|
||||||
List<Class> result = new ArrayList<Class>(types.size());
|
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);
|
Class<?> clazz = types.get(i);
|
||||||
if (clazz.isAssignableFrom(Integer.class)) {
|
if (clazz.isAssignableFrom(Integer.class)) {
|
||||||
result.add(Integer.TYPE);
|
result.add(Integer.TYPE);
|
||||||
|
|
@ -208,7 +214,7 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
||||||
} else if (clazz.isAssignableFrom(Boolean.class)) {
|
} else if (clazz.isAssignableFrom(Boolean.class)) {
|
||||||
result.add(Boolean.TYPE);
|
result.add(Boolean.TYPE);
|
||||||
} else {
|
} 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 result;
|
||||||
|
|
@ -287,9 +293,11 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
||||||
public void addStringSplitConverterStep(StringSplitConverterStep stringSplitConverterStep) {
|
public void addStringSplitConverterStep(StringSplitConverterStep stringSplitConverterStep) {
|
||||||
stringSplitConverterSteps.add(stringSplitConverterStep);
|
stringSplitConverterSteps.add(stringSplitConverterStep);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeStringSplitConverterStep(StringSplitConverterStep stringSplitConverterStep) {
|
public void removeStringSplitConverterStep(StringSplitConverterStep stringSplitConverterStep) {
|
||||||
stringSplitConverterSteps.remove(stringSplitConverterStep);
|
stringSplitConverterSteps.remove(stringSplitConverterStep);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<StringSplitConverterStep> getStringSplitConverterSteps() {
|
public List<StringSplitConverterStep> getStringSplitConverterSteps() {
|
||||||
return stringSplitConverterSteps;
|
return stringSplitConverterSteps;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ public class URLConverter extends AbstractStringObjectConverter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the convert to class.
|
* Returns the convert to class.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
||||||
* @return The class to convert to.
|
* @return The class to convert to.
|
||||||
*/
|
*/
|
||||||
|
|
@ -53,7 +54,7 @@ public class URLConverter extends AbstractStringObjectConverter {
|
||||||
* Converts string into object.
|
* Converts string into object.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
||||||
* @param str The string to convert to object.
|
* @param str The string to convert to object.
|
||||||
* @param locale The locale to convert the string from.
|
* @param locale The locale to convert the string from.
|
||||||
* @return The object converted from the string.
|
* @return The object converted from the string.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
|
|
@ -62,7 +63,7 @@ public class URLConverter extends AbstractStringObjectConverter {
|
||||||
try {
|
try {
|
||||||
return new URL(str);
|
return new URL(str);
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
throw new ObjectConverterException(this,e.getMessage(),e);
|
throw new ObjectConverterException(this, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,17 +71,18 @@ public class URLConverter extends AbstractStringObjectConverter {
|
||||||
* Converts object into string.
|
* Converts object into string.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
||||||
* @param obj The object to convert to string.
|
* @param obj The object to convert to string.
|
||||||
* @param locale The locale to convert the object from.
|
* @param locale The locale to convert the object from.
|
||||||
* @return The string converted from the object.
|
* @return The string converted from the object.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
|
public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException {
|
||||||
return ((URL)obj).toString();
|
return ((URL) obj).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone this ObjectConverter.
|
* Clone this ObjectConverter.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
||||||
* @return The cloned ObjectConverter.
|
* @return The cloned ObjectConverter.
|
||||||
* @throws CloneNotSupportedException When cloning fails.
|
* @throws CloneNotSupportedException When cloning fails.
|
||||||
|
|
@ -88,7 +90,7 @@ public class URLConverter extends AbstractStringObjectConverter {
|
||||||
@Override
|
@Override
|
||||||
public ObjectConverter clone() throws CloneNotSupportedException {
|
public ObjectConverter clone() throws CloneNotSupportedException {
|
||||||
URLConverter result = new URLConverter();
|
URLConverter result = new URLConverter();
|
||||||
result.converters=cloneConverters();
|
result.converters = cloneConverters();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,13 +58,14 @@ public class X4OELContext extends ELContext {
|
||||||
compositeELResolver.add(new BeanELResolver());
|
compositeELResolver.add(new BeanELResolver());
|
||||||
compositeELResolver.add(new MapELResolver());
|
compositeELResolver.add(new MapELResolver());
|
||||||
|
|
||||||
elResolver = compositeELResolver;
|
elResolver = compositeELResolver;
|
||||||
functionMapper = new X4OELFunctionMapper();
|
functionMapper = new X4OELFunctionMapper();
|
||||||
variableMapper = new X4OELVariableMapper();
|
variableMapper = new X4OELVariableMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ELResolver.
|
* Returns the ELResolver.
|
||||||
|
*
|
||||||
* @return The ELResolver.
|
* @return The ELResolver.
|
||||||
* @see javax.el.ELContext#getELResolver()
|
* @see javax.el.ELContext#getELResolver()
|
||||||
*/
|
*/
|
||||||
|
|
@ -75,6 +76,7 @@ public class X4OELContext extends ELContext {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the FunctionMapper.
|
* Returns the FunctionMapper.
|
||||||
|
*
|
||||||
* @return The FunctionMapper.
|
* @return The FunctionMapper.
|
||||||
* @see javax.el.ELContext#getFunctionMapper()
|
* @see javax.el.ELContext#getFunctionMapper()
|
||||||
*/
|
*/
|
||||||
|
|
@ -85,6 +87,7 @@ public class X4OELContext extends ELContext {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the VariableMapper.
|
* Returns the VariableMapper.
|
||||||
|
*
|
||||||
* @return The VariableMapper.
|
* @return The VariableMapper.
|
||||||
* @see javax.el.ELContext#getVariableMapper()
|
* @see javax.el.ELContext#getVariableMapper()
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -40,20 +40,21 @@ public class X4OELFunctionMapper extends FunctionMapper {
|
||||||
/**
|
/**
|
||||||
* Stores the el to method function mapping.
|
* Stores the el to method function mapping.
|
||||||
*/
|
*/
|
||||||
private Map<String,Method> functionMap = null;
|
private Map<String, Method> functionMap = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a X4OELFunctionMapper.
|
* Creates a X4OELFunctionMapper.
|
||||||
*/
|
*/
|
||||||
public X4OELFunctionMapper() {
|
public X4OELFunctionMapper() {
|
||||||
functionMap = new HashMap<String,Method>(50);
|
functionMap = new HashMap<String, Method>(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves method el functions.
|
* Resolves method el functions.
|
||||||
* @param prefix The function prefix.
|
*
|
||||||
* @param localName The local name of function.
|
* @param prefix The function prefix.
|
||||||
* @return The resolved function or null is not found.
|
* @param localName The local name of function.
|
||||||
|
* @return The resolved function or null is not found.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Method resolveFunction(String prefix, String localName) {
|
public Method resolveFunction(String prefix, String localName) {
|
||||||
|
|
@ -63,23 +64,24 @@ public class X4OELFunctionMapper extends FunctionMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an static method to the function mapper.
|
* Add an static method to the function mapper.
|
||||||
* @param prefix The function prefix.
|
*
|
||||||
* @param localName The local name of function.
|
* @param prefix The function prefix.
|
||||||
* @param method The method to execute on.
|
* @param localName The local name of function.
|
||||||
|
* @param method The method to execute on.
|
||||||
*/
|
*/
|
||||||
public void addFunction(String prefix, String localName, Method method) {
|
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();
|
throw new NullPointerException();
|
||||||
}
|
}
|
||||||
int modifiers = method.getModifiers();
|
int modifiers = method.getModifiers();
|
||||||
if(!Modifier.isPublic(modifiers)) {
|
if (!Modifier.isPublic(modifiers)) {
|
||||||
throw new IllegalArgumentException("method not public");
|
throw new IllegalArgumentException("method not public");
|
||||||
}
|
}
|
||||||
if(!Modifier.isStatic(modifiers)) {
|
if (!Modifier.isStatic(modifiers)) {
|
||||||
throw new IllegalArgumentException("method not static");
|
throw new IllegalArgumentException("method not static");
|
||||||
}
|
}
|
||||||
Class<?> retType = method.getReturnType();
|
Class<?> retType = method.getReturnType();
|
||||||
if(retType == Void.TYPE) {
|
if (retType == Void.TYPE) {
|
||||||
throw new IllegalArgumentException("method returns void");
|
throw new IllegalArgumentException("method returns void");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ import javax.el.ELContext;
|
||||||
import javax.el.ELResolver;
|
import javax.el.ELResolver;
|
||||||
import javax.el.MapELResolver;
|
import javax.el.MapELResolver;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* X4OELResolver simple EL resolver.
|
* X4OELResolver simple EL resolver.
|
||||||
*
|
*
|
||||||
|
|
@ -39,11 +38,12 @@ import javax.el.MapELResolver;
|
||||||
public class X4OELResolver extends ELResolver {
|
public class X4OELResolver extends ELResolver {
|
||||||
|
|
||||||
private ELResolver delegate = null;
|
private ELResolver delegate = null;
|
||||||
private Map<Object,Object> objectStore = null;
|
private Map<Object, Object> objectStore = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates X4OELResolver which is backed by the objectStore.
|
* Creates X4OELResolver which is backed by the objectStore.
|
||||||
* @param objectStore The objectStore.
|
*
|
||||||
|
* @param objectStore The objectStore.
|
||||||
*/
|
*/
|
||||||
public X4OELResolver(Map<Object, Object> objectStore) {
|
public X4OELResolver(Map<Object, Object> objectStore) {
|
||||||
this.objectStore = objectStore;
|
this.objectStore = objectStore;
|
||||||
|
|
@ -52,11 +52,12 @@ public class X4OELResolver extends ELResolver {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if base object is null and else return objectStore.
|
* 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) {
|
private Object checkBase(Object base) {
|
||||||
if (base==null) {
|
if (base == null) {
|
||||||
return objectStore;
|
return objectStore;
|
||||||
}
|
}
|
||||||
return base;
|
return base;
|
||||||
|
|
@ -76,7 +77,7 @@ public class X4OELResolver extends ELResolver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
public Iterator getFeatureDescriptors(ELContext context,Object base) {
|
public Iterator getFeatureDescriptors(ELContext context, Object base) {
|
||||||
base = checkBase(base);
|
base = checkBase(base);
|
||||||
return delegate.getFeatureDescriptors(context, base);
|
return delegate.getFeatureDescriptors(context, base);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ public class X4OELVariableMapper extends VariableMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see javax.el.VariableMapper#setVariable(java.lang.String, javax.el.ValueExpression)
|
* @see javax.el.VariableMapper#setVariable(java.lang.String, javax.el.ValueExpression)
|
||||||
* @param var Resolve this var to an ValueExpression.
|
* @param var Resolve this var to an ValueExpression.
|
||||||
* @param expression The ValueExpression of the var.
|
* @param expression The ValueExpression of the var.
|
||||||
* @return The ValueExpression being set.
|
* @return The ValueExpression being set.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,8 @@ public class X4OExpressionFactory {
|
||||||
Class<?> expressionFactoryClass = X4OLanguageClassLoader.loadClass(EL_FACTORY_IMPL_ODYSSEUS);
|
Class<?> expressionFactoryClass = X4OLanguageClassLoader.loadClass(EL_FACTORY_IMPL_ODYSSEUS);
|
||||||
result = X4OLanguageClassLoader.newInstance(ExpressionFactory.class, expressionFactoryClass);
|
result = X4OLanguageClassLoader.newInstance(ExpressionFactory.class, expressionFactoryClass);
|
||||||
} catch (ClassNotFoundException ee) {
|
} 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;
|
return result;
|
||||||
|
|
@ -58,7 +59,7 @@ public class X4OExpressionFactory {
|
||||||
try {
|
try {
|
||||||
return X4OLanguageClassLoader.newInstance(ELContext.class, elContextClass);
|
return X4OLanguageClassLoader.newInstance(ELContext.class, elContextClass);
|
||||||
} catch (ClassNotFoundException e) {
|
} 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
|
* 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.
|
* 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.X4ODriver;
|
||||||
import org.x4o.xml.lang.X4OLanguageModule;
|
import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
|
|
@ -37,7 +37,7 @@ public class CelDriver extends X4ODriver<X4OLanguageModule> {
|
||||||
public static final String LANGUAGE_NAME = "cel";
|
public static final String LANGUAGE_NAME = "cel";
|
||||||
|
|
||||||
/** Defines the versions this langauge knowns. */
|
/** 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
|
@Override
|
||||||
public String getLanguageName() {
|
public String getLanguageName() {
|
||||||
|
|
|
||||||
|
|
@ -20,14 +20,13 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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.X4ODriver;
|
||||||
import org.x4o.xml.lang.X4OLanguageModule;
|
import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An Element Language Definition X4O parser.
|
* An Element Language Definition X4O parser. This eld parser config parent x4o parser with the eld x4o parser.
|
||||||
* This eld parser config parent x4o parser with the eld x4o parser.
|
|
||||||
*
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Aug 20, 2005
|
* @version 1.0 Aug 20, 2005
|
||||||
|
|
@ -38,7 +37,7 @@ public class EldDriver extends X4ODriver<X4OLanguageModule> {
|
||||||
public static final String LANGUAGE_NAME = "eld";
|
public static final String LANGUAGE_NAME = "eld";
|
||||||
|
|
||||||
/** Defines the identifier of the ELD x4o language. */
|
/** 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
|
@Override
|
||||||
public String getLanguageName() {
|
public String getLanguageName() {
|
||||||
|
|
|
||||||
|
|
@ -61,10 +61,11 @@ public class EldModuleLoader implements X4OLanguageModuleLoader {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an ELD/CEL module loader.
|
* Creates an ELD/CEL module loader.
|
||||||
* @param eldResource The resource to load.
|
*
|
||||||
* @param isEldCore If true then load CEL else load ELD.
|
* @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) {
|
if (eldResource == null) {
|
||||||
throw new NullPointerException("Can't load null eld resource.");
|
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.
|
* 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 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.
|
* @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)
|
* @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);
|
logger.fine("Loading name eld file from resource: " + eldResource);
|
||||||
try {
|
try {
|
||||||
X4ODriver<?> driver = null;
|
X4ODriver<?> driver = null;
|
||||||
|
|
@ -98,21 +101,23 @@ public class EldModuleLoader implements X4OLanguageModuleLoader {
|
||||||
}
|
}
|
||||||
reader.readResource(eldResource);
|
reader.readResource(eldResource);
|
||||||
} catch (X4OConnectionException e) {
|
} 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) {
|
} 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) {
|
} 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) {
|
public static X4OLanguage getLanguage(X4OLanguageSession context) {
|
||||||
ValueExpression ee = context.getExpressionLanguageFactory().createValueExpression(context.getExpressionLanguageContext(),"${"+EL_PARENT_LANGUAGE+"}", X4OLanguage.class);
|
ValueExpression ee = context.getExpressionLanguageFactory().createValueExpression(context.getExpressionLanguageContext(),
|
||||||
return (X4OLanguage)ee.getValue(context.getExpressionLanguageContext());
|
"${" + EL_PARENT_LANGUAGE + "}", X4OLanguage.class);
|
||||||
|
return (X4OLanguage) ee.getValue(context.getExpressionLanguageContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static X4OLanguageModule getLanguageModule(X4OLanguageSession context) {
|
public static X4OLanguageModule getLanguageModule(X4OLanguageSession context) {
|
||||||
ValueExpression ee = context.getExpressionLanguageFactory().createValueExpression(context.getExpressionLanguageContext(),"${"+EL_PARENT_LANGUAGE_MODULE+"}", X4OLanguageModule.class);
|
ValueExpression ee = context.getExpressionLanguageFactory().createValueExpression(context.getExpressionLanguageContext(),
|
||||||
return (X4OLanguageModule)ee.getValue(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;
|
import org.x4o.xml.lang.X4OLanguageSession;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EldModuleLoaderCore provides a few basic elements for the core eld x4o
|
* EldModuleLoaderCore provides a few basic elements for the core eld x4o language.
|
||||||
* language.
|
|
||||||
*
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Jan 11, 2009
|
* @version 1.0 Jan 11, 2009
|
||||||
|
|
@ -89,11 +88,11 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
* @param session The session to run in.
|
* @param session The session to run in.
|
||||||
* @param language The langauge to load for.
|
* @param language The langauge to load for.
|
||||||
* @param languageModule The module to load it in.
|
* @param languageModule The module to load it in.
|
||||||
* @see org.x4o.xml.lang.X4OLanguageModuleLoader#loadLanguageModule(org.x4o.xml.lang.X4OLanguageLocal,
|
* @see org.x4o.xml.lang.X4OLanguageModuleLoader#loadLanguageModule(org.x4o.xml.lang.X4OLanguageLocal, org.x4o.xml.lang.X4OLanguageModuleLocald)
|
||||||
* org.x4o.xml.lang.X4OLanguageModuleLocald)
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@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
|
// Config module meta data
|
||||||
configLanguageModule(languageModule);
|
configLanguageModule(languageModule);
|
||||||
|
|
@ -113,7 +112,8 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
// Create cel-root namespace in language for schema support
|
// 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);
|
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.
|
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, "id", true, null));
|
||||||
rootElement.addElementClassAttribute(createElementClassAttribute(language, "providerHost", true, null));
|
rootElement.addElementClassAttribute(createElementClassAttribute(language, "providerHost", true, null));
|
||||||
namespaceRoot.addElementClass(rootElement);
|
namespaceRoot.addElementClass(rootElement);
|
||||||
|
|
@ -130,14 +130,16 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
private void configElementClasses(X4OLanguage language, ElementNamespace namespace) throws X4OLanguageModuleLoaderException {
|
private void configElementClasses(X4OLanguage language, ElementNamespace namespace) throws X4OLanguageModuleLoaderException {
|
||||||
ElementClass ec = null;
|
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 = createElementClass(language, "attributeAlias", null, AttributeAliasElement.class, "Adds an attribute alias.");
|
||||||
ec.addElementClassAttribute(createElementClassAttribute(language, "name", true, null));
|
ec.addElementClassAttribute(createElementClassAttribute(language, "name", true, null));
|
||||||
ec.addElementParent(CEL_CORE_URI, "attribute");
|
ec.addElementParent(CEL_CORE_URI, "attribute");
|
||||||
namespace.addElementClass(ec);
|
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 = createElementClass(language, "namespace", language.getLanguageConfiguration().getDefaultElementNamespace(), null, "Defines an xml namespace.");
|
||||||
ec.addElementClassAttribute(createElementClassAttribute(language, "uri", true, null));
|
ec.addElementClassAttribute(createElementClassAttribute(language, "uri", true, null));
|
||||||
|
|
@ -148,7 +150,8 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
ec.addElementClassAttribute(createElementClassAttribute(language, "elementClass", false, new ClassConverter()));
|
ec.addElementClassAttribute(createElementClassAttribute(language, "elementClass", false, new ClassConverter()));
|
||||||
namespace.addElementClass(ec);
|
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()));
|
ec.addElementClassAttribute(createElementClassAttribute(language, "interfaceClass", false, new ClassConverter()));
|
||||||
namespace.addElementClass(ec);
|
namespace.addElementClass(ec);
|
||||||
|
|
||||||
|
|
@ -204,7 +207,8 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
languageModule.setDescription("Core Element Language Module Loader");
|
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 {
|
try {
|
||||||
namespace.getElementNamespaceInstanceProvider().start(language, namespace);
|
namespace.getElementNamespaceInstanceProvider().start(language, namespace);
|
||||||
} catch (ElementNamespaceInstanceProviderException e) {
|
} catch (ElementNamespaceInstanceProviderException e) {
|
||||||
|
|
@ -213,7 +217,8 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
languageModule.addElementNamespace(namespace);
|
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.");
|
logger.finer("Creating " + language.getLanguageName() + " namespace.");
|
||||||
ElementNamespace namespace;
|
ElementNamespace namespace;
|
||||||
try {
|
try {
|
||||||
|
|
@ -222,7 +227,8 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
throw new X4OLanguageModuleLoaderException(this, e.getMessage(), e);
|
throw new X4OLanguageModuleLoaderException(this, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
namespace.setElementNamespaceInstanceProvider(X4OLanguageClassLoader.newInstance(ElementNamespaceInstanceProvider.class, language.getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider()));
|
namespace.setElementNamespaceInstanceProvider(X4OLanguageClassLoader.newInstance(ElementNamespaceInstanceProvider.class,
|
||||||
|
language.getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider()));
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new X4OLanguageModuleLoaderException(this, e.getMessage(), e);
|
throw new X4OLanguageModuleLoaderException(this, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
@ -234,7 +240,8 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
return namespace;
|
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 {
|
try {
|
||||||
ElementClass result = X4OLanguageClassLoader.newInstance(ElementClass.class, language.getLanguageConfiguration().getDefaultElementClass());
|
ElementClass result = X4OLanguageClassLoader.newInstance(ElementClass.class, language.getLanguageConfiguration().getDefaultElementClass());
|
||||||
result.setId(tag);
|
result.setId(tag);
|
||||||
|
|
@ -257,9 +264,11 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
* @return The new ElementClassAttribute instance.
|
* @return The new ElementClassAttribute instance.
|
||||||
* @throws X4OLanguageModuleLoaderException When class could not be created.
|
* @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 {
|
try {
|
||||||
ElementClassAttribute result = X4OLanguageClassLoader.newInstance(ElementClassAttribute.class, language.getLanguageConfiguration().getDefaultElementClassAttribute());
|
ElementClassAttribute result = X4OLanguageClassLoader.newInstance(ElementClassAttribute.class,
|
||||||
|
language.getLanguageConfiguration().getDefaultElementClassAttribute());
|
||||||
result.setId(name);
|
result.setId(name);
|
||||||
if (required) {
|
if (required) {
|
||||||
result.setRequired(required);
|
result.setRequired(required);
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,12 @@ import org.x4o.xml.lang.task.X4OLanguageTaskExecutor;
|
||||||
*/
|
*/
|
||||||
public class EldDocLanguageTask extends AbstractX4OLanguageTask {
|
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_NAME = "ELD DOC Writer Task";
|
||||||
private static final String TASK_DESC = "Writes out the documentation of the language elements.";
|
private static final String TASK_DESC = "Writes out the documentation of the language elements.";
|
||||||
|
|
||||||
public EldDocLanguageTask() {
|
public EldDocLanguageTask() {
|
||||||
super(TASK_ID,TASK_NAME,TASK_DESC,EldDocWriter.DEFAULT_PROPERTY_CONFIG);
|
super(TASK_ID, TASK_NAME, TASK_DESC, EldDocWriter.DEFAULT_PROPERTY_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -52,9 +52,9 @@ public class EldDocLanguageTask extends AbstractX4OLanguageTask {
|
||||||
return new X4OLanguageTaskExecutor() {
|
return new X4OLanguageTaskExecutor() {
|
||||||
public void execute(X4OLanguage language) throws X4OLanguageTaskException {
|
public void execute(X4OLanguage language) throws X4OLanguageTaskException {
|
||||||
try {
|
try {
|
||||||
new EldDocWriter(language,config).writeDocumentation();
|
new EldDocWriter(language, config).writeDocumentation();
|
||||||
} catch (ElementException e) {
|
} catch (ElementException e) {
|
||||||
throw new X4OLanguageTaskException(config,e.getMessage(),e);
|
throw new X4OLanguageTaskException(config, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ import org.x4o.xml.lang.X4OLanguageSession;
|
||||||
*/
|
*/
|
||||||
public class EldDocWriter {
|
public class EldDocWriter {
|
||||||
|
|
||||||
|
//@formatter:off
|
||||||
private final static String DEFAULT_NAME = "X4O ELD DOC";
|
private final static String DEFAULT_NAME = "X4O ELD DOC";
|
||||||
private final static String DEFAULT_DESCRIPTION = "X4O Meta Language Documentation.";
|
private final static String DEFAULT_DESCRIPTION = "X4O Meta Language Documentation.";
|
||||||
|
|
||||||
|
|
@ -116,6 +117,7 @@ public class EldDocWriter {
|
||||||
new PropertyConfigItem(PAGE_PRINT_HELP,Boolean.class,true)
|
new PropertyConfigItem(PAGE_PRINT_HELP,Boolean.class,true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
//@formatter:on
|
||||||
|
|
||||||
/** The config of this writer. */
|
/** The config of this writer. */
|
||||||
private final SAX3PropertyConfig propertyConfig;
|
private final SAX3PropertyConfig propertyConfig;
|
||||||
|
|
@ -125,17 +127,19 @@ public class EldDocWriter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an EldDocGenerator for this langauge context.
|
* 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) {
|
public EldDocWriter(X4OLanguage language, SAX3PropertyConfig parentConfig) {
|
||||||
this.language=language;
|
this.language = language;
|
||||||
this.propertyConfig=new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG,PROPERTY_CONTEXT_PREFIX);
|
this.propertyConfig = new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG, PROPERTY_CONTEXT_PREFIX);
|
||||||
this.propertyConfig.copyParentProperties(parentConfig);
|
this.propertyConfig.copyParentProperties(parentConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes the language documentation to the base path.
|
* 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 {
|
public void writeDocumentation() throws ElementException {
|
||||||
try {
|
try {
|
||||||
|
|
@ -150,41 +154,42 @@ public class EldDocWriter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a fully configured ApiDco object.
|
* 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() {
|
private MaisDoc buildLanguageDoc() {
|
||||||
|
|
||||||
// Generic config
|
// Generic config
|
||||||
MaisDoc doc = new MaisDoc();
|
MaisDoc doc = new MaisDoc();
|
||||||
List<String> javadocLinkList = propertyConfig.getPropertyList(JAVADOC_LINK);
|
List<String> javadocLinkList = propertyConfig.getPropertyList(JAVADOC_LINK);
|
||||||
Map<String,String> javadocLinkOfflineMap = propertyConfig.getPropertyMap(JAVADOC_LINK_OFFLINE);
|
Map<String, String> javadocLinkOfflineMap = propertyConfig.getPropertyMap(JAVADOC_LINK_OFFLINE);
|
||||||
if (javadocLinkList!=null) {
|
if (javadocLinkList != null) {
|
||||||
for (String javadocUrl:javadocLinkList) {
|
for (String javadocUrl : javadocLinkList) {
|
||||||
doc.addRemoteClass(new MaisDocRemoteClass(javadocUrl));
|
doc.addRemoteClass(new MaisDocRemoteClass(javadocUrl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (javadocLinkOfflineMap!=null) {
|
if (javadocLinkOfflineMap != null) {
|
||||||
for (Map.Entry<String,String> offlineLink:javadocLinkOfflineMap.entrySet()) {
|
for (Map.Entry<String, String> offlineLink : javadocLinkOfflineMap.entrySet()) {
|
||||||
doc.addRemoteClass(new MaisDocRemoteClass(offlineLink.getKey(),offlineLink.getValue()));
|
doc.addRemoteClass(new MaisDocRemoteClass(offlineLink.getKey(), offlineLink.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
doc.setName( propertyConfig.getPropertyString(DOC_NAME, DEFAULT_NAME));
|
doc.setName(propertyConfig.getPropertyString(DOC_NAME, DEFAULT_NAME));
|
||||||
doc.setDescription( propertyConfig.getPropertyString(DOC_DESCRIPTION, DEFAULT_DESCRIPTION));
|
doc.setDescription(propertyConfig.getPropertyString(DOC_DESCRIPTION, DEFAULT_DESCRIPTION));
|
||||||
doc.setDocAbout( propertyConfig.getPropertyString(DOC_ABOUT, createLanguageAbout()));
|
doc.setDocAbout(propertyConfig.getPropertyString(DOC_ABOUT, createLanguageAbout()));
|
||||||
doc.setDocCopyright( propertyConfig.getPropertyString(DOC_COPYRIGHT, createLanguageCopyright()));
|
doc.setDocCopyright(propertyConfig.getPropertyString(DOC_COPYRIGHT, createLanguageCopyright()));
|
||||||
doc.setDocPageSubTitle( propertyConfig.getPropertyString(DOC_PAGE_SUB_TITLE, createPageSubTitle()));
|
doc.setDocPageSubTitle(propertyConfig.getPropertyString(DOC_PAGE_SUB_TITLE, createPageSubTitle()));
|
||||||
doc.setMetaStyleSheetThema( propertyConfig.getPropertyString(META_STYLESHEET_THEMA));
|
doc.setMetaStyleSheetThema(propertyConfig.getPropertyString(META_STYLESHEET_THEMA));
|
||||||
doc.setMetaStyleSheet( propertyConfig.getPropertyFile(META_STYLESHEET));
|
doc.setMetaStyleSheet(propertyConfig.getPropertyFile(META_STYLESHEET));
|
||||||
List<String> keywords = propertyConfig.getPropertyList(META_KEYWORDS);
|
List<String> keywords = propertyConfig.getPropertyList(META_KEYWORDS);
|
||||||
if (keywords==null) {
|
if (keywords == null) {
|
||||||
keywords = createLanguageKeywords();
|
keywords = createLanguageKeywords();
|
||||||
}
|
}
|
||||||
doc.addMetaKeywordAll(keywords);
|
doc.addMetaKeywordAll(keywords);
|
||||||
doc.setNoFrameAllName("All Elements");
|
doc.setNoFrameAllName("All Elements");
|
||||||
doc.setFrameNavPrintParent(true);
|
doc.setFrameNavPrintParent(true);
|
||||||
doc.setFrameNavPrintParentId(true);
|
doc.setFrameNavPrintParentId(true);
|
||||||
doc.setGroupTypeName("summary", "Summary",1);
|
doc.setGroupTypeName("summary", "Summary", 1);
|
||||||
doc.setGroupTypeName("overview", "Overview",2);
|
doc.setGroupTypeName("overview", "Overview", 2);
|
||||||
doc.setFrameNavConceptClass(ElementClass.class);
|
doc.setFrameNavConceptClass(ElementClass.class);
|
||||||
|
|
||||||
doc.addTreeNodePageModeClass(X4OLanguageSession.class);
|
doc.addTreeNodePageModeClass(X4OLanguageSession.class);
|
||||||
|
|
@ -198,71 +203,109 @@ public class EldDocWriter {
|
||||||
doc.addAnnotatedClasses(EldDocWriterElementNamespace.class);
|
doc.addAnnotatedClasses(EldDocWriterElementNamespace.class);
|
||||||
doc.addAnnotatedClasses(EldDocWriterElementInterface.class);
|
doc.addAnnotatedClasses(EldDocWriterElementInterface.class);
|
||||||
|
|
||||||
MaisDocConcept adcRoot = doc.addConcept(new MaisDocConcept(null,C_CONTEXT,X4OLanguage.class));
|
MaisDocConcept adcRoot = doc.addConcept(new MaisDocConcept(null, C_CONTEXT, X4OLanguage.class));
|
||||||
MaisDocConcept adcMod = doc.addConcept(new MaisDocConcept(adcRoot,C_MODULE,X4OLanguageModule.class));
|
MaisDocConcept adcMod = doc.addConcept(new MaisDocConcept(adcRoot, C_MODULE, X4OLanguageModule.class));
|
||||||
MaisDocConcept adcIface = doc.addConcept(new MaisDocConcept(adcMod,C_INTERFACE,ElementInterface.class));
|
MaisDocConcept adcIface = doc.addConcept(new MaisDocConcept(adcMod, C_INTERFACE, ElementInterface.class));
|
||||||
MaisDocConcept adcNs = doc.addConcept(new MaisDocConcept(adcMod,C_NAMESPACE,ElementNamespace.class));
|
MaisDocConcept adcNs = doc.addConcept(new MaisDocConcept(adcMod, C_NAMESPACE, ElementNamespace.class));
|
||||||
MaisDocConcept adcEc = doc.addConcept(new MaisDocConcept(adcNs,C_ELEMENT,ElementClass.class));
|
MaisDocConcept adcEc = doc.addConcept(new MaisDocConcept(adcNs, C_ELEMENT, ElementClass.class));
|
||||||
|
|
||||||
// mm maybe redo something here
|
// mm maybe redo something here
|
||||||
adcMod.addChildConcept(new MaisDocConcept(adcMod,CC_ATTRIBUTE_H,ElementNamespaceAttribute.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_CONFIGURATOR_G, ElementConfiguratorGlobal.class));
|
||||||
adcMod.addChildConcept(new MaisDocConcept(adcMod,CC_BINDING,ElementBindingHandler.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_ATTRIBUTE, ElementClassAttribute.class));
|
||||||
adcIface.addChildConcept(new MaisDocConcept(adcMod,CC_CONFIGURATOR,ElementConfigurator.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_CONFIGURATOR, ElementConfigurator.class));
|
||||||
adcEc.addChildConcept(new MaisDocConcept(adcEc,CC_ATTRIBUTE,ElementClassAttribute.class));
|
adcEc.addChildConcept(new MaisDocConcept(adcEc, CC_ATTRIBUTE, ElementClassAttribute.class));
|
||||||
|
|
||||||
// Non-tree pages config
|
// Non-tree pages config
|
||||||
if (propertyConfig.getPropertyBoolean(PAGE_PRINT_XTREE)) { doc.addDocPage(EldDocXTreePageWriter.createDocPage()); }
|
if (propertyConfig.getPropertyBoolean(PAGE_PRINT_XTREE)) {
|
||||||
if (propertyConfig.getPropertyBoolean(PAGE_PRINT_TREE)) { doc.addDocPage(DefaultPageWriterTree.createDocPage()); }
|
doc.addDocPage(EldDocXTreePageWriter.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_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
|
// 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);
|
doc.setRootNode(rootNode);
|
||||||
for (X4OLanguageModule mod:language.getLanguageModules()) { MaisDocNode modNode = rootNode.addNode(createNodeLanguageModule(mod));
|
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||||
for (ElementBindingHandler bind:mod.getElementBindingHandlers()) { modNode.addNode(createNodeElementBindingHandler(bind)); }
|
MaisDocNode modNode = rootNode.addNode(createNodeLanguageModule(mod));
|
||||||
for (ElementConfiguratorGlobal conf:mod.getElementConfiguratorGlobals()) { modNode.addNode(createNodeElementConfiguratorGlobal(conf)); }
|
for (ElementBindingHandler bind : mod.getElementBindingHandlers()) {
|
||||||
for (ElementInterface iface:mod.getElementInterfaces()) { MaisDocNode ifaceNode = modNode.addNode(createNodeElementInterface(iface));
|
modNode.addNode(createNodeElementBindingHandler(bind));
|
||||||
for (ElementClassAttribute eca:iface.getElementClassAttributes()) { ifaceNode.addNode(createNodeElementClassAttribute(eca)); }
|
}
|
||||||
for (ElementConfigurator conf:iface.getElementConfigurators()) { ifaceNode.addNode(createNodeElementConfigurator(conf)); } }
|
for (ElementConfiguratorGlobal conf : mod.getElementConfiguratorGlobals()) {
|
||||||
for (ElementNamespace ns:mod.getElementNamespaces()) { MaisDocNode nsNode = modNode.addNode(createNodeElementNamespace(ns));
|
modNode.addNode(createNodeElementConfiguratorGlobal(conf));
|
||||||
for (ElementNamespaceAttribute attr:ns.getElementNamespaceAttributes()) { nsNode.addNode(createNodeElementNamespaceAttribute(attr)); }
|
}
|
||||||
for (ElementClass ec:ns.getElementClasses()) { MaisDocNode ecNode = nsNode.addNode(createNodeElementClass(ec));
|
for (ElementInterface iface : mod.getElementInterfaces()) {
|
||||||
for (ElementClassAttribute eca:ec.getElementClassAttributes()) { ecNode.addNode(createNodeElementClassAttribute(eca)); }
|
MaisDocNode ifaceNode = modNode.addNode(createNodeElementInterface(iface));
|
||||||
for (ElementConfigurator conf:ec.getElementConfigurators()) { ecNode.addNode(createNodeElementConfigurator(conf)); } } }
|
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;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MaisDocNode createNodeElementBindingHandler(ElementBindingHandler bind) {
|
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) {
|
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) {
|
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) {
|
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) {
|
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) {
|
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) {
|
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) {
|
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) {
|
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() {
|
private String createPageSubTitle() {
|
||||||
|
|
|
||||||
|
|
@ -51,14 +51,16 @@ import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
*/
|
*/
|
||||||
public class EldDocWriterElementClass implements MaisDocContentPrinter {
|
public class EldDocWriterElementClass implements MaisDocContentPrinter {
|
||||||
|
|
||||||
@MaisDocNodeDataConfiguratorMethod(targetClasses={ElementClass.class})
|
@MaisDocNodeDataConfiguratorMethod(targetClasses = { ElementClass.class })
|
||||||
public void configNavBar(MaisDoc doc,MaisDocNode node,MaisDocNodeData data) {
|
public void configNavBar(MaisDoc doc, MaisDocNode node, MaisDocNodeData data) {
|
||||||
/*
|
/*
|
||||||
|
//@formatter:off
|
||||||
ElementClass ec = (ElementClass)node.getUserData();
|
ElementClass ec = (ElementClass)node.getUserData();
|
||||||
Collection<ElementClassAttribute> list = ec.getElementClassAttributes();
|
Collection<ElementClassAttribute> list = ec.getElementClassAttributes();
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
clearHrefContentGroupAlways(doc,"summary","attribute");
|
clearHrefContentGroupAlways(doc,"summary","attribute");
|
||||||
}
|
}
|
||||||
|
//@formatter:om
|
||||||
*/
|
*/
|
||||||
clearHrefContentGroup(doc,node,"summary","attribute",ElementClassAttribute.class);
|
clearHrefContentGroup(doc,node,"summary","attribute",ElementClassAttribute.class);
|
||||||
clearHrefContentGroup(doc,node,"summary","configurator",ElementConfigurator.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")
|
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementClass.class},nodeBodyOrders={2},contentGroup="attribute",contentGroupType="summary")
|
||||||
public void writeElementX4OAttributeSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
public void writeElementX4OAttributeSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||||
ElementClass ec = (ElementClass)event.getEventObject().getUserData();
|
ElementClass ec = (ElementClass)event.getEventObject().getUserData();
|
||||||
|
|
@ -95,77 +98,79 @@ public class EldDocWriterElementClass implements MaisDocContentPrinter {
|
||||||
}
|
}
|
||||||
writer.docTableEnd();
|
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 {
|
public void writeElementObjectPropertiesSummary(MaisDocWriteEvent<MaisDocNode> event) throws IOException {
|
||||||
ElementClass ec = (ElementClass)event.getEventObject().getUserData();
|
ElementClass ec = (ElementClass) event.getEventObject().getUserData();
|
||||||
Class<?> beanClass = ec.getObjectClass();
|
Class<?> beanClass = ec.getObjectClass();
|
||||||
if (beanClass==null) {
|
if (beanClass == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printApiTableBeanClass(event, beanClass, "Object");
|
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 {
|
public void writeElementRelationLinks(MaisDocWriteEvent<MaisDocNode> event) throws IOException {
|
||||||
MaisDocContentWriter writer = event.getWriter();
|
MaisDocContentWriter writer = event.getWriter();
|
||||||
ElementClass ec = (ElementClass)event.getEventObject().getUserData();
|
ElementClass ec = (ElementClass) event.getEventObject().getUserData();
|
||||||
ElementNamespace ns = (ElementNamespace)event.getEventObject().getParent().getUserData();
|
ElementNamespace ns = (ElementNamespace) event.getEventObject().getParent().getUserData();
|
||||||
X4OLanguageModule mod = (X4OLanguageModule)event.getEventObject().getParent().getParent().getUserData();
|
X4OLanguageModule mod = (X4OLanguageModule) event.getEventObject().getParent().getParent().getUserData();
|
||||||
X4OLanguage language = (X4OLanguage)event.getEventObject().getParent().getParent().getParent().getUserData();
|
X4OLanguage language = (X4OLanguage) event.getEventObject().getParent().getParent().getParent().getUserData();
|
||||||
|
|
||||||
// TODO: this is hacky
|
// 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();
|
TreeNode node = xtree.new TreeNode();
|
||||||
node.language=language;
|
node.language = language;
|
||||||
node.module=mod;
|
node.module = mod;
|
||||||
node.namespace=ns;
|
node.namespace = ns;
|
||||||
node.elementClass=ec;
|
node.elementClass = ec;
|
||||||
|
|
||||||
String pathPrefix = "../../../../language/";
|
String pathPrefix = "../../../../language/";
|
||||||
|
|
||||||
List<TreeNode> parents = xtree.findParents(node);
|
List<TreeNode> parents = xtree.findParents(node);
|
||||||
writer.printTagStart(Tag.dl);
|
writer.printTagStart(Tag.dl);
|
||||||
writer.printTagCharacters(Tag.dt,"All Element Parents:");
|
writer.printTagCharacters(Tag.dt, "All Element Parents:");
|
||||||
writer.printTagStart(Tag.dd);
|
writer.printTagStart(Tag.dd);
|
||||||
if (parents.isEmpty()) {
|
if (parents.isEmpty()) {
|
||||||
writer.printCharacters("No parent.");
|
writer.printCharacters("No parent.");
|
||||||
}
|
}
|
||||||
for (int i=0;i<parents.size();i++) {
|
for (int i = 0; i < parents.size(); i++) {
|
||||||
TreeNode n = parents.get(i);
|
TreeNode n = parents.get(i);
|
||||||
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
|
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
|
||||||
writer.printHref(uri, n.namespace.getId()+":"+n.elementClass.getId());
|
writer.printHref(uri, n.namespace.getId() + ":" + n.elementClass.getId());
|
||||||
if (i<parents.size()-1) {
|
if (i < parents.size() - 1) {
|
||||||
writer.printCharacters(", ");
|
writer.printCharacters(", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writer.printTagEnd(Tag.dd);
|
writer.printTagEnd(Tag.dd);
|
||||||
writer.printTagEnd(Tag.dl);
|
writer.printTagEnd(Tag.dl);
|
||||||
|
|
||||||
List<TreeNode> childs = xtree.findChilderen(node);
|
List<TreeNode> childs = xtree.findChilderen(node);
|
||||||
writer.printTagStart(Tag.dl);
|
writer.printTagStart(Tag.dl);
|
||||||
writer.printTagCharacters(Tag.dt,"All Element Childeren:");
|
writer.printTagCharacters(Tag.dt, "All Element Childeren:");
|
||||||
writer.printTagStart(Tag.dd);
|
writer.printTagStart(Tag.dd);
|
||||||
if (childs.isEmpty()) {
|
if (childs.isEmpty()) {
|
||||||
writer.printCharacters("No childeren.");
|
writer.printCharacters("No childeren.");
|
||||||
}
|
}
|
||||||
for (int i=0;i<childs.size();i++) {
|
for (int i = 0; i < childs.size(); i++) {
|
||||||
TreeNode n = childs.get(i);
|
TreeNode n = childs.get(i);
|
||||||
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
|
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
|
||||||
writer.printHref(uri, n.namespace.getId()+":"+n.elementClass.getId());
|
writer.printHref(uri, n.namespace.getId() + ":" + n.elementClass.getId());
|
||||||
if (i<childs.size()-1) {
|
if (i < childs.size() - 1) {
|
||||||
writer.printCharacters(", ");
|
writer.printCharacters(", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writer.printTagEnd(Tag.dd);
|
writer.printTagEnd(Tag.dd);
|
||||||
writer.printTagEnd(Tag.dl);
|
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);
|
StringBuilder buf = new StringBuilder(100);
|
||||||
if (pathPrefix!=null) {
|
if (pathPrefix != null) {
|
||||||
buf.append(pathPrefix);
|
buf.append(pathPrefix);
|
||||||
}
|
}
|
||||||
buf.append(MaisDocContentWriter.toSafeUri(mod.getId()));
|
buf.append(MaisDocContentWriter.toSafeUri(mod.getId()));
|
||||||
|
|
|
||||||
|
|
@ -46,31 +46,34 @@ import org.xml.sax.SAXException;
|
||||||
*/
|
*/
|
||||||
public class EldDocWriterElementInterface implements MaisDocContentPrinter {
|
public class EldDocWriterElementInterface implements MaisDocContentPrinter {
|
||||||
|
|
||||||
@MaisDocNodeDataConfiguratorMethod(targetClasses={ElementInterface.class})
|
@MaisDocNodeDataConfiguratorMethod(targetClasses = { ElementInterface.class })
|
||||||
public void configNavBar(MaisDoc doc,MaisDocNode node,MaisDocNodeData data) {
|
public void configNavBar(MaisDoc doc, MaisDocNode node, MaisDocNodeData data) {
|
||||||
clearHrefContentGroup(doc,node,"summary","attribute",ElementClassAttribute.class);
|
clearHrefContentGroup(doc, node, "summary", "attribute", ElementClassAttribute.class);
|
||||||
clearHrefContentGroup(doc,node,"summary","binding",ElementBindingHandler.class);
|
clearHrefContentGroup(doc, node, "summary", "binding", ElementBindingHandler.class);
|
||||||
clearHrefContentGroup(doc,node,"summary","configurator",ElementConfigurator.class);
|
clearHrefContentGroup(doc, node, "summary", "configurator", ElementConfigurator.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementInterface.class }, nodeBodyOrders = {
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementInterface.class},nodeBodyOrders={1},contentGroup="interface",contentGroupType="summary")
|
1 }, contentGroup = "interface", contentGroupType = "summary")
|
||||||
public void writeElementNamespaceBeanProperties(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
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 {
|
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 {
|
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 {
|
public void writeElementConfigurator(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
printApiTable(event,"Element Configurator Summary",ElementConfigurator.class);
|
printApiTable(event, "Element Configurator Summary", ElementConfigurator.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,23 +44,25 @@ import org.xml.sax.SAXException;
|
||||||
*/
|
*/
|
||||||
public class EldDocWriterElementNamespace implements MaisDocContentPrinter {
|
public class EldDocWriterElementNamespace implements MaisDocContentPrinter {
|
||||||
|
|
||||||
@MaisDocNodeDataConfiguratorMethod(targetClasses={ElementNamespace.class})
|
@MaisDocNodeDataConfiguratorMethod(targetClasses = { ElementNamespace.class })
|
||||||
public void configNavBar(MaisDoc doc,MaisDocNode node,MaisDocNodeData data) {
|
public void configNavBar(MaisDoc doc, MaisDocNode node, MaisDocNodeData data) {
|
||||||
clearHrefContentGroup(doc,node,"summary","element",ElementClass.class);
|
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 {
|
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 {
|
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})
|
// @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY_PAGE,targetClasses={ElementNamespace.class},nodeBodyOrders={2})
|
||||||
//public void writeElementNamespaceAttributes(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
// public void writeElementNamespaceAttributes(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||||
// printApiTable(event,"Element Summary",ElementClass.class);
|
// printApiTable(event,"Element Summary",ElementClass.class);
|
||||||
//}
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,46 +48,46 @@ import org.xml.sax.SAXException;
|
||||||
public class EldDocWriterLanguage implements MaisDocContentPrinter {
|
public class EldDocWriterLanguage implements MaisDocContentPrinter {
|
||||||
|
|
||||||
// TODO move
|
// TODO move
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementBindingHandler.class})
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementBindingHandler.class })
|
||||||
public void writeElementBindingHandlerBean(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
public void writeElementBindingHandlerBean(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
printApiTableBean(event,"BindingHandler","description");
|
printApiTableBean(event, "BindingHandler", "description");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO move
|
// TODO move
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementConfigurator.class})
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementConfigurator.class })
|
||||||
public void writeElementConfiguratorBean(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
public void writeElementConfiguratorBean(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
printApiTableBean(event,"Configurator","description");
|
printApiTableBean(event, "Configurator", "description");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO move
|
// TODO move
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementClassAttribute.class})
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementClassAttribute.class })
|
||||||
public void writeElementClassAttributeBean(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
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 {
|
public void writeLanguageSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
MaisDocContentWriter writer = event.getWriter();
|
MaisDocContentWriter writer = event.getWriter();
|
||||||
MaisDocNode node = event.getEventObject();
|
MaisDocNode node = event.getEventObject();
|
||||||
X4OLanguage language = (X4OLanguage)node.getUserData();
|
X4OLanguage language = (X4OLanguage) node.getUserData();
|
||||||
int attrHandlers = 0;
|
int attrHandlers = 0;
|
||||||
int bindHandlers = 0;
|
int bindHandlers = 0;
|
||||||
int interFaces = 0;
|
int interFaces = 0;
|
||||||
int eleConfigs = 0;
|
int eleConfigs = 0;
|
||||||
int elements = 0;
|
int elements = 0;
|
||||||
int namespaces = 0;
|
int namespaces = 0;
|
||||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||||
bindHandlers += mod.getElementBindingHandlers().size();
|
bindHandlers += mod.getElementBindingHandlers().size();
|
||||||
interFaces += mod.getElementInterfaces().size();
|
interFaces += mod.getElementInterfaces().size();
|
||||||
eleConfigs += mod.getElementConfiguratorGlobals().size();
|
eleConfigs += mod.getElementConfiguratorGlobals().size();
|
||||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||||
namespaces++;
|
namespaces++;
|
||||||
elements += ns.getElementClasses().size();
|
elements += ns.getElementClasses().size();
|
||||||
attrHandlers += ns.getElementNamespaceAttributes().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.docTableHeader("Name", "Value");
|
||||||
writer.docTableRow("LanguageName:", ""+language.getLanguageName(), null);
|
writer.docTableRow("LanguageName:", ""+language.getLanguageName(), null);
|
||||||
writer.docTableRow("LanguageVersion:",""+language.getLanguageVersion(),null);
|
writer.docTableRow("LanguageVersion:",""+language.getLanguageVersion(),null);
|
||||||
|
|
@ -99,23 +99,26 @@ public class EldDocWriterLanguage implements MaisDocContentPrinter {
|
||||||
writer.docTableRow("ElementBindingHandlers:",""+bindHandlers,null);
|
writer.docTableRow("ElementBindingHandlers:",""+bindHandlers,null);
|
||||||
writer.docTableRow("ElementConfigurators:",""+eleConfigs,null);
|
writer.docTableRow("ElementConfigurators:",""+eleConfigs,null);
|
||||||
writer.docTableEnd();
|
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 {
|
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 {
|
public void writeNamespaceSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
MaisDocContentWriter writer = event.getWriter();
|
MaisDocContentWriter writer = event.getWriter();
|
||||||
MaisDocNode node = event.getEventObject();
|
MaisDocNode node = event.getEventObject();
|
||||||
X4OLanguage language = (X4OLanguage)node.getUserData();
|
X4OLanguage language = (X4OLanguage) node.getUserData();
|
||||||
writer.docTableStart("Namespace Summary", "All Language Namespaces Overview",MaisDocContentCss.overviewSummary);
|
writer.docTableStart("Namespace Summary", "All Language Namespaces Overview", MaisDocContentCss.overviewSummary);
|
||||||
writer.docTableHeader("ID", "URI");
|
writer.docTableHeader("ID", "URI");
|
||||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||||
writer.docTableRowLink("language/"+MaisDocContentWriter.toSafeUri(mod.getId())+"/"+MaisDocContentWriter.toSafeUri(ns.getId())+"/index.html",ns.getId(),ns.getUri());
|
writer.docTableRowLink(
|
||||||
|
"language/" + MaisDocContentWriter.toSafeUri(mod.getId()) + "/" + MaisDocContentWriter.toSafeUri(ns.getId()) + "/index.html",
|
||||||
|
ns.getId(), ns.getUri());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writer.docTableEnd();
|
writer.docTableEnd();
|
||||||
|
|
|
||||||
|
|
@ -49,37 +49,42 @@ import org.xml.sax.SAXException;
|
||||||
*/
|
*/
|
||||||
public class EldDocWriterLanguageModule implements MaisDocContentPrinter {
|
public class EldDocWriterLanguageModule implements MaisDocContentPrinter {
|
||||||
|
|
||||||
@MaisDocNodeDataConfiguratorMethod(targetClasses={X4OLanguageModule.class})
|
@MaisDocNodeDataConfiguratorMethod(targetClasses = { X4OLanguageModule.class })
|
||||||
public void configNavBar(MaisDoc doc,MaisDocNode node,MaisDocNodeData data) {
|
public void configNavBar(MaisDoc doc, MaisDocNode node, MaisDocNodeData data) {
|
||||||
clearHrefContentGroup(doc,node,"summary","interface",ElementInterface.class);
|
clearHrefContentGroup(doc, node, "summary", "interface", ElementInterface.class);
|
||||||
clearHrefContentGroup(doc,node,"summary","binding",ElementBindingHandler.class);
|
clearHrefContentGroup(doc, node, "summary", "binding", ElementBindingHandler.class);
|
||||||
clearHrefContentGroup(doc,node,"summary","attribute",ElementNamespaceAttribute.class);
|
clearHrefContentGroup(doc, node, "summary", "attribute", ElementNamespaceAttribute.class);
|
||||||
clearHrefContentGroup(doc,node,"summary","configurator",ElementConfigurator.class);
|
clearHrefContentGroup(doc, node, "summary", "configurator", ElementConfigurator.class);
|
||||||
clearHrefContentGroup(doc,node,"summary","namespace",ElementNamespace.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 {
|
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 {
|
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 {
|
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 {
|
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 {
|
public void writeNamespaceSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
printApiTable(event,"Namespace Summary",ElementNamespace.class);
|
printApiTable(event, "Namespace Summary", ElementNamespace.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,64 +52,66 @@ import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
public class EldDocXTreePageWriter extends DefaultPageWriterTree implements MaisDocPageWriter {
|
public class EldDocXTreePageWriter extends DefaultPageWriterTree implements MaisDocPageWriter {
|
||||||
|
|
||||||
public static MaisDocPage createDocPage() {
|
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;
|
// TODO: rm this old tree code;
|
||||||
private void walkTree(TreeNode node,MaisDocContentWriter writer,String pathPrefix) throws IOException {
|
private void walkTree(TreeNode node, MaisDocContentWriter writer, String pathPrefix) throws IOException {
|
||||||
String href = toElementUri(pathPrefix,node.module,node.namespace,node.elementClass);
|
String href = toElementUri(pathPrefix, node.module, node.namespace, node.elementClass);
|
||||||
|
|
||||||
writer.printTagStart(Tag.ul);
|
writer.printTagStart(Tag.ul);
|
||||||
writer.printTagStart(Tag.li,"",null,"circle");
|
writer.printTagStart(Tag.li, "", null, "circle");
|
||||||
writer.printCharacters(node.namespace.getId());
|
writer.printCharacters(node.namespace.getId());
|
||||||
writer.printCharacters(":");
|
writer.printCharacters(":");
|
||||||
writer.printHref(href, node.elementClass.getId(), node.elementClass.getId(), "strong");
|
writer.printHref(href, node.elementClass.getId(), node.elementClass.getId(), "strong");
|
||||||
writer.printTagEnd(Tag.li);
|
writer.printTagEnd(Tag.li);
|
||||||
|
|
||||||
List<TreeNode> childs = findChilderen(node);
|
List<TreeNode> childs = findChilderen(node);
|
||||||
for (TreeNode child:childs) {
|
for (TreeNode child : childs) {
|
||||||
walkTree(child,writer,pathPrefix);
|
walkTree(child, writer, pathPrefix);
|
||||||
}
|
}
|
||||||
writer.printTagEnd(Tag.ul);
|
writer.printTagEnd(Tag.ul);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: remove this
|
* TODO: remove this
|
||||||
|
*
|
||||||
* @see org.x4o.maisdoc.flake.DefaultPageWriterTree#writePageContent(org.x4o.maisdoc.model.MaisDocWriteEvent)
|
* @see org.x4o.maisdoc.flake.DefaultPageWriterTree#writePageContent(org.x4o.maisdoc.model.MaisDocWriteEvent)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void writePageContent(MaisDocWriteEvent<MaisDocPage> e) throws IOException {
|
public void writePageContent(MaisDocWriteEvent<MaisDocPage> e) throws IOException {
|
||||||
//selectRootNode(e.getDoc()); // create
|
// selectRootNode(e.getDoc()); // create
|
||||||
MaisDoc doc = e.getDoc();
|
MaisDoc doc = e.getDoc();
|
||||||
X4OLanguage language = (X4OLanguage)doc.getRootNode().getUserData();
|
X4OLanguage language = (X4OLanguage) doc.getRootNode().getUserData();
|
||||||
|
|
||||||
String pathPrefix = "language/";
|
String pathPrefix = "language/";
|
||||||
|
|
||||||
// temp print old way
|
// temp print old way
|
||||||
List<TreeNode> rootNodes = new ArrayList<TreeNode>(3);
|
List<TreeNode> rootNodes = new ArrayList<TreeNode>(3);
|
||||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||||
if (ns.getLanguageRoot()!=null && ns.getLanguageRoot()) {
|
if (ns.getLanguageRoot() != null && ns.getLanguageRoot()) {
|
||||||
// found language root elements.
|
// found language root elements.
|
||||||
for (ElementClass ec:ns.getElementClasses()) {
|
for (ElementClass ec : ns.getElementClasses()) {
|
||||||
TreeNode node = new TreeNode();
|
TreeNode node = new TreeNode();
|
||||||
node.language=language;
|
node.language = language;
|
||||||
node.module=mod;
|
node.module = mod;
|
||||||
node.namespace=ns;
|
node.namespace = ns;
|
||||||
node.elementClass=ec;
|
node.elementClass = ec;
|
||||||
rootNodes.add(node);
|
rootNodes.add(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Collections.sort(rootNodes,new TreeNodeComparator());
|
Collections.sort(rootNodes, new TreeNodeComparator());
|
||||||
for (TreeNode rootNode:rootNodes) {
|
for (TreeNode rootNode : rootNodes) {
|
||||||
walkTree(rootNode,e.getWriter(),pathPrefix);
|
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);
|
StringBuilder buf = new StringBuilder(100);
|
||||||
if (pathPrefix!=null) {
|
if (pathPrefix != null) {
|
||||||
buf.append(pathPrefix);
|
buf.append(pathPrefix);
|
||||||
}
|
}
|
||||||
buf.append(MaisDocContentWriter.toSafeUri(mod.getId()));
|
buf.append(MaisDocContentWriter.toSafeUri(mod.getId()));
|
||||||
|
|
@ -121,9 +123,9 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements Mais
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrided to select the dom view of the tree.
|
* Overrided to select the dom view of the tree.
|
||||||
|
*
|
||||||
* @see org.x4o.maisdoc.flake.DefaultPageWriterTree#selectRootNode(org.x4o.maisdoc.model.MaisDoc)
|
* @see org.x4o.maisdoc.flake.DefaultPageWriterTree#selectRootNode(org.x4o.maisdoc.model.MaisDoc)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -131,49 +133,47 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements Mais
|
||||||
try {
|
try {
|
||||||
return createXTree(doc);
|
return createXTree(doc);
|
||||||
} catch (IOException e) {
|
} 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 {
|
private MaisDocNode createXTree(MaisDoc doc) throws IOException {
|
||||||
|
|
||||||
X4OLanguage language = (X4OLanguage)doc.getRootNode().getUserData();
|
X4OLanguage language = (X4OLanguage) doc.getRootNode().getUserData();
|
||||||
MaisDocNode root = new MaisDocNode(language,"root","Root","Language root");
|
MaisDocNode root = new MaisDocNode(language, "root", "Root", "Language root");
|
||||||
|
|
||||||
List<TreeNode> rootNodes = new ArrayList<TreeNode>(3);
|
List<TreeNode> rootNodes = new ArrayList<TreeNode>(3);
|
||||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||||
if (ns.getLanguageRoot()!=null && ns.getLanguageRoot()) {
|
if (ns.getLanguageRoot() != null && ns.getLanguageRoot()) {
|
||||||
// found language root elements.
|
// found language root elements.
|
||||||
for (ElementClass ec:ns.getElementClasses()) {
|
for (ElementClass ec : ns.getElementClasses()) {
|
||||||
TreeNode node = new TreeNode();
|
TreeNode node = new TreeNode();
|
||||||
node.language=language;
|
node.language = language;
|
||||||
node.module=mod;
|
node.module = mod;
|
||||||
node.namespace=ns;
|
node.namespace = ns;
|
||||||
node.elementClass=ec;
|
node.elementClass = ec;
|
||||||
rootNodes.add(node);
|
rootNodes.add(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Collections.sort(rootNodes,new TreeNodeComparator());
|
Collections.sort(rootNodes, new TreeNodeComparator());
|
||||||
for (TreeNode rootNode:rootNodes) {
|
for (TreeNode rootNode : rootNodes) {
|
||||||
walkTree(rootNode,"../");
|
walkTree(rootNode, "../");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void walkTree(TreeNode node,String pathPrefix) throws IOException {
|
private void walkTree(TreeNode node, String pathPrefix) throws IOException {
|
||||||
//String href = toElementUri(pathPrefix,node.module,node.namespace,node.elementClass);
|
// String href = toElementUri(pathPrefix,node.module,node.namespace,node.elementClass);
|
||||||
List<TreeNode> childs = findChilderen(node);
|
List<TreeNode> childs = findChilderen(node);
|
||||||
for (TreeNode child:childs) {
|
for (TreeNode child : childs) {
|
||||||
walkTree(child,pathPrefix);
|
walkTree(child, pathPrefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class TreeNode {
|
class TreeNode {
|
||||||
X4OLanguage language;
|
X4OLanguage language;
|
||||||
X4OLanguageModule module;
|
X4OLanguageModule module;
|
||||||
|
|
@ -186,146 +186,144 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements Mais
|
||||||
public List<TreeNode> findChilderen(TreeNode node) {
|
public List<TreeNode> findChilderen(TreeNode node) {
|
||||||
List<TreeNode> result = new ArrayList<TreeNode>(10);
|
List<TreeNode> result = new ArrayList<TreeNode>(10);
|
||||||
|
|
||||||
if (node.indent>20) {
|
if (node.indent > 20) {
|
||||||
return result; // hard fail limit
|
return result; // hard fail limit
|
||||||
}
|
}
|
||||||
for (X4OLanguageModule mod:node.language.getLanguageModules()) {
|
for (X4OLanguageModule mod : node.language.getLanguageModules()) {
|
||||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||||
for (ElementClass ec:ns.getElementClasses()) {
|
for (ElementClass ec : ns.getElementClasses()) {
|
||||||
TreeNode n=null;
|
TreeNode n = null;
|
||||||
List<String> tags = ec.getElementParents(node.namespace.getUri());
|
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 = new TreeNode();
|
||||||
n.language=node.language;
|
n.language = node.language;
|
||||||
n.module=mod;
|
n.module = mod;
|
||||||
n.namespace=ns;
|
n.namespace = ns;
|
||||||
n.elementClass=ec;
|
n.elementClass = ec;
|
||||||
n.indent=node.indent+1;
|
n.indent = node.indent + 1;
|
||||||
n.parent=node;
|
n.parent = node;
|
||||||
} else {
|
} else {
|
||||||
if (ec.getObjectClass()==null) {
|
if (ec.getObjectClass() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Check interfaces of parent , and see if child tag is there.
|
// 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());
|
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 = new TreeNode();
|
||||||
n.language=node.language;
|
n.language = node.language;
|
||||||
n.module=mod;
|
n.module = mod;
|
||||||
n.namespace=ns;
|
n.namespace = ns;
|
||||||
n.elementClass=ec;
|
n.elementClass = ec;
|
||||||
n.indent=node.indent+1;
|
n.indent = node.indent + 1;
|
||||||
n.parent=node;
|
n.parent = node;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.elementClass.getObjectClass()==null) {
|
if (node.elementClass.getObjectClass() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
List<ElementBindingHandler> binds = node.language.findElementBindingHandlers(node.elementClass.getObjectClass(), ec.getObjectClass());
|
List<ElementBindingHandler> binds = node.language.findElementBindingHandlers(node.elementClass.getObjectClass(), ec.getObjectClass());
|
||||||
if (binds.isEmpty()==false) {
|
if (binds.isEmpty() == false) {
|
||||||
n = new TreeNode();
|
n = new TreeNode();
|
||||||
n.language=node.language;
|
n.language = node.language;
|
||||||
n.module=mod;
|
n.module = mod;
|
||||||
n.namespace=ns;
|
n.namespace = ns;
|
||||||
n.elementClass=ec;
|
n.elementClass = ec;
|
||||||
n.indent=node.indent+1;
|
n.indent = node.indent + 1;
|
||||||
n.parent=node;
|
n.parent = node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (n!=null && isInTree(node,n)==false) {
|
if (n != null && isInTree(node, n) == false) {
|
||||||
result.add(n);
|
result.add(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Collections.sort(result,new TreeNodeComparator());
|
Collections.sort(result, new TreeNodeComparator());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInTree(TreeNode node,TreeNode checkNode) {
|
private boolean isInTree(TreeNode node, TreeNode checkNode) {
|
||||||
|
|
||||||
if ( node.namespace.getUri().equals(checkNode.namespace.getUri()) &&
|
if (node.namespace.getUri().equals(checkNode.namespace.getUri()) && node.elementClass.getId().equals(checkNode.elementClass.getId())) {
|
||||||
node.elementClass.getId().equals(checkNode.elementClass.getId())
|
|
||||||
) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (node.parent!=null) {
|
if (node.parent != null) {
|
||||||
return isInTree(node.parent,checkNode);
|
return isInTree(node.parent, checkNode);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TreeNode> findParents(TreeNode node) {
|
public List<TreeNode> findParents(TreeNode node) {
|
||||||
List<TreeNode> result = new ArrayList<TreeNode>(10);
|
List<TreeNode> result = new ArrayList<TreeNode>(10);
|
||||||
TreeNode n=null;
|
TreeNode n = null;
|
||||||
for (X4OLanguageModule mod:node.language.getLanguageModules()) {
|
for (X4OLanguageModule mod : node.language.getLanguageModules()) {
|
||||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||||
|
|
||||||
List<String> tags = node.elementClass.getElementParents(ns.getUri());
|
List<String> tags = node.elementClass.getElementParents(ns.getUri());
|
||||||
if (tags!=null) {
|
if (tags != null) {
|
||||||
for (ElementClass ec:ns.getElementClasses()) {
|
for (ElementClass ec : ns.getElementClasses()) {
|
||||||
if (tags.contains(ec.getId())) {
|
if (tags.contains(ec.getId())) {
|
||||||
n = new TreeNode();
|
n = new TreeNode();
|
||||||
n.language=node.language;
|
n.language = node.language;
|
||||||
n.module=mod;
|
n.module = mod;
|
||||||
n.namespace=ns;
|
n.namespace = ns;
|
||||||
n.elementClass=ec;
|
n.elementClass = ec;
|
||||||
n.indent=node.indent+1;
|
n.indent = node.indent + 1;
|
||||||
n.parent=node;
|
n.parent = node;
|
||||||
result.add(n);
|
result.add(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ElementClass ec:ns.getElementClasses()) {
|
for (ElementClass ec : ns.getElementClasses()) {
|
||||||
|
|
||||||
// Check interfaces of parent , and see if child tag is there.
|
// Check interfaces of parent , and see if child tag is there.
|
||||||
if (node.elementClass.getObjectClass()!=null) {
|
if (node.elementClass.getObjectClass() != null) {
|
||||||
for (ElementInterface ei:node.language.findElementInterfaces(node.elementClass.getObjectClass())) {
|
for (ElementInterface ei : node.language.findElementInterfaces(node.elementClass.getObjectClass())) {
|
||||||
List<String> eiTags = ei.getElementParents(ns.getUri());
|
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 = new TreeNode();
|
||||||
n.language=node.language;
|
n.language = node.language;
|
||||||
n.module=mod;
|
n.module = mod;
|
||||||
n.namespace=ns;
|
n.namespace = ns;
|
||||||
n.elementClass=ec;
|
n.elementClass = ec;
|
||||||
n.indent=node.indent+1;
|
n.indent = node.indent + 1;
|
||||||
n.parent=node;
|
n.parent = node;
|
||||||
result.add(n);
|
result.add(n);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ec.getObjectClass()==null) {
|
if (ec.getObjectClass() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (node.elementClass.getObjectClass()==null) {
|
if (node.elementClass.getObjectClass() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
List<ElementBindingHandler> binds = node.language.findElementBindingHandlers(ec.getObjectClass(),node.elementClass.getObjectClass());
|
List<ElementBindingHandler> binds = node.language.findElementBindingHandlers(ec.getObjectClass(), node.elementClass.getObjectClass());
|
||||||
if (binds.isEmpty()==false) {
|
if (binds.isEmpty() == false) {
|
||||||
n = new TreeNode();
|
n = new TreeNode();
|
||||||
n.language=node.language;
|
n.language = node.language;
|
||||||
n.module=mod;
|
n.module = mod;
|
||||||
n.namespace=ns;
|
n.namespace = ns;
|
||||||
n.elementClass=ec;
|
n.elementClass = ec;
|
||||||
n.indent=node.indent+1;
|
n.indent = node.indent + 1;
|
||||||
n.parent=node;
|
n.parent = node;
|
||||||
if (isInTree(node,n)==false) {
|
if (isInTree(node, n) == false) {
|
||||||
result.add(n);
|
result.add(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Collections.sort(result,new TreeNodeComparator());
|
Collections.sort(result, new TreeNodeComparator());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
class TreeNodeComparator implements Comparator<TreeNode> {
|
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());
|
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.
|
* Add the xml attribute 'name' to ElementClassAttribute as attribute alias.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.element.AbstractElement#doElementEnd()
|
* @see org.x4o.xml.element.AbstractElement#doElementEnd()
|
||||||
* @throws ElementException When name attribute is not set or when parent element object is not ElementClassAttribute interface.
|
* @throws ElementException When name attribute is not set or when parent element object is not ElementClassAttribute interface.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doElementEnd() throws ElementException {
|
public void doElementEnd() throws ElementException {
|
||||||
String alias = getAttributes().get("name");
|
String alias = getAttributes().get("name");
|
||||||
if (alias==null) {
|
if (alias == null) {
|
||||||
throw new ElementException("'name' attribute is not set on: "+getElementClass().getId());
|
throw new ElementException("'name' attribute is not set on: " + getElementClass().getId());
|
||||||
}
|
}
|
||||||
if (getParent().getElementObject() instanceof ElementClassAttribute) {
|
if (getParent().getElementObject() instanceof ElementClassAttribute) {
|
||||||
((ElementClassAttribute)getParent().getElementObject()).addAttributeAlias(alias);
|
((ElementClassAttribute) getParent().getElementObject()).addAttributeAlias(alias);
|
||||||
} else {
|
} 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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,14 +50,17 @@ public class BeanElement extends AbstractElement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On start of element create the element object, filled from the bean.class attribute.
|
* On start of element create the element object, filled from the bean.class attribute.
|
||||||
|
*
|
||||||
* @throws ElementException When bean could not be created.
|
* @throws ElementException When bean could not be created.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doElementStart() throws ElementException {
|
public void doElementStart() throws ElementException {
|
||||||
String className = getAttributes().get("bean.class");
|
String className = getAttributes().get("bean.class");
|
||||||
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 {
|
try {
|
||||||
Class<?> beanClass = X4OLanguageClassLoader.loadClass(className);
|
Class<?> beanClass = X4OLanguageClassLoader.loadClass(className);
|
||||||
if (constructorArguments.isEmpty()) {
|
if (constructorArguments.isEmpty()) {
|
||||||
setElementObject(X4OLanguageClassLoader.newInstance(beanClass));
|
setElementObject(X4OLanguageClassLoader.newInstance(beanClass));
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -83,10 +86,11 @@ public class BeanElement extends AbstractElement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add bean constructor arguments.
|
* 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) {
|
public void addConstuctorArgument(Object argu) {
|
||||||
if (argu==null) {
|
if (argu == null) {
|
||||||
throw new NullPointerException("Can't add null argument for constructor.");
|
throw new NullPointerException("Can't add null argument for constructor.");
|
||||||
}
|
}
|
||||||
constructorArguments.add(argu);
|
constructorArguments.add(argu);
|
||||||
|
|
|
||||||
|
|
@ -36,12 +36,13 @@ public class DescriptionElement extends AbstractElement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the description element and validates that it is not root and parent is meta base.
|
* 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()
|
* @see org.x4o.xml.element.AbstractElement#doElementStart()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doElementStart() throws ElementException {
|
public void doElementStart() throws ElementException {
|
||||||
if (getParent()==null) {
|
if (getParent() == null) {
|
||||||
throw new ElementException("can't be a root tag");
|
throw new ElementException("can't be a root tag");
|
||||||
}
|
}
|
||||||
if (getParent().getElementObject() instanceof ElementMetaBase == false) {
|
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.
|
* 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)
|
* @see org.x4o.xml.element.AbstractElement#doCharacters(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -63,16 +65,17 @@ public class DescriptionElement extends AbstractElement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ends the description element and sets the description on the parent.
|
* 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()
|
* @see org.x4o.xml.element.AbstractElement#doElementEnd()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doElementEnd() throws ElementException {
|
public void doElementEnd() throws ElementException {
|
||||||
if (getElementObject()==null) {
|
if (getElementObject() == null) {
|
||||||
throw new ElementException("description is not set.");
|
throw new ElementException("description is not set.");
|
||||||
}
|
}
|
||||||
if (getParent().getElementObject() instanceof ElementMetaBase) {
|
if (getParent().getElementObject() instanceof ElementMetaBase) {
|
||||||
((ElementMetaBase)getParent().getElementObject()).setDescription(getElementObject().toString());
|
((ElementMetaBase) getParent().getElementObject()).setDescription(getElementObject().toString());
|
||||||
} else {
|
} else {
|
||||||
throw new ElementException("Wrong parent class is not ElementClass");
|
throw new ElementException("Wrong parent class is not ElementClass");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,17 +41,17 @@ public class ElementClassAddParentElement extends AbstractElement {
|
||||||
@Override
|
@Override
|
||||||
public void doElementEnd() throws ElementException {
|
public void doElementEnd() throws ElementException {
|
||||||
String tag = getAttributes().get("tag");
|
String tag = getAttributes().get("tag");
|
||||||
if (tag==null) {
|
if (tag == null) {
|
||||||
throw new ElementException("'tag' attribute is not set on: "+getElementClass().getId());
|
throw new ElementException("'tag' attribute is not set on: " + getElementClass().getId());
|
||||||
}
|
}
|
||||||
String namespaceUri = getAttributes().get("uri");
|
String namespaceUri = getAttributes().get("uri");
|
||||||
if (namespaceUri==null) {
|
if (namespaceUri == null) {
|
||||||
namespaceUri = getParent().getParent().getAttributes().get("uri"); // copy uri from namespace element.
|
namespaceUri = getParent().getParent().getAttributes().get("uri"); // copy uri from namespace element.
|
||||||
}
|
}
|
||||||
if (getParent().getElementObject() instanceof ElementClassBase) {
|
if (getParent().getElementObject() instanceof ElementClassBase) {
|
||||||
((ElementClassBase)getParent().getElementObject()).addElementParent(namespaceUri,tag);
|
((ElementClassBase) getParent().getElementObject()).addElementParent(namespaceUri, tag);
|
||||||
} else {
|
} 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
|
* 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.
|
* 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.ObjectConverter;
|
||||||
import org.x4o.xml.element.AbstractElementBindingHandler;
|
import org.x4o.xml.element.AbstractElementBindingHandler;
|
||||||
|
|
@ -36,10 +36,7 @@ import org.x4o.xml.element.ElementClassAttribute;
|
||||||
*/
|
*/
|
||||||
public class ElementClassAttributeBindingHandler extends AbstractElementBindingHandler<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()
|
* @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)
|
* @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 {
|
public void bindChild(Element childElement, ElementClassAttribute parentObject, Object childObject) throws ElementBindingHandlerException {
|
||||||
if (childObject instanceof ObjectConverter) {
|
if (childObject instanceof ObjectConverter) {
|
||||||
parentObject.setObjectConverter((ObjectConverter)childObject);
|
parentObject.setObjectConverter((ObjectConverter) childObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
* @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());
|
createChild(parentElement, parentObject.getObjectConverter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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.AbstractElementBindingHandler;
|
||||||
import org.x4o.xml.element.Element;
|
import org.x4o.xml.element.Element;
|
||||||
|
|
@ -30,18 +30,14 @@ import org.x4o.xml.element.ElementClassAttribute;
|
||||||
import org.x4o.xml.element.ElementConfigurator;
|
import org.x4o.xml.element.ElementConfigurator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This ElementBindingHandler adds the ElementClassAttributeConverter and the
|
* This ElementBindingHandler adds the ElementClassAttributeConverter and the ElementConfigurator to the ElementClass.
|
||||||
* ElementConfigurator to the ElementClass.
|
|
||||||
*
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Jan 31, 2007
|
* @version 1.0 Jan 31, 2007
|
||||||
*/
|
*/
|
||||||
public class ElementClassBindingHandler extends AbstractElementBindingHandler<ElementClass> {
|
public class ElementClassBindingHandler extends AbstractElementBindingHandler<ElementClass> {
|
||||||
|
|
||||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
private final static Class<?>[] CLASSES_CHILD = new Class[] { ElementClassAttribute.class, ElementConfigurator.class };
|
||||||
ElementClassAttribute.class,
|
|
||||||
ElementConfigurator.class
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
* @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)
|
* @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) {
|
if (childObject instanceof ElementClassAttribute) {
|
||||||
parent.addElementClassAttribute((ElementClassAttribute)childObject);
|
parent.addElementClassAttribute((ElementClassAttribute) childObject);
|
||||||
}
|
}
|
||||||
if (childObject instanceof ElementConfigurator) {
|
if (childObject instanceof ElementConfigurator) {
|
||||||
parent.addElementConfigurators((ElementConfigurator)childObject);
|
parent.addElementConfigurators((ElementConfigurator) childObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void createChilderen(Element parentElement,ElementClass parent) throws ElementBindingHandlerException {
|
public void createChilderen(Element parentElement, ElementClass parent) throws ElementBindingHandlerException {
|
||||||
for (ElementClassAttribute child:parent.getElementClassAttributes()) {
|
for (ElementClassAttribute child : parent.getElementClassAttributes()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
for (ElementConfigurator child:parent.getElementConfigurators()) {
|
for (ElementConfigurator child : parent.getElementConfigurators()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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.AbstractElementBindingHandler;
|
||||||
import org.x4o.xml.element.Element;
|
import org.x4o.xml.element.Element;
|
||||||
|
|
@ -37,10 +37,7 @@ import org.x4o.xml.element.ElementInterface;
|
||||||
*/
|
*/
|
||||||
public class ElementInterfaceBindingHandler extends AbstractElementBindingHandler<ElementInterface> {
|
public class ElementInterfaceBindingHandler extends AbstractElementBindingHandler<ElementInterface> {
|
||||||
|
|
||||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
private final static Class<?>[] CLASSES_CHILD = new Class[] { ElementClassAttribute.class, ElementConfigurator.class };
|
||||||
ElementClassAttribute.class,
|
|
||||||
ElementConfigurator.class
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
* @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)
|
* @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) {
|
if (childObject instanceof ElementClassAttribute) {
|
||||||
parent.addElementClassAttribute((ElementClassAttribute)childObject);
|
parent.addElementClassAttribute((ElementClassAttribute) childObject);
|
||||||
}
|
}
|
||||||
if (childObject instanceof ElementConfigurator) {
|
if (childObject instanceof ElementConfigurator) {
|
||||||
parent.addElementConfigurators((ElementConfigurator)childObject);
|
parent.addElementConfigurators((ElementConfigurator) childObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void createChilderen(Element parentElement,ElementInterface parent) throws ElementBindingHandlerException {
|
public void createChilderen(Element parentElement, ElementInterface parent) throws ElementBindingHandlerException {
|
||||||
for (ElementClassAttribute child:parent.getElementClassAttributes()) {
|
for (ElementClassAttribute child : parent.getElementClassAttributes()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
for (ElementConfigurator child:parent.getElementConfigurators()) {
|
for (ElementConfigurator child : parent.getElementConfigurators()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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.eld.EldModuleLoader;
|
||||||
import org.x4o.xml.element.AbstractElementBindingHandler;
|
import org.x4o.xml.element.AbstractElementBindingHandler;
|
||||||
|
|
@ -44,15 +44,10 @@ import org.x4o.xml.lang.X4OLanguageModuleLocal;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Jan 19, 2007
|
* @version 1.0 Jan 19, 2007
|
||||||
*/
|
*/
|
||||||
public class ElementModuleBindingHandler extends AbstractElementBindingHandler<X4OLanguageModuleLocal> {
|
public class ElementModuleBindingHandler extends AbstractElementBindingHandler<X4OLanguageModuleLocal> {
|
||||||
|
|
||||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
|
||||||
ElementInterface.class,
|
|
||||||
ElementNamespace.class,
|
|
||||||
ElementBindingHandler.class,
|
|
||||||
ElementConfiguratorGlobal.class,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
private final static Class<?>[] CLASSES_CHILD = new Class[] { ElementInterface.class, ElementNamespace.class, ElementBindingHandler.class,
|
||||||
|
ElementConfiguratorGlobal.class, };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||||
|
|
@ -71,86 +66,82 @@ public class ElementModuleBindingHandler extends AbstractElementBindingHandler<
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
* @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());
|
X4OLanguage x4oParsingContext = EldModuleLoader.getLanguage(childElement.getLanguageSession());
|
||||||
if (x4oParsingContext==null) {
|
if (x4oParsingContext == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (languageModule==null) {
|
if (languageModule == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (childObject instanceof ElementInterface) {
|
if (childObject instanceof ElementInterface) {
|
||||||
ElementInterface elementInterface = (ElementInterface)childObject;
|
ElementInterface elementInterface = (ElementInterface) childObject;
|
||||||
languageModule.addElementInterface(elementInterface);
|
languageModule.addElementInterface(elementInterface);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (childObject instanceof ElementNamespace) {
|
if (childObject instanceof ElementNamespace) {
|
||||||
ElementNamespace elementNamespace = (ElementNamespace)childObject;
|
ElementNamespace elementNamespace = (ElementNamespace) childObject;
|
||||||
|
|
||||||
if (elementNamespace.getId()==null) {
|
if (elementNamespace.getId() == null) {
|
||||||
throw new NullPointerException("Can add elementNamespace without id.");
|
throw new NullPointerException("Can add elementNamespace without id.");
|
||||||
}
|
}
|
||||||
// TODO: no language here so move to EL default on eld attribute tag
|
// 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);
|
StringBuilder buf = new StringBuilder(30);
|
||||||
for (char c:elementNamespace.getId().toLowerCase().toCharArray()) {
|
for (char c : elementNamespace.getId().toLowerCase().toCharArray()) {
|
||||||
if (Character.isLetter(c)) {buf.append(c);}
|
if (Character.isLetter(c)) {
|
||||||
if (Character.isDigit(c)) {buf.append(c);}
|
buf.append(c);
|
||||||
if ('-'==c) {buf.append(c);}
|
}
|
||||||
|
if (Character.isDigit(c)) {
|
||||||
|
buf.append(c);
|
||||||
|
}
|
||||||
|
if ('-' == c) {
|
||||||
|
buf.append(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String id = buf.toString();
|
String id = buf.toString();
|
||||||
elementNamespace.setId(id);
|
elementNamespace.setId(id);
|
||||||
}
|
}
|
||||||
if (elementNamespace.getUri()==null) {
|
if (elementNamespace.getUri() == null) {
|
||||||
elementNamespace.setUri(
|
elementNamespace.setUri(
|
||||||
"http://"+languageModule.getProviderHost()+
|
"http://" + languageModule.getProviderHost() + "/xml/ns/" + x4oParsingContext.getLanguageName() + "-" + elementNamespace.getId());
|
||||||
"/xml/ns/"+x4oParsingContext.getLanguageName()+
|
|
||||||
"-"+elementNamespace.getId());
|
|
||||||
}
|
}
|
||||||
if (elementNamespace.getSchemaUri()==null) {
|
if (elementNamespace.getSchemaUri() == null) {
|
||||||
elementNamespace.setSchemaUri(
|
elementNamespace.setSchemaUri("http://" + languageModule.getProviderHost() + "/xml/ns/" + x4oParsingContext.getLanguageName() + "-"
|
||||||
"http://"+languageModule.getProviderHost()+
|
+ elementNamespace.getId() + "-" + x4oParsingContext.getLanguageVersion() + ".xsd");
|
||||||
"/xml/ns/"+x4oParsingContext.getLanguageName()+
|
|
||||||
"-"+elementNamespace.getId()+
|
|
||||||
"-"+x4oParsingContext.getLanguageVersion()+
|
|
||||||
".xsd"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (elementNamespace.getSchemaResource()==null) {
|
if (elementNamespace.getSchemaResource() == null) {
|
||||||
elementNamespace.setSchemaResource(
|
elementNamespace.setSchemaResource(
|
||||||
x4oParsingContext.getLanguageName()+
|
x4oParsingContext.getLanguageName() + "-" + elementNamespace.getId() + "-" + x4oParsingContext.getLanguageVersion() + ".xsd");
|
||||||
"-"+elementNamespace.getId()+
|
|
||||||
"-"+x4oParsingContext.getLanguageVersion()+
|
|
||||||
".xsd"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (elementNamespace.getSchemaPrefix()==null) {
|
if (elementNamespace.getSchemaPrefix() == null) {
|
||||||
elementNamespace.setSchemaPrefix(elementNamespace.getId());
|
elementNamespace.setSchemaPrefix(elementNamespace.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
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) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new ElementBindingHandlerException("Error loading: "+e.getMessage(),e);
|
throw new ElementBindingHandlerException("Error loading: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
||||||
elementNamespace.getElementNamespaceInstanceProvider().start(x4oParsingContext, elementNamespace);
|
elementNamespace.getElementNamespaceInstanceProvider().start(x4oParsingContext, elementNamespace);
|
||||||
} catch (ElementNamespaceInstanceProviderException e) {
|
} catch (ElementNamespaceInstanceProviderException e) {
|
||||||
throw new ElementBindingHandlerException("Error starting: "+e.getMessage(),e);
|
throw new ElementBindingHandlerException("Error starting: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
languageModule.addElementNamespace(elementNamespace);
|
languageModule.addElementNamespace(elementNamespace);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (childObject instanceof ElementBindingHandler) {
|
if (childObject instanceof ElementBindingHandler) {
|
||||||
ElementBindingHandler elementBindingHandler = (ElementBindingHandler)childObject;
|
ElementBindingHandler elementBindingHandler = (ElementBindingHandler) childObject;
|
||||||
languageModule.addElementBindingHandler(elementBindingHandler);
|
languageModule.addElementBindingHandler(elementBindingHandler);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (childObject instanceof ElementConfiguratorGlobal) {
|
if (childObject instanceof ElementConfiguratorGlobal) {
|
||||||
ElementConfiguratorGlobal elementConfigurator = (ElementConfiguratorGlobal)childObject;
|
ElementConfiguratorGlobal elementConfigurator = (ElementConfiguratorGlobal) childObject;
|
||||||
languageModule.addElementConfiguratorGlobal(elementConfigurator);
|
languageModule.addElementConfiguratorGlobal(elementConfigurator);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -159,17 +150,17 @@ public class ElementModuleBindingHandler extends AbstractElementBindingHandler<
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void createChilderen(Element parentElement,X4OLanguageModuleLocal parent) throws ElementBindingHandlerException {
|
public void createChilderen(Element parentElement, X4OLanguageModuleLocal parent) throws ElementBindingHandlerException {
|
||||||
for (ElementInterface child:parent.getElementInterfaces()) {
|
for (ElementInterface child : parent.getElementInterfaces()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
for (ElementNamespace child:parent.getElementNamespaces()) {
|
for (ElementNamespace child : parent.getElementNamespaces()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
for (ElementBindingHandler child:parent.getElementBindingHandlers()) {
|
for (ElementBindingHandler child : parent.getElementBindingHandlers()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
for (ElementConfiguratorGlobal child:parent.getElementConfiguratorGlobals()) {
|
for (ElementConfiguratorGlobal child : parent.getElementConfiguratorGlobals()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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.AbstractElementBindingHandler;
|
||||||
import org.x4o.xml.element.Element;
|
import org.x4o.xml.element.Element;
|
||||||
|
|
@ -37,10 +37,7 @@ import org.x4o.xml.element.ElementNamespaceAttribute;
|
||||||
*/
|
*/
|
||||||
public class ElementNamespaceBindingHandler extends AbstractElementBindingHandler<ElementNamespace> {
|
public class ElementNamespaceBindingHandler extends AbstractElementBindingHandler<ElementNamespace> {
|
||||||
|
|
||||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
private final static Class<?>[] CLASSES_CHILD = new Class[] { ElementClass.class, ElementNamespaceAttribute.class };
|
||||||
ElementClass.class,
|
|
||||||
ElementNamespaceAttribute.class
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||||
|
|
@ -59,16 +56,16 @@ public class ElementNamespaceBindingHandler extends AbstractElementBindingHandle
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
* @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) {
|
if (childObject instanceof ElementClass) {
|
||||||
ElementClass elementClass = (ElementClass)childObject;
|
ElementClass elementClass = (ElementClass) childObject;
|
||||||
if (elementClass.getId()==null && elementClass.getObjectClass()!=null) {
|
if (elementClass.getId() == null && elementClass.getObjectClass() != null) {
|
||||||
elementClass.setId(elementClass.getObjectClass().getSimpleName()); // TODO: move to defaults layer
|
elementClass.setId(elementClass.getObjectClass().getSimpleName()); // TODO: move to defaults layer
|
||||||
}
|
}
|
||||||
parent.addElementClass(elementClass);
|
parent.addElementClass(elementClass);
|
||||||
}
|
}
|
||||||
if (childObject instanceof ElementNamespaceAttribute) {
|
if (childObject instanceof ElementNamespaceAttribute) {
|
||||||
ElementNamespaceAttribute elementNamespaceAttribute = (ElementNamespaceAttribute)childObject;
|
ElementNamespaceAttribute elementNamespaceAttribute = (ElementNamespaceAttribute) childObject;
|
||||||
parent.addElementNamespaceAttribute(elementNamespaceAttribute);
|
parent.addElementNamespaceAttribute(elementNamespaceAttribute);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -77,11 +74,11 @@ public class ElementNamespaceBindingHandler extends AbstractElementBindingHandle
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void createChilderen(Element parentElement,ElementNamespace parent) throws ElementBindingHandlerException {
|
public void createChilderen(Element parentElement, ElementNamespace parent) throws ElementBindingHandlerException {
|
||||||
for (ElementClass child:parent.getElementClasses()) {
|
for (ElementClass child : parent.getElementClasses()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
for (ElementNamespaceAttribute child:parent.getElementNamespaceAttributes()) {
|
for (ElementNamespaceAttribute child : parent.getElementNamespaceAttributes()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -58,20 +58,20 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindChildClasses()
|
* @see org.x4o.xml.element.ElementBindingHandler#getBindChildClasses()
|
||||||
*/
|
*/
|
||||||
public Class<?>[] 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)
|
* @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 {
|
public void bindChild(Element childElement, Object parentObject, Object childObject) throws ElementBindingHandlerException {
|
||||||
if (parentClass==null | childClass==null) {
|
if (parentClass == null | childClass == null) {
|
||||||
throw new IllegalStateException("Missing property: parentClass="+parentClass+" childClass="+childClass+" addMethod="+addMethod+".");
|
throw new IllegalStateException("Missing property: parentClass=" + parentClass + " childClass=" + childClass + " addMethod=" + addMethod + ".");
|
||||||
}
|
}
|
||||||
if (property != null) { // Tmp hanky code here...
|
if (property != null) { // Tmp hanky code here...
|
||||||
try {
|
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);
|
Method propType = parentObject.getClass().getMethod("get" + pop);
|
||||||
if (List.class.isAssignableFrom(propType.getReturnType())) {
|
if (List.class.isAssignableFrom(propType.getReturnType())) {
|
||||||
Object data = childElement.getLanguageSession().getElementObjectPropertyValue().getProperty(parentObject, property);
|
Object data = childElement.getLanguageSession().getElementObjectPropertyValue().getProperty(parentObject, property);
|
||||||
|
|
@ -81,22 +81,23 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
||||||
data = childElement.getLanguageSession().getElementObjectPropertyValue().getProperty(parentObject, property);
|
data = childElement.getLanguageSession().getElementObjectPropertyValue().getProperty(parentObject, property);
|
||||||
}
|
}
|
||||||
if (data instanceof Collection) {
|
if (data instanceof Collection) {
|
||||||
Collection dataCollection = (Collection)data;
|
Collection dataCollection = (Collection) data;
|
||||||
dataCollection.add(childObject);
|
dataCollection.add(childObject);
|
||||||
return;
|
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);
|
childElement.getLanguageSession().getElementObjectPropertyValue().setProperty(parentObject, property, childObject);
|
||||||
return;
|
return;
|
||||||
} catch (/*ElementObjectPropertyValueException |*/ Exception e) {
|
} catch (/* ElementObjectPropertyValueException | */ Exception e) {
|
||||||
throw new ElementBindingHandlerException(getId() + " error " + e.getMessage(), e);
|
throw new ElementBindingHandlerException(getId() + " error " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: remove old...
|
// TODO: remove old...
|
||||||
Method[] ms = parentObject.getClass().getMethods();
|
Method[] ms = parentObject.getClass().getMethods();
|
||||||
for (Method m:ms) {
|
for (Method m : ms) {
|
||||||
Class<?>[] types = m.getParameterTypes();
|
Class<?>[] types = m.getParameterTypes();
|
||||||
if (types.length == 0) {
|
if (types.length == 0) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -104,28 +105,28 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
||||||
if (types.length > 1) {
|
if (types.length > 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (addMethod.equalsIgnoreCase(m.getName())==false) {
|
if (addMethod.equalsIgnoreCase(m.getName()) == false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (types[0].isAssignableFrom(childClass)) {
|
if (types[0].isAssignableFrom(childClass)) {
|
||||||
try {
|
try {
|
||||||
m.invoke(parentObject, childObject);
|
m.invoke(parentObject, childObject);
|
||||||
} catch (Exception e) {
|
} 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;
|
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)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void createChilderen(Element parentElement,Object parentObject) throws ElementBindingHandlerException {
|
public void createChilderen(Element parentElement, Object parentObject) throws ElementBindingHandlerException {
|
||||||
if (parentClass==null | childClass==null) {
|
if (parentClass == null | childClass == null) {
|
||||||
throw new IllegalStateException("Missing property: parentClass="+parentClass+" childClass="+childClass+" getMethod="+getMethod+".");
|
throw new IllegalStateException("Missing property: parentClass=" + parentClass + " childClass=" + childClass + " getMethod=" + getMethod + ".");
|
||||||
}
|
}
|
||||||
if (property != null) {
|
if (property != null) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -137,43 +138,44 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Method[] ms = parentObject.getClass().getMethods();
|
Method[] ms = parentObject.getClass().getMethods();
|
||||||
for (Method m:ms) {
|
for (Method m : ms) {
|
||||||
Class<?>[] types = m.getParameterTypes();
|
Class<?>[] types = m.getParameterTypes();
|
||||||
if (types.length != 0) {
|
if (types.length != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (getMethod.equalsIgnoreCase(m.getName())==false) {
|
if (getMethod.equalsIgnoreCase(m.getName()) == false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Object result;
|
Object result;
|
||||||
try {
|
try {
|
||||||
result = m.invoke(parentObject, new Object[]{});
|
result = m.invoke(parentObject, new Object[] {});
|
||||||
} catch (Exception e) {
|
} 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);
|
createSafeChildLoop(parentElement, result);
|
||||||
return;
|
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")
|
@SuppressWarnings("rawtypes")
|
||||||
protected void createSafeChildLoop(Element parentElement,Object result) throws ElementBindingHandlerException {
|
protected void createSafeChildLoop(Element parentElement, Object result) throws ElementBindingHandlerException {
|
||||||
if (result==null) {
|
if (result == null) {
|
||||||
return; // null is no childeren
|
return; // null is no childeren
|
||||||
}
|
}
|
||||||
if (result instanceof List) {
|
if (result instanceof List) {
|
||||||
for (Object o:(List)result) {
|
for (Object o : (List) result) {
|
||||||
createSafeChild(parentElement, o);
|
createSafeChild(parentElement, o);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (result instanceof Collection) {
|
} else if (result instanceof Collection) {
|
||||||
for (Object o:(Collection)result) {
|
for (Object o : (Collection) result) {
|
||||||
createSafeChild(parentElement, o);
|
createSafeChild(parentElement, o);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (result.getClass().isArray()) {
|
} else if (result.getClass().isArray()) {
|
||||||
for (Object o:(Object[])result) {
|
for (Object o : (Object[]) result) {
|
||||||
createSafeChild(parentElement, o);
|
createSafeChild(parentElement, o);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
@ -181,23 +183,25 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
||||||
createSafeChild(parentElement, result);
|
createSafeChild(parentElement, result);
|
||||||
return;
|
return;
|
||||||
} else {
|
} 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.
|
* 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) {
|
protected void createSafeChild(Element parentElement, Object childObject) {
|
||||||
if (childClass.isAssignableFrom(childObject.getClass())==false) {
|
if (childClass.isAssignableFrom(childObject.getClass()) == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (skipChilderenClassRegex!=null && childObject.getClass().getName().matches(skipChilderenClassRegex)) {
|
if (skipChilderenClassRegex != null && childObject.getClass().getName().matches(skipChilderenClassRegex)) {
|
||||||
return; // skip
|
return; // skip
|
||||||
}
|
}
|
||||||
createChild(parentElement,childObject);
|
createChild(parentElement, childObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ public class ModuleElement extends AbstractElement {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doElementStart() throws ElementException {
|
public void doElementStart() throws ElementException {
|
||||||
if (getParent()!=null) {
|
if (getParent() != null) {
|
||||||
throw new ElementException("Need to be root tag");
|
throw new ElementException("Need to be root tag");
|
||||||
}
|
}
|
||||||
X4OLanguageModule elementLanguageModule = EldModuleLoader.getLanguageModule(getLanguageSession());
|
X4OLanguageModule elementLanguageModule = EldModuleLoader.getLanguageModule(getLanguageSession());
|
||||||
|
|
|
||||||
|
|
@ -38,14 +38,14 @@ public class NextAttributeElement extends AbstractElement {
|
||||||
@Override
|
@Override
|
||||||
public void doElementRun() throws ElementException {
|
public void doElementRun() throws ElementException {
|
||||||
String param = getAttributes().get("attributeName");
|
String param = getAttributes().get("attributeName");
|
||||||
if (param==null) {
|
if (param == null) {
|
||||||
throw new ElementException("attributeName may not be null");
|
throw new ElementException("attributeName may not be null");
|
||||||
}
|
}
|
||||||
if (getParent()==null) {
|
if (getParent() == null) {
|
||||||
throw new ElementException("can't be a root tag");
|
throw new ElementException("can't be a root tag");
|
||||||
}
|
}
|
||||||
if (getParent().getElementObject() instanceof ElementNamespaceAttribute) {
|
if (getParent().getElementObject() instanceof ElementNamespaceAttribute) {
|
||||||
((ElementNamespaceAttribute)getParent().getElementObject()).addNextAttribute(param);
|
((ElementNamespaceAttribute) getParent().getElementObject()).addNextAttribute(param);
|
||||||
} else {
|
} else {
|
||||||
throw new ElementException("Wrong parent class");
|
throw new ElementException("Wrong parent class");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,13 +41,13 @@ public class SkipPhaseElement extends AbstractElement {
|
||||||
@Override
|
@Override
|
||||||
public void doElementEnd() throws ElementException {
|
public void doElementEnd() throws ElementException {
|
||||||
String phase = getAttributes().get("name");
|
String phase = getAttributes().get("name");
|
||||||
if (phase==null) {
|
if (phase == null) {
|
||||||
throw new ElementException("'name' attribute is not set on: "+getElementClass().getId());
|
throw new ElementException("'name' attribute is not set on: " + getElementClass().getId());
|
||||||
}
|
}
|
||||||
if (getParent().getElementObject() instanceof ElementClass) {
|
if (getParent().getElementObject() instanceof ElementClass) {
|
||||||
((ElementClass)getParent().getElementObject()).addSkipPhase(phase);
|
((ElementClass) getParent().getElementObject()).addSkipPhase(phase);
|
||||||
} else {
|
} 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
|
* 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.
|
* 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.StringSplitConverter;
|
||||||
import org.x4o.xml.conv.text.StringSplitConverterStep;
|
import org.x4o.xml.conv.text.StringSplitConverterStep;
|
||||||
|
|
@ -36,10 +36,7 @@ import org.x4o.xml.element.ElementBindingHandlerException;
|
||||||
*/
|
*/
|
||||||
public class StringSplitConverterBindingHandler extends AbstractElementBindingHandler<StringSplitConverter> {
|
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()
|
* @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)
|
* @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 {
|
public void bindChild(Element childElement, StringSplitConverter parent, Object childObject) throws ElementBindingHandlerException {
|
||||||
if (childObject instanceof StringSplitConverterStep) {
|
if (childObject instanceof StringSplitConverterStep) {
|
||||||
parent.addStringSplitConverterStep((StringSplitConverterStep)childObject);
|
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)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void createChilderen(Element parentElement,StringSplitConverter parentObject) throws ElementBindingHandlerException {
|
public void createChilderen(Element parentElement, StringSplitConverter parentObject) throws ElementBindingHandlerException {
|
||||||
for (StringSplitConverterStep child:parentObject.getStringSplitConverterSteps()) {
|
for (StringSplitConverterStep child : parentObject.getStringSplitConverterSteps()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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.ObjectConverter;
|
||||||
import org.x4o.xml.conv.text.StringSplitConverterStep;
|
import org.x4o.xml.conv.text.StringSplitConverterStep;
|
||||||
|
|
@ -36,10 +36,7 @@ import org.x4o.xml.element.ElementBindingHandlerException;
|
||||||
*/
|
*/
|
||||||
public class StringSplitConverterStepBindingHandler extends AbstractElementBindingHandler<StringSplitConverterStep> {
|
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()
|
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||||
|
|
@ -58,9 +55,9 @@ public class StringSplitConverterStepBindingHandler extends AbstractElementBindi
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
* @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 {
|
public void bindChild(Element childElement, StringSplitConverterStep parent, Object childObject) throws ElementBindingHandlerException {
|
||||||
if (childObject instanceof ObjectConverter) {
|
if (childObject instanceof ObjectConverter) {
|
||||||
parent.setObjectConverter((ObjectConverter)childObject);
|
parent.setObjectConverter((ObjectConverter) childObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,7 +65,7 @@ public class StringSplitConverterStepBindingHandler extends AbstractElementBindi
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void createChilderen(Element parentElement,StringSplitConverterStep parentObject) throws ElementBindingHandlerException {
|
public void createChilderen(Element parentElement, StringSplitConverterStep parentObject) throws ElementBindingHandlerException {
|
||||||
createChild(parentElement, parentObject.getObjectConverter());
|
createChild(parentElement, parentObject.getObjectConverter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,12 +39,12 @@ import org.xml.sax.SAXException;
|
||||||
*/
|
*/
|
||||||
public class EldXsdLanguageTask extends AbstractX4OLanguageTask {
|
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_NAME = "ELD XSD Writer Task";
|
||||||
private static final String TASK_DESC = "Writes out the schema of the language elements.";
|
private static final String TASK_DESC = "Writes out the schema of the language elements.";
|
||||||
|
|
||||||
public EldXsdLanguageTask() {
|
public EldXsdLanguageTask() {
|
||||||
super(TASK_ID,TASK_NAME,TASK_DESC,EldXsdWriter.DEFAULT_PROPERTY_CONFIG);
|
super(TASK_ID, TASK_NAME, TASK_DESC, EldXsdWriter.DEFAULT_PROPERTY_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -54,11 +54,11 @@ public class EldXsdLanguageTask extends AbstractX4OLanguageTask {
|
||||||
return new X4OLanguageTaskExecutor() {
|
return new X4OLanguageTaskExecutor() {
|
||||||
public void execute(X4OLanguage language) throws X4OLanguageTaskException {
|
public void execute(X4OLanguage language) throws X4OLanguageTaskException {
|
||||||
try {
|
try {
|
||||||
new EldXsdWriter(language,config).writeSchema();
|
new EldXsdWriter(language, config).writeSchema();
|
||||||
} catch (SAXException e) {
|
} catch (SAXException e) {
|
||||||
throw new X4OLanguageTaskException(config,e.getMessage(),e);
|
throw new X4OLanguageTaskException(config, e.getMessage(), e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new X4OLanguageTaskException(config,e.getMessage(),e);
|
throw new X4OLanguageTaskException(config, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,10 @@ import org.xml.sax.SAXException;
|
||||||
*/
|
*/
|
||||||
public class EldXsdWriter {
|
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;
|
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_PATH = PROPERTY_CONTEXT_PREFIX+"output/path";
|
||||||
public final static String OUTPUT_DOCUMENTATION = PROPERTY_CONTEXT_PREFIX+"output/documentation";
|
public final static String OUTPUT_DOCUMENTATION = PROPERTY_CONTEXT_PREFIX+"output/documentation";
|
||||||
public final static String FILTER_NAMESPACE = PROPERTY_CONTEXT_PREFIX+"filter/namespace";
|
public final static String FILTER_NAMESPACE = PROPERTY_CONTEXT_PREFIX+"filter/namespace";
|
||||||
|
|
@ -78,22 +79,23 @@ public class EldXsdWriter {
|
||||||
new PropertyConfigItem(PROLOG_XMLNS_DESC_ENABLE, Boolean.class, true)
|
new PropertyConfigItem(PROLOG_XMLNS_DESC_ENABLE, Boolean.class, true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
//@formatter:on
|
||||||
|
|
||||||
private final X4OLanguage language;
|
private final X4OLanguage language;
|
||||||
private final SAX3PropertyConfig propertyConfig;
|
private final SAX3PropertyConfig propertyConfig;
|
||||||
|
|
||||||
public EldXsdWriter(X4OLanguage language,SAX3PropertyConfig parentConfig) {
|
public EldXsdWriter(X4OLanguage language, SAX3PropertyConfig parentConfig) {
|
||||||
this.language=language;
|
this.language = language;
|
||||||
this.propertyConfig=new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG,PROPERTY_CONTEXT_PREFIX);
|
this.propertyConfig = new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG, PROPERTY_CONTEXT_PREFIX);
|
||||||
this.propertyConfig.copyParentProperties(parentConfig);
|
this.propertyConfig.copyParentProperties(parentConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkNamespace(ElementNamespace ns) {
|
private void checkNamespace(ElementNamespace ns) {
|
||||||
if (ns.getSchemaResource()==null) {
|
if (ns.getSchemaResource() == null) {
|
||||||
throw new NullPointerException("Can't generate xsd for namespace without schemaResource uri: "+ns.getUri());
|
throw new NullPointerException("Can't generate xsd for namespace without schemaResource uri: " + ns.getUri());
|
||||||
}
|
}
|
||||||
if (ns.getSchemaResource().length()==0) {
|
if (ns.getSchemaResource().length() == 0) {
|
||||||
throw new NullPointerException("Can't generate xsd for namespace with empty schemaResource uri: "+ns.getUri());
|
throw new NullPointerException("Can't generate xsd for namespace with empty schemaResource uri: " + ns.getUri());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,22 +103,22 @@ public class EldXsdWriter {
|
||||||
File basePath = propertyConfig.getPropertyFile(OUTPUT_PATH);
|
File basePath = propertyConfig.getPropertyFile(OUTPUT_PATH);
|
||||||
String encoding = propertyConfig.getPropertyString(SAX3WriterXml.OUTPUT_ENCODING);
|
String encoding = propertyConfig.getPropertyString(SAX3WriterXml.OUTPUT_ENCODING);
|
||||||
String namespace = propertyConfig.getPropertyString(FILTER_NAMESPACE);
|
String namespace = propertyConfig.getPropertyString(FILTER_NAMESPACE);
|
||||||
if (basePath==null) {
|
if (basePath == null) {
|
||||||
throw new NullPointerException("Can't write schema to null output path.");
|
throw new NullPointerException("Can't write schema to null output path.");
|
||||||
}
|
}
|
||||||
if (!basePath.exists()) {
|
if (!basePath.exists()) {
|
||||||
basePath.mkdirs();
|
basePath.mkdirs();
|
||||||
}
|
}
|
||||||
if (namespace!=null) {
|
if (namespace != null) {
|
||||||
ElementNamespace ns = language.findElementNamespace(namespace);
|
ElementNamespace ns = language.findElementNamespace(namespace);
|
||||||
if (ns==null) {
|
if (ns == null) {
|
||||||
throw new NullPointerException("Could not find namespace: "+namespace);
|
throw new NullPointerException("Could not find namespace: " + namespace);
|
||||||
}
|
}
|
||||||
checkNamespace(ns);
|
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);
|
Writer wr = new OutputStreamWriter(new FileOutputStream(outputFile), encoding);
|
||||||
try {
|
try {
|
||||||
SAX3WriterXsd xsdWriter = new SAX3WriterXsd(wr,encoding);
|
SAX3WriterXsd xsdWriter = new SAX3WriterXsd(wr, encoding);
|
||||||
xsdWriter.getPropertyConfig().copyParentProperties(propertyConfig);
|
xsdWriter.getPropertyConfig().copyParentProperties(propertyConfig);
|
||||||
generateSchema(ns.getUri(), xsdWriter);
|
generateSchema(ns.getUri(), xsdWriter);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -124,13 +126,13 @@ public class EldXsdWriter {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||||
checkNamespace(ns);
|
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);
|
Writer wr = new OutputStreamWriter(new FileOutputStream(outputFile), encoding);
|
||||||
try {
|
try {
|
||||||
SAX3WriterXsd xsdWriter = new SAX3WriterXsd(wr,encoding);
|
SAX3WriterXsd xsdWriter = new SAX3WriterXsd(wr, encoding);
|
||||||
xsdWriter.getPropertyConfig().copyParentProperties(propertyConfig);
|
xsdWriter.getPropertyConfig().copyParentProperties(propertyConfig);
|
||||||
generateSchema(ns.getUri(), xsdWriter);
|
generateSchema(ns.getUri(), xsdWriter);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -140,26 +142,26 @@ 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);
|
ElementNamespace ns = language.findElementNamespace(namespaceUri);
|
||||||
if (ns==null) {
|
if (ns == null) {
|
||||||
throw new NullPointerException("Could not find namespace: "+namespaceUri);
|
throw new NullPointerException("Could not find namespace: " + namespaceUri);
|
||||||
}
|
}
|
||||||
String filterElement = propertyConfig.getPropertyString(FILTER_ELEMENT);
|
String filterElement = propertyConfig.getPropertyString(FILTER_ELEMENT);
|
||||||
EldXsdWriterElement xsdWriterElement = new EldXsdWriterElement(xsdWriter,language,propertyConfig);
|
EldXsdWriterElement xsdWriterElement = new EldXsdWriterElement(xsdWriter, language, propertyConfig);
|
||||||
xsdWriterElement.startNamespaces(namespaceUri);
|
xsdWriterElement.startNamespaces(namespaceUri);
|
||||||
xsdWriterElement.startSchema(ns);
|
xsdWriterElement.startSchema(ns);
|
||||||
for (ElementClass ec:ns.getElementClasses()) {
|
for (ElementClass ec : ns.getElementClasses()) {
|
||||||
if (filterElement!=null && !ec.getId().equals(filterElement)) {
|
if (filterElement != null && !ec.getId().equals(filterElement)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
xsdWriterElement.writeElementClass(ec,ns);
|
xsdWriterElement.writeElementClass(ec, ns);
|
||||||
}
|
}
|
||||||
for (ElementClass ec:ns.getElementClasses()) {
|
for (ElementClass ec : ns.getElementClasses()) {
|
||||||
if (filterElement!=null && !ec.getId().equals(filterElement)) {
|
if (filterElement != null && !ec.getId().equals(filterElement)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
xsdWriterElement.writeElement(ec,ns);
|
xsdWriterElement.writeElement(ec, ns);
|
||||||
}
|
}
|
||||||
xsdWriterElement.endSchema();
|
xsdWriterElement.endSchema();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
@ -66,28 +66,28 @@ public class EldXsdWriterElement {
|
||||||
protected String writeNamespace = null;
|
protected String writeNamespace = null;
|
||||||
protected Map<String, String> namespaces = null;
|
protected Map<String, String> namespaces = null;
|
||||||
|
|
||||||
public EldXsdWriterElement(SAX3WriterXsd xsdWriter,X4OLanguage language,SAX3PropertyConfig propertyConfig) {
|
public EldXsdWriterElement(SAX3WriterXsd xsdWriter, X4OLanguage language, SAX3PropertyConfig propertyConfig) {
|
||||||
this.xsdWriter=xsdWriter;
|
this.xsdWriter = xsdWriter;
|
||||||
this.language=language;
|
this.language = language;
|
||||||
this.propertyConfig=propertyConfig;
|
this.propertyConfig = propertyConfig;
|
||||||
this.namespaces=new HashMap<String,String>(10);
|
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);
|
String prefix = namespaces.get(uri);
|
||||||
if (prefix!=null) {
|
if (prefix != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (uri.equals(writeNamespace)) {
|
if (uri.equals(writeNamespace)) {
|
||||||
namespaces.put(uri, "this");
|
namespaces.put(uri, "this");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (prefixNamespace!=null) {
|
if (prefixNamespace != null) {
|
||||||
namespaces.put(uri, prefixNamespace); // let user define it
|
namespaces.put(uri, prefixNamespace); // let user define it
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
StringBuilder buf = new StringBuilder(20);
|
StringBuilder buf = new StringBuilder(20);
|
||||||
for (char c:uri.toLowerCase().toCharArray()) {
|
for (char c : uri.toLowerCase().toCharArray()) {
|
||||||
if (Character.isLetter(c)) {
|
if (Character.isLetter(c)) {
|
||||||
buf.append(c);
|
buf.append(c);
|
||||||
}
|
}
|
||||||
|
|
@ -110,34 +110,34 @@ public class EldXsdWriterElement {
|
||||||
|
|
||||||
public void startNamespaces(String namespaceUri) {
|
public void startNamespaces(String namespaceUri) {
|
||||||
|
|
||||||
this.writeNamespace=namespaceUri;
|
this.writeNamespace = namespaceUri;
|
||||||
this.namespaces.clear();
|
this.namespaces.clear();
|
||||||
|
|
||||||
// redo this mess, add nice find for binding handlers
|
// redo this mess, add nice find for binding handlers
|
||||||
for (X4OLanguageModule modContext:language.getLanguageModules()) {
|
for (X4OLanguageModule modContext : language.getLanguageModules()) {
|
||||||
for (ElementNamespace nsContext:modContext.getElementNamespaces()) {
|
for (ElementNamespace nsContext : modContext.getElementNamespaces()) {
|
||||||
for (ElementClass ec:nsContext.getElementClasses()) {
|
for (ElementClass ec : nsContext.getElementClasses()) {
|
||||||
Class<?> objectClass = null;
|
Class<?> objectClass = null;
|
||||||
if (ec.getObjectClass()!=null) {
|
if (ec.getObjectClass() != null) {
|
||||||
objectClass = ec.getObjectClass();
|
objectClass = ec.getObjectClass();
|
||||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||||
for (ElementClass checkClass:ns.getElementClasses()) {
|
for (ElementClass checkClass : ns.getElementClasses()) {
|
||||||
if (checkClass.getObjectClass()==null) {
|
if (checkClass.getObjectClass() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Class<?> checkObjectClass = checkClass.getObjectClass();
|
Class<?> checkObjectClass = checkClass.getObjectClass();
|
||||||
List<ElementBindingHandler> b = language.findElementBindingHandlers(objectClass,checkObjectClass);
|
List<ElementBindingHandler> b = language.findElementBindingHandlers(objectClass, checkObjectClass);
|
||||||
if (b.isEmpty()==false) {
|
if (b.isEmpty() == false) {
|
||||||
startNamespace(ns.getUri(),ns.getSchemaPrefix());
|
startNamespace(ns.getUri(), ns.getSchemaPrefix());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ElementInterface ei:language.findElementInterfaces(objectClass)) {
|
for (ElementInterface ei : language.findElementInterfaces(objectClass)) {
|
||||||
List<String> eiTags = ei.getElementParents(namespaceUri);
|
List<String> eiTags = ei.getElementParents(namespaceUri);
|
||||||
if (eiTags!=null) {
|
if (eiTags != null) {
|
||||||
startNamespace(nsContext.getUri(),nsContext.getSchemaPrefix());
|
startNamespace(nsContext.getUri(), nsContext.getSchemaPrefix());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -146,7 +146,6 @@ public class EldXsdWriterElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static final String COMMENT_FORMAT = "%1$-20s %2$s";
|
private static final String COMMENT_FORMAT = "%1$-20s %2$s";
|
||||||
|
|
||||||
private void prologWriteGenerator() throws IOException {
|
private void prologWriteGenerator() throws IOException {
|
||||||
|
|
@ -161,13 +160,13 @@ public class EldXsdWriterElement {
|
||||||
String generatedBy = propertyConfig.getPropertyString(EldXsdWriter.PROLOG_GENERATED_BY, EldXsdWriter.class.getSimpleName());
|
String generatedBy = propertyConfig.getPropertyString(EldXsdWriter.PROLOG_GENERATED_BY, EldXsdWriter.class.getSimpleName());
|
||||||
String generatedVersion = propertyConfig.getPropertyString(EldXsdWriter.PROLOG_GENERATED_VERSION);
|
String generatedVersion = propertyConfig.getPropertyString(EldXsdWriter.PROLOG_GENERATED_VERSION);
|
||||||
StringBuilder b = new StringBuilder();
|
StringBuilder b = new StringBuilder();
|
||||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"GeneratedBy:",generatedBy));
|
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, "GeneratedDate:", new Date()));
|
||||||
if (generatedVersion != null && !generatedVersion.isEmpty()) {
|
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, "LanguageName:", language.getLanguageName()));
|
||||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"LanguageVersion:",language.getLanguageVersion()));
|
b.append(chEnter + chTab + String.format(COMMENT_FORMAT, "LanguageVersion:", language.getLanguageVersion()));
|
||||||
b.append(chEnter);
|
b.append(chEnter);
|
||||||
xsdWriter.printComment(b.toString());
|
xsdWriter.printComment(b.toString());
|
||||||
}
|
}
|
||||||
|
|
@ -177,10 +176,10 @@ public class EldXsdWriterElement {
|
||||||
String chTab = propertyConfig.getPropertyString(SAX3WriterXml.OUTPUT_CHAR_TAB);
|
String chTab = propertyConfig.getPropertyString(SAX3WriterXml.OUTPUT_CHAR_TAB);
|
||||||
if (propertyConfig.getPropertyBoolean(EldXsdWriter.PROLOG_XMLNS_INFO_ENABLE)) {
|
if (propertyConfig.getPropertyBoolean(EldXsdWriter.PROLOG_XMLNS_INFO_ENABLE)) {
|
||||||
StringBuilder b = new StringBuilder();
|
StringBuilder b = new StringBuilder();
|
||||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"NSId:",ns.getId()));
|
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, "NSName:", ns.getName()));
|
||||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"NSUri:",ns.getUri()));
|
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, "NSUriSchema:", ns.getSchemaUri()));
|
||||||
b.append(chEnter);
|
b.append(chEnter);
|
||||||
xsdWriter.printComment(b.toString());
|
xsdWriter.printComment(b.toString());
|
||||||
}
|
}
|
||||||
|
|
@ -212,7 +211,7 @@ public class EldXsdWriterElement {
|
||||||
prologWriteGenerator();
|
prologWriteGenerator();
|
||||||
prologWriteNSMeta(ns);
|
prologWriteNSMeta(ns);
|
||||||
|
|
||||||
for (String uri:namespaces.keySet()) {
|
for (String uri : namespaces.keySet()) {
|
||||||
String prefix = namespaces.get(uri);
|
String prefix = namespaces.get(uri);
|
||||||
try {
|
try {
|
||||||
xsdWriter.getContentWriterWrapped().startPrefixMapping(prefix, uri);
|
xsdWriter.getContentWriterWrapped().startPrefixMapping(prefix, uri);
|
||||||
|
|
@ -222,13 +221,13 @@ public class EldXsdWriterElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "version", "", "", "1.0");
|
atts.addAttribute("", "version", "", "", "1.0");
|
||||||
atts.addAttribute ("", "elementFormDefault", "", "", "qualified");
|
atts.addAttribute("", "elementFormDefault", "", "", "qualified");
|
||||||
atts.addAttribute ("", "attributeFormDefault", "", "", "unqualified");
|
atts.addAttribute("", "attributeFormDefault", "", "", "unqualified");
|
||||||
atts.addAttribute ("", "targetNamespace", "", "", ns.getUri());
|
atts.addAttribute("", "targetNamespace", "", "", ns.getUri());
|
||||||
xsdWriter.printTagStart(Tag.schema, atts);
|
xsdWriter.printTagStart(Tag.schema, atts);
|
||||||
|
|
||||||
for (String uri:namespaces.keySet()) {
|
for (String uri : namespaces.keySet()) {
|
||||||
if (ns.getUri().equals(uri)) {
|
if (ns.getUri().equals(uri)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -250,78 +249,78 @@ public class EldXsdWriterElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeNamespaceAttributes(ElementNamespace ns) throws IOException {
|
private void writeNamespaceAttributes(ElementNamespace ns) throws IOException {
|
||||||
for (ElementNamespaceAttribute eah:ns.getElementNamespaceAttributes()) {
|
for (ElementNamespaceAttribute eah : ns.getElementNamespaceAttributes()) {
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "name", "", "", eah.getAttributeName());
|
atts.addAttribute("", "name", "", "", eah.getAttributeName());
|
||||||
atts.addAttribute ("", "type", "", "", "string");
|
atts.addAttribute("", "type", "", "", "string");
|
||||||
writeElementAttribute(eah,atts);
|
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();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) {
|
if (nsWrite.getLanguageRoot() != null && nsWrite.getLanguageRoot()) {
|
||||||
atts.addAttribute ("", "name", "", "", ec.getId());
|
atts.addAttribute("", "name", "", "", ec.getId());
|
||||||
xsdWriter.printTagStart(Tag.element, atts);// Only in the language root xsd there is an element.
|
xsdWriter.printTagStart(Tag.element, atts);// Only in the language root xsd there is an element.
|
||||||
|
|
||||||
atts = new AttributesImpl();
|
atts = new AttributesImpl();
|
||||||
xsdWriter.printTagStart(Tag.complexType, atts);
|
xsdWriter.printTagStart(Tag.complexType, atts);
|
||||||
} else {
|
} else {
|
||||||
atts.addAttribute ("", "name", "", "", ec.getId()+"Type");
|
atts.addAttribute("", "name", "", "", ec.getId() + "Type");
|
||||||
xsdWriter.printTagStart(Tag.complexType, atts);
|
xsdWriter.printTagStart(Tag.complexType, atts);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ec.getSchemaContentBase()!=null) {
|
if (ec.getSchemaContentBase() != null) {
|
||||||
atts = new AttributesImpl();
|
atts = new AttributesImpl();
|
||||||
if (ec.getSchemaContentComplex()!=null && ec.getSchemaContentComplex()) {
|
if (ec.getSchemaContentComplex() != null && ec.getSchemaContentComplex()) {
|
||||||
if (ec.getSchemaContentMixed()!=null && ec.getSchemaContentMixed()) {
|
if (ec.getSchemaContentMixed() != null && ec.getSchemaContentMixed()) {
|
||||||
atts.addAttribute ("", "mixed", "", "", "true");
|
atts.addAttribute("", "mixed", "", "", "true");
|
||||||
}
|
}
|
||||||
xsdWriter.printTagStart(Tag.complexContent, atts);
|
xsdWriter.printTagStart(Tag.complexContent, atts);
|
||||||
} else {
|
} else {
|
||||||
xsdWriter.printTagStart(Tag.simpleContent, atts);
|
xsdWriter.printTagStart(Tag.simpleContent, atts);
|
||||||
}
|
}
|
||||||
atts = new AttributesImpl();
|
atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "base", "", "", ec.getSchemaContentBase());
|
atts.addAttribute("", "base", "", "", ec.getSchemaContentBase());
|
||||||
xsdWriter.printTagStart(Tag.extension, atts);
|
xsdWriter.printTagStart(Tag.extension, atts);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ec.getSchemaContentBase()==null) {
|
if (ec.getSchemaContentBase() == null) {
|
||||||
atts = new AttributesImpl();
|
atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "minOccurs", "", "", "0"); // TODO: make unordered elements
|
atts.addAttribute("", "minOccurs", "", "", "0"); // TODO: make unordered elements
|
||||||
atts.addAttribute ("", "maxOccurs", "", "", "unbounded");
|
atts.addAttribute("", "maxOccurs", "", "", "unbounded");
|
||||||
xsdWriter.printTagStart(Tag.choice, atts);
|
xsdWriter.printTagStart(Tag.choice, atts);
|
||||||
|
|
||||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||||
writeElementClassNamespaces(ec,nsWrite,ns);
|
writeElementClassNamespaces(ec, nsWrite, ns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xsdWriter.printTagEnd(Tag.choice);
|
xsdWriter.printTagEnd(Tag.choice);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> attrNames = new ArrayList<String>(30);
|
List<String> attrNames = new ArrayList<String>(30);
|
||||||
for (ElementClassAttribute eca:ec.getElementClassAttributes()) {
|
for (ElementClassAttribute eca : ec.getElementClassAttributes()) {
|
||||||
attrNames.add(eca.getId());
|
attrNames.add(eca.getId());
|
||||||
atts = new AttributesImpl();
|
atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "name", "", "", eca.getId());
|
atts.addAttribute("", "name", "", "", eca.getId());
|
||||||
atts.addAttribute ("", "type", "", "", "string");
|
atts.addAttribute("", "type", "", "", "string");
|
||||||
if (eca.getRequired()!=null && eca.getRequired()) {
|
if (eca.getRequired() != null && eca.getRequired()) {
|
||||||
atts.addAttribute ("", "use", "", "", "required");
|
atts.addAttribute("", "use", "", "", "required");
|
||||||
}
|
}
|
||||||
writeElementAttribute(eca,atts);
|
writeElementAttribute(eca, atts);
|
||||||
|
|
||||||
for (String alias:eca.getAttributeAliases()) {
|
for (String alias : eca.getAttributeAliases()) {
|
||||||
attrNames.add(alias);
|
attrNames.add(alias);
|
||||||
atts = new AttributesImpl();
|
atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "name", "", "", alias);
|
atts.addAttribute("", "name", "", "", alias);
|
||||||
atts.addAttribute ("", "type", "", "", "string");
|
atts.addAttribute("", "type", "", "", "string");
|
||||||
writeElementAttribute(null,atts);
|
writeElementAttribute(null, atts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ec.getAutoAttributes()!=null && ec.getAutoAttributes()==false) {
|
if (ec.getAutoAttributes() != null && ec.getAutoAttributes() == false) {
|
||||||
// oke, reverse this if and rm whitespace.
|
// oke, reverse this if and rm whitespace.
|
||||||
try {
|
try {
|
||||||
xsdWriter.getContentWriterWrapped().ignorableWhitespace(' ');
|
xsdWriter.getContentWriterWrapped().ignorableWhitespace(' ');
|
||||||
|
|
@ -331,39 +330,39 @@ public class EldXsdWriterElement {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (ec.getObjectClass()!=null) {
|
if (ec.getObjectClass() != null) {
|
||||||
for (Method m:ec.getObjectClass().getMethods()) {
|
for (Method m : ec.getObjectClass().getMethods()) {
|
||||||
if (m.getName().startsWith("set")) {
|
if (m.getName().startsWith("set")) {
|
||||||
String n = m.getName().substring(3);
|
String n = m.getName().substring(3);
|
||||||
if (m.getParameterTypes().length==0) {
|
if (m.getParameterTypes().length == 0) {
|
||||||
continue; // set without parameters
|
continue; // set without parameters
|
||||||
}
|
}
|
||||||
if (n.length()<2) {
|
if (n.length() < 2) {
|
||||||
continue;
|
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)) {
|
if (attrNames.contains(n)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
attrNames.add(n);
|
attrNames.add(n);
|
||||||
atts = new AttributesImpl();
|
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.
|
Class<?> type = m.getParameterTypes()[0]; // TODO make full list for auto attribute type resolving.
|
||||||
if (type.equals(Object.class)) {
|
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)) {
|
} 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)) {
|
} 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)) {
|
} 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)) {
|
} 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)) {
|
} else if (type.isAssignableFrom(Double.class) | type.isAssignableFrom(Double.TYPE)) {
|
||||||
atts.addAttribute ("", "type", "", "", "double");
|
atts.addAttribute("", "type", "", "", "double");
|
||||||
} else {
|
} else {
|
||||||
atts.addAttribute ("", "type", "", "", "string");
|
atts.addAttribute("", "type", "", "", "string");
|
||||||
}
|
}
|
||||||
xsdWriter.printTagStartEnd(Tag.attribute, atts);
|
xsdWriter.printTagStartEnd(Tag.attribute, atts);
|
||||||
}
|
}
|
||||||
|
|
@ -373,51 +372,51 @@ public class EldXsdWriterElement {
|
||||||
xsdWriter.printTagStartEnd(Tag.anyAttribute, atts);
|
xsdWriter.printTagStartEnd(Tag.anyAttribute, atts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ec.getSchemaContentBase()!=null) {
|
if (ec.getSchemaContentBase() != null) {
|
||||||
xsdWriter.printTagEnd(Tag.extension);
|
xsdWriter.printTagEnd(Tag.extension);
|
||||||
if (ec.getSchemaContentComplex()!=null && ec.getSchemaContentComplex()) {
|
if (ec.getSchemaContentComplex() != null && ec.getSchemaContentComplex()) {
|
||||||
xsdWriter.printTagEnd(Tag.complexContent);
|
xsdWriter.printTagEnd(Tag.complexContent);
|
||||||
} else {
|
} else {
|
||||||
xsdWriter.printTagEnd(Tag.simpleContent);
|
xsdWriter.printTagEnd(Tag.simpleContent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xsdWriter.printTagEnd(Tag.complexType);
|
xsdWriter.printTagEnd(Tag.complexType);
|
||||||
if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) {
|
if (nsWrite.getLanguageRoot() != null && nsWrite.getLanguageRoot()) {
|
||||||
xsdWriter.printTagEnd(Tag.element);
|
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();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
List<String> refElements = new ArrayList<String>(20);
|
List<String> refElements = new ArrayList<String>(20);
|
||||||
for (ElementClass checkClass:ns.getElementClasses()) {
|
for (ElementClass checkClass : ns.getElementClasses()) {
|
||||||
List<String> parents = checkClass.getElementParents(nsWrite.getUri());
|
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());
|
refElements.add(checkClass.getId());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (checkClass.getObjectClass()==null) {
|
if (checkClass.getObjectClass() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (ElementInterface ei:language.findElementInterfaces(checkClass.getObjectClass())) {
|
for (ElementInterface ei : language.findElementInterfaces(checkClass.getObjectClass())) {
|
||||||
parents = ei.getElementParents(nsWrite.getUri());
|
parents = ei.getElementParents(nsWrite.getUri());
|
||||||
if (parents!=null && parents.contains(ecWrite.getId())) {
|
if (parents != null && parents.contains(ecWrite.getId())) {
|
||||||
refElements.add(checkClass.getId());
|
refElements.add(checkClass.getId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ecWrite.getObjectClass()==null) {
|
if (ecWrite.getObjectClass() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Class<?> objectClass = ecWrite.getObjectClass();
|
Class<?> objectClass = ecWrite.getObjectClass();
|
||||||
Class<?> checkObjectClass = checkClass.getObjectClass();
|
Class<?> checkObjectClass = checkClass.getObjectClass();
|
||||||
List<ElementBindingHandler> b = language.findElementBindingHandlers(objectClass,checkObjectClass);
|
List<ElementBindingHandler> b = language.findElementBindingHandlers(objectClass, checkObjectClass);
|
||||||
if (b.isEmpty()==false) {
|
if (b.isEmpty() == false) {
|
||||||
refElements.add(checkClass.getId());
|
refElements.add(checkClass.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (refElements.isEmpty()==false) {
|
if (refElements.isEmpty() == false) {
|
||||||
Set<String> s = new HashSet<String>(refElements.size());
|
Set<String> s = new HashSet<String>(refElements.size());
|
||||||
s.addAll(refElements);
|
s.addAll(refElements);
|
||||||
List<String> r = new ArrayList<String>(s.size());
|
List<String> r = new ArrayList<String>(s.size());
|
||||||
|
|
@ -425,45 +424,44 @@ public class EldXsdWriterElement {
|
||||||
Collections.sort(r);
|
Collections.sort(r);
|
||||||
|
|
||||||
String prefix = namespaces.get(ns.getUri());
|
String prefix = namespaces.get(ns.getUri());
|
||||||
for (String refElement:r) {
|
for (String refElement : r) {
|
||||||
atts = new AttributesImpl();
|
atts = new AttributesImpl();
|
||||||
if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) {
|
if (nsWrite.getLanguageRoot() != null && nsWrite.getLanguageRoot()) {
|
||||||
atts.addAttribute ("", "ref", "", "", prefix+":"+refElement);
|
atts.addAttribute("", "ref", "", "", prefix + ":" + refElement);
|
||||||
} else if (nsWrite.getUri().equals(ns.getUri())==false) {
|
} else if (nsWrite.getUri().equals(ns.getUri()) == false) {
|
||||||
atts.addAttribute ("", "ref", "", "", prefix+":"+refElement);
|
atts.addAttribute("", "ref", "", "", prefix + ":" + refElement);
|
||||||
} else {
|
} else {
|
||||||
atts.addAttribute ("", "name", "", "", refElement);
|
atts.addAttribute("", "name", "", "", refElement);
|
||||||
atts.addAttribute ("", "type", "", "", prefix+":"+refElement+"Type");
|
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 {
|
||||||
public void writeElement(ElementClass ec,ElementNamespace nsWrite) throws IOException {
|
if (nsWrite.getLanguageRoot() != null && nsWrite.getLanguageRoot()) {
|
||||||
if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) {
|
|
||||||
return; // is done in writeElementClass
|
return; // is done in writeElementClass
|
||||||
}
|
}
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "name", "", "", ec.getId());
|
atts.addAttribute("", "name", "", "", ec.getId());
|
||||||
atts.addAttribute ("", "type", "", "", "this:"+ec.getId()+"Type");
|
atts.addAttribute("", "type", "", "", "this:" + ec.getId() + "Type");
|
||||||
xsdWriter.printTagStart(Tag.element,atts);
|
xsdWriter.printTagStart(Tag.element, atts);
|
||||||
writeElementMetaBase(ec);
|
writeElementMetaBase(ec);
|
||||||
xsdWriter.printTagEnd(Tag.element);
|
xsdWriter.printTagEnd(Tag.element);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeElementAttribute(ElementMetaBase base,AttributesImpl atts) throws IOException {
|
private void writeElementAttribute(ElementMetaBase base, AttributesImpl atts) throws IOException {
|
||||||
xsdWriter.printTagStart(Tag.attribute,atts);
|
xsdWriter.printTagStart(Tag.attribute, atts);
|
||||||
writeElementMetaBase(base);
|
writeElementMetaBase(base);
|
||||||
xsdWriter.printTagEnd(Tag.attribute);
|
xsdWriter.printTagEnd(Tag.attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeElementMetaBase(ElementMetaBase base) throws IOException {
|
private void writeElementMetaBase(ElementMetaBase base) throws IOException {
|
||||||
if (base==null) {
|
if (base == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (base.getDescription()==null) {
|
if (base.getDescription() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!propertyConfig.getPropertyBoolean(EldXsdWriter.OUTPUT_DOCUMENTATION)) {
|
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
|
* 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.
|
* 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.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -47,7 +47,7 @@ public abstract class AbstractElement implements Element {
|
||||||
/** The ElementClass */
|
/** The ElementClass */
|
||||||
private ElementClass elementClass = null;
|
private ElementClass elementClass = null;
|
||||||
/** The attributes */
|
/** The attributes */
|
||||||
private Map<String,String> attributes = new HashMap<String,String>(10);
|
private Map<String, String> attributes = new HashMap<String, String>(10);
|
||||||
/** The Childeren */
|
/** The Childeren */
|
||||||
private List<Element> childeren = new ArrayList<Element>(10);
|
private List<Element> childeren = new ArrayList<Element>(10);
|
||||||
/** All Childeren */
|
/** All Childeren */
|
||||||
|
|
@ -87,6 +87,7 @@ public abstract class AbstractElement implements Element {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleans the attributes and elements(class) and context.
|
* Cleans the attributes and elements(class) and context.
|
||||||
|
*
|
||||||
* @see Element#release()
|
* @see Element#release()
|
||||||
*/
|
*/
|
||||||
public void release() throws ElementException {
|
public void release() throws ElementException {
|
||||||
|
|
@ -110,14 +111,14 @@ public abstract class AbstractElement implements Element {
|
||||||
* @see Element#setElementObject(Object)
|
* @see Element#setElementObject(Object)
|
||||||
*/
|
*/
|
||||||
public void setElementObject(Object object) {
|
public void setElementObject(Object object) {
|
||||||
elementObject=object;
|
elementObject = object;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Element#setLanguageSession(X4OLanguageSession)
|
* @see Element#setLanguageSession(X4OLanguageSession)
|
||||||
*/
|
*/
|
||||||
public void setLanguageSession(X4OLanguageSession languageSession) {
|
public void setLanguageSession(X4OLanguageSession languageSession) {
|
||||||
this.languageSession=languageSession;
|
this.languageSession = languageSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -132,7 +133,8 @@ public abstract class AbstractElement implements Element {
|
||||||
*/
|
*/
|
||||||
public void doCharacters(String characters) throws ElementException {
|
public void doCharacters(String characters) throws ElementException {
|
||||||
try {
|
try {
|
||||||
Element e = X4OLanguageClassLoader.newInstance(Element.class, getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyCharacters());
|
Element e = X4OLanguageClassLoader.newInstance(Element.class,
|
||||||
|
getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyCharacters());
|
||||||
e.setElementObject(characters);
|
e.setElementObject(characters);
|
||||||
addChild(e);
|
addChild(e);
|
||||||
} catch (ClassNotFoundException exception) {
|
} catch (ClassNotFoundException exception) {
|
||||||
|
|
@ -145,7 +147,8 @@ public abstract class AbstractElement implements Element {
|
||||||
*/
|
*/
|
||||||
public void doComment(String comment) throws ElementException {
|
public void doComment(String comment) throws ElementException {
|
||||||
try {
|
try {
|
||||||
Element e = X4OLanguageClassLoader.newInstance(Element.class, getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyComment());
|
Element e = X4OLanguageClassLoader.newInstance(Element.class,
|
||||||
|
getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyComment());
|
||||||
e.setElementObject(comment);
|
e.setElementObject(comment);
|
||||||
addChild(e);
|
addChild(e);
|
||||||
} catch (ClassNotFoundException exception) {
|
} catch (ClassNotFoundException exception) {
|
||||||
|
|
@ -158,7 +161,8 @@ public abstract class AbstractElement implements Element {
|
||||||
*/
|
*/
|
||||||
public void doIgnorableWhitespace(String space) throws ElementException {
|
public void doIgnorableWhitespace(String space) throws ElementException {
|
||||||
try {
|
try {
|
||||||
Element e = X4OLanguageClassLoader.newInstance(Element.class, getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyWhitespace());
|
Element e = X4OLanguageClassLoader.newInstance(Element.class,
|
||||||
|
getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyWhitespace());
|
||||||
e.setElementObject(space);
|
e.setElementObject(space);
|
||||||
addChild(e);
|
addChild(e);
|
||||||
} catch (ClassNotFoundException exception) {
|
} catch (ClassNotFoundException exception) {
|
||||||
|
|
@ -170,7 +174,7 @@ public abstract class AbstractElement implements Element {
|
||||||
* @see org.x4o.xml.element.Element#setElementClass(ElementClass)
|
* @see org.x4o.xml.element.Element#setElementClass(ElementClass)
|
||||||
*/
|
*/
|
||||||
public void setElementClass(ElementClass elementClass) {
|
public void setElementClass(ElementClass elementClass) {
|
||||||
this.elementClass=elementClass;
|
this.elementClass = elementClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -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);
|
attributes.put(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -235,6 +239,7 @@ public abstract class AbstractElement implements Element {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defaults to false.
|
* Defaults to false.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.element.Element#isTransformingTree()
|
* @see org.x4o.xml.element.Element#isTransformingTree()
|
||||||
*/
|
*/
|
||||||
public boolean isTransformingTree() {
|
public boolean isTransformingTree() {
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An AbstractElementBindingHandler.<br>
|
* An AbstractElementBindingHandler.<br>
|
||||||
|
|
@ -33,30 +32,31 @@ package org.x4o.xml.element;
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractElementBindingHandler<T> extends AbstractElementMetaBase implements ElementBindingHandler {
|
public abstract class AbstractElementBindingHandler<T> extends AbstractElementMetaBase implements ElementBindingHandler {
|
||||||
|
|
||||||
abstract public void bindChild(Element childElement,T parentObject,Object childObject) throws ElementBindingHandlerException;
|
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 createChilderen(Element parentElement, T parentObject) throws ElementBindingHandlerException;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void bindChild(Element childElement) throws ElementBindingHandlerException {
|
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")
|
@SuppressWarnings("unchecked")
|
||||||
public void createChilderen(Element parentElement) throws ElementBindingHandlerException {
|
public void createChilderen(Element parentElement) throws ElementBindingHandlerException {
|
||||||
createChilderen(parentElement,(T)parentElement.getElementObject());
|
createChilderen(parentElement, (T) parentElement.getElementObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createChild(Element parentElement,Object childObject) {
|
protected void createChild(Element parentElement, Object childObject) {
|
||||||
if (childObject==null) {
|
if (childObject == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (parentElement==null) {
|
if (parentElement == null) {
|
||||||
throw new NullPointerException("Can't create child with null parent.");
|
throw new NullPointerException("Can't create child with null parent.");
|
||||||
}
|
}
|
||||||
Element childElement = parentElement.getLanguageSession().getLanguage().createElementInstance(parentElement.getLanguageSession(), childObject.getClass());
|
Element childElement = parentElement.getLanguageSession().getLanguage().createElementInstance(parentElement.getLanguageSession(),
|
||||||
if (childElement==null) {
|
childObject.getClass());
|
||||||
throw new NullPointerException("Could not find Element for child: "+childObject.getClass());
|
if (childElement == null) {
|
||||||
|
throw new NullPointerException("Could not find Element for child: " + childObject.getClass());
|
||||||
}
|
}
|
||||||
childElement.setElementObject(childObject);
|
childElement.setElementObject(childObject);
|
||||||
childElement.setParent(parentElement);
|
childElement.setParent(parentElement);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
|
||||||
private List<String> attributeAliases = null;
|
private List<String> attributeAliases = null;
|
||||||
private Boolean required = null;
|
private Boolean required = null;
|
||||||
private Boolean runResolveEL = null;
|
private Boolean runResolveEL = null;
|
||||||
//private Boolean runInterfaces = null;
|
// private Boolean runInterfaces = null;
|
||||||
private Boolean runConverters = null;
|
private Boolean runConverters = null;
|
||||||
private Boolean runBeanValue = null;
|
private Boolean runBeanValue = null;
|
||||||
private Integer writeOrder = null;
|
private Integer writeOrder = null;
|
||||||
|
|
@ -54,6 +54,7 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the objectConverter.
|
* Returns the objectConverter.
|
||||||
|
*
|
||||||
* @return The objectConverter.
|
* @return The objectConverter.
|
||||||
*/
|
*/
|
||||||
public ObjectConverter getObjectConverter() {
|
public ObjectConverter getObjectConverter() {
|
||||||
|
|
@ -62,6 +63,7 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the objectConverter.
|
* Sets the objectConverter.
|
||||||
|
*
|
||||||
* @param objectConverter The objectConverter to set.
|
* @param objectConverter The objectConverter to set.
|
||||||
*/
|
*/
|
||||||
public void setObjectConverter(ObjectConverter objectConverter) {
|
public void setObjectConverter(ObjectConverter objectConverter) {
|
||||||
|
|
@ -70,15 +72,17 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the default value.
|
* 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)
|
* @see org.x4o.xml.element.ElementClassAttribute#setDefaultValue(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void setDefaultValue(Object defaultValue) {
|
public void setDefaultValue(Object defaultValue) {
|
||||||
this.defaultValue=defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the default value.
|
* Returns the default value.
|
||||||
|
*
|
||||||
* @return The default value.
|
* @return The default value.
|
||||||
* @see org.x4o.xml.element.ElementClassAttribute#getDefaultValue()
|
* @see org.x4o.xml.element.ElementClassAttribute#getDefaultValue()
|
||||||
*/
|
*/
|
||||||
|
|
@ -88,7 +92,8 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an alias of this attribute.
|
* 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)
|
* @see org.x4o.xml.element.ElementClassAttribute#addAttributeAlias(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void addAttributeAlias(String alias) {
|
public void addAttributeAlias(String alias) {
|
||||||
|
|
@ -97,7 +102,8 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an alias of this attribute.
|
* 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)
|
* @see org.x4o.xml.element.ElementClassAttribute#removeAttributeAlias(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void removeAttributeAlias(String alias) {
|
public void removeAttributeAlias(String alias) {
|
||||||
|
|
@ -106,7 +112,8 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all aliases of this attribute.
|
* Returns all aliases of this attribute.
|
||||||
* @return An list of aliases.
|
*
|
||||||
|
* @return An list of aliases.
|
||||||
* @see org.x4o.xml.element.ElementClassAttribute#getAttributeAliases()
|
* @see org.x4o.xml.element.ElementClassAttribute#getAttributeAliases()
|
||||||
*/
|
*/
|
||||||
public List<String> getAttributeAliases() {
|
public List<String> getAttributeAliases() {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
@ -36,22 +36,23 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractElementClassBase extends AbstractElementMetaBase implements ElementClassBase {
|
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 List<ElementConfigurator> elementConfigurators = null;
|
||||||
private Map<String,List<String>> elementParents = null;
|
private Map<String, List<String>> elementParents = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a AbstractElementClassBase.
|
* Creates a AbstractElementClassBase.
|
||||||
*/
|
*/
|
||||||
public AbstractElementClassBase() {
|
public AbstractElementClassBase() {
|
||||||
elementConfigurators = new ArrayList<ElementConfigurator>(5);
|
elementConfigurators = new ArrayList<ElementConfigurator>(5);
|
||||||
elementClassAttributes = new HashMap<String,ElementClassAttribute>(15);
|
elementClassAttributes = new HashMap<String, ElementClassAttribute>(15);
|
||||||
elementParents = new HashMap<String,List<String>>(5);
|
elementParents = new HashMap<String, List<String>>(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of ElementConfigurators.
|
* Returns a list of ElementConfigurators.
|
||||||
* @return List of ElementConfigurators.
|
*
|
||||||
|
* @return List of ElementConfigurators.
|
||||||
* @see ElementClass#getElementConfigurators()
|
* @see ElementClass#getElementConfigurators()
|
||||||
*/
|
*/
|
||||||
public List<ElementConfigurator> getElementConfigurators() {
|
public List<ElementConfigurator> getElementConfigurators() {
|
||||||
|
|
@ -70,7 +71,7 @@ public abstract class AbstractElementClassBase extends AbstractElementMetaBase i
|
||||||
* @param elementClassAttribute The ElementClassAttribute to add.
|
* @param elementClassAttribute The ElementClassAttribute to add.
|
||||||
*/
|
*/
|
||||||
public void addElementClassAttribute(ElementClassAttribute elementClassAttribute) {
|
public void addElementClassAttribute(ElementClassAttribute elementClassAttribute) {
|
||||||
elementClassAttributes.put(elementClassAttribute.getId(),elementClassAttribute);
|
elementClassAttributes.put(elementClassAttribute.getId(), elementClassAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -82,6 +83,7 @@ public abstract class AbstractElementClassBase extends AbstractElementMetaBase i
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the ElementClassAttribute from its name.
|
* Get the ElementClassAttribute from its name.
|
||||||
|
*
|
||||||
* @param attributeName The attribute name.
|
* @param attributeName The attribute name.
|
||||||
* @return The element class attribute for the name.
|
* @return The element class attribute for the name.
|
||||||
*/
|
*/
|
||||||
|
|
@ -91,19 +93,20 @@ public abstract class AbstractElementClassBase extends AbstractElementMetaBase i
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds parent tag.
|
* Adds parent tag.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.element.ElementClassBase#addElementParent(java.lang.String,java.lang.String)
|
* @see org.x4o.xml.element.ElementClassBase#addElementParent(java.lang.String,java.lang.String)
|
||||||
* @param namespaceUri The namespace uri of the parent tag.
|
* @param 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) {
|
public void addElementParent(String namespaceUri, String tag) {
|
||||||
if (namespaceUri==null) {
|
if (namespaceUri == null) {
|
||||||
throw new NullPointerException("Can't add parent tag with null namespace uri.");
|
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.");
|
throw new IllegalArgumentException("Can't add parent tag with empty namespace uri.");
|
||||||
}
|
}
|
||||||
List<String> tags = elementParents.get(namespaceUri);
|
List<String> tags = elementParents.get(namespaceUri);
|
||||||
if (tags==null) {
|
if (tags == null) {
|
||||||
tags = new ArrayList<String>(5);
|
tags = new ArrayList<String>(5);
|
||||||
elementParents.put(namespaceUri, tags);
|
elementParents.put(namespaceUri, tags);
|
||||||
}
|
}
|
||||||
|
|
@ -112,13 +115,14 @@ public abstract class AbstractElementClassBase extends AbstractElementMetaBase i
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes parent tag.
|
* Removes parent tag.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.element.ElementClassBase#removeElementParent(java.lang.String,java.lang.String)
|
* @see org.x4o.xml.element.ElementClassBase#removeElementParent(java.lang.String,java.lang.String)
|
||||||
* @param namespaceUri The namespace uri of the parent tag.
|
* @param 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);
|
List<String> tags = elementParents.get(namespaceUri);
|
||||||
if (tags==null) {
|
if (tags == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tags.remove(tag);
|
tags.remove(tag);
|
||||||
|
|
@ -126,6 +130,7 @@ public abstract class AbstractElementClassBase extends AbstractElementMetaBase i
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the parent per namespace uri.
|
* Returns the parent per namespace uri.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.element.ElementClassBase#getElementParents(java.lang.String)
|
* @see org.x4o.xml.element.ElementClassBase#getElementParents(java.lang.String)
|
||||||
* @param namespaceUri The namespace uri to gets the parents of.
|
* @param namespaceUri The namespace uri to gets the parents of.
|
||||||
* @return List of parent tags of requested parent namespace uri.
|
* @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
|
* 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.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An AbstractElementConfigurator.<br>
|
* An AbstractElementConfigurator.<br>
|
||||||
|
|
@ -36,6 +36,7 @@ public abstract class AbstractElementConfigurator extends AbstractElementMetaBas
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defaults to false.
|
* Defaults to false.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.element.ElementConfigurator#isConfigAction()
|
* @see org.x4o.xml.element.ElementConfigurator#isConfigAction()
|
||||||
* @return True if set to configAction
|
* @return True if set to configAction
|
||||||
*/
|
*/
|
||||||
|
|
@ -45,9 +46,10 @@ public abstract class AbstractElementConfigurator extends AbstractElementMetaBas
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the configAction.
|
* Sets the configAction.
|
||||||
* @param configAction The configAction to set.
|
*
|
||||||
|
* @param configAction The configAction to set.
|
||||||
*/
|
*/
|
||||||
public void setConfigAction(boolean configAction) {
|
public void setConfigAction(boolean configAction) {
|
||||||
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
|
* 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.
|
* 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.
|
* AbstractElementInterface extends base support with element interface support.
|
||||||
|
|
@ -51,6 +51,6 @@ public abstract class AbstractElementInterface extends AbstractElementClassBase
|
||||||
* @param interfaceClass The interface class to set.
|
* @param interfaceClass The interface class to set.
|
||||||
*/
|
*/
|
||||||
public void setInterfaceClass(Class<?> interfaceClass) {
|
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
|
* 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.
|
* 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.
|
* AbstractElementMetaBase stores the id and description.
|
||||||
|
|
@ -39,6 +39,7 @@ public abstract class AbstractElementMetaBase implements ElementMetaBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the id.
|
* Gets the id.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.element.ElementMetaBase#getId()
|
* @see org.x4o.xml.element.ElementMetaBase#getId()
|
||||||
* @return The id.
|
* @return The id.
|
||||||
*/
|
*/
|
||||||
|
|
@ -48,15 +49,17 @@ public abstract class AbstractElementMetaBase implements ElementMetaBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the id.
|
* Sets the id.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.element.ElementMetaBase#setId(java.lang.String)
|
* @see org.x4o.xml.element.ElementMetaBase#setId(java.lang.String)
|
||||||
* @param id The id to set.
|
* @param id The id to set.
|
||||||
*/
|
*/
|
||||||
public void setId(String id) {
|
public void setId(String id) {
|
||||||
this.id=id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the description.
|
* Gets the description.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.element.ElementConfigurator#getDescription()
|
* @see org.x4o.xml.element.ElementConfigurator#getDescription()
|
||||||
* @return The description.
|
* @return The description.
|
||||||
*/
|
*/
|
||||||
|
|
@ -66,10 +69,11 @@ public abstract class AbstractElementMetaBase implements ElementMetaBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the description.
|
* Sets the description.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.element.ElementConfigurator#setDescription(java.lang.String)
|
* @see org.x4o.xml.element.ElementConfigurator#setDescription(java.lang.String)
|
||||||
* @param description The description to set.
|
* @param description The description to set.
|
||||||
*/
|
*/
|
||||||
public void setDescription(String description) {
|
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 ElementNamespaceInstanceProvider elementNamespaceInstanceProvider = null;
|
||||||
private String prefixMapping = null;
|
private String prefixMapping = null;
|
||||||
private Map<String,ElementClass> elementClasses = null;
|
private Map<String, ElementClass> elementClasses = null;
|
||||||
private String uri = null;
|
private String uri = null;
|
||||||
private String name = null;
|
private String name = null;
|
||||||
private String schemaUri = null;
|
private String schemaUri = null;
|
||||||
|
|
@ -47,7 +47,7 @@ public abstract class AbstractElementNamespace extends AbstractElementMetaBase i
|
||||||
private List<ElementNamespaceAttribute> elementNamespaceAttributes = null;
|
private List<ElementNamespaceAttribute> elementNamespaceAttributes = null;
|
||||||
|
|
||||||
public AbstractElementNamespace() {
|
public AbstractElementNamespace() {
|
||||||
elementClasses = new HashMap<String,ElementClass>(60);
|
elementClasses = new HashMap<String, ElementClass>(60);
|
||||||
elementNamespaceAttributes = new ArrayList<ElementNamespaceAttribute>(5);
|
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)
|
* @see org.x4o.xml.element.ElementNamespace#setPrefixMapping(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void setPrefixMapping(String prefixMapping) {
|
public void setPrefixMapping(String prefixMapping) {
|
||||||
this.prefixMapping=prefixMapping;
|
this.prefixMapping = prefixMapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementNamespace#addElementClass(org.x4o.xml.element.ElementClass)
|
* @see org.x4o.xml.element.ElementNamespace#addElementClass(org.x4o.xml.element.ElementClass)
|
||||||
*/
|
*/
|
||||||
public void addElementClass(ElementClass elementClass) {
|
public void addElementClass(ElementClass elementClass) {
|
||||||
if (elementClass.getId()==null) {
|
if (elementClass.getId() == null) {
|
||||||
throw new NullPointerException("ElementClass not correctly configured getId is null.");
|
throw new NullPointerException("ElementClass not correctly configured getId is null.");
|
||||||
}
|
}
|
||||||
elementClasses.put(elementClass.getId(), elementClass);
|
elementClasses.put(elementClass.getId(), elementClass);
|
||||||
|
|
@ -187,15 +187,14 @@ public abstract class AbstractElementNamespace extends AbstractElementMetaBase i
|
||||||
this.schemaPrefix = schemaPrefix;
|
this.schemaPrefix = schemaPrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addElementNamespaceAttribute(ElementNamespaceAttribute elementNamespaceAttribute) {
|
public void addElementNamespaceAttribute(ElementNamespaceAttribute elementNamespaceAttribute) {
|
||||||
if (elementNamespaceAttribute==null) {
|
if (elementNamespaceAttribute == null) {
|
||||||
throw new NullPointerException("Can't add null object");
|
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.");
|
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);
|
elementNamespaceAttributes.add(elementNamespaceAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ public abstract class AbstractElementNamespaceAttribute extends AbstractElementC
|
||||||
* @see org.x4o.xml.element.ElementNamespaceAttribute#addNextAttribute(java.lang.String)
|
* @see org.x4o.xml.element.ElementNamespaceAttribute#addNextAttribute(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void addNextAttribute(String attribute) {
|
public void addNextAttribute(String attribute) {
|
||||||
if (attribute==null) {
|
if (attribute == null) {
|
||||||
throw new NullPointerException("Can add null attribute for loading.");
|
throw new NullPointerException("Can add null attribute for loading.");
|
||||||
}
|
}
|
||||||
nextAttributes.add(attribute);
|
nextAttributes.add(attribute);
|
||||||
|
|
@ -50,7 +50,7 @@ public abstract class AbstractElementNamespaceAttribute extends AbstractElementC
|
||||||
* @see org.x4o.xml.element.ElementNamespaceAttribute#removeNextAttribute(java.lang.String)
|
* @see org.x4o.xml.element.ElementNamespaceAttribute#removeNextAttribute(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void removeNextAttribute(String attribute) {
|
public void removeNextAttribute(String attribute) {
|
||||||
if (attribute==null) {
|
if (attribute == null) {
|
||||||
throw new NullPointerException("Can remove null attribute for loading.");
|
throw new NullPointerException("Can remove null attribute for loading.");
|
||||||
}
|
}
|
||||||
nextAttributes.remove(attribute);
|
nextAttributes.remove(attribute);
|
||||||
|
|
@ -74,6 +74,6 @@ public abstract class AbstractElementNamespaceAttribute extends AbstractElementC
|
||||||
* @see org.x4o.xml.element.ElementNamespaceAttribute#setAttributeName(java.lang.String)
|
* @see org.x4o.xml.element.ElementNamespaceAttribute#setAttributeName(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void setAttributeName(String attributeName) {
|
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
|
* 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.
|
* 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.
|
* 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
|
* 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.
|
* 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.Locale;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
@ -29,7 +29,6 @@ import javax.el.ValueExpression;
|
||||||
|
|
||||||
import org.x4o.xml.conv.ObjectConverterException;
|
import org.x4o.xml.conv.ObjectConverterException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An DefaultElementAttributeValueParser.
|
* An DefaultElementAttributeValueParser.
|
||||||
*
|
*
|
||||||
|
|
@ -38,18 +37,16 @@ import org.x4o.xml.conv.ObjectConverterException;
|
||||||
*/
|
*/
|
||||||
public class DefaultElementAttributeValueParser implements ElementAttributeValueParser {
|
public class DefaultElementAttributeValueParser implements ElementAttributeValueParser {
|
||||||
|
|
||||||
|
|
||||||
private Logger logger = null;
|
private Logger logger = null;
|
||||||
|
|
||||||
public DefaultElementAttributeValueParser() {
|
public DefaultElementAttributeValueParser() {
|
||||||
logger = Logger.getLogger(DefaultElementAttributeValueParser.class.getName());
|
logger = Logger.getLogger(DefaultElementAttributeValueParser.class.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementAttributeValueParser#getParameterValue(java.lang.String, java.lang.String, org.x4o.xml.element.Element)
|
* @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;
|
Object value = valueString;
|
||||||
|
|
||||||
if (isELParameter(name, valueString, element)) {
|
if (isELParameter(name, valueString, element)) {
|
||||||
|
|
@ -58,43 +55,40 @@ public class DefaultElementAttributeValueParser implements ElementAttributeValue
|
||||||
return getConvertedParameterValue(name, value, element);
|
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)
|
* @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 {
|
public Object getConvertedParameterValue(String name, Object value, Element element) throws ElementAttributeValueParserException, ObjectConverterException {
|
||||||
//bit slow here
|
// bit slow here
|
||||||
if (value==null) {
|
if (value == null) {
|
||||||
return null; // TODO: make setting for null
|
return null; // TODO: make setting for null
|
||||||
}
|
}
|
||||||
|
|
||||||
// do converts for ElementClass
|
// do converts for ElementClass
|
||||||
ElementClassAttribute attr = element.getElementClass().getElementClassAttributeByName(name);
|
ElementClassAttribute attr = element.getElementClass().getElementClassAttributeByName(name);
|
||||||
if (attr!=null && attr.getObjectConverter()!=null && value.getClass().isAssignableFrom(attr.getObjectConverter().getObjectClassTo())==false) {
|
if (attr != null && attr.getObjectConverter() != null && value.getClass().isAssignableFrom(attr.getObjectConverter().getObjectClassTo()) == false) {
|
||||||
logger.finer("attr conv: "+attr.getObjectConverter()+" for name: "+name);
|
logger.finer("attr conv: " + attr.getObjectConverter() + " for name: " + name);
|
||||||
Object result = attr.getObjectConverter().convertTo(value.toString(), Locale.getDefault());
|
Object result = attr.getObjectConverter().convertTo(value.toString(), Locale.getDefault());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
// check interfaces
|
// check interfaces
|
||||||
if (element.getElementObject()==null) {
|
if (element.getElementObject() == null) {
|
||||||
return value;
|
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.");
|
logger.finer("Found interface match executing converter.");
|
||||||
for (ElementClassAttribute attrClass:ei.getElementClassAttributes()) {
|
for (ElementClassAttribute attrClass : ei.getElementClassAttributes()) {
|
||||||
if (name.equals(attrClass.getId())==false) {
|
if (name.equals(attrClass.getId()) == false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (attrClass.getObjectConverter()==null) {
|
if (attrClass.getObjectConverter() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (value.getClass().isAssignableFrom(attrClass.getObjectConverter().getObjectClassTo())) {
|
if (value.getClass().isAssignableFrom(attrClass.getObjectConverter().getObjectClassTo())) {
|
||||||
continue; // make flag ?
|
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());
|
Object result = attrClass.getObjectConverter().convertTo(value.toString(), Locale.getDefault());
|
||||||
return result; // ??
|
return result; // ??
|
||||||
}
|
}
|
||||||
|
|
@ -106,7 +100,8 @@ public class DefaultElementAttributeValueParser implements ElementAttributeValue
|
||||||
* @see org.x4o.xml.element.ElementAttributeValueParser#getELParameterValue(java.lang.String, org.x4o.xml.element.Element)
|
* @see org.x4o.xml.element.ElementAttributeValueParser#getELParameterValue(java.lang.String, org.x4o.xml.element.Element)
|
||||||
*/
|
*/
|
||||||
public Object getELParameterValue(String value, Element element) throws ElementAttributeValueParserException {
|
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());
|
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)
|
* @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) {
|
public boolean isELParameter(String name, String value, Element element) {
|
||||||
if (value==null) {
|
if (value == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (value.startsWith("${")==false) {
|
if (value.startsWith("${") == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (element==null) {
|
if (element == null) {
|
||||||
return true; // null element disables checks
|
return true; // null element disables checks
|
||||||
}
|
}
|
||||||
ElementClassAttribute attr = element.getElementClass().getElementClassAttributeByName(name);
|
ElementClassAttribute attr = element.getElementClass().getElementClassAttributeByName(name);
|
||||||
if (attr!=null && attr.getRunResolveEL()!=null && attr.getRunResolveEL()==false) {
|
if (attr != null && attr.getRunResolveEL() != null && attr.getRunResolveEL() == false) {
|
||||||
logger.finest("Skipping EL parsing for: "+name);
|
logger.finest("Skipping EL parsing for: " + name);
|
||||||
return false;
|
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.");
|
logger.finest("Found interface match checking disables el parameters.");
|
||||||
|
|
||||||
attr = ei.getElementClassAttributeByName(name);
|
attr = ei.getElementClassAttributeByName(name);
|
||||||
if (attr!=null && attr.getRunResolveEL()!=null && attr.getRunResolveEL()==false) {
|
if (attr != null && attr.getRunResolveEL() != null && attr.getRunResolveEL() == false) {
|
||||||
logger.finest("Skipping EL parsing for: "+name+" in interface element.");
|
logger.finest("Skipping EL parsing for: " + name + " in interface element.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -29,7 +29,6 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.x4o.xml.lang.X4OLanguageSession;
|
import org.x4o.xml.lang.X4OLanguageSession;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DefaultElementBodyCharacters the default characters element.
|
* DefaultElementBodyCharacters the default characters element.
|
||||||
*
|
*
|
||||||
|
|
@ -44,7 +43,7 @@ public class DefaultElementBodyCharacters implements Element {
|
||||||
private Object elementObject = null;
|
private Object elementObject = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The ElementType for characters.
|
* @return The ElementType for characters.
|
||||||
* @see org.x4o.xml.element.Element#getElementType()
|
* @see org.x4o.xml.element.Element#getElementType()
|
||||||
*/
|
*/
|
||||||
public ElementType getElementType() {
|
public ElementType getElementType() {
|
||||||
|
|
@ -106,7 +105,7 @@ public class DefaultElementBodyCharacters implements Element {
|
||||||
* @see org.x4o.xml.element.Element#getAttributes()
|
* @see org.x4o.xml.element.Element#getAttributes()
|
||||||
*/
|
*/
|
||||||
public Map<String, String> getAttributes() {
|
public Map<String, String> getAttributes() {
|
||||||
return new HashMap<String,String>(0);
|
return new HashMap<String, String>(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -185,13 +184,13 @@ public class DefaultElementBodyCharacters implements Element {
|
||||||
* @see org.x4o.xml.element.Element#setElementObject(java.lang.Object)
|
* @see org.x4o.xml.element.Element#setElementObject(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void setElementObject(Object elementObject) {
|
public void setElementObject(Object elementObject) {
|
||||||
this.elementObject=elementObject;
|
this.elementObject = elementObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.Element#setParent(org.x4o.xml.element.Element)
|
* @see org.x4o.xml.element.Element#setParent(org.x4o.xml.element.Element)
|
||||||
*/
|
*/
|
||||||
public void setParent(Element parent) {
|
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
|
* 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.
|
* 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.
|
* DefaultElementBodyComment the default comment element.
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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.
|
* DefaultElementBodyWhitespace the default white space element.
|
||||||
|
|
@ -32,7 +31,7 @@ package org.x4o.xml.element;
|
||||||
public class DefaultElementBodyWhitespace extends AbstractElement {
|
public class DefaultElementBodyWhitespace extends AbstractElement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the whitespace element type.
|
* @return Returns the whitespace element type.
|
||||||
* @see org.x4o.xml.element.AbstractElement#getElementType()
|
* @see org.x4o.xml.element.AbstractElement#getElementType()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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.
|
* 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
|
* 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.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default ElementClassAttribute.
|
* The default ElementClassAttribute.
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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.
|
* The default ElementInterface to store config based on class interface.
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DefaultElementNamespace is the default element namespace implementation.
|
* DefaultElementNamespace is the default element namespace implementation.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,6 @@ package org.x4o.xml.element;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DefaultElementNamespaceAttributeComparator.<br>
|
* The DefaultElementNamespaceAttributeComparator.<br>
|
||||||
* This Comparator compares the NextAttribute names with the attributeName of the ElementNamespaceAttribute.<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> {
|
public class DefaultElementNamespaceAttributeComparator implements Comparator<ElementNamespaceAttribute> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param e1 The first ElementNamespaceAttribute to compare.
|
* @param e1 The first ElementNamespaceAttribute to compare.
|
||||||
* @param e2 The second ElementNamespaceAttribute to compare.
|
* @param e2 The second ElementNamespaceAttribute to compare.
|
||||||
* @return 0 is same.
|
* @return 0 is same.
|
||||||
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public int compare(ElementNamespaceAttribute e1, ElementNamespaceAttribute e2) {
|
public int compare(ElementNamespaceAttribute e1, ElementNamespaceAttribute e2) {
|
||||||
|
|
||||||
for (String param:e1.getNextAttributes()) {
|
for (String param : e1.getNextAttributes()) {
|
||||||
if(param.equals(e2.getAttributeName())) {
|
if (param.equals(e2.getAttributeName())) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String param:e2.getNextAttributes()) {
|
for (String param : e2.getNextAttributes()) {
|
||||||
if(param.equals(e1.getAttributeName())) {
|
if (param.equals(e1.getAttributeName())) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,47 +47,47 @@ public class DefaultElementNamespaceInstanceProvider implements ElementNamespace
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param language The elementLanguage of this provider.
|
* @param language The elementLanguage of this provider.
|
||||||
* @param elementNamespace The elementNamespace for 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)
|
* @see org.x4o.xml.element.ElementNamespaceInstanceProvider#start(org.x4o.xml.lang.X4OLanguage, org.x4o.xml.element.ElementNamespace)
|
||||||
*/
|
*/
|
||||||
public void start(X4OLanguage language,ElementNamespace elementNamespace) {
|
public void start(X4OLanguage language, ElementNamespace elementNamespace) {
|
||||||
this.elementNamespace=elementNamespace;
|
this.elementNamespace = elementNamespace;
|
||||||
logger.finer("Starting DefaultElementNamespaceInstanceProvider for: "+elementNamespace.getUri());
|
logger.finer("Starting DefaultElementNamespaceInstanceProvider for: " + elementNamespace.getUri());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param languageSession The language context for which we create the Element instance.
|
* @param languageSession The language context for which we create the Element instance.
|
||||||
* @param tag The xml tag to create an Element instance for.
|
* @param tag The xml tag to create an Element instance for.
|
||||||
* @return The Element to handle the given tag.
|
* @return The Element to handle the given tag.
|
||||||
* @throws ElementNamespaceInstanceProviderException
|
* @throws ElementNamespaceInstanceProviderException
|
||||||
* @see org.x4o.xml.element.ElementNamespaceInstanceProvider#createElementInstance(org.x4o.xml.lang.X4OLanguageSession,java.lang.String)
|
* @see org.x4o.xml.element.ElementNamespaceInstanceProvider#createElementInstance(org.x4o.xml.lang.X4OLanguageSession,java.lang.String)
|
||||||
*/
|
*/
|
||||||
public Element createElementInstance(X4OLanguageSession languageSession,String tag) throws ElementNamespaceInstanceProviderException {
|
public Element createElementInstance(X4OLanguageSession languageSession, String tag) throws ElementNamespaceInstanceProviderException {
|
||||||
ElementClass elementClass = elementNamespace.getElementClass(tag);
|
ElementClass elementClass = elementNamespace.getElementClass(tag);
|
||||||
Element element = null;
|
Element element = null;
|
||||||
|
|
||||||
if (elementClass==null) {
|
if (elementClass == null) {
|
||||||
throw new ElementNamespaceInstanceProviderException(this,"Tag: " + tag + " unknown in: " + elementNamespace.getUri());
|
throw new ElementNamespaceInstanceProviderException(this, "Tag: " + tag + " unknown in: " + elementNamespace.getUri());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (elementClass.getElementClass()!=null) {
|
if (elementClass.getElementClass() != null) {
|
||||||
Object obj = X4OLanguageClassLoader.newInstance(elementClass.getElementClass());
|
Object obj = X4OLanguageClassLoader.newInstance(elementClass.getElementClass());
|
||||||
if (obj instanceof Element) {
|
if (obj instanceof Element) {
|
||||||
element = (Element) obj;
|
element = (Element) obj;
|
||||||
} else {
|
} 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 {
|
} 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()));
|
element.setElementObject(X4OLanguageClassLoader.newInstance(elementClass.getObjectClass()));
|
||||||
}
|
}
|
||||||
} catch (ClassNotFoundException e) {
|
} 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.setElementClass(elementClass);
|
||||||
element.setLanguageSession(languageSession);
|
element.setLanguageSession(languageSession);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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.io.Serializable;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
@ -39,24 +39,24 @@ import org.x4o.xml.conv.ObjectConverterException;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Feb 16, 2007
|
* @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 static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private Logger logger = Logger.getLogger(DefaultElementObjectPropertyValue.class.getName());
|
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.
|
// Get class but can be null.
|
||||||
Class<?> parameterClass = null;
|
Class<?> parameterClass = null;
|
||||||
if(parameter!=null) {
|
if (parameter != null) {
|
||||||
parameterClass=parameter.getClass();
|
parameterClass = parameter.getClass();
|
||||||
}
|
}
|
||||||
logger.finer("Trying value: pn="+parameterName+" o="+object+" p="+parameter+"("+parameterClass+")");
|
logger.finer("Trying value: pn=" + parameterName + " o=" + object + " p=" + parameter + "(" + parameterClass + ")");
|
||||||
String parameterNameSet = "set"+parameterName;
|
String parameterNameSet = "set" + parameterName;
|
||||||
Method[] methodes = object.getClass().getMethods();
|
Method[] methodes = object.getClass().getMethods();
|
||||||
Method lastMethodFall = null;
|
Method lastMethodFall = null;
|
||||||
for (int i=0;i<methodes.length;i++) {
|
for (int i = 0; i < methodes.length; i++) {
|
||||||
Method method = methodes[i];
|
Method method = methodes[i];
|
||||||
Class<?>[] types = method.getParameterTypes();
|
Class<?>[] types = method.getParameterTypes();
|
||||||
if (types.length == 0) {
|
if (types.length == 0) {
|
||||||
|
|
@ -67,32 +67,32 @@ public class DefaultElementObjectPropertyValue implements ElementObjectPropertyV
|
||||||
}
|
}
|
||||||
if (method.getName().equalsIgnoreCase(parameterNameSet)) {
|
if (method.getName().equalsIgnoreCase(parameterNameSet)) {
|
||||||
lastMethodFall = method;
|
lastMethodFall = method;
|
||||||
if (parameterClass!=null) {
|
if (parameterClass != null) {
|
||||||
// Check for class based parameters.
|
// Check for class based parameters.
|
||||||
if (types[0].isAssignableFrom(parameterClass)) {
|
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;
|
return method;
|
||||||
}
|
}
|
||||||
// Check the native parameter types.
|
// 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;
|
return method;
|
||||||
}
|
}
|
||||||
if (parameterClass.isAssignableFrom(Integer.class) && types[0].isAssignableFrom(Integer.TYPE) ) {
|
if (parameterClass.isAssignableFrom(Integer.class) && types[0].isAssignableFrom(Integer.TYPE)) {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
if (parameterClass.isAssignableFrom(Long.class) && types[0].isAssignableFrom(Long.TYPE) ) {
|
if (parameterClass.isAssignableFrom(Long.class) && types[0].isAssignableFrom(Long.TYPE)) {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
if (parameterClass.isAssignableFrom(Double.class) && types[0].isAssignableFrom(Double.TYPE) ) {
|
if (parameterClass.isAssignableFrom(Double.class) && types[0].isAssignableFrom(Double.TYPE)) {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
if (parameterClass.isAssignableFrom(Float.class) && types[0].isAssignableFrom(Float.TYPE) ) {
|
if (parameterClass.isAssignableFrom(Float.class) && types[0].isAssignableFrom(Float.TYPE)) {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
if (parameterClass.isAssignableFrom(Byte.class) && types[0].isAssignableFrom(Byte.TYPE) ) {
|
if (parameterClass.isAssignableFrom(Byte.class) && types[0].isAssignableFrom(Byte.TYPE)) {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
if (parameterClass.isAssignableFrom(Character.class) && types[0].isAssignableFrom(Character.TYPE) ) {
|
if (parameterClass.isAssignableFrom(Character.class) && types[0].isAssignableFrom(Character.TYPE)) {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -111,56 +111,55 @@ public class DefaultElementObjectPropertyValue implements ElementObjectPropertyV
|
||||||
* @param parameter
|
* @param parameter
|
||||||
* @throws ElementObjectPropertyValueException
|
* @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
|
// find the method for the parameter
|
||||||
Method lastMethod = findMethod(object,parameterName,parameter);
|
Method lastMethod = findMethod(object, parameterName, parameter);
|
||||||
if (lastMethod==null) {
|
if (lastMethod == null) {
|
||||||
logger.finest("No method found, aborting parameter: "+parameterName);
|
logger.finest("No method found, aborting parameter: " + parameterName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special case for null value.
|
// Special case for null value.
|
||||||
if (parameter==null) {
|
if (parameter == null) {
|
||||||
logger.finest("Found parameter is null Setting method: "+lastMethod.getParameterTypes()[0]+" for parameter: "+parameterName);
|
logger.finest("Found parameter is null Setting method: " + lastMethod.getParameterTypes()[0] + " for parameter: " + parameterName);
|
||||||
try {
|
try {
|
||||||
lastMethod.invoke(object,new Object[]{parameter});
|
lastMethod.invoke(object, new Object[] { parameter });
|
||||||
return;
|
return;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ElementObjectPropertyValueException(e.getMessage(),e);
|
throw new ElementObjectPropertyValueException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invoke for class based parameters
|
// Invoke for class based parameters
|
||||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(parameter.getClass())) {
|
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 {
|
try {
|
||||||
lastMethod.invoke(object,new Object[]{parameter});
|
lastMethod.invoke(object, new Object[] { parameter });
|
||||||
return;
|
return;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ElementObjectPropertyValueException(e.getMessage(),e);
|
throw new ElementObjectPropertyValueException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invoke for native based types
|
// Invoke for native based types
|
||||||
|
|
||||||
|
|
||||||
// not found 2sec try
|
// not found 2sec try
|
||||||
logger.finest("No corresoning class is found, trying convert manualy");
|
logger.finest("No corresoning class is found, trying convert manualy");
|
||||||
|
|
||||||
// special case for object.
|
// special case for object.
|
||||||
if (lastMethod.getParameterTypes()[0].equals(Object.class) ) {
|
if (lastMethod.getParameterTypes()[0].equals(Object.class)) {
|
||||||
logger.finest("Set Special object value: "+parameterName+" parm2: "+parameter+" on2="+lastMethod.getName()+" with="+object);
|
logger.finest("Set Special object value: " + parameterName + " parm2: " + parameter + " on2=" + lastMethod.getName() + " with=" + object);
|
||||||
try {
|
try {
|
||||||
lastMethod.invoke(object,new Object[]{parameter});
|
lastMethod.invoke(object, new Object[] { parameter });
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ElementObjectPropertyValueException(e.getMessage(),e);
|
throw new ElementObjectPropertyValueException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// all below creates from string
|
// 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.
|
return; // can't set value from string with empty size.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -173,82 +172,73 @@ public class DefaultElementObjectPropertyValue implements ElementObjectPropertyV
|
||||||
DefaultObjectConverterProvider convProvider = new DefaultObjectConverterProvider();
|
DefaultObjectConverterProvider convProvider = new DefaultObjectConverterProvider();
|
||||||
convProvider.addDefaults();
|
convProvider.addDefaults();
|
||||||
ObjectConverter conv = convProvider.getObjectConverterForClass(lastMethod.getParameterTypes()[0]);
|
ObjectConverter conv = convProvider.getObjectConverterForClass(lastMethod.getParameterTypes()[0]);
|
||||||
if (conv!=null) {
|
if (conv != null) {
|
||||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* JAVA NATIVE TYPES:
|
* JAVA NATIVE TYPES:
|
||||||
*
|
*
|
||||||
* TYPE: Size in bits:
|
* 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
|
||||||
* 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);
|
conv = convProvider.getObjectConverterForClass(Boolean.class);
|
||||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
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);
|
conv = convProvider.getObjectConverterForClass(Integer.class);
|
||||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
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);
|
conv = convProvider.getObjectConverterForClass(Long.class);
|
||||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
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);
|
conv = convProvider.getObjectConverterForClass(Double.class);
|
||||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
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);
|
conv = convProvider.getObjectConverterForClass(Float.class);
|
||||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
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);
|
conv = convProvider.getObjectConverterForClass(Byte.class);
|
||||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
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);
|
conv = convProvider.getObjectConverterForClass(Character.class);
|
||||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (ObjectConverterException oce) {
|
} catch (ObjectConverterException oce) {
|
||||||
throw new ElementObjectPropertyValueException(oce.getMessage(),oce);
|
throw new ElementObjectPropertyValueException(oce.getMessage(), oce);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameter2==null) {
|
if (parameter2 == null) {
|
||||||
throw new ElementObjectPropertyValueException("Could not convert to type for parameter: '"+parameterName+"' value: '"+parameter+"'");
|
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 {
|
try {
|
||||||
lastMethod.invoke(object,new Object[]{parameter2});
|
lastMethod.invoke(object, new Object[] { parameter2 });
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ElementObjectPropertyValueException(e.getMessage(),e);
|
throw new ElementObjectPropertyValueException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the property of an bean.
|
* Gets the property of an bean.
|
||||||
*
|
*
|
||||||
* @param object The object to get from.
|
* @param object The object to get from.
|
||||||
* @param parameterName The parameter name of the property to get.
|
* @param parameterName The parameter name of the property to get.
|
||||||
* @throws ElementObjectPropertyValueException
|
* @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.");
|
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.");
|
throw new NullPointerException("Can't get property is the name is null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -256,64 +246,64 @@ public class DefaultElementObjectPropertyValue implements ElementObjectPropertyV
|
||||||
|
|
||||||
String propRest = null;
|
String propRest = null;
|
||||||
int index = parameterName.indexOf(".");
|
int index = parameterName.indexOf(".");
|
||||||
if(index>0) {
|
if (index > 0) {
|
||||||
propRest = parameterName.substring(index+1);
|
propRest = parameterName.substring(index + 1);
|
||||||
parameterName = parameterName.substring(0,index);
|
parameterName = parameterName.substring(0, index);
|
||||||
logger.finest("slit property into: '"+propRest+"' and '"+parameterName+"'");
|
logger.finest("slit property into: '" + propRest + "' and '" + parameterName + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.finer("Trying value: pn="+parameterName+" o="+object);
|
logger.finer("Trying value: pn=" + parameterName + " o=" + object);
|
||||||
String parameterNameSet = "get"+parameterName;
|
String parameterNameSet = "get" + parameterName;
|
||||||
Method[] methodes = object.getClass().getMethods();
|
Method[] methodes = object.getClass().getMethods();
|
||||||
Method lastMethod = null;
|
Method lastMethod = null;
|
||||||
|
|
||||||
// a bit hackie
|
// a bit hackie
|
||||||
for(int i=0;i<methodes.length;i++) {
|
for (int i = 0; i < methodes.length; i++) {
|
||||||
Method method = methodes[i];
|
Method method = methodes[i];
|
||||||
Class<?>[] types = method.getParameterTypes();
|
Class<?>[] types = method.getParameterTypes();
|
||||||
if (types.length != 0) {
|
if (types.length != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(method.getName().equalsIgnoreCase(parameterNameSet)) {
|
if (method.getName().equalsIgnoreCase(parameterNameSet)) {
|
||||||
logger.finest("Found method: "+method.getName());
|
logger.finest("Found method: " + method.getName());
|
||||||
lastMethod = method;
|
lastMethod = method;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastMethod==null) {
|
if (lastMethod == null) {
|
||||||
for(int i=0;i<methodes.length;i++) {
|
for (int i = 0; i < methodes.length; i++) {
|
||||||
Method method = methodes[i];
|
Method method = methodes[i];
|
||||||
if(method.getName().equalsIgnoreCase("is"+parameterName)) {
|
if (method.getName().equalsIgnoreCase("is" + parameterName)) {
|
||||||
logger.finest("Found is method: "+method.getName());
|
logger.finest("Found is method: " + method.getName());
|
||||||
lastMethod = method;
|
lastMethod = method;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(method.getName().equalsIgnoreCase("has"+parameterName)) {
|
if (method.getName().equalsIgnoreCase("has" + parameterName)) {
|
||||||
logger.finest("Found has method: "+method.getName());
|
logger.finest("Found has method: " + method.getName());
|
||||||
lastMethod = method;
|
lastMethod = method;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastMethod==null) {
|
if (lastMethod == null) {
|
||||||
throw new ElementObjectPropertyValueException("Could not find method for parameter: '"+parameterName+"' object: '"+object+"'");
|
throw new ElementObjectPropertyValueException("Could not find method for parameter: '" + parameterName + "' object: '" + object + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
Object result = null;
|
Object result = null;
|
||||||
try {
|
try {
|
||||||
result = lastMethod.invoke(object,new Object[]{});
|
result = lastMethod.invoke(object, new Object[] {});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ElementObjectPropertyValueException(e.getMessage(),e);
|
throw new ElementObjectPropertyValueException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (propRest!=null) {
|
if (propRest != null) {
|
||||||
if (result==null) {
|
if (result == null) {
|
||||||
return null; // no need to go deeper into a null value.
|
return null; // no need to go deeper into a null value.
|
||||||
}
|
}
|
||||||
// recursif function:
|
// recursif function:
|
||||||
return getProperty(result,propRest);
|
return getProperty(result, propRest);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -324,9 +314,9 @@ public class DefaultElementObjectPropertyValue implements ElementObjectPropertyV
|
||||||
*/
|
*/
|
||||||
public void setPropertyMap(Object object, Map<String, Object> attributes) throws ElementObjectPropertyValueException {
|
public void setPropertyMap(Object object, Map<String, Object> attributes) throws ElementObjectPropertyValueException {
|
||||||
Iterator<String> keyIterator = attributes.keySet().iterator();
|
Iterator<String> keyIterator = attributes.keySet().iterator();
|
||||||
while(keyIterator.hasNext()) {
|
while (keyIterator.hasNext()) {
|
||||||
String key = keyIterator.next();
|
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
|
* 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.
|
* 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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -32,8 +32,7 @@ import org.x4o.xml.lang.X4OLanguageSession;
|
||||||
* Defines an XML element with an object.<br>
|
* Defines an XML element with an object.<br>
|
||||||
* <br>
|
* <br>
|
||||||
* The main function is to store the ElementObject.<br>
|
* The main function is to store the ElementObject.<br>
|
||||||
* Also we can configure the ElementObject from differted events hooks.
|
* Also we can configure the ElementObject from differted events hooks. from the attibutes or parent (object)element.
|
||||||
* from the attibutes or parent (object)element.
|
|
||||||
*
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Feb 01, 2005
|
* @version 1.0 Feb 01, 2005
|
||||||
|
|
@ -62,13 +61,14 @@ public interface Element {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the given elments list to elementType.
|
* Filters the given elments list to elementType.
|
||||||
* @param elements The elements to filter.
|
*
|
||||||
* @param elementType The elementType to filter on.
|
* @param elements The elements to filter.
|
||||||
* @return Always returns List of Elements of filter type.
|
* @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);
|
List<Element> result = new ArrayList<Element>(3);
|
||||||
for (int i=0;i<elements.size();i++) {
|
for (int i = 0; i < elements.size(); i++) {
|
||||||
Element element = elements.get(i);
|
Element element = elements.get(i);
|
||||||
if (elementType == element.getElementType()) {
|
if (elementType == element.getElementType()) {
|
||||||
result.add(element);
|
result.add(element);
|
||||||
|
|
@ -80,25 +80,29 @@ public interface Element {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is fired when the end xml tag is parsed.
|
* This method is fired when the end xml tag is parsed.
|
||||||
|
*
|
||||||
* @throws ElementException Can be thrown when structure is not correct.
|
* @throws ElementException Can be thrown when structure is not correct.
|
||||||
*/
|
*/
|
||||||
void doElementEnd() throws ElementException;
|
void doElementEnd() throws ElementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is fired when the start of xml tag is parsed.
|
* This method is fired when the start of xml tag is parsed.
|
||||||
|
*
|
||||||
* @throws ElementException Can be thrown when structure is not correct.
|
* @throws ElementException Can be thrown when structure is not correct.
|
||||||
*/
|
*/
|
||||||
void doElementStart() throws ElementException;
|
void doElementStart() throws ElementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is fired only once in the run phase.
|
* This method is fired only once in the run phase.
|
||||||
|
*
|
||||||
* @throws ElementException Can be thrown when structure is not correct.
|
* @throws ElementException Can be thrown when structure is not correct.
|
||||||
*/
|
*/
|
||||||
void doElementRun() throws ElementException;
|
void doElementRun() throws ElementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the parent Element.
|
* Set the parent Element.
|
||||||
* @param element The paraent Element to set.
|
*
|
||||||
|
* @param element The paraent Element to set.
|
||||||
*/
|
*/
|
||||||
void setParent(Element element);
|
void setParent(Element element);
|
||||||
|
|
||||||
|
|
@ -106,13 +110,14 @@ public interface Element {
|
||||||
* Returns the parent Element.<br>
|
* Returns the parent Element.<br>
|
||||||
* Or null when there is no parent Element.
|
* Or null when there is no parent Element.
|
||||||
*
|
*
|
||||||
* @return Returns the parent Element
|
* @return Returns the parent Element
|
||||||
*/
|
*/
|
||||||
Element getParent();
|
Element getParent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method get called when this Element object is not needed anymore.<br>
|
* This method get called when this Element object is not needed anymore.<br>
|
||||||
* Can be used to close resources.
|
* Can be used to close resources.
|
||||||
|
*
|
||||||
* @throws ElementException Can be thrown when structure is not correct.
|
* @throws ElementException Can be thrown when structure is not correct.
|
||||||
*/
|
*/
|
||||||
void release() throws ElementException;
|
void release() throws ElementException;
|
||||||
|
|
@ -121,107 +126,121 @@ public interface Element {
|
||||||
* Gives back the object this Element has made and configed.<br>
|
* Gives back the object this Element has made and configed.<br>
|
||||||
* So other elements can do stuff to that object.<br>
|
* So other elements can do stuff to that object.<br>
|
||||||
*
|
*
|
||||||
* @return An Object.
|
* @return An Object.
|
||||||
*/
|
*/
|
||||||
Object getElementObject();
|
Object getElementObject();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the object which we control.
|
* 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);
|
void setElementObject(Object object);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the X4OLanguageSession.
|
* Sets the X4OLanguageSession.
|
||||||
* @param languageSession The X4OLanguageSession to set.
|
*
|
||||||
|
* @param languageSession The X4OLanguageSession to set.
|
||||||
*/
|
*/
|
||||||
void setLanguageSession(X4OLanguageSession languageSession);
|
void setLanguageSession(X4OLanguageSession languageSession);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the X4OLanguageSession.
|
* Gets the X4OLanguageSession.
|
||||||
* @return Returns the X4OLanguageSession.
|
*
|
||||||
|
* @return Returns the X4OLanguageSession.
|
||||||
*/
|
*/
|
||||||
X4OLanguageSession getLanguageSession();
|
X4OLanguageSession getLanguageSession();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the body texts on an event based system.
|
* Sets the body texts on an event based system.
|
||||||
* @param body The body text.
|
*
|
||||||
|
* @param body The body text.
|
||||||
* @throws ElementException Can be thrown when structure is not correct.
|
* @throws ElementException Can be thrown when structure is not correct.
|
||||||
*/
|
*/
|
||||||
void doCharacters(String body) throws ElementException;
|
void doCharacters(String body) throws ElementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the comment texts on an event based system.
|
* Sets the comment texts on an event based system.
|
||||||
* @param comment The comment text.
|
*
|
||||||
|
* @param comment The comment text.
|
||||||
* @throws ElementException Can be thrown when structure is not correct.
|
* @throws ElementException Can be thrown when structure is not correct.
|
||||||
*/
|
*/
|
||||||
void doComment(String comment) throws ElementException;
|
void doComment(String comment) throws ElementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is called when there is whitespace in xml.
|
* Is called when there is whitespace in xml.
|
||||||
* @param space The space.
|
*
|
||||||
|
* @param space The space.
|
||||||
* @throws ElementException Can be thrown when structure is not correct.
|
* @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.
|
* Sets the ElementClass.
|
||||||
* @param elementClass The ElementClass to set.
|
*
|
||||||
|
* @param elementClass The ElementClass to set.
|
||||||
*/
|
*/
|
||||||
void setElementClass(ElementClass elementClass);
|
void setElementClass(ElementClass elementClass);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ElementClass.
|
* Gets the ElementClass.
|
||||||
* @return Returns the ElementClass.
|
*
|
||||||
|
* @return Returns the ElementClass.
|
||||||
*/
|
*/
|
||||||
ElementClass getElementClass();
|
ElementClass getElementClass();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the xml attributes.
|
* 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.
|
* 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.
|
* Gets the childeren elements.
|
||||||
* @return Returns the childeren.
|
*
|
||||||
|
* @return Returns the childeren.
|
||||||
*/
|
*/
|
||||||
List<Element> getChilderen();
|
List<Element> getChilderen();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the childeren elements including those which are comment and white space. (text)
|
* 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();
|
List<Element> getAllChilderen();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an Elment as child of this element.
|
* Adds an Elment as child of this element.
|
||||||
* @param element The child to add.
|
*
|
||||||
|
* @param element The child to add.
|
||||||
*/
|
*/
|
||||||
void addChild(Element element);
|
void addChild(Element element);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an Elment as child of this 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);
|
void removeChild(Element element);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Element type.
|
* Gets the Element type.
|
||||||
* @return Returns the ElementType.
|
*
|
||||||
|
* @return Returns the ElementType.
|
||||||
*/
|
*/
|
||||||
ElementType getElementType();
|
ElementType getElementType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if this elements transforms the tree.
|
* Returns if this elements transforms the tree. if true the the doElementRun is runned in the transform phase insteat of the run phase.
|
||||||
* 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.
|
* 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
|
* 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.
|
* 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;
|
import org.x4o.xml.conv.ObjectConverterException;
|
||||||
|
|
||||||
|
|
@ -34,43 +34,46 @@ public interface ElementAttributeValueParser {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the value is an EL parameter.
|
* Checks if the value is an EL parameter.
|
||||||
* @param name The name of the attribute.
|
*
|
||||||
* @param value The value of the attribute.
|
* @param name The name of the attribute.
|
||||||
* @param element The element of the attribute.
|
* @param value The value of the attribute.
|
||||||
* @return Returns true if value is EL parameter.
|
* @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
|
* Returns the object which is stored in the ELContext
|
||||||
* @param value The attribute value.
|
*
|
||||||
* @param element The element of the attribute.
|
* @param value The attribute value.
|
||||||
* @return Returns the resolved el parameter value.
|
* @param element The element of the attribute.
|
||||||
|
* @return Returns the resolved el parameter value.
|
||||||
* @throws ElementAttributeValueParserException
|
* @throws ElementAttributeValueParserException
|
||||||
* @throws ObjectConverterException
|
* @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.
|
* 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 name The name of the attribute.
|
||||||
* @param element The element of the attribute.
|
* @param value The value of the attribute.
|
||||||
* @return Returns the converted attribute value.
|
* @param element The element of the attribute.
|
||||||
|
* @return Returns the converted attribute value.
|
||||||
* @throws ElementAttributeValueParserException
|
* @throws ElementAttributeValueParserException
|
||||||
* @throws ObjectConverterException
|
* @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.
|
* Does is all, Checks if value is EL parameter and lookups the object. and converts to new object via parameter converter and return value.
|
||||||
* and converts to new object via parameter converter and return value.
|
*
|
||||||
* @param name The name of the attribute.
|
* @param name The name of the attribute.
|
||||||
* @param value The value of the attribute.
|
* @param value The value of the attribute.
|
||||||
* @param element The element of the attribute.
|
* @param element The element of the attribute.
|
||||||
* @return Returns the attribute value.
|
* @return Returns the attribute value.
|
||||||
* @throws ElementAttributeValueParserException
|
* @throws ElementAttributeValueParserException
|
||||||
* @throws ObjectConverterException
|
* @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
|
* 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.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElementAttributeValueParserException.<br>
|
* ElementAttributeValueParserException.<br>
|
||||||
|
|
@ -35,12 +34,8 @@ package org.x4o.xml.element;
|
||||||
public class ElementAttributeValueParserException extends ElementException {
|
public class ElementAttributeValueParserException extends ElementException {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public ElementAttributeValueParserException(ElementAttributeConverter converter,String message) {
|
* public ElementAttributeValueParserException(ElementAttributeConverter converter,String message) { super(message); }
|
||||||
super(message);
|
*
|
||||||
}
|
* public ElementAttributeValueParserException(ElementAttributeConverter converter,String message,Exception exception) { super(message,exception); }
|
||||||
|
*/
|
||||||
public ElementAttributeValueParserException(ElementAttributeConverter converter,String message,Exception exception) {
|
|
||||||
super(message,exception);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,15 +20,13 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind ElementObjects together.
|
* Bind ElementObjects together.
|
||||||
*
|
*
|
||||||
* This interface is used to bind a parent and child ElementObject 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
|
||||||
* For example; when both objects are an JComponent then we can add the child to the parent
|
* parent with the method: ((JComponent)parent).add((JComponent)child);
|
||||||
* with the method: ((JComponent)parent).add((JComponent)child);
|
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
|
|
@ -37,25 +35,27 @@ package org.x4o.xml.element;
|
||||||
public interface ElementBindingHandler extends ElementMetaBase {
|
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();
|
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();
|
Class<?>[] getBindChildClasses();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do the binding of this child to the parent object.
|
* 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.
|
* @throws ElementBindingHandlerException When binding could not happen.
|
||||||
*/
|
*/
|
||||||
void bindChild(Element childElement) throws ElementBindingHandlerException;
|
void bindChild(Element childElement) throws ElementBindingHandlerException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the childeren of the parent object.
|
* 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.
|
* @throws ElementBindingHandlerException When binding could not happen.
|
||||||
*/
|
*/
|
||||||
void createChilderen(Element parentElement) throws ElementBindingHandlerException;
|
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
|
* 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.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElementBindingException.<br>
|
* ElementBindingException.<br>
|
||||||
|
|
@ -36,7 +35,8 @@ public class ElementBindingHandlerException extends ElementException {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates binding exception.
|
* Creates binding exception.
|
||||||
* @param message The error message.
|
*
|
||||||
|
* @param message The error message.
|
||||||
*/
|
*/
|
||||||
public ElementBindingHandlerException(String message) {
|
public ElementBindingHandlerException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
|
|
@ -44,10 +44,11 @@ public class ElementBindingHandlerException extends ElementException {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates binding exception.
|
* 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) {
|
public ElementBindingHandlerException(String message, Exception exception) {
|
||||||
super(message,exception);
|
super(message, exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -35,12 +35,14 @@ public interface ElementClass extends ElementClassBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ElementClass.
|
* Gets the ElementClass.
|
||||||
|
*
|
||||||
* @return the elementClass
|
* @return the elementClass
|
||||||
*/
|
*/
|
||||||
Class<?> getElementClass();
|
Class<?> getElementClass();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the ElementClass.
|
* Sets the ElementClass.
|
||||||
|
*
|
||||||
* @param elementClass the elementClass to set.
|
* @param elementClass the elementClass to set.
|
||||||
*/
|
*/
|
||||||
void setElementClass(Class<?> elementClass);
|
void setElementClass(Class<?> elementClass);
|
||||||
|
|
@ -97,19 +99,22 @@ public interface ElementClass extends ElementClassBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an skip phase for this element.
|
* Add an skip phase for this element.
|
||||||
* @param phase The phase name.
|
*
|
||||||
|
* @param phase The phase name.
|
||||||
*/
|
*/
|
||||||
void addSkipPhase(String phase);
|
void addSkipPhase(String phase);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an skip phase for this element.
|
* Removes an skip phase for this element.
|
||||||
* @param phase The phase name.
|
*
|
||||||
|
* @param phase The phase name.
|
||||||
*/
|
*/
|
||||||
void removeSkipPhase(String phase);
|
void removeSkipPhase(String phase);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the skip phases for this element.
|
* Get all the skip phases for this element.
|
||||||
* @return The defined phases.
|
*
|
||||||
|
* @return The defined phases.
|
||||||
*/
|
*/
|
||||||
List<String> getSkipPhases();
|
List<String> getSkipPhases();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -37,54 +37,63 @@ public interface ElementClassAttribute extends ElementMetaBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ObjectConverter.
|
* Gets the ObjectConverter.
|
||||||
|
*
|
||||||
* @return The ObjectConverter.
|
* @return The ObjectConverter.
|
||||||
*/
|
*/
|
||||||
ObjectConverter getObjectConverter();
|
ObjectConverter getObjectConverter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the ObjectConverter whichs converts.
|
* Add the ObjectConverter whichs converts.
|
||||||
* @param objectConverter The objectConverter to set for this attribute.
|
*
|
||||||
|
* @param objectConverter The objectConverter to set for this attribute.
|
||||||
*/
|
*/
|
||||||
void setObjectConverter(ObjectConverter objectConverter);
|
void setObjectConverter(ObjectConverter objectConverter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the defaultValue of this attribute.
|
* Sets the defaultValue of this attribute.
|
||||||
* @param defaultValue The defaultValue to set.
|
*
|
||||||
|
* @param defaultValue The defaultValue to set.
|
||||||
*/
|
*/
|
||||||
void setDefaultValue(Object defaultValue);
|
void setDefaultValue(Object defaultValue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the default value.
|
* Gets the default value.
|
||||||
* @return Returns the default value if any.
|
*
|
||||||
|
* @return Returns the default value if any.
|
||||||
*/
|
*/
|
||||||
Object getDefaultValue();
|
Object getDefaultValue();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an attribute alias for this attribute.
|
* Add an attribute alias for this attribute.
|
||||||
* @param alias The alias.
|
*
|
||||||
|
* @param alias The alias.
|
||||||
*/
|
*/
|
||||||
void addAttributeAlias(String alias);
|
void addAttributeAlias(String alias);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an attribute alias.
|
* Removes an attribute alias.
|
||||||
* @param alias The alias.
|
*
|
||||||
|
* @param alias The alias.
|
||||||
*/
|
*/
|
||||||
void removeAttributeAlias(String alias);
|
void removeAttributeAlias(String alias);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the aliases for this attribute.
|
* Get all the aliases for this attribute.
|
||||||
* @return The defined aliases.
|
*
|
||||||
|
* @return The defined aliases.
|
||||||
*/
|
*/
|
||||||
List<String> getAttributeAliases();
|
List<String> getAttributeAliases();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the required state of this attribute.
|
* Gets the required state of this attribute.
|
||||||
|
*
|
||||||
* @return If true then attribute is required.
|
* @return If true then attribute is required.
|
||||||
*/
|
*/
|
||||||
Boolean getRequired();
|
Boolean getRequired();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the required state of this attribute.
|
* Sets the required state of this attribute.
|
||||||
|
*
|
||||||
* @param required the required to set.
|
* @param required the required to set.
|
||||||
*/
|
*/
|
||||||
void setRequired(Boolean required);
|
void setRequired(Boolean required);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -35,33 +35,36 @@ import java.util.List;
|
||||||
public interface ElementClassBase extends ElementMetaBase {
|
public interface ElementClassBase extends ElementMetaBase {
|
||||||
|
|
||||||
List<ElementConfigurator> getElementConfigurators();
|
List<ElementConfigurator> getElementConfigurators();
|
||||||
|
|
||||||
void addElementConfigurators(ElementConfigurator elementConfigurator);
|
void addElementConfigurators(ElementConfigurator elementConfigurator);
|
||||||
|
|
||||||
Collection<ElementClassAttribute> getElementClassAttributes();
|
Collection<ElementClassAttribute> getElementClassAttributes();
|
||||||
|
|
||||||
ElementClassAttribute getElementClassAttributeByName(String attributeName);
|
ElementClassAttribute getElementClassAttributeByName(String attributeName);
|
||||||
|
|
||||||
void addElementClassAttribute(ElementClassAttribute elementClassAttribute);
|
void addElementClassAttribute(ElementClassAttribute elementClassAttribute);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an parent element tag.
|
* Add an parent element tag. Used: for xsd/doc only.
|
||||||
* Used: for xsd/doc only.
|
*
|
||||||
* @param namespaceUri The namespace uri of this tag relation.
|
* @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
|
* Remove and parent element Used: for xsd/doc only.
|
||||||
* Used: for xsd/doc only.
|
*
|
||||||
* @param namespaceUri The namespace uri of this tag relation.
|
* @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.
|
* Returns list of parent element tags. Used: for xsd/doc only.
|
||||||
* Used: for xsd/doc only.
|
*
|
||||||
* @param namespaceUri The namespace uri of this tag relation.
|
* @param namespaceUri The namespace uri of this tag relation.
|
||||||
* @return The list of tags.
|
* @return The list of tags.
|
||||||
*/
|
*/
|
||||||
List<String> getElementParents(String namespaceUri);
|
List<String> getElementParents(String namespaceUri);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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).
|
* Provides an Interface to configure Element(Object).
|
||||||
|
|
@ -34,16 +33,17 @@ public interface ElementConfigurator extends ElementMetaBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets called for configuring the given Element.
|
* 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;
|
void doConfigElement(Element element) throws ElementConfiguratorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return if this ElementConfigurator is an Action.
|
* 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
|
||||||
* which means is is executed in the runPhase in the end.
|
* finnisched object and toss it around.
|
||||||
* 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 Returns true if need to run in config phase.
|
||||||
*/
|
*/
|
||||||
boolean isConfigAction();
|
boolean isConfigAction();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElementConfiguratorException.<br>
|
* ElementConfiguratorException.<br>
|
||||||
|
|
@ -36,39 +35,43 @@ public class ElementConfiguratorException extends ElementException {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an configurator exception.
|
* 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);
|
super(message);
|
||||||
this.elementConfigurator=config;
|
this.elementConfigurator = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an configurator exception.
|
* Creates an configurator exception.
|
||||||
* @param config The ElementConfigurator.
|
*
|
||||||
* @param message The error message.
|
* @param config The ElementConfigurator.
|
||||||
* @param exception The error exception.
|
* @param message The error message.
|
||||||
|
* @param exception The error exception.
|
||||||
*/
|
*/
|
||||||
public ElementConfiguratorException(ElementConfigurator config,String message,Exception exception) {
|
public ElementConfiguratorException(ElementConfigurator config, String message, Exception exception) {
|
||||||
super(message,exception);
|
super(message, exception);
|
||||||
this.elementConfigurator=config;
|
this.elementConfigurator = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an configurator exception.
|
* Creates an configurator exception.
|
||||||
* @param config The ElementConfigurator.
|
*
|
||||||
* @param message The error message.
|
* @param config The ElementConfigurator.
|
||||||
* @param exception The wrapped element error exception.
|
* @param message The error message.
|
||||||
|
* @param exception The wrapped element error exception.
|
||||||
*/
|
*/
|
||||||
public ElementConfiguratorException(ElementConfigurator config,String message,ElementException exception) {
|
public ElementConfiguratorException(ElementConfigurator config, String message, ElementException exception) {
|
||||||
super(message,exception);
|
super(message, exception);
|
||||||
this.elementConfigurator=config;
|
this.elementConfigurator = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ElementConfigurator which has thrown this exception.
|
* Gets the ElementConfigurator which has thrown this exception.
|
||||||
* @return The ElementConfigurator.
|
*
|
||||||
|
* @return The ElementConfigurator.
|
||||||
*/
|
*/
|
||||||
public ElementConfigurator getElementConfigurator() {
|
public ElementConfigurator getElementConfigurator() {
|
||||||
return elementConfigurator;
|
return elementConfigurator;
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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.
|
* Provides an Interface to configure Element(Object) global.
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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.
|
* Is throw when there is en Exception within an Element.
|
||||||
|
|
@ -42,7 +42,8 @@ public class ElementException extends Exception {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an ElementException with a detail message.
|
* 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) {
|
public ElementException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
|
|
@ -50,7 +51,8 @@ public class ElementException extends Exception {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an ElementException from a parent exception.
|
* Creates an ElementException from a parent exception.
|
||||||
* @param e The error exception.
|
*
|
||||||
|
* @param e The error exception.
|
||||||
*/
|
*/
|
||||||
public ElementException(Exception e) {
|
public ElementException(Exception e) {
|
||||||
super(e);
|
super(e);
|
||||||
|
|
@ -58,10 +60,11 @@ public class ElementException extends Exception {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an ElementException with a detail message.
|
* 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) {
|
public ElementException(String message, Exception e) {
|
||||||
super(message,e);
|
super(message, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines an ElementInterface.
|
* Defines an ElementInterface.
|
||||||
|
|
@ -32,12 +32,14 @@ public interface ElementInterface extends ElementClassBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets this class of the interface to match this converters/etc/ to.
|
* Gets this class of the interface to match this converters/etc/ to.
|
||||||
|
*
|
||||||
* @return the tag.
|
* @return the tag.
|
||||||
*/
|
*/
|
||||||
Class<?> getInterfaceClass();
|
Class<?> getInterfaceClass();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the interface class.
|
* Sets the interface class.
|
||||||
|
*
|
||||||
* @param interfaceClass the interfaceClass to set.
|
* @param interfaceClass the interfaceClass to set.
|
||||||
*/
|
*/
|
||||||
void setInterfaceClass(Class<?> interfaceClass);
|
void setInterfaceClass(Class<?> interfaceClass);
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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.
|
* ElementMetaBase provides a base interface describe meta information.
|
||||||
|
|
@ -34,25 +33,29 @@ public interface ElementMetaBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the id of the ElementMetaBase.
|
* Sets the id of the ElementMetaBase.
|
||||||
* @param id The id to set.
|
*
|
||||||
|
* @param id The id to set.
|
||||||
*/
|
*/
|
||||||
void setId(String id);
|
void setId(String id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the id of the ElementMetaBase.
|
* Returns the id of the ElementMetaBase.
|
||||||
* @return Returns the id.
|
*
|
||||||
|
* @return Returns the id.
|
||||||
*/
|
*/
|
||||||
String getId();
|
String getId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the description of the ElementMetaBase.
|
* Sets the description of the ElementMetaBase.
|
||||||
* @param description The description to set.
|
*
|
||||||
|
* @param description The description to set.
|
||||||
*/
|
*/
|
||||||
void setDescription(String description);
|
void setDescription(String description);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the description of the ElementMetaBase.
|
* Returns the description of the ElementMetaBase.
|
||||||
* @return Returns the description.
|
*
|
||||||
|
* @return Returns the description.
|
||||||
*/
|
*/
|
||||||
String getDescription();
|
String getDescription();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,44 +34,51 @@ public interface ElementNamespace extends ElementMetaBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the prefix mapping.
|
* Sets the prefix mapping.
|
||||||
* @param prefixMapping The prefix mapping to set.
|
*
|
||||||
|
* @param prefixMapping The prefix mapping to set.
|
||||||
*/
|
*/
|
||||||
void setPrefixMapping(String prefixMapping);
|
void setPrefixMapping(String prefixMapping);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the set prefix mapping of this namespace.
|
* Gets the set prefix mapping of this namespace.
|
||||||
|
*
|
||||||
* @return Returns the prefix mapping.
|
* @return Returns the prefix mapping.
|
||||||
*/
|
*/
|
||||||
String getPrefixMapping();
|
String getPrefixMapping();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the elememen instance provider which creates the elements objects.
|
* 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);
|
void setElementNamespaceInstanceProvider(ElementNamespaceInstanceProvider elementNamespaceInstanceProvider);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ElementProvider.
|
* Returns the ElementProvider.
|
||||||
* @return Returns the ElementNamespaceInstanceProvider for this namespace.
|
*
|
||||||
|
* @return Returns the ElementNamespaceInstanceProvider for this namespace.
|
||||||
*/
|
*/
|
||||||
ElementNamespaceInstanceProvider getElementNamespaceInstanceProvider();
|
ElementNamespaceInstanceProvider getElementNamespaceInstanceProvider();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an ElementClass.
|
* 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);
|
void addElementClass(ElementClass elementClass);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ElementClass for an namespace and tag.
|
* 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);
|
ElementClass getElementClass(String tag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the loaded ElementClass'es in an namespace in this context.
|
* 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();
|
List<ElementClass> getElementClasses();
|
||||||
|
|
||||||
|
|
@ -147,12 +154,14 @@ public interface ElementNamespace extends ElementMetaBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an ElementNamespaceAttribute.
|
* Adds an ElementNamespaceAttribute.
|
||||||
* @param elementNamespaceAttribute Adds an ElementNamespaceAttribute.
|
*
|
||||||
|
* @param elementNamespaceAttribute Adds an ElementNamespaceAttribute.
|
||||||
*/
|
*/
|
||||||
void addElementNamespaceAttribute(ElementNamespaceAttribute elementNamespaceAttribute);
|
void addElementNamespaceAttribute(ElementNamespaceAttribute elementNamespaceAttribute);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Geta All ElementNamespaceAttributes.
|
* Geta All ElementNamespaceAttributes.
|
||||||
|
*
|
||||||
* @return Returns an List of ElementNamespaceAttributes.
|
* @return Returns an List of ElementNamespaceAttributes.
|
||||||
*/
|
*/
|
||||||
List<ElementNamespaceAttribute> getElementNamespaceAttributes();
|
List<ElementNamespaceAttribute> getElementNamespaceAttributes();
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -34,32 +34,36 @@ public interface ElementNamespaceAttribute extends ElementConfigurator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the attribute name this attribute handler handles.
|
* 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();
|
String getAttributeName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the attribute name this attribute handler handles.
|
* Sets the attribute name this attribute handler handles.
|
||||||
* @param attributeName The attribute to handle.
|
*
|
||||||
|
* @param attributeName The attribute to handle.
|
||||||
*/
|
*/
|
||||||
void setAttributeName(String attributeName);
|
void setAttributeName(String attributeName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an NextAttribute.
|
* Adds an NextAttribute. There next attributes will defines the order in which the ElementNamespaceAttribute are executed.
|
||||||
* There next attributes will defines the order in which the ElementNamespaceAttribute are executed.
|
*
|
||||||
* @param attribute Add attribute which be will processed after this one.
|
* @param attribute Add attribute which be will processed after this one.
|
||||||
*/
|
*/
|
||||||
void addNextAttribute(String attribute);
|
void addNextAttribute(String attribute);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an next attribute.
|
* Removes an next attribute.
|
||||||
* @param attribute Removes this next attribute.
|
*
|
||||||
|
* @param attribute Removes this next attribute.
|
||||||
*/
|
*/
|
||||||
void removeNextAttribute(String attribute);
|
void removeNextAttribute(String attribute);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all next attributes.
|
* Get all next attributes.
|
||||||
* @return Returns the list of all next attributes.
|
*
|
||||||
|
* @return Returns the list of all next attributes.
|
||||||
*/
|
*/
|
||||||
List<String> getNextAttributes();
|
List<String> getNextAttributes();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,18 +35,20 @@ public interface ElementNamespaceInstanceProvider {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the ElementProvider.
|
* Starts the ElementProvider.
|
||||||
* @param language The X4OLanguage to start in.
|
*
|
||||||
|
* @param language The X4OLanguage to start in.
|
||||||
* @param elementNamespace The elementNamespace to start for.
|
* @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.
|
* Provide an Element for an xml tag.
|
||||||
|
*
|
||||||
* @param languageSession The languageSession to create element for.
|
* @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.
|
* @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
|
* 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.
|
* 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>
|
* ElementNamespaceInstanceProviderException holds the ElementNamespaceInstanceProvider which created this Exception.<br>
|
||||||
|
|
@ -36,28 +35,31 @@ public class ElementNamespaceInstanceProviderException extends ElementException
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates provider instance exception.
|
* Creates provider instance exception.
|
||||||
* @param elementNamespaceInstanceProvider The provider which creates this exception.
|
*
|
||||||
* @param message The message of this exception.
|
* @param elementNamespaceInstanceProvider The provider which creates this exception.
|
||||||
|
* @param message The message of this exception.
|
||||||
*/
|
*/
|
||||||
public ElementNamespaceInstanceProviderException(ElementNamespaceInstanceProvider elementNamespaceInstanceProvider,String message) {
|
public ElementNamespaceInstanceProviderException(ElementNamespaceInstanceProvider elementNamespaceInstanceProvider, String message) {
|
||||||
super(message);
|
super(message);
|
||||||
this.elementNamespaceInstanceProvider=elementNamespaceInstanceProvider;
|
this.elementNamespaceInstanceProvider = elementNamespaceInstanceProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates provider instance exception.
|
* Creates provider instance exception.
|
||||||
* @param elementNamespaceInstanceProvider The provider which creates this exception.
|
*
|
||||||
* @param message The message of this exception.
|
* @param elementNamespaceInstanceProvider The provider which creates this exception.
|
||||||
* @param exception The root cause of this exception.
|
* @param message The message of this exception.
|
||||||
|
* @param exception The root cause of this exception.
|
||||||
*/
|
*/
|
||||||
public ElementNamespaceInstanceProviderException(ElementNamespaceInstanceProvider elementNamespaceInstanceProvider,String message,Exception exception) {
|
public ElementNamespaceInstanceProviderException(ElementNamespaceInstanceProvider elementNamespaceInstanceProvider, String message, Exception exception) {
|
||||||
super(message,exception);
|
super(message, exception);
|
||||||
this.elementNamespaceInstanceProvider=elementNamespaceInstanceProvider;
|
this.elementNamespaceInstanceProvider = elementNamespaceInstanceProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ElementNamespaceInstanceProvider which created this exception.
|
* Gets the ElementNamespaceInstanceProvider which created this exception.
|
||||||
* @return The provider which created the exception.
|
*
|
||||||
|
* @return The provider which created the exception.
|
||||||
*/
|
*/
|
||||||
public ElementNamespaceInstanceProvider getElementNamespaceInstanceProvider() {
|
public ElementNamespaceInstanceProvider getElementNamespaceInstanceProvider() {
|
||||||
return elementNamespaceInstanceProvider;
|
return elementNamespaceInstanceProvider;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
@ -34,27 +34,30 @@ public interface ElementObjectPropertyValue {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an bean property of the object.
|
* Sets an bean property of the object.
|
||||||
|
*
|
||||||
* @param object
|
* @param object
|
||||||
* @param propertyName
|
* @param propertyName
|
||||||
* @param value
|
* @param value
|
||||||
* @throws ElementObjectPropertyValueException
|
* @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,
|
* 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.
|
* @param object The object to get the properties from
|
||||||
* @return Returns the value of the property.
|
* @param propertyName The name of the property to get.
|
||||||
|
* @return Returns the value of the property.
|
||||||
* @throws ElementObjectPropertyValueException
|
* @throws ElementObjectPropertyValueException
|
||||||
*/
|
*/
|
||||||
Object getProperty(Object object,String propertyName) throws ElementObjectPropertyValueException;
|
Object getProperty(Object object, String propertyName) throws ElementObjectPropertyValueException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets all bean properties.
|
* 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
|
* @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
|
* 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.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElementObjectPropertyValueException.<br>
|
* ElementObjectPropertyValueException.<br>
|
||||||
|
|
@ -36,7 +35,8 @@ public class ElementObjectPropertyValueException extends ElementException {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates ElementObjectPropertyValueException with message.
|
* Creates ElementObjectPropertyValueException with message.
|
||||||
* @param message The error message.
|
*
|
||||||
|
* @param message The error message.
|
||||||
*/
|
*/
|
||||||
public ElementObjectPropertyValueException(String message) {
|
public ElementObjectPropertyValueException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
|
|
@ -44,10 +44,11 @@ public class ElementObjectPropertyValueException extends ElementException {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates ElementObjectPropertyValueException with message and exception.
|
* 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) {
|
public ElementObjectPropertyValueException(String message, Exception exception) {
|
||||||
super(message,exception);
|
super(message, exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,11 +64,12 @@ public abstract class AbstractX4OConnection extends AbstractX4OConnectionDebug {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an X4O Language property.
|
* 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
|
@Override
|
||||||
public final void setProperty(String key,Object value) {
|
public final void setProperty(String key, Object value) {
|
||||||
getPropertyConfig().setProperty(key, value);
|
getPropertyConfig().setProperty(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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_HANDLER = "debug/output-handler";
|
||||||
protected final static String ABSTRACT_DEBUG_OUTPUT_STREAM = "debug/output-stream";
|
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 debugOutputHandler = getProperty(debugHandlerKey);
|
||||||
Object debugOutputStream = getProperty(debugStreamKey);
|
Object debugOutputStream = getProperty(debugStreamKey);
|
||||||
// init debug infra
|
// 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
|
* Fetched the data direct from remote url to a InputStream to is can me readd by SAX.
|
||||||
* by SAX.
|
|
||||||
*
|
*
|
||||||
* @param url The url to read.
|
* @param url The url to read.
|
||||||
* @throws X4OConnectionException Is thrown after x4o exception.
|
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||||
|
|
|
||||||
|
|
@ -36,12 +36,12 @@ public class DefaultX4ODriver<T> extends X4ODriver<T> {
|
||||||
private final String languageVersion;
|
private final String languageVersion;
|
||||||
|
|
||||||
public DefaultX4ODriver(String languageName) {
|
public DefaultX4ODriver(String languageName) {
|
||||||
this(languageName,X4ODriver.DEFAULT_LANGUAGE_VERSION);
|
this(languageName, X4ODriver.DEFAULT_LANGUAGE_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DefaultX4ODriver(String languageName,String languageVersion) {
|
public DefaultX4ODriver(String languageName, String languageVersion) {
|
||||||
this.languageName=languageName;
|
this.languageName = languageName;
|
||||||
this.languageVersion=languageVersion;
|
this.languageVersion = languageVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -51,6 +51,6 @@ public class DefaultX4ODriver<T> extends X4ODriver<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getLanguageVersions() {
|
public String[] getLanguageVersions() {
|
||||||
return new String[]{languageVersion};
|
return new String[] { languageVersion };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
|
||||||
private final SAX3PropertyConfig propertyConfig;
|
private final SAX3PropertyConfig propertyConfig;
|
||||||
private final Map<String, Object> elBeans = new HashMap<>();
|
private final Map<String, Object> elBeans = new HashMap<>();
|
||||||
|
|
||||||
|
//@formatter:off
|
||||||
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"reader/x4o/";
|
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"reader/x4o/";
|
||||||
public final static SAX3PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
public final static SAX3PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
||||||
public final static String SAX_ERROR_HANDLER = PROPERTY_CONTEXT_PREFIX + "sax/error-handler";
|
public final static String SAX_ERROR_HANDLER = PROPERTY_CONTEXT_PREFIX + "sax/error-handler";
|
||||||
|
|
@ -96,6 +97,7 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
|
||||||
new PropertyConfigItem(DEBUG_OUTPUT_STREAM,OutputStream.class)
|
new PropertyConfigItem(DEBUG_OUTPUT_STREAM,OutputStream.class)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
//@formatter:on
|
||||||
|
|
||||||
public DefaultX4OReader(X4OLanguage language) {
|
public DefaultX4OReader(X4OLanguage language) {
|
||||||
super(language);
|
super(language);
|
||||||
|
|
@ -111,13 +113,15 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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_STREAM, input);
|
||||||
setProperty(INPUT_SYSTEM_ID, systemId);
|
setProperty(INPUT_SYSTEM_ID, systemId);
|
||||||
setProperty(INPUT_BASE_PATH, basePath);
|
setProperty(INPUT_BASE_PATH, basePath);
|
||||||
for (String name : elBeans.keySet()) {
|
for (String name : elBeans.keySet()) {
|
||||||
Object bean = elBeans.get(name);
|
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);
|
ve.setValue(languageSession.getExpressionLanguageContext(), bean);
|
||||||
}
|
}
|
||||||
readSession(languageSession);
|
readSession(languageSession);
|
||||||
|
|
@ -147,7 +151,7 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
|
||||||
|
|
||||||
// Insert stop/skip phase if we allowed to. TODO: move layer ?
|
// Insert stop/skip phase if we allowed to. TODO: move layer ?
|
||||||
if (languageSession instanceof X4OLanguageSessionLocal) {
|
if (languageSession instanceof X4OLanguageSessionLocal) {
|
||||||
X4OLanguageSessionLocal ll = (X4OLanguageSessionLocal)languageSession;
|
X4OLanguageSessionLocal ll = (X4OLanguageSessionLocal) languageSession;
|
||||||
if (phaseStop != null) {
|
if (phaseStop != null) {
|
||||||
ll.setPhaseStop(phaseStop);
|
ll.setPhaseStop(phaseStop);
|
||||||
}
|
}
|
||||||
|
|
@ -176,18 +180,18 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
|
||||||
// unwrap exception
|
// unwrap exception
|
||||||
// TODO: cleanup exceptions a bit more see X4OConnectionException
|
// TODO: cleanup exceptions a bit more see X4OConnectionException
|
||||||
if (e.getCause() instanceof ParserConfigurationException) {
|
if (e.getCause() instanceof ParserConfigurationException) {
|
||||||
throw new X4OConnectionException((ParserConfigurationException)e.getCause());
|
throw new X4OConnectionException((ParserConfigurationException) e.getCause());
|
||||||
}
|
}
|
||||||
if (e.getCause() instanceof SAXException) {
|
if (e.getCause() instanceof SAXException) {
|
||||||
throw (SAXException)e.getCause();
|
throw (SAXException) e.getCause();
|
||||||
}
|
}
|
||||||
if (e.getCause() instanceof IOException) {
|
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);
|
throw new SAXException(e);
|
||||||
} else {
|
} else {
|
||||||
throw new SAXException((Exception)e.getCause());
|
throw new SAXException((Exception) e.getCause());
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
debugStop(languageSession);
|
debugStop(languageSession);
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
|
||||||
private boolean schemaUriPrint;
|
private boolean schemaUriPrint;
|
||||||
private String schemaUriRoot;
|
private String schemaUriRoot;
|
||||||
|
|
||||||
|
//@formatter:off
|
||||||
private final static AttributeEntryComparator ATTR_ENTRY_COMPARATOR = new AttributeEntryComparator();
|
private final static AttributeEntryComparator ATTR_ENTRY_COMPARATOR = new AttributeEntryComparator();
|
||||||
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"writer/x4o/";
|
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"writer/x4o/";
|
||||||
public final static SAX3PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
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)
|
new PropertyConfigItem(DEBUG_OUTPUT_STREAM,OutputStream.class)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
//@formatter:on
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,9 @@ public interface X4OConnection {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an X4O Language property.
|
* 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);
|
void setProperty(String key, Object value);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* 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.
|
* 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.
|
* X4OConnectionException is top level exception for io connections.
|
||||||
|
|
@ -42,7 +42,8 @@ public class X4OConnectionException extends Exception {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an X4OConnectionException with a detail message.
|
* 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) {
|
public X4OConnectionException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
|
|
@ -50,7 +51,8 @@ public class X4OConnectionException extends Exception {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an X4OConnectionException from a parent exception.
|
* Creates an X4OConnectionException from a parent exception.
|
||||||
* @param e The error exception.
|
*
|
||||||
|
* @param e The error exception.
|
||||||
*/
|
*/
|
||||||
public X4OConnectionException(Exception e) {
|
public X4OConnectionException(Exception e) {
|
||||||
super(e);
|
super(e);
|
||||||
|
|
@ -58,10 +60,11 @@ public class X4OConnectionException extends Exception {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an X4OConnectionException with a detail message.
|
* 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) {
|
public X4OConnectionException(String message, Exception e) {
|
||||||
super(message,e);
|
super(message, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,10 +71,9 @@ public class X4OContentHandler extends DefaultHandler2 {
|
||||||
private final SAX3PropertyConfig propertyConfig;
|
private final SAX3PropertyConfig propertyConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an X4OTagHandler
|
* Creates an X4OTagHandler which can receice sax xml events and converts them into the Element* interfaces events.
|
||||||
* 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());
|
logger = Logger.getLogger(X4OContentHandler.class.getName());
|
||||||
loggerFinest = logger.isLoggable(Level.FINEST);
|
loggerFinest = logger.isLoggable(Level.FINEST);
|
||||||
elementStack = new Stack<Element>();
|
elementStack = new Stack<Element>();
|
||||||
|
|
@ -87,7 +86,7 @@ public class X4OContentHandler extends DefaultHandler2 {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setDocumentLocator(Locator locator) {
|
public void setDocumentLocator(Locator locator) {
|
||||||
this.locator=locator;
|
this.locator = locator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -95,7 +94,7 @@ public class X4OContentHandler extends DefaultHandler2 {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void startPrefixMapping(String prefix, String namespaceUri) throws SAXException {
|
public void startPrefixMapping(String prefix, String namespaceUri) throws SAXException {
|
||||||
if (overrideSaxHandler!=null) {
|
if (overrideSaxHandler != null) {
|
||||||
overrideSaxHandler.startPrefixMapping(prefix, namespaceUri);
|
overrideSaxHandler.startPrefixMapping(prefix, namespaceUri);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -106,8 +105,8 @@ public class X4OContentHandler extends DefaultHandler2 {
|
||||||
return; // skip xinclude ns.
|
return; // skip xinclude ns.
|
||||||
}
|
}
|
||||||
ElementNamespace enc = elementLanguage.getLanguage().findElementNamespace(namespaceUri);
|
ElementNamespace enc = elementLanguage.getLanguage().findElementNamespace(namespaceUri);
|
||||||
if (enc==null) {
|
if (enc == null) {
|
||||||
throw new SAXException("Can't find namespace uri: "+namespaceUri+" in language: "+elementLanguage.getLanguage().getLanguageName());
|
throw new SAXException("Can't find namespace uri: " + namespaceUri + " in language: " + elementLanguage.getLanguage().getLanguageName());
|
||||||
}
|
}
|
||||||
enc.setPrefixMapping(prefix);
|
enc.setPrefixMapping(prefix);
|
||||||
}
|
}
|
||||||
|
|
@ -116,38 +115,38 @@ 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)
|
* @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
|
||||||
*/
|
*/
|
||||||
@Override
|
@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) {
|
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);
|
overrideSaxHandler.startElement(namespaceUri, tag, qName, attributes);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ElementNamespace enc = elementLanguage.getLanguage().findElementNamespace(namespaceUri);
|
ElementNamespace enc = elementLanguage.getLanguage().findElementNamespace(namespaceUri);
|
||||||
if (enc==null) {
|
if (enc == null) {
|
||||||
if ("".equals(namespaceUri)) {
|
if ("".equals(namespaceUri)) {
|
||||||
String configEmptryUri = propertyConfig.getPropertyString(DefaultX4OReader.DOC_EMPTY_NAMESPACE_URI);
|
String configEmptryUri = propertyConfig.getPropertyString(DefaultX4OReader.DOC_EMPTY_NAMESPACE_URI);
|
||||||
if (configEmptryUri!=null) {
|
if (configEmptryUri != null) {
|
||||||
namespaceUri = configEmptryUri;
|
namespaceUri = configEmptryUri;
|
||||||
enc = elementLanguage.getLanguage().findElementNamespace(namespaceUri);
|
enc = elementLanguage.getLanguage().findElementNamespace(namespaceUri);
|
||||||
}
|
}
|
||||||
if (enc==null) {
|
if (enc == null) {
|
||||||
throw new SAXParseException("No ElementNamespace found for empty namespace.",locator);
|
throw new SAXParseException("No ElementNamespace found for empty namespace.", locator);
|
||||||
}
|
}
|
||||||
enc.setPrefixMapping("");
|
enc.setPrefixMapping("");
|
||||||
}
|
}
|
||||||
if (enc==null) {
|
if (enc == null) {
|
||||||
throw new SAXParseException("No ElementProvider found for namespace: "+namespaceUri,locator);
|
throw new SAXParseException("No ElementProvider found for namespace: " + namespaceUri, locator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementNamespaceInstanceProvider eip = enc.getElementNamespaceInstanceProvider();
|
ElementNamespaceInstanceProvider eip = enc.getElementNamespaceInstanceProvider();
|
||||||
Element element = null;
|
Element element = null;
|
||||||
try {
|
try {
|
||||||
element = eip.createElementInstance(elementLanguage,tag);
|
element = eip.createElementInstance(elementLanguage, tag);
|
||||||
} catch (Exception e) {
|
} 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());
|
enc.addElementClass(element.getElementClass());
|
||||||
|
|
||||||
|
|
@ -161,18 +160,18 @@ public class X4OContentHandler extends DefaultHandler2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
// create attribute map
|
// 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);
|
element.getAttributes().putAll(map);
|
||||||
|
|
||||||
elementStack.push(element);
|
elementStack.push(element);
|
||||||
try {
|
try {
|
||||||
element.doElementStart();
|
element.doElementStart();
|
||||||
} catch (ElementException ee) {
|
} 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())) {
|
if (ElementType.overrideSax.equals(element.getElementType())) {
|
||||||
overrideSaxElement = element;
|
overrideSaxElement = element;
|
||||||
overrideSaxHandler = (DefaultHandler2)element.getElementObject();
|
overrideSaxHandler = (DefaultHandler2) element.getElementObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -180,11 +179,11 @@ public class X4OContentHandler extends DefaultHandler2 {
|
||||||
* @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
|
* @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@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) {
|
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)) {
|
if (overrideSaxElement.getElementClass().getId().equals(tag)) {
|
||||||
overrideSaxHandler.endDocument();
|
overrideSaxHandler.endDocument();
|
||||||
overrideSaxHandler = null;
|
overrideSaxHandler = null;
|
||||||
|
|
@ -201,38 +200,37 @@ public class X4OContentHandler extends DefaultHandler2 {
|
||||||
try {
|
try {
|
||||||
element.doElementEnd();
|
element.doElementEnd();
|
||||||
} catch (ElementException ee) {
|
} 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.
|
* 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
|
||||||
* When this string is 0 length then nothing is done.
|
* the stact noting is done.
|
||||||
* If there are no element on the stact noting is done.
|
|
||||||
*
|
*
|
||||||
* @see org.xml.sax.helpers.DefaultHandler#characters(char[],int,int)
|
* @see org.xml.sax.helpers.DefaultHandler#characters(char[],int,int)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void characters(char[] ch, int start, int length) throws SAXException {
|
public void characters(char[] ch, int start, int length) throws SAXException {
|
||||||
if (overrideSaxHandler!=null) {
|
if (overrideSaxHandler != null) {
|
||||||
overrideSaxHandler.characters(ch, start, length);
|
overrideSaxHandler.characters(ch, start, length);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (length==0) {
|
if (length == 0) {
|
||||||
return; // no text
|
return; // no text
|
||||||
}
|
}
|
||||||
String text = new String(ch,start,length);
|
String text = new String(ch, start, length);
|
||||||
if (text.length()==0) {
|
if (text.length() == 0) {
|
||||||
return; // no text
|
return; // no text
|
||||||
}
|
}
|
||||||
if (elementStack.isEmpty()) {
|
if (elementStack.isEmpty()) {
|
||||||
return; // no element
|
return; // no element
|
||||||
}
|
}
|
||||||
Element e = elementStack.peek();
|
Element e = elementStack.peek();
|
||||||
try {
|
try {
|
||||||
e.doCharacters(text);
|
e.doCharacters(text);
|
||||||
} catch (ElementException ee) {
|
} 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
|
@Override
|
||||||
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
|
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
|
||||||
if (overrideSaxHandler!=null) {
|
if (overrideSaxHandler != null) {
|
||||||
overrideSaxHandler.ignorableWhitespace(ch, start, length);
|
overrideSaxHandler.ignorableWhitespace(ch, start, length);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String text = new String(ch);
|
String text = new String(ch);
|
||||||
text = text.substring(start, start + length);
|
text = text.substring(start, start + length);
|
||||||
if (text.length()==0) {
|
if (text.length() == 0) {
|
||||||
return; // no text
|
return; // no text
|
||||||
}
|
}
|
||||||
if (elementStack.empty()) {
|
if (elementStack.empty()) {
|
||||||
return; // no element
|
return; // no element
|
||||||
}
|
}
|
||||||
Element e = elementStack.peek();
|
Element e = elementStack.peek();
|
||||||
try {
|
try {
|
||||||
e.doIgnorableWhitespace(text);
|
e.doIgnorableWhitespace(text);
|
||||||
} catch (ElementException ee) {
|
} 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,23 +264,23 @@ public class X4OContentHandler extends DefaultHandler2 {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void comment(char[] ch, int start, int length) throws SAXException {
|
public void comment(char[] ch, int start, int length) throws SAXException {
|
||||||
if (overrideSaxHandler!=null) {
|
if (overrideSaxHandler != null) {
|
||||||
overrideSaxHandler.comment(ch, start, length);
|
overrideSaxHandler.comment(ch, start, length);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String text = new String(ch);
|
String text = new String(ch);
|
||||||
text = text.substring(start, start + length);
|
text = text.substring(start, start + length);
|
||||||
if (text.length()==0) {
|
if (text.length() == 0) {
|
||||||
return; // no text
|
return; // no text
|
||||||
}
|
}
|
||||||
if (elementStack.empty()) {
|
if (elementStack.empty()) {
|
||||||
return; // no element
|
return; // no element
|
||||||
}
|
}
|
||||||
Element e = elementStack.peek();
|
Element e = elementStack.peek();
|
||||||
try {
|
try {
|
||||||
e.doComment(text);
|
e.doComment(text);
|
||||||
} catch (ElementException ee) {
|
} 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -291,6 +289,6 @@ public class X4OContentHandler extends DefaultHandler2 {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void processingInstruction(String target, String data) throws SAXException {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ public class X4OContentParser {
|
||||||
private final SAX3PropertyConfig propertyConfig;
|
private final SAX3PropertyConfig propertyConfig;
|
||||||
|
|
||||||
public X4OContentParser(SAX3PropertyConfig propertyConfig) {
|
public X4OContentParser(SAX3PropertyConfig propertyConfig) {
|
||||||
this.propertyConfig=propertyConfig;
|
this.propertyConfig = propertyConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SAX3PropertyConfig getPropertyConfig() {
|
private SAX3PropertyConfig getPropertyConfig() {
|
||||||
|
|
@ -75,67 +75,67 @@ public class X4OContentParser {
|
||||||
|
|
||||||
private void parseSax(X4OLanguageSession languageSession) throws SAXException, IOException, ParserConfigurationException {
|
private void parseSax(X4OLanguageSession languageSession) throws SAXException, IOException, ParserConfigurationException {
|
||||||
// If xsd caching is needed this should be the way
|
// If xsd caching is needed this should be the way
|
||||||
//XMLParserConfiguration config = new XIncludeAwareParserConfiguration();
|
// XMLParserConfiguration config = new XIncludeAwareParserConfiguration();
|
||||||
//config.setProperty("http://apache.org/xml/properties/internal/grammar-pool",myFullGrammarPool);
|
// config.setProperty("http://apache.org/xml/properties/internal/grammar-pool",myFullGrammarPool);
|
||||||
//SAXParser parser = new SAXParser(config);
|
// SAXParser parser = new SAXParser(config);
|
||||||
|
|
||||||
// Create Sax parser with x4o tag handler
|
// Create Sax parser with x4o tag handler
|
||||||
X4OContentHandler xth = new X4OContentHandler(languageSession,getPropertyConfig());
|
X4OContentHandler xth = new X4OContentHandler(languageSession, getPropertyConfig());
|
||||||
SAXParserFactory factory = SAXParserFactory.newInstance();
|
SAXParserFactory factory = SAXParserFactory.newInstance();
|
||||||
factory.setNamespaceAware(true);
|
factory.setNamespaceAware(true);
|
||||||
SAXParser parser = factory.newSAXParser();
|
SAXParser parser = factory.newSAXParser();
|
||||||
XMLReader reader = parser.getXMLReader();
|
XMLReader reader = parser.getXMLReader();
|
||||||
reader.setErrorHandler(new X4OErrorHandler(languageSession,getPropertyConfig()));
|
reader.setErrorHandler(new X4OErrorHandler(languageSession, getPropertyConfig()));
|
||||||
reader.setEntityResolver(new X4OEntityResolver(languageSession,getPropertyConfig()));
|
reader.setEntityResolver(new X4OEntityResolver(languageSession, getPropertyConfig()));
|
||||||
reader.setContentHandler(xth);
|
reader.setContentHandler(xth);
|
||||||
reader.setProperty("http://xml.org/sax/properties/lexical-handler", xth);
|
reader.setProperty("http://xml.org/sax/properties/lexical-handler", xth);
|
||||||
reader.setProperty("http://xml.org/sax/properties/declaration-handler",xth);
|
reader.setProperty("http://xml.org/sax/properties/declaration-handler", xth);
|
||||||
|
|
||||||
// Set properties and optional
|
// Set properties and optional
|
||||||
Map<String,Object> saxParserProperties = getSAXParserProperties(languageSession);
|
Map<String, Object> saxParserProperties = getSAXParserProperties(languageSession);
|
||||||
for (Map.Entry<String,Object> entry:saxParserProperties.entrySet()) {
|
for (Map.Entry<String, Object> entry : saxParserProperties.entrySet()) {
|
||||||
String name = entry.getKey();
|
String name = entry.getKey();
|
||||||
Object value= entry.getValue();
|
Object value = entry.getValue();
|
||||||
reader.setProperty(name, value);
|
reader.setProperty(name, value);
|
||||||
debugMessage("property",name,value,languageSession);
|
debugMessage("property", name, value, languageSession);
|
||||||
}
|
}
|
||||||
Map<String,Object> saxParserPropertiesOptional = getSAXParserPropertiesOptional(languageSession);
|
Map<String, Object> saxParserPropertiesOptional = getSAXParserPropertiesOptional(languageSession);
|
||||||
for (Map.Entry<String,Object> entry:saxParserPropertiesOptional.entrySet()) {
|
for (Map.Entry<String, Object> entry : saxParserPropertiesOptional.entrySet()) {
|
||||||
String name = entry.getKey();
|
String name = entry.getKey();
|
||||||
Object value= entry.getValue();
|
Object value = entry.getValue();
|
||||||
try {
|
try {
|
||||||
reader.setProperty(name, value);
|
reader.setProperty(name, value);
|
||||||
debugMessage("optional-property",name,value,languageSession);
|
debugMessage("optional-property", name, value, languageSession);
|
||||||
} catch (SAXException e) {
|
} catch (SAXException e) {
|
||||||
debugMessageLog("Could not set optional SAX property: "+name+" to: "+value+" error: "+e.getMessage(),languageSession);
|
debugMessageLog("Could not set optional SAX property: " + name + " to: " + value + " error: " + e.getMessage(), languageSession);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set sax features and optional
|
// Set sax features and optional
|
||||||
Map<String, Boolean> features = getSAXParserFeatures(languageSession);
|
Map<String, Boolean> features = getSAXParserFeatures(languageSession);
|
||||||
for (String key:features.keySet()) {
|
for (String key : features.keySet()) {
|
||||||
Boolean value=features.get(key);
|
Boolean value = features.get(key);
|
||||||
reader.setFeature(key, value);
|
reader.setFeature(key, value);
|
||||||
debugMessage("feature",key,value,languageSession);
|
debugMessage("feature", key, value, languageSession);
|
||||||
}
|
}
|
||||||
Map<String, Boolean> featuresOptional = getSAXParserFeaturesOptional(languageSession);
|
Map<String, Boolean> featuresOptional = getSAXParserFeaturesOptional(languageSession);
|
||||||
for (String key:featuresOptional.keySet()) {
|
for (String key : featuresOptional.keySet()) {
|
||||||
Boolean value=featuresOptional.get(key);
|
Boolean value = featuresOptional.get(key);
|
||||||
try {
|
try {
|
||||||
reader.setFeature(key, value);
|
reader.setFeature(key, value);
|
||||||
debugMessage("optional-feature",key,value,languageSession);
|
debugMessage("optional-feature", key, value, languageSession);
|
||||||
} catch (SAXException e) {
|
} catch (SAXException e) {
|
||||||
debugMessageLog("Could not set optional SAX feature: "+key+" to: "+value+" error: "+e.getMessage(),languageSession);
|
debugMessageLog("Could not set optional SAX feature: " + key + " to: " + value + " error: " + e.getMessage(), languageSession);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for required features
|
// check for required features
|
||||||
List<String> requiredFeatures = getSAXParserFeaturesRequired(languageSession);
|
List<String> requiredFeatures = getSAXParserFeaturesRequired(languageSession);
|
||||||
for (String requiredFeature:requiredFeatures) {
|
for (String requiredFeature : requiredFeatures) {
|
||||||
if (reader.getFeature(requiredFeature)==false) {
|
if (reader.getFeature(requiredFeature) == false) {
|
||||||
throw new IllegalStateException("Missing required feature: "+requiredFeature);
|
throw new IllegalStateException("Missing required feature: " + requiredFeature);
|
||||||
}
|
}
|
||||||
debugMessage("required",requiredFeature,"true",languageSession);
|
debugMessage("required", requiredFeature, "true", languageSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally start parsing the xml input stream
|
// Finally start parsing the xml input stream
|
||||||
|
|
@ -143,31 +143,31 @@ public class X4OContentParser {
|
||||||
InputSource input = null;
|
InputSource input = null;
|
||||||
InputStream inputStream = null;
|
InputStream inputStream = null;
|
||||||
if (requestInputSource instanceof InputSource) {
|
if (requestInputSource instanceof InputSource) {
|
||||||
input = (InputSource)requestInputSource;
|
input = (InputSource) requestInputSource;
|
||||||
} else {
|
} else {
|
||||||
inputStream = (InputStream)getPropertyConfig().getProperty(DefaultX4OReader.INPUT_STREAM);
|
inputStream = (InputStream) getPropertyConfig().getProperty(DefaultX4OReader.INPUT_STREAM);
|
||||||
input = new InputSource(inputStream);
|
input = new InputSource(inputStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
Object requestInputEncoding = getPropertyConfig().getProperty(DefaultX4OReader.INPUT_ENCODING);
|
Object requestInputEncoding = getPropertyConfig().getProperty(DefaultX4OReader.INPUT_ENCODING);
|
||||||
if (requestInputEncoding!=null && requestInputEncoding instanceof String) {
|
if (requestInputEncoding != null && requestInputEncoding instanceof String) {
|
||||||
input.setEncoding(requestInputEncoding.toString());
|
input.setEncoding(requestInputEncoding.toString());
|
||||||
}
|
}
|
||||||
Object requestSystemId = getPropertyConfig().getProperty(DefaultX4OReader.INPUT_SYSTEM_ID);
|
Object requestSystemId = getPropertyConfig().getProperty(DefaultX4OReader.INPUT_SYSTEM_ID);
|
||||||
if (requestSystemId!=null && requestSystemId instanceof String) {
|
if (requestSystemId != null && requestSystemId instanceof String) {
|
||||||
input.setSystemId(requestSystemId.toString());
|
input.setSystemId(requestSystemId.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
reader.parse(input);
|
reader.parse(input);
|
||||||
} finally {
|
} finally {
|
||||||
if (inputStream!=null) {
|
if (inputStream != null) {
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void debugMessageLog(String message,X4OLanguageSession languageSession) throws SAXException {
|
private void debugMessageLog(String message, X4OLanguageSession languageSession) throws SAXException {
|
||||||
if (languageSession.hasX4ODebugWriter()) {
|
if (languageSession.hasX4ODebugWriter()) {
|
||||||
try {
|
try {
|
||||||
languageSession.getX4ODebugWriter().debugPhaseMessage(message, getClass());
|
languageSession.getX4ODebugWriter().debugPhaseMessage(message, getClass());
|
||||||
|
|
@ -177,27 +177,29 @@ public class X4OContentParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void debugMessage(String type,String key,Object value,X4OLanguageSession languageSession) throws IOException {
|
private void debugMessage(String type, String key, Object value, X4OLanguageSession languageSession) throws IOException {
|
||||||
if (languageSession.hasX4ODebugWriter()) {
|
if (languageSession.hasX4ODebugWriter()) {
|
||||||
languageSession.getX4ODebugWriter().debugSAXMessage(type,key,""+value);
|
languageSession.getX4ODebugWriter().debugSAXMessage(type, key, "" + value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> getSAXParserProperties(X4OLanguageSession elementContext) {
|
public Map<String, Object> getSAXParserProperties(X4OLanguageSession elementContext) {
|
||||||
Map<String,Object> saxParserProperties = new HashMap<String,Object>(1);
|
Map<String, Object> saxParserProperties = new HashMap<String, Object>(1);
|
||||||
return saxParserProperties;
|
return saxParserProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> getSAXParserPropertiesOptional(X4OLanguageSession elementContext) {
|
public Map<String, Object> getSAXParserPropertiesOptional(X4OLanguageSession elementContext) {
|
||||||
Map<String,Object> saxParserProperties = new HashMap<String,Object>(1);
|
Map<String, Object> saxParserProperties = new HashMap<String, Object>(1);
|
||||||
saxParserProperties.put("http://apache.org/xml/properties/input-buffer-size",getPropertyConfig().getProperty(DefaultX4OReader.DOC_BUFFER_SIZE)); // Increase buffer to 8KB
|
// Increase buffer to 8KB
|
||||||
|
saxParserProperties.put("http://apache.org/xml/properties/input-buffer-size", getPropertyConfig().getProperty(DefaultX4OReader.DOC_BUFFER_SIZE));
|
||||||
return saxParserProperties;
|
return saxParserProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Boolean> getSAXParserFeatures(X4OLanguageSession elementContext) {
|
public Map<String, Boolean> getSAXParserFeatures(X4OLanguageSession elementContext) {
|
||||||
|
|
||||||
// see example: http://xerces.apache.org/xerces2-j/features.html
|
// see example: http://xerces.apache.org/xerces2-j/features.html
|
||||||
Map<String,Boolean> saxParserFeatures = new HashMap<String,Boolean>(20);
|
Map<String, Boolean> saxParserFeatures = new HashMap<String, Boolean>(20);
|
||||||
|
//@formatter:off
|
||||||
|
|
||||||
// Tune Sax Parser
|
// Tune Sax Parser
|
||||||
saxParserFeatures.put("http://xml.org/sax/features/namespaces", true); // Perform namespace processing
|
saxParserFeatures.put("http://xml.org/sax/features/namespaces", true); // Perform namespace processing
|
||||||
|
|
@ -235,14 +237,14 @@ public class X4OContentParser {
|
||||||
} else {
|
} else {
|
||||||
saxParserFeatures.put("http://apache.org/xml/features/validation/schema-full-checking", false); // Disable validation of the schema grammar itself for errors.
|
saxParserFeatures.put("http://apache.org/xml/features/validation/schema-full-checking", false); // Disable validation of the schema grammar itself for errors.
|
||||||
}
|
}
|
||||||
|
//@formatter:on
|
||||||
|
|
||||||
return saxParserFeatures;
|
return saxParserFeatures;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Boolean> getSAXParserFeaturesOptional(X4OLanguageSession elementContext) {
|
public Map<String, Boolean> getSAXParserFeaturesOptional(X4OLanguageSession elementContext) {
|
||||||
Map<String,Boolean> saxParserFeatures = new HashMap<String,Boolean>(20);
|
Map<String, Boolean> saxParserFeatures = new HashMap<String, Boolean>(20);
|
||||||
|
//@formatter:off
|
||||||
// Make Sax Impl more strict.
|
// Make Sax Impl more strict.
|
||||||
saxParserFeatures.put("http://apache.org/xml/features/disallow-doctype-decl", true); // Throws error if document contains a DOCTYPE declaration.
|
saxParserFeatures.put("http://apache.org/xml/features/disallow-doctype-decl", true); // Throws error if document contains a DOCTYPE declaration.
|
||||||
saxParserFeatures.put("http://apache.org/xml/features/validation/schema/normalized-value", true); // Expose normalized values for attributes and elements.
|
saxParserFeatures.put("http://apache.org/xml/features/validation/schema/normalized-value", true); // Expose normalized values for attributes and elements.
|
||||||
|
|
@ -257,15 +259,17 @@ public class X4OContentParser {
|
||||||
//saxParserFeatures.put("http://apache.org/xml/features/validation/warn-on-undeclared-elemdef", true); // Report a warning if an element referenced in a content model is not declared.
|
//saxParserFeatures.put("http://apache.org/xml/features/validation/warn-on-undeclared-elemdef", true); // Report a warning if an element referenced in a content model is not declared.
|
||||||
//saxParserFeatures.put("http://apache.org/xml/features/validation/balance-syntax-trees", false); // No optimize DTD content models.
|
//saxParserFeatures.put("http://apache.org/xml/features/validation/balance-syntax-trees", false); // No optimize DTD content models.
|
||||||
//saxParserFeatures.put("http://apache.org/xml/features/validation/unparsed-entity-checking", false); // Do not check that each value of type ENTITY in DTD.
|
//saxParserFeatures.put("http://apache.org/xml/features/validation/unparsed-entity-checking", false); // Do not check that each value of type ENTITY in DTD.
|
||||||
|
//@formatter:on
|
||||||
return saxParserFeatures;
|
return saxParserFeatures;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getSAXParserFeaturesRequired(X4OLanguageSession elementContext) {
|
public List<String> getSAXParserFeaturesRequired(X4OLanguageSession elementContext) {
|
||||||
List<String> result = new ArrayList<String>(5);
|
List<String> result = new ArrayList<String>(5);
|
||||||
|
//@formatter:off
|
||||||
result.add("http://xml.org/sax/features/use-attributes2"); // Attributes objects passed by the parser are ext.Attributes2 interface.
|
result.add("http://xml.org/sax/features/use-attributes2"); // Attributes objects passed by the parser are ext.Attributes2 interface.
|
||||||
result.add("http://xml.org/sax/features/use-locator2"); // Locator objects passed by the parser are org.xml.sax.ext.Locator2 interface.
|
result.add("http://xml.org/sax/features/use-locator2"); // Locator objects passed by the parser are org.xml.sax.ext.Locator2 interface.
|
||||||
result.add("http://xml.org/sax/features/xml-1.1"); // The parser supports both XML 1.0 and XML 1.1.
|
result.add("http://xml.org/sax/features/xml-1.1"); // The parser supports both XML 1.0 and XML 1.1.
|
||||||
|
//@formatter:on
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
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