Created sax content writers and created generic api doc model for
documentation. Improved writer support with attribute write order and new-lining after long attribute values.
2
pom.xml
|
@ -47,7 +47,7 @@
|
||||||
</prerequisites>
|
</prerequisites>
|
||||||
<modules>
|
<modules>
|
||||||
<module>x4o-driver</module>
|
<module>x4o-driver</module>
|
||||||
<module>x4o-elddoc</module>
|
<module>x4o-eld-doc</module>
|
||||||
<module>x4o-meta</module>
|
<module>x4o-meta</module>
|
||||||
<module>x4o-plugin</module>
|
<module>x4o-plugin</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
|
@ -37,9 +37,10 @@ cd `dirname $0`/../../..;
|
||||||
# Copy to one new dir.
|
# Copy to one new dir.
|
||||||
mkdir -p target/gnu-up/$2;
|
mkdir -p target/gnu-up/$2;
|
||||||
cp x4o-driver/target/x4o-driver-*.jar target/gnu-up/$2;
|
cp x4o-driver/target/x4o-driver-*.jar target/gnu-up/$2;
|
||||||
cp x4o-elddoc/target/x4o-elddoc-*.jar target/gnu-up/$2;
|
cp x4o-eld-doc/target/x4o-eld-doc-*.jar target/gnu-up/$2;
|
||||||
cp x4o-meta/target/x4o-meta-*.jar target/gnu-up/$2;
|
cp x4o-meta/target/x4o-meta-*.jar target/gnu-up/$2;
|
||||||
cp x4o-plugin/x4o-plugin-ant/target/x4o-plugin-ant-*.jar target/gnu-up/$2;
|
cp x4o-plugin/x4o-plugin-ant/target/x4o-plugin-ant-*.jar target/gnu-up/$2;
|
||||||
|
cp x4o-plugin/x4o-plugin-maven/target/x4o-plugin-maven-*.jar target/gnu-up/$2;
|
||||||
|
|
||||||
# Sign per file we want to upload.
|
# Sign per file we want to upload.
|
||||||
for FILE in `ls target/gnu-up/$2/*`; do
|
for FILE in `ls target/gnu-up/$2/*`; do
|
||||||
|
|
|
@ -23,61 +23,43 @@
|
||||||
|
|
||||||
Sample SwiXml
|
Sample SwiXml
|
||||||
|
|
||||||
Lets create an xml example from swixml language.
|
Lets create an xml example from the swixml language.
|
||||||
|
|
||||||
* Create parser
|
* Create language driver
|
||||||
|
|
||||||
+--
|
+--
|
||||||
public class SwiXmlParser extends X4OParser {
|
public class SwiXmlDriver extends X4ODriver<Component> {
|
||||||
|
|
||||||
public static final String LANGUAGE = "swixml";
|
public static final String LANGUAGE_NAME = "swixml";
|
||||||
public static final String VERSION_2_NS_URI = "http://swixml.x4o.org/xml/ns/swixml-lang";
|
public static final String LANGUAGE_VERSION_2 = "2.0";
|
||||||
public static final String SWING_ENGINE_EL_NAME = "swingEngine";
|
public static final String LANGUAGE_VERSION_2_NSURI = "http://swixml.x4o.org/xml/ns/swixml-lang"; // todo
|
||||||
|
public static final String LANGUAGE_VERSION_3 = "3.0";
|
||||||
|
public static final String[] LANGUAGE_VERSIONS = new String[]{LANGUAGE_VERSION_2,LANGUAGE_VERSION_3};
|
||||||
|
public static final String LANGUAGE_EL_SWING_ENGINE = "swingEngine";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Protected constructor for language support
|
* Helper for while parsing to get the SwingEngine.
|
||||||
|
* @param elementLanguage The elementLanguage to get the swingEngine out.
|
||||||
|
* @return Returns the SwingEngine for this elementLanguage.
|
||||||
*/
|
*/
|
||||||
protected SwiXmlParser() {
|
static public SwingEngine getSwingEngine(X4OLanguageContext elementLanguage) {
|
||||||
super(LANGUAGE);
|
ValueExpression ee = elementLanguage.getExpressionLanguageFactory().createValueExpression(elementLanguage.getExpressionLanguageContext(),"${"+SwiXmlDriver.LANGUAGE_EL_SWING_ENGINE+"}",Object.class);
|
||||||
}
|
SwingEngine se = (SwingEngine)ee.getValue(elementLanguage.getExpressionLanguageContext());
|
||||||
|
|
||||||
public SwiXmlParser(SwingEngine engine) {
|
|
||||||
|
|
||||||
// Create language by version
|
|
||||||
super(LANGUAGE);
|
|
||||||
|
|
||||||
// Check engine
|
|
||||||
if (engine==null) {
|
|
||||||
throw new NullPointerException("Can't parse with null SwingEngine.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add engine for callback
|
|
||||||
addELBeanInstance(SWING_ENGINE_EL_NAME,engine);
|
|
||||||
|
|
||||||
// Set empty ns for v2 documents
|
|
||||||
setProperty(X4OLanguagePropertyKeys.INPUT_EMPTY_NAMESPACE_URI, VERSION_2_NS_URI);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Component getRootComponent() {
|
|
||||||
return (Component)getDriver().getElementLanguage().getRootElement().getElementObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
static public SwingEngine getSwingEngine(ElementLanguage elementLanguage) {
|
|
||||||
ValueExpression ee = elementLanguage.getExpressionFactory().createValueExpression(elementLanguage.getELContext(),"${"+SwiXmlParser.SWING_ENGINE_EL_NAME+"}",Object.class);
|
|
||||||
SwingEngine se = (SwingEngine)ee.getValue(elementLanguage.getELContext());
|
|
||||||
return se;
|
return se;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
+--
|
|
||||||
|
|
||||||
* Create parser support
|
static public SwiXmlDriver getInstance() {
|
||||||
|
return (SwiXmlDriver)X4ODriverManager.getX4ODriver(LANGUAGE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
+--
|
@Override
|
||||||
public class SwiXmlParserSupport2 implements X4OParserSupport {
|
public String getLanguageName() {
|
||||||
|
return LANGUAGE_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
public ElementLanguage loadElementLanguageSupport() throws X4OParserSupportException {
|
@Override
|
||||||
SwiXmlParser parser = new SwiXmlParser();
|
public String[] getLanguageVersions() {
|
||||||
return parser.loadElementLanguageSupport();
|
return LANGUAGE_VERSIONS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+--
|
+--
|
||||||
|
@ -103,27 +85,30 @@ public class SwiXmlParserSupport2 implements X4OParserSupport {
|
||||||
* Define the element language
|
* Define the element language
|
||||||
|
|
||||||
+--
|
+--
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<root:module
|
<root:module
|
||||||
xmlns:root="http://eld.x4o.org/xml/ns/eld-root"
|
xmlns:root="http://eld.x4o.org/xml/ns/eld-root"
|
||||||
xmlns="http://eld.x4o.org/xml/ns/eld-lang"
|
xmlns="http://eld.x4o.org/xml/ns/eld-lang"
|
||||||
xmlns:conv="http://eld.x4o.org/xml/ns/eld-conv"
|
xmlns:conv="http://eld.x4o.org/xml/ns/eld-conv"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://eld.x4o.org/xml/ns/eld-root http://eld.x4o.org/xml/ns/eld-root-1.0.xsd"
|
xsi:schemaLocation="http://eld.x4o.org/xml/ns/eld-root http://eld.x4o.org/xml/ns/eld-root-1.0.xsd"
|
||||||
providerName="swixml.test.x4o.org"
|
providerHost="swixml2.test.x4o.org"
|
||||||
name="Swixml Language"
|
providerName="Swixml2 Language"
|
||||||
id="swixml-lang"
|
id="swixml2-module"
|
||||||
>
|
>
|
||||||
|
|
||||||
<bindingHandler id="JComponentBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JComponentBindingHandler"/>
|
<bindingHandler id="JFrameBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JFrameBindingHandler"/>
|
||||||
<bindingHandler id="JMenuBarBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JMenuBarBindingHandler"/>
|
<bindingHandler id="JInternalFrameBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JInternalFrameBindingHandler"/>
|
||||||
<classBindingHandler id="JDesktopPane-JInternalFrame" parentClass="javax.swing.JDesktopPane" childClass="javax.swing.JInternalFrame" method="add"/>
|
<bindingHandler id="JPanelBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JPanelBindingHandler"/>
|
||||||
<classBindingHandler id="JFrame-JDesktopPane" parentClass="javax.swing.JFrame" childClass="javax.swing.JDesktopPane" method="setContentPane"/>
|
<bindingHandler id="JSplitPaneBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JSplitPaneBindingHandler"/>
|
||||||
<classBindingHandler id="JMenuBar-JMenu" parentClass="javax.swing.JMenuBar" childClass="javax.swing.JMenu" method="add"/>
|
<classBindingHandler id="JScrollPane-JComponent" parentClass="javax.swing.JScrollPane" childClass="javax.swing.JComponent" addMethod="setViewportView" getMethod="getViewport"/>
|
||||||
<classBindingHandler id="JMenu-JMenuItem" parentClass="javax.swing.JMenu" childClass="javax.swing.JMenuItem" method="add"/>
|
<classBindingHandler id="JDesktopPane-JInternalFrame" parentClass="javax.swing.JDesktopPane" childClass="javax.swing.JInternalFrame" addMethod="add" getMethod="getComponents"/>
|
||||||
|
<classBindingHandler id="JFrame-JDesktopPane" parentClass="javax.swing.JFrame" childClass="javax.swing.JDesktopPane" addMethod="setContentPane" getMethod="getContentPane"/>
|
||||||
|
<classBindingHandler id="JMenuBar-JMenu" parentClass="javax.swing.JMenuBar" childClass="javax.swing.JMenu" addMethod="add" getMethod="getComponents"/>
|
||||||
|
<classBindingHandler id="JMenu-JMenuItem" parentClass="javax.swing.JMenu" childClass="javax.swing.JMenuItem" addMethod="add" getMethod="getComponents"/>
|
||||||
|
<classBindingHandler id="JRootPane-JComponent" parentClass="javax.swing.JRootPane" childClass="javax.swing.JComponent" addMethod="add" getMethod="getComponents"/>
|
||||||
|
|
||||||
<elementInterface id="Component" interfaceClass="java.awt.Component">
|
<elementInterface id="Component" interfaceClass="java.awt.Component">
|
||||||
<attribute name="bounds">
|
<attribute id="bounds">
|
||||||
<conv:stringSplitConverter classTo="java.awt.Rectangle" split="," splitSize="4" singleToMethod="setRect" useNativeType="true">
|
<conv:stringSplitConverter classTo="java.awt.Rectangle" split="," splitSize="4" singleToMethod="setRect" useNativeType="true">
|
||||||
<conv:stringSplitConverterStep fromMethod="getX" fromOrder="1" toOrder="1"><conv:doubleConverter/></conv:stringSplitConverterStep>
|
<conv:stringSplitConverterStep fromMethod="getX" fromOrder="1" toOrder="1"><conv:doubleConverter/></conv:stringSplitConverterStep>
|
||||||
<conv:stringSplitConverterStep fromMethod="getY" fromOrder="2" toOrder="2"><conv:doubleConverter/></conv:stringSplitConverterStep>
|
<conv:stringSplitConverterStep fromMethod="getY" fromOrder="2" toOrder="2"><conv:doubleConverter/></conv:stringSplitConverterStep>
|
||||||
|
@ -131,76 +116,75 @@ public class SwiXmlParserSupport2 implements X4OParserSupport {
|
||||||
<conv:stringSplitConverterStep fromMethod="getHeight" fromOrder="4" toOrder="4"><conv:doubleConverter/></conv:stringSplitConverterStep>
|
<conv:stringSplitConverterStep fromMethod="getHeight" fromOrder="4" toOrder="4"><conv:doubleConverter/></conv:stringSplitConverterStep>
|
||||||
</conv:stringSplitConverter>
|
</conv:stringSplitConverter>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="size">
|
<attribute id="size">
|
||||||
<conv:stringSplitConverter classTo="java.awt.Dimension" split="," splitSize="2" singleToMethod="setSize" useNativeType="true">
|
<conv:stringSplitConverter classTo="java.awt.Dimension" split="," splitSize="2" singleToMethod="setSize" useNativeType="true">
|
||||||
<conv:stringSplitConverterStep fromMethod="getHeight" fromOrder="1" toOrder="1"><conv:integerConverter/></conv:stringSplitConverterStep>
|
<conv:stringSplitConverterStep fromMethod="getHeight" fromOrder="1" toOrder="1"><conv:integerConverter/></conv:stringSplitConverterStep>
|
||||||
<conv:stringSplitConverterStep fromMethod="getWidth" fromOrder="2" toOrder="2"><conv:integerConverter/></conv:stringSplitConverterStep>
|
<conv:stringSplitConverterStep fromMethod="getWidth" fromOrder="2" toOrder="2"><conv:integerConverter/></conv:stringSplitConverterStep>
|
||||||
</conv:stringSplitConverter>
|
</conv:stringSplitConverter>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="icon">
|
<attribute id="icon">
|
||||||
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.IconConverter"/>
|
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.IconConverter"/>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="background">
|
<attribute id="background">
|
||||||
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.ColorConverter"/>
|
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.ColorConverter"/>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="location">
|
<attribute id="location">
|
||||||
<conv:stringSplitConverter classTo="java.awt.Point" split="," splitSize="2" singleToMethod="setLocation" useNativeType="true">
|
<conv:stringSplitConverter classTo="java.awt.Point" split="," splitSize="2" singleToMethod="setLocation" useNativeType="true">
|
||||||
<conv:stringSplitConverterStep fromMethod="getX" fromOrder="1" toOrder="1"><conv:integerConverter/></conv:stringSplitConverterStep>
|
<conv:stringSplitConverterStep fromMethod="getX" fromOrder="1" toOrder="1"><conv:integerConverter/></conv:stringSplitConverterStep>
|
||||||
<conv:stringSplitConverterStep fromMethod="getY" fromOrder="2" toOrder="2"><conv:integerConverter/></conv:stringSplitConverterStep>
|
<conv:stringSplitConverterStep fromMethod="getY" fromOrder="2" toOrder="2"><conv:integerConverter/></conv:stringSplitConverterStep>
|
||||||
</conv:stringSplitConverter>
|
</conv:stringSplitConverter>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<attribute id="locationOnScreen" runBeanValue="false"/>
|
||||||
</elementInterface>
|
</elementInterface>
|
||||||
|
|
||||||
<elementInterface id="JComponent" interfaceClass="javax.swing.JComponent">
|
<elementInterface id="JComponent" interfaceClass="javax.swing.JComponent">
|
||||||
<attribute name="layout">
|
<attribute id="layout">
|
||||||
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.LayoutConverter"/>
|
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.LayoutConverter"/>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="border">
|
<attribute id="border">
|
||||||
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.BorderConverter"/>
|
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.BorderConverter"/>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<attribute id="toolTipText"><attributeAlias name="ToolTipText"/></attribute>
|
||||||
|
<attribute id="focusPainted"><attributeAlias name="FocusPainted"/></attribute>
|
||||||
|
<attribute id="borderPainted"><attributeAlias name="BorderPainted"/></attribute>
|
||||||
</elementInterface>
|
</elementInterface>
|
||||||
|
|
||||||
|
|
||||||
<namespace
|
<namespace id="root" languageRoot="true">
|
||||||
uri="http://swixml.x4o.org/xml/ns/swixml-root"
|
<element tag="frame" objectClass="javax.swing.JFrame">
|
||||||
schemaUri="http://swixml.x4o.org/xml/ns/swixml-root-2.0.xsd"
|
<description>Single element in language root to create nice tree, for imports in xsd namespace aware generated files.</description>
|
||||||
schemaResource="swixml-root-2.0.xsd"
|
</element>
|
||||||
schemaPrefix="root"
|
|
||||||
name="Root element"
|
|
||||||
languageRoot="true"
|
|
||||||
>
|
|
||||||
<!-- Single element in language root to create nice tree, for imports in xsd namespace aware generated files. -->
|
|
||||||
<element tag="frame" objectClass="javax.swing.JFrame"/>
|
|
||||||
</namespace>
|
</namespace>
|
||||||
<namespace
|
<namespace id="lang">
|
||||||
uri="http://swixml.x4o.org/xml/ns/swixml-lang"
|
|
||||||
schemaUri="http://swixml.x4o.org/xml/ns/swixml-lang-2.0.xsd"
|
|
||||||
schemaResource="swixml-lang-2.0.xsd"
|
|
||||||
schemaPrefix="sx-lang"
|
|
||||||
>
|
|
||||||
<!-- Note frame should not be here(it can but xsd needs root), but else classic xml does not parse without xmlns additions. -->
|
<!-- Note frame should not be here(it can but xsd needs root), but else classic xml does not parse without xmlns additions. -->
|
||||||
<element tag="frame" objectClass="javax.swing.JFrame"/>
|
<element tag="frame" objectClass="javax.swing.JFrame"/>
|
||||||
<element tag="menubar" objectClass="javax.swing.JMenuBar"/>
|
<element tag="menubar" objectClass="javax.swing.JMenuBar"/>
|
||||||
<element tag="menu" objectClass="javax.swing.JMenu"/>
|
<element tag="menu" objectClass="javax.swing.JMenu"/>
|
||||||
<element tag="menuitem" objectClass="javax.swing.JMenuItem">
|
<element tag="menuitem" objectClass="javax.swing.JMenuItem">
|
||||||
<attribute name="accelerator">
|
<attribute id="accelerator">
|
||||||
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.KeyStrokeConverter"/>
|
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.KeyStrokeConverter"/>
|
||||||
<attributeAlias name="Accelerator"/>
|
<attributeAlias name="Accelerator"/>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="Action" runBeanFill="false"/>
|
<attribute id="mnemonic" runBeanValue="false"/>
|
||||||
|
<attribute id="Action" runBeanValue="false"/>
|
||||||
<configurator id="menuitem-action" bean.class="org.x4o.xml.test.swixml.SwiXmlActionConfigurator"/>
|
<configurator id="menuitem-action" bean.class="org.x4o.xml.test.swixml.SwiXmlActionConfigurator"/>
|
||||||
</element>
|
</element>
|
||||||
<element tag="separator" />
|
<element tag="separator" />
|
||||||
<element tag="panel" objectClass="javax.swing.JPanel"/>
|
<element tag="panel" objectClass="javax.swing.JPanel"/>
|
||||||
<element tag="splitpane" objectClass="javax.swing.JSplitPane">
|
<element tag="splitpane" objectClass="javax.swing.JSplitPane">
|
||||||
<attribute name="orientation">
|
<attribute id="orientation">
|
||||||
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.JSplitPaneOrientationConverter"/>
|
<conv:beanConverter bean.class="org.x4o.xml.test.swixml.conv.JSplitPaneOrientationConverter"/>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<attribute id="dividerLocation">
|
||||||
|
<conv:integerConverter/>
|
||||||
|
</attribute>
|
||||||
</element>
|
</element>
|
||||||
|
<element tag="layeredPane" objectClass="javax.swing.JLayeredPane"/>
|
||||||
|
<element tag="rootPane" objectClass="javax.swing.JRootPane"/>
|
||||||
<element tag="scrollPane" objectClass="javax.swing.JScrollPane"/>
|
<element tag="scrollPane" objectClass="javax.swing.JScrollPane"/>
|
||||||
<element tag="tree" objectClass="javax.swing.JTree"/>
|
<element tag="tree" objectClass="javax.swing.JTree"/>
|
||||||
<element tag="button" objectClass="javax.swing.JButton">
|
<element tag="button" objectClass="javax.swing.JButton">
|
||||||
<attributeFromBody name="text"/>
|
<attributeFromBody id="button-text" name="text"/>
|
||||||
</element>
|
</element>
|
||||||
<element tag="table" objectClass="javax.swing.JTable"/>
|
<element tag="table" objectClass="javax.swing.JTable"/>
|
||||||
<element tag="textarea" objectClass="javax.swing.JTextArea"/>
|
<element tag="textarea" objectClass="javax.swing.JTextArea"/>
|
||||||
|
@ -208,33 +192,57 @@ public class SwiXmlParserSupport2 implements X4OParserSupport {
|
||||||
<element tag="textfield" objectClass="javax.swing.JTextField"/>
|
<element tag="textfield" objectClass="javax.swing.JTextField"/>
|
||||||
<element tag="desktoppane" objectClass="javax.swing.JDesktopPane"/>
|
<element tag="desktoppane" objectClass="javax.swing.JDesktopPane"/>
|
||||||
<element tag="internalframe" objectClass="javax.swing.JInternalFrame">
|
<element tag="internalframe" objectClass="javax.swing.JInternalFrame">
|
||||||
<attribute name="title"><attributeAlias name="Title"/></attribute>
|
<attribute id="title"><attributeAlias name="Title"/></attribute>
|
||||||
<attribute name="bounds"><attributeAlias name="Bounds"/></attribute>
|
<attribute id="bounds"><attributeAlias name="Bounds"/></attribute>
|
||||||
<attribute name="layout"><attributeAlias name="Layout"/></attribute>
|
<attribute id="layout"><attributeAlias name="Layout"/></attribute>
|
||||||
<attribute name="visible"><attributeAlias name="Visible"/></attribute>
|
<attribute id="visible"><attributeAlias name="Visible"/></attribute>
|
||||||
<attribute name="resizable"><attributeAlias name="Resizable"/></attribute>
|
<attribute id="resizable"><attributeAlias name="Resizable"/></attribute>
|
||||||
</element>
|
</element>
|
||||||
</namespace>
|
</namespace>
|
||||||
</root:module>
|
</root:module>
|
||||||
+--
|
+--
|
||||||
|
|
||||||
* JMenuBarBindingHandler
|
* Example of hard coded binding handlers
|
||||||
|
|
||||||
+--
|
+--
|
||||||
public class JMenuBarBindingHandler extends AbstractElementBindingHandler {
|
public class JPanelBindingHandler extends AbstractElementBindingHandler<JPanel> {
|
||||||
|
|
||||||
public Class<?> getBindParentClass() {
|
public Class<?> getBindParentClass() {
|
||||||
return JFrame.class;
|
return JPanel.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<?>[] getBindChildClasses() {
|
public Class<?>[] getBindChildClasses() {
|
||||||
return new Class[] {JMenuBar.class};
|
return new Class[] {JComponent.class};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doBind(Object parentObject, Object childObject, Element childElement) throws ElementBindingHandlerException {
|
public void bindChild(Element childElement, JPanel parent, Object childObject) throws ElementBindingHandlerException {
|
||||||
JMenuBar child = (JMenuBar)childObject;
|
JComponent child = (JComponent)childObject;
|
||||||
JFrame frame = (JFrame)parentObject;
|
|
||||||
frame.getRootPane().setJMenuBar(child);
|
String c = childElement.getAttributes().get("constraints");
|
||||||
|
Object con = null;
|
||||||
|
if ("BorderLayout.CENTER".equals(c)) {
|
||||||
|
con = BorderLayout.CENTER;
|
||||||
|
} else if ("BorderLayout.NORTH".equals(c)) {
|
||||||
|
con = BorderLayout.NORTH;
|
||||||
|
} else if ("BorderLayout.CENTER".equals(c)) {
|
||||||
|
con = BorderLayout.CENTER;
|
||||||
|
} else if ("BorderLayout.SOUTH".equals(c)) {
|
||||||
|
con = BorderLayout.SOUTH;
|
||||||
|
}
|
||||||
|
if (con==null) {
|
||||||
|
parent.add(child);
|
||||||
|
} else {
|
||||||
|
parent.add(child,con);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createChilderen(Element parentElement,JPanel parent) throws ElementBindingHandlerException {
|
||||||
|
for (Component c:parent.getComponents()) {
|
||||||
|
if (c instanceof JComponent) {
|
||||||
|
createChild(parentElement, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+--
|
+--
|
||||||
|
|
|
@ -26,47 +26,57 @@ Start Language
|
||||||
To integrate x4o as parser for your language there needs to be a few minimal steps
|
To integrate x4o as parser for your language there needs to be a few minimal steps
|
||||||
be te taken, to have a working language.
|
be te taken, to have a working language.
|
||||||
|
|
||||||
* Create parser and support classes.
|
* Create driver class.
|
||||||
|
|
||||||
|
* Create driver config file.
|
||||||
|
|
||||||
* Create language modules files.
|
* Create language modules files.
|
||||||
|
|
||||||
* Create eld files.
|
* Create element language definition files.
|
||||||
|
|
||||||
|
|
||||||
* Create your parser
|
* Create your parser
|
||||||
|
|
||||||
+--
|
+--
|
||||||
public class FooBarParser extends X4OParser {
|
public class TestFooBarDriver extends X4ODriver<TestFooBar> {
|
||||||
|
|
||||||
static public String FOOBAR_LANGUAGE = "foobar";
|
static final public String LANGUAGE_NAME = "test-foo-bar";
|
||||||
|
static final public String[] LANGUAGE_VERSIONS = new String[]{X4ODriver.DEFAULT_LANGUAGE_VERSION};
|
||||||
|
|
||||||
public FooBarParser() throws Exception {
|
@Override
|
||||||
super(FOOBAR_LANGUAGE);
|
public String getLanguageName() {
|
||||||
|
return LANGUAGE_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getLanguageVersions() {
|
||||||
|
return LANGUAGE_VERSIONS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static public TestFooBarDriver getInstance() {
|
||||||
|
return (TestFooBarDriver)X4ODriverManager.getX4ODriver(LANGUAGE_NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+--
|
+--
|
||||||
|
|
||||||
* Create parser support
|
* Create driver config
|
||||||
|
|
||||||
|
In the file "META-INF/x4o-drivers.xml"
|
||||||
|
|
||||||
+--
|
+--
|
||||||
public class FooBarParserSupport implements X4OParserSupport {
|
<drivers version="1.0"
|
||||||
|
xmlns="http://language.x4o.org/xml/ns/drivers"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://language.x4o.org/xml/ns/drivers http://language.x4o.org/xml/ns/drivers-1.0.xsd"
|
||||||
|
>
|
||||||
|
<driver language="test-foo-bar" className="org.x4o.xml.test.TestFooBarDriver"/>
|
||||||
|
</drivers>
|
||||||
|
|
||||||
public ElementLanguage loadElementLanguageSupport() throws X4OParserSupportException {
|
|
||||||
FooBarParser parser = new FooBarParser();
|
|
||||||
return parser.loadElementLanguageSupport();
|
|
||||||
}
|
|
||||||
|
|
||||||
public TestBeanRoot getRoot() {
|
|
||||||
// Simple way to return single root object.
|
|
||||||
// note; element tree is cleared after parsing only root element is there.
|
|
||||||
return (TestBeanRoot)getDriver().getElementLanguage().getRootElement().getElementObject();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+--
|
+--
|
||||||
|
|
||||||
* Create modules
|
* Create modules
|
||||||
|
|
||||||
Create the file "META-INF/foobar/foobar-modules.xml" with:
|
Create the file "META-INF/test-foo-bar/test-foo-bar-modules.xml" with:
|
||||||
|
|
||||||
+--
|
+--
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
@ -83,7 +93,7 @@ public class FooBarParserSupport implements X4OParserSupport {
|
||||||
|
|
||||||
* Create ELD file
|
* Create ELD file
|
||||||
|
|
||||||
Create the file "META-INF/foobar/foobar-lang.eld" with:
|
Create the file "META-INF/test-foo-bar/foobar-lang.eld" with:
|
||||||
|
|
||||||
+--
|
+--
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
@ -93,8 +103,6 @@ public class FooBarParserSupport implements X4OParserSupport {
|
||||||
xmlns:conv="http://eld.x4o.org/xml/ns/eld-conv"
|
xmlns:conv="http://eld.x4o.org/xml/ns/eld-conv"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://eld.x4o.org/xml/ns/eld-root http://eld.x4o.org/xml/ns/eld-root-1.0.xsd"
|
xsi:schemaLocation="http://eld.x4o.org/xml/ns/eld-root http://eld.x4o.org/xml/ns/eld-root-1.0.xsd"
|
||||||
providerName="foobar.test.x4o.org"
|
|
||||||
name="FooBar Language"
|
|
||||||
id="foobar"
|
id="foobar"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
@ -112,8 +120,9 @@ public class FooBarParserSupport implements X4OParserSupport {
|
||||||
schemaPrefix="root"
|
schemaPrefix="root"
|
||||||
name="FooBar Root Namespace"
|
name="FooBar Root Namespace"
|
||||||
languageRoot="true"
|
languageRoot="true"
|
||||||
|
id="root"
|
||||||
>
|
>
|
||||||
<eld:element tag="root" objectClass="org.foo.bar.TestBeanRoot">
|
<eld:element tag="foobar" objectClass="org.foo.bar.TestFooBar">
|
||||||
<eld:description>The root element.</eld:description>
|
<eld:description>The root element.</eld:description>
|
||||||
</eld:element>
|
</eld:element>
|
||||||
</eld:namespace>
|
</eld:namespace>
|
||||||
|
@ -124,6 +133,7 @@ public class FooBarParserSupport implements X4OParserSupport {
|
||||||
schemaResource="foobar-lang-1.0.xsd"
|
schemaResource="foobar-lang-1.0.xsd"
|
||||||
schemaPrefix="lang"
|
schemaPrefix="lang"
|
||||||
name="FooBar Language Namespace"
|
name="FooBar Language Namespace"
|
||||||
|
id="lang"
|
||||||
>
|
>
|
||||||
<eld:element tag="testBean" objectClass="org.foo.bar.TestBean"/>
|
<eld:element tag="testBean" objectClass="org.foo.bar.TestBean"/>
|
||||||
|
|
||||||
|
@ -138,19 +148,39 @@ public class FooBarParserSupport implements X4OParserSupport {
|
||||||
|
|
||||||
+--
|
+--
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<r:root
|
<root:foobar
|
||||||
xmlns:l="http://foobar.test.x4o.org/xml/ns/foobar-lang"
|
xmlns="http://foobar.test.x4o.org/xml/ns/foobar-lang"
|
||||||
xmlns:r="http://foobar.test.x4o.org/xml/ns/foobar-root""
|
xmlns:root="http://foobar.test.x4o.org/xml/ns/foobar-root"
|
||||||
>
|
>
|
||||||
<l:testBean value="testing xml"/>
|
<testBean value="testing foo bar language."/>
|
||||||
</r:root>
|
</root:foobar>
|
||||||
+--
|
+--
|
||||||
|
|
||||||
* Parse the xml
|
* Parse the xml
|
||||||
|
|
||||||
+--
|
+--
|
||||||
FooBarParser p = new FooBarParser();
|
TestFooBarDriver driver = TestFooBarDriver.getInstance();
|
||||||
p.parseFile("foobar/example.xml");
|
|
||||||
TestBeanRoot root = p.getRoot();
|
X4OReader<TestFooBar> reader = driver.createReader();
|
||||||
|
TestFooBar result = reader.readResource("junit/test-foo-bar/test-bean.xml");
|
||||||
|
|
||||||
|
result.addTestBean(new TestBean("test-bean"));
|
||||||
|
result.addTestBean(new TestBean("test-bean-extra"));
|
||||||
|
|
||||||
|
X4OWriter<TestFooBar> writer = driver.createReader();
|
||||||
|
writer.writeFile(result, new File("/tmp/test-bean.xml");
|
||||||
+--
|
+--
|
||||||
|
|
||||||
|
And writer gives output like;
|
||||||
|
|
||||||
|
+--
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<root:foobar
|
||||||
|
xmlns:lang="http://foobar.test.x4o.org/xml/ns/foobar-lang"
|
||||||
|
xmlns:root="http://foobar.test.x4o.org/xml/ns/foobar-root"
|
||||||
|
>
|
||||||
|
<lang:testBean value="testing foo bar language."/>
|
||||||
|
<lang:testBean value="test-bean"/>
|
||||||
|
<lang:testBean value="test-bean-extra"/>
|
||||||
|
</root:foobar>
|
||||||
|
+--
|
||||||
|
|
25
todo.txt
|
@ -1,17 +1,31 @@
|
||||||
|
|
||||||
-- x4o TODO list --
|
-- x4o TODO list --
|
||||||
|
|
||||||
|
-- RM function methods from Element interface.
|
||||||
|
-- Change global attr to namespace attributes.
|
||||||
|
- finish eld doc-output content.
|
||||||
|
- Make generic/safe? config bean.
|
||||||
|
- Make language config done by driver xml parser.
|
||||||
|
- Add langauge task api + reg via driver conf or service
|
||||||
|
- Convert ant/mvn plugin to single task executor.
|
||||||
|
- change x4o language to "x4o-" prefix so; x4o-cel,x4o-eld,x4o-meta
|
||||||
|
- Add language locking, and lock eld/cel and add <lang>-eld wrap language for eld extentions per language.
|
||||||
|
|
||||||
|
- Add doc version upgrade handler;
|
||||||
|
- per version step xslt doc upgrade (check dyna sax piplining hooking)
|
||||||
|
- per version eld + support code + backing objects
|
||||||
|
- per version eld for dyna tree convert to new backing objects.
|
||||||
|
- Add *Local layer for X4OLanguage* classes.
|
||||||
|
- Add default define (EL) layer
|
||||||
|
- Bring back xml read+write streaming language support.
|
||||||
- static field constant converter
|
- static field constant converter
|
||||||
|
- add default list and map converter/handler
|
||||||
- full Xinclude test
|
- full Xinclude test
|
||||||
- compleet eld doc html/css.
|
|
||||||
- move loading back into sax phase so version can readout on root tag.
|
- move loading back into sax phase so version can readout on root tag.
|
||||||
- meta add more ns and jndi ref/etc'
|
|
||||||
- redo eld/default converters config
|
|
||||||
- tag aliases
|
- tag aliases
|
||||||
- lang-el-beans.xml loading
|
- <lang>-el-beans.xml loading
|
||||||
- Add XML schema tags to ELD
|
- Add XML schema tags to ELD
|
||||||
- Auto generate schemas from eld
|
- Auto generate schemas from eld
|
||||||
- Basic write support
|
|
||||||
- Basic editor support
|
- Basic editor support
|
||||||
- Make converter config/loading better
|
- Make converter config/loading better
|
||||||
- Single xsd output
|
- Single xsd output
|
||||||
|
@ -22,6 +36,7 @@
|
||||||
|
|
||||||
-- IDEAS --
|
-- IDEAS --
|
||||||
|
|
||||||
|
- add mini xslt parse on top of streaming api.
|
||||||
- add support javax.xml.xpath for xpath support
|
- add support javax.xml.xpath for xpath support
|
||||||
- add java.script support
|
- add java.script support
|
||||||
- event listeners on all DOM tree element operations
|
- event listeners on all DOM tree element operations
|
||||||
|
|
|
@ -24,13 +24,14 @@ package org.x4o.xml.eld.xsd;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.io.Writer;
|
||||||
|
|
||||||
import org.x4o.xml.element.ElementClass;
|
import org.x4o.xml.element.ElementClass;
|
||||||
import org.x4o.xml.element.ElementException;
|
import org.x4o.xml.element.ElementException;
|
||||||
import org.x4o.xml.element.ElementNamespaceContext;
|
import org.x4o.xml.element.ElementNamespaceContext;
|
||||||
import org.x4o.xml.io.XMLConstants;
|
import org.x4o.xml.io.XMLConstants;
|
||||||
import org.x4o.xml.io.sax.ContentWriter;
|
import org.x4o.xml.io.sax.ext.ContentWriterXsd;
|
||||||
import org.x4o.xml.io.sax.ContentWriterXml;
|
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
import org.x4o.xml.lang.X4OLanguageModule;
|
import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
import org.x4o.xml.lang.X4OLanguage;
|
import org.x4o.xml.lang.X4OLanguage;
|
||||||
|
@ -71,8 +72,8 @@ public class EldXsdXmlGenerator {
|
||||||
throw new ElementException("Can't write schema to null output path.");
|
throw new ElementException("Can't write schema to null output path.");
|
||||||
}
|
}
|
||||||
if (encoding==null) { encoding = XMLConstants.XML_DEFAULT_ENCODING; }
|
if (encoding==null) { encoding = XMLConstants.XML_DEFAULT_ENCODING; }
|
||||||
if (charNew==null) { charNew = XMLConstants.CHAR_NEWLINE; }
|
if (charNew==null) { charNew = XMLConstants.CHAR_NEWLINE+""; }
|
||||||
if (charTab==null) { charTab = XMLConstants.CHAR_TAB; }
|
if (charTab==null) { charTab = XMLConstants.CHAR_TAB+""; }
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,24 +83,26 @@ public class EldXsdXmlGenerator {
|
||||||
throw new NullPointerException("Could not find namespace: "+namespace);
|
throw new NullPointerException("Could not find namespace: "+namespace);
|
||||||
}
|
}
|
||||||
checkNamespace(ns);
|
checkNamespace(ns);
|
||||||
FileOutputStream fio = new FileOutputStream(new File(basePath.getAbsolutePath()+File.separatorChar+ns.getSchemaResource()));
|
File outputFile = new File(basePath.getAbsolutePath()+File.separatorChar+ns.getSchemaResource());
|
||||||
|
Writer wr = new OutputStreamWriter(new FileOutputStream(outputFile), encoding);
|
||||||
try {
|
try {
|
||||||
ContentWriterXml out = new ContentWriterXml(fio,encoding,charNew,charTab);
|
ContentWriterXsd out = new ContentWriterXsd(wr,encoding,charNew,charTab);
|
||||||
generateSchema(ns.getUri(), out);
|
generateSchema(ns.getUri(), out);
|
||||||
} finally {
|
} finally {
|
||||||
fio.close();
|
wr.close();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
||||||
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
|
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
|
||||||
checkNamespace(ns);
|
checkNamespace(ns);
|
||||||
FileOutputStream fio = new FileOutputStream(new File(basePath.getAbsolutePath()+File.separatorChar+ns.getSchemaResource()));
|
File outputFile = new File(basePath.getAbsolutePath()+File.separatorChar+ns.getSchemaResource());
|
||||||
|
Writer wr = new OutputStreamWriter(new FileOutputStream(outputFile), encoding);
|
||||||
try {
|
try {
|
||||||
ContentWriterXml out = new ContentWriterXml(fio,encoding,charNew,charTab);
|
ContentWriterXsd out = new ContentWriterXsd(wr,encoding,charNew,charTab);
|
||||||
generateSchema(ns.getUri(), out);
|
generateSchema(ns.getUri(), out);
|
||||||
} finally {
|
} finally {
|
||||||
fio.close();
|
wr.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,7 +112,7 @@ public class EldXsdXmlGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateSchema(String namespaceUri,ContentWriter xmlWriter) throws SAXException {
|
public void generateSchema(String namespaceUri,ContentWriterXsd xmlWriter) throws SAXException {
|
||||||
|
|
||||||
ElementNamespaceContext ns = language.findElementNamespaceContext(namespaceUri);
|
ElementNamespaceContext ns = language.findElementNamespaceContext(namespaceUri);
|
||||||
if (ns==null) {
|
if (ns==null) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ import org.x4o.xml.element.ElementInterface;
|
||||||
import org.x4o.xml.element.ElementMetaBase;
|
import org.x4o.xml.element.ElementMetaBase;
|
||||||
import org.x4o.xml.element.ElementNamespaceContext;
|
import org.x4o.xml.element.ElementNamespaceContext;
|
||||||
import org.x4o.xml.io.XMLConstants;
|
import org.x4o.xml.io.XMLConstants;
|
||||||
import org.x4o.xml.io.sax.ContentWriter;
|
import org.x4o.xml.io.sax.ext.ContentWriterXsd;
|
||||||
import org.x4o.xml.lang.X4OLanguageModule;
|
import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
import org.x4o.xml.lang.X4OLanguage;
|
import org.x4o.xml.lang.X4OLanguage;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
@ -57,14 +57,14 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||||
public class EldXsdXmlWriter {
|
public class EldXsdXmlWriter {
|
||||||
|
|
||||||
|
|
||||||
static public final String SCHEMA_URI = "http://www.w3.org/2001/XMLSchema";
|
static public final String SCHEMA_URI = XMLConstants.XML_SCHEMA_NS_URI;
|
||||||
|
|
||||||
protected X4OLanguage language = null;
|
protected X4OLanguage language = null;
|
||||||
protected ContentWriter xmlWriter = null;
|
protected ContentWriterXsd xmlWriter = null;
|
||||||
protected String writeNamespace = null;
|
protected String writeNamespace = null;
|
||||||
protected Map<String, String> namespaces = null;
|
protected Map<String, String> namespaces = null;
|
||||||
|
|
||||||
public EldXsdXmlWriter(ContentWriter xmlWriter,X4OLanguage language) {
|
public EldXsdXmlWriter(ContentWriterXsd xmlWriter,X4OLanguage language) {
|
||||||
this.xmlWriter=xmlWriter;
|
this.xmlWriter=xmlWriter;
|
||||||
this.language=language;
|
this.language=language;
|
||||||
this.namespaces=new HashMap<String,String>(10);
|
this.namespaces=new HashMap<String,String>(10);
|
||||||
|
@ -150,9 +150,9 @@ public class EldXsdXmlWriter {
|
||||||
public void startSchema(ElementNamespaceContext ns) throws SAXException {
|
public void startSchema(ElementNamespaceContext ns) throws SAXException {
|
||||||
|
|
||||||
xmlWriter.startDocument();
|
xmlWriter.startDocument();
|
||||||
writeIgnorableWhitespace(XMLConstants.CHAR_NEWLINE);
|
xmlWriter.ignorableWhitespace(XMLConstants.CHAR_NEWLINE);
|
||||||
writeComment(COMMENT_SEPERATOR);
|
xmlWriter.comment(COMMENT_SEPERATOR);
|
||||||
writeIgnorableWhitespace(XMLConstants.CHAR_NEWLINE);
|
xmlWriter.ignorableWhitespace(XMLConstants.CHAR_NEWLINE);
|
||||||
|
|
||||||
// this is a mess;
|
// this is a mess;
|
||||||
String desc = "Automatic generated schema for language: "+language.getLanguageName();
|
String desc = "Automatic generated schema for language: "+language.getLanguageName();
|
||||||
|
@ -167,10 +167,10 @@ public class EldXsdXmlWriter {
|
||||||
}
|
}
|
||||||
b.append(COMMENT_TEXT);
|
b.append(COMMENT_TEXT);
|
||||||
b.append(" ");
|
b.append(" ");
|
||||||
writeComment(b.toString());
|
xmlWriter.comment(b.toString());
|
||||||
writeIgnorableWhitespace(XMLConstants.CHAR_NEWLINE);
|
xmlWriter.ignorableWhitespace(XMLConstants.CHAR_NEWLINE);
|
||||||
writeComment(COMMENT_SEPERATOR);
|
xmlWriter.comment(COMMENT_SEPERATOR);
|
||||||
writeIgnorableWhitespace(XMLConstants.CHAR_NEWLINE);
|
xmlWriter.ignorableWhitespace(XMLConstants.CHAR_NEWLINE);
|
||||||
|
|
||||||
X4OLanguageModule module = null;
|
X4OLanguageModule module = null;
|
||||||
for (X4OLanguageModule elm:language.getLanguageModules()) {
|
for (X4OLanguageModule elm:language.getLanguageModules()) {
|
||||||
|
@ -190,7 +190,7 @@ public class EldXsdXmlWriter {
|
||||||
b.append("\n\tUri schema:\t"); b.append(ns.getSchemaUri());
|
b.append("\n\tUri schema:\t"); b.append(ns.getSchemaUri());
|
||||||
b.append("\n\tCreated on:\t\t"); b.append(new Date());
|
b.append("\n\tCreated on:\t\t"); b.append(new Date());
|
||||||
b.append("\n");
|
b.append("\n");
|
||||||
writeComment(b.toString());
|
xmlWriter.comment(b.toString());
|
||||||
|
|
||||||
|
|
||||||
xmlWriter.startPrefixMapping("", SCHEMA_URI);
|
xmlWriter.startPrefixMapping("", SCHEMA_URI);
|
||||||
|
@ -222,7 +222,7 @@ public class EldXsdXmlWriter {
|
||||||
|
|
||||||
public void endSchema() throws SAXException {
|
public void endSchema() throws SAXException {
|
||||||
xmlWriter.endElement (SCHEMA_URI, "schema" , "");
|
xmlWriter.endElement (SCHEMA_URI, "schema" , "");
|
||||||
writeIgnorableWhitespace(XMLConstants.CHAR_NEWLINE);
|
xmlWriter.ignorableWhitespace(XMLConstants.CHAR_NEWLINE);
|
||||||
xmlWriter.endDocument();
|
xmlWriter.endDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ public class EldXsdXmlWriter {
|
||||||
|
|
||||||
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.
|
||||||
writeIgnorableWhitespace(" ");
|
xmlWriter.ignorableWhitespace(' ');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -447,32 +447,8 @@ public class EldXsdXmlWriter {
|
||||||
atts = new AttributesImpl();
|
atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "xml:lang", "", "", "en");
|
atts.addAttribute ("", "xml:lang", "", "", "en");
|
||||||
xmlWriter.startElement(SCHEMA_URI, "documentation", "", atts);
|
xmlWriter.startElement(SCHEMA_URI, "documentation", "", atts);
|
||||||
writeCharacters(base.getDescription());
|
xmlWriter.characters(base.getDescription());
|
||||||
xmlWriter.endElement(SCHEMA_URI, "documentation", "");
|
xmlWriter.endElement(SCHEMA_URI, "documentation", "");
|
||||||
xmlWriter.endElement(SCHEMA_URI, "annotation", "");
|
xmlWriter.endElement(SCHEMA_URI, "annotation", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeCharacters(String text) throws SAXException {
|
|
||||||
if (text==null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
char[] msg = text.toCharArray();
|
|
||||||
xmlWriter.characters(msg,0,msg.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void writeComment(String text) throws SAXException {
|
|
||||||
if (text==null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
char[] msg = text.toCharArray();
|
|
||||||
xmlWriter.comment(msg,0,msg.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void writeIgnorableWhitespace(String text) throws SAXException {
|
|
||||||
if (text==null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
char[] msg = text.toCharArray();
|
|
||||||
xmlWriter.ignorableWhitespace(msg,0,msg.length);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
* from the attibutes or parent (object)element.
|
* from the attibutes or parent (object)element.
|
||||||
*
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 01/02/2005
|
* @version 1.0 Feb 01, 2005
|
||||||
*/
|
*/
|
||||||
public interface Element {
|
public interface Element {
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,9 @@ import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
import org.x4o.xml.io.sax.ContentWriter;
|
|
||||||
import org.x4o.xml.io.sax.X4ODebugWriter;
|
import org.x4o.xml.io.sax.X4ODebugWriter;
|
||||||
import org.x4o.xml.io.sax.ContentWriterXml;
|
import org.x4o.xml.io.sax.ext.ContentWriter;
|
||||||
|
import org.x4o.xml.io.sax.ext.ContentWriterXml;
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
import org.x4o.xml.lang.X4OLanguageContextLocal;
|
import org.x4o.xml.lang.X4OLanguageContextLocal;
|
||||||
import org.x4o.xml.lang.X4OLanguageProperty;
|
import org.x4o.xml.lang.X4OLanguageProperty;
|
||||||
|
|
|
@ -139,12 +139,12 @@ public final class XMLConstants {
|
||||||
/**
|
/**
|
||||||
* Tab char
|
* Tab char
|
||||||
*/
|
*/
|
||||||
public static final String CHAR_TAB = "\t";
|
public static final char CHAR_TAB = '\t';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Newline char
|
* Newline char
|
||||||
*/
|
*/
|
||||||
public static final String CHAR_NEWLINE = "\n";
|
public static final char CHAR_NEWLINE = '\n';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -220,6 +220,16 @@ public final class XMLConstants {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public boolean isCharString(String value) {
|
||||||
|
for (int i=0;i<value.length();i++) {
|
||||||
|
char c = value.charAt(i);
|
||||||
|
if (isNameChar(c)==false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static public boolean isNameString(String value) {
|
static public boolean isNameString(String value) {
|
||||||
for (int i=0;i<value.length();i++) {
|
for (int i=0;i<value.length();i++) {
|
||||||
char c = value.charAt(i);
|
char c = value.charAt(i);
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.x4o.xml.element.Element.ElementType;
|
||||||
import org.x4o.xml.element.ElementException;
|
import org.x4o.xml.element.ElementException;
|
||||||
import org.x4o.xml.element.ElementNamespaceContext;
|
import org.x4o.xml.element.ElementNamespaceContext;
|
||||||
import org.x4o.xml.element.ElementNamespaceInstanceProvider;
|
import org.x4o.xml.element.ElementNamespaceInstanceProvider;
|
||||||
|
import org.x4o.xml.io.sax.ext.AttributeMap;
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
import org.x4o.xml.lang.X4OLanguageProperty;
|
import org.x4o.xml.lang.X4OLanguageProperty;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
|
@ -46,7 +47,7 @@ import java.util.logging.Logger;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Aug 20, 2005
|
* @version 1.0 Aug 20, 2005
|
||||||
*/
|
*/
|
||||||
public class X4OTagHandler extends DefaultHandler2 {
|
public class X4OContentHandler extends DefaultHandler2 {
|
||||||
|
|
||||||
/** The logger to log to */
|
/** The logger to log to */
|
||||||
private Logger logger = null;
|
private Logger logger = null;
|
||||||
|
@ -71,8 +72,8 @@ public class X4OTagHandler extends DefaultHandler2 {
|
||||||
* 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 X4OTagHandler(X4OLanguageContext elementLanguage) {
|
public X4OContentHandler(X4OLanguageContext elementLanguage) {
|
||||||
logger = Logger.getLogger(X4OTagHandler.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>();
|
||||||
this.elementLanguage = elementLanguage;
|
this.elementLanguage = elementLanguage;
|
|
@ -0,0 +1,147 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.io.sax;
|
||||||
|
|
||||||
|
import org.x4o.xml.element.ElementException;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageProperty;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
import org.xml.sax.XMLReader;
|
||||||
|
import org.xml.sax.helpers.XMLReaderFactory;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OContentParser Runs the SAX parser with the X4OContentHandler.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Aug 20, 2005
|
||||||
|
*/
|
||||||
|
public class X4OContentParser {
|
||||||
|
|
||||||
|
public void parse(X4OLanguageContext languageContext) throws SAXException, IOException {
|
||||||
|
|
||||||
|
// If xsd caching is needed this should be the way
|
||||||
|
//XMLParserConfiguration config = new XIncludeAwareParserConfiguration();
|
||||||
|
//config.setProperty("http://apache.org/xml/properties/internal/grammar-pool",myFullGrammarPool);
|
||||||
|
//SAXParser parser = new SAXParser(config);
|
||||||
|
|
||||||
|
// Create Sax parser with x4o tag handler
|
||||||
|
X4OContentHandler xth = new X4OContentHandler(languageContext);
|
||||||
|
XMLReader saxParser = XMLReaderFactory.createXMLReader();
|
||||||
|
saxParser.setErrorHandler(new X4OErrorHandler(languageContext));
|
||||||
|
saxParser.setEntityResolver(new X4OEntityResolver(languageContext));
|
||||||
|
saxParser.setContentHandler(xth);
|
||||||
|
saxParser.setProperty("http://xml.org/sax/properties/lexical-handler", xth);
|
||||||
|
saxParser.setProperty("http://xml.org/sax/properties/declaration-handler",xth);
|
||||||
|
|
||||||
|
// Set properties and optional
|
||||||
|
Map<String,Object> saxParserProperties = languageContext.getLanguage().getLanguageConfiguration().getSAXParserProperties(languageContext);
|
||||||
|
for (Map.Entry<String,Object> entry:saxParserProperties.entrySet()) {
|
||||||
|
String name = entry.getKey();
|
||||||
|
Object value= entry.getValue();
|
||||||
|
saxParser.setProperty(name, value);
|
||||||
|
debugMessage("Set SAX property: "+name+" to: "+value,languageContext);
|
||||||
|
}
|
||||||
|
Map<String,Object> saxParserPropertiesOptional = languageContext.getLanguage().getLanguageConfiguration().getSAXParserPropertiesOptional(languageContext);
|
||||||
|
for (Map.Entry<String,Object> entry:saxParserPropertiesOptional.entrySet()) {
|
||||||
|
String name = entry.getKey();
|
||||||
|
Object value= entry.getValue();
|
||||||
|
try {
|
||||||
|
saxParser.setProperty(name, value);
|
||||||
|
debugMessage("Set SAX optional property: "+name+" to: "+value,languageContext);
|
||||||
|
} catch (SAXException e) {
|
||||||
|
debugMessage("Could not set optional SAX property: "+name+" to: "+value+" error: "+e.getMessage(),languageContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set sax features and optional
|
||||||
|
Map<String, Boolean> features = languageContext.getLanguage().getLanguageConfiguration().getSAXParserFeatures(languageContext);
|
||||||
|
for (String key:features.keySet()) {
|
||||||
|
Boolean value=features.get(key);
|
||||||
|
saxParser.setFeature(key, value);
|
||||||
|
debugMessage("Set SAX feature: "+key+" to: "+value,languageContext);
|
||||||
|
}
|
||||||
|
Map<String, Boolean> featuresOptional = languageContext.getLanguage().getLanguageConfiguration().getSAXParserFeaturesOptional(languageContext);
|
||||||
|
for (String key:featuresOptional.keySet()) {
|
||||||
|
Boolean value=featuresOptional.get(key);
|
||||||
|
try {
|
||||||
|
saxParser.setFeature(key, value);
|
||||||
|
debugMessage("Set SAX optional feature: "+key+" to: "+value,languageContext);
|
||||||
|
} catch (SAXException e) {
|
||||||
|
debugMessage("Could not set optional SAX feature: "+key+" to: "+value+" error: "+e.getMessage(),languageContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for required features
|
||||||
|
List<String> requiredFeatures = languageContext.getLanguage().getLanguageConfiguration().getSAXParserFeaturesRequired(languageContext);
|
||||||
|
for (String requiredFeature:requiredFeatures) {
|
||||||
|
debugMessage("Checking required SAX feature: "+requiredFeature,languageContext);
|
||||||
|
if (saxParser.getFeature(requiredFeature)==false) {
|
||||||
|
throw new IllegalStateException("Missing required feature: "+requiredFeature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finally start parsing the xml input stream
|
||||||
|
Object requestInputSource = languageContext.getLanguageProperty(X4OLanguageProperty.READER_INPUT_SOURCE);
|
||||||
|
InputSource input = null;
|
||||||
|
InputStream inputStream = null;
|
||||||
|
if (requestInputSource instanceof InputSource) {
|
||||||
|
input = (InputSource)requestInputSource;
|
||||||
|
} else {
|
||||||
|
inputStream = (InputStream)languageContext.getLanguageProperty(X4OLanguageProperty.READER_INPUT_STREAM);
|
||||||
|
input = new InputSource(inputStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
Object requestInputEncoding = languageContext.getLanguageProperty(X4OLanguageProperty.READER_INPUT_ENCODING);
|
||||||
|
if (requestInputEncoding!=null && requestInputEncoding instanceof String) {
|
||||||
|
input.setEncoding(requestInputEncoding.toString());
|
||||||
|
}
|
||||||
|
Object requestSystemId = languageContext.getLanguageProperty(X4OLanguageProperty.READER_INPUT_SYSTEM_ID);
|
||||||
|
if (requestSystemId!=null && requestSystemId instanceof String) {
|
||||||
|
input.setSystemId(requestSystemId.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
saxParser.parse(input);
|
||||||
|
} finally {
|
||||||
|
if (inputStream!=null) {
|
||||||
|
inputStream.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void debugMessage(String message,X4OLanguageContext languageContext) throws SAXException {
|
||||||
|
if (languageContext.hasX4ODebugWriter()) {
|
||||||
|
try {
|
||||||
|
languageContext.getX4ODebugWriter().debugPhaseMessage(message, X4OContentParser.class);
|
||||||
|
} catch (ElementException ee) {
|
||||||
|
throw new SAXException(ee);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -40,6 +40,7 @@ import org.x4o.xml.element.ElementException;
|
||||||
import org.x4o.xml.element.ElementInterface;
|
import org.x4o.xml.element.ElementInterface;
|
||||||
import org.x4o.xml.element.ElementNamespaceContext;
|
import org.x4o.xml.element.ElementNamespaceContext;
|
||||||
import org.x4o.xml.element.ElementNamespaceInstanceProvider;
|
import org.x4o.xml.element.ElementNamespaceInstanceProvider;
|
||||||
|
import org.x4o.xml.io.sax.ext.ContentWriter;
|
||||||
import org.x4o.xml.lang.X4OLanguageModule;
|
import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
import org.x4o.xml.lang.X4OLanguageConfiguration;
|
import org.x4o.xml.lang.X4OLanguageConfiguration;
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.io.sax.ext;
|
||||||
|
|
||||||
|
import java.io.Writer;
|
||||||
|
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ContentWriterXml writes SAX content handler events to XML.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 3, 2013
|
||||||
|
*/
|
||||||
|
public abstract class AbstractContentWriter extends AbstractContentWriterLexical implements ContentWriter {
|
||||||
|
|
||||||
|
public AbstractContentWriter(Writer out, String encoding,String charNewLine, String charTab) {
|
||||||
|
super(out, encoding, charNewLine, charTab);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts and end then element.
|
||||||
|
* @see org.x4o.xml.io.sax.ext.ContentWriter#startElementEnd(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
|
||||||
|
*/
|
||||||
|
public void startElementEnd(String uri, String localName, String name,Attributes atts) throws SAXException {
|
||||||
|
startElement(uri,localName,name,atts);
|
||||||
|
endElement(uri, localName, name);
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,12 +20,9 @@
|
||||||
* 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.sax;
|
package org.x4o.xml.io.sax.ext;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -36,19 +33,20 @@ import java.util.Stack;
|
||||||
|
|
||||||
import org.x4o.xml.io.XMLConstants;
|
import org.x4o.xml.io.XMLConstants;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
|
import org.xml.sax.ContentHandler;
|
||||||
import org.xml.sax.Locator;
|
import org.xml.sax.Locator;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import org.xml.sax.helpers.AttributesImpl;
|
import org.xml.sax.helpers.AttributesImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ContentWriterXml writes SAX content handler events to XML.
|
* AbstractContentWriterHandler writes SAX content handler events as XML.
|
||||||
*
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Apr 17, 2005
|
* @version 1.0 May 3, 2013
|
||||||
*/
|
*/
|
||||||
public class ContentWriterXml implements ContentWriter {
|
public class AbstractContentWriterHandler implements ContentHandler {
|
||||||
|
|
||||||
public final Attributes EMPTY_ATTRIBUTES = new AttributesImpl();
|
protected final Attributes EMPTY_ATTRIBUTES = new AttributesImpl();
|
||||||
protected String encoding = null;
|
protected String encoding = null;
|
||||||
private String charNewline = null;
|
private String charNewline = null;
|
||||||
private String charTab = null;
|
private String charTab = null;
|
||||||
|
@ -59,14 +57,13 @@ public class ContentWriterXml implements ContentWriter {
|
||||||
private StringBuffer startElement = null;
|
private StringBuffer startElement = null;
|
||||||
private boolean printReturn = false;
|
private boolean printReturn = false;
|
||||||
private String lastElement = null;
|
private String lastElement = null;
|
||||||
private boolean printCDATA = false;
|
|
||||||
private Stack<String> elements = null;
|
private Stack<String> elements = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates XmlWriter which prints to the Writer interface.
|
* Creates XmlWriter which prints to the Writer interface.
|
||||||
* @param out The writer to print the xml to.
|
* @param out The writer to print the xml to.
|
||||||
*/
|
*/
|
||||||
public ContentWriterXml(Writer out,String encoding,String charNewLine,String charTab) {
|
public AbstractContentWriterHandler(Writer out,String encoding,String charNewLine,String charTab) {
|
||||||
if (out==null) {
|
if (out==null) {
|
||||||
throw new NullPointerException("Can't write on null writer.");
|
throw new NullPointerException("Can't write on null writer.");
|
||||||
}
|
}
|
||||||
|
@ -74,10 +71,10 @@ public class ContentWriterXml implements ContentWriter {
|
||||||
encoding = XMLConstants.XML_DEFAULT_ENCODING;
|
encoding = XMLConstants.XML_DEFAULT_ENCODING;
|
||||||
}
|
}
|
||||||
if (charNewLine==null) {
|
if (charNewLine==null) {
|
||||||
charNewLine = XMLConstants.CHAR_NEWLINE;
|
charNewLine = XMLConstants.CHAR_NEWLINE+"";
|
||||||
}
|
}
|
||||||
if (charTab==null) {
|
if (charTab==null) {
|
||||||
charTab = XMLConstants.CHAR_TAB;
|
charTab = XMLConstants.CHAR_TAB+"";
|
||||||
}
|
}
|
||||||
this.out = out;
|
this.out = out;
|
||||||
this.encoding = encoding;
|
this.encoding = encoding;
|
||||||
|
@ -88,52 +85,6 @@ public class ContentWriterXml implements ContentWriter {
|
||||||
elements = new Stack<String>();
|
elements = new Stack<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates XmlWriter which prints to the Writer interface.
|
|
||||||
* @param out The writer to print the xml to.
|
|
||||||
*/
|
|
||||||
public ContentWriterXml(Writer out,String encoding) {
|
|
||||||
this(out,encoding,null,null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates XmlWriter which prints to the OutputStream interface.
|
|
||||||
* @param out The OutputStream to write to.
|
|
||||||
* @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed.
|
|
||||||
*/
|
|
||||||
public ContentWriterXml(OutputStream out,String encoding) throws UnsupportedEncodingException {
|
|
||||||
this(new OutputStreamWriter(out, encoding),encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates XmlWriter which prints to the Writer interface.
|
|
||||||
* @param out The writer to print the xml to.
|
|
||||||
*/
|
|
||||||
public ContentWriterXml(Writer out) {
|
|
||||||
this(out,null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates XmlWriter which prints to the OutputStream interface.
|
|
||||||
* @param out The OutputStream to write to.
|
|
||||||
* @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed.
|
|
||||||
*/
|
|
||||||
public ContentWriterXml(OutputStream out) throws UnsupportedEncodingException {
|
|
||||||
this(new OutputStreamWriter(out, XMLConstants.XML_DEFAULT_ENCODING),XMLConstants.XML_DEFAULT_ENCODING);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates XmlWriter which prints to the OutputStream interface.
|
|
||||||
* @param out The OutputStream to write to.
|
|
||||||
* @param encoding The OutputStream encoding.
|
|
||||||
* @param charNewLine The newline char.
|
|
||||||
* @param charTab The tab char.
|
|
||||||
* @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed.
|
|
||||||
*/
|
|
||||||
public ContentWriterXml(OutputStream out,String encoding,String charNewLine,String charTab) throws UnsupportedEncodingException {
|
|
||||||
this(new OutputStreamWriter(out, encoding),encoding,charNewLine,charTab);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: check location of this. (add to api?)
|
// TODO: check location of this. (add to api?)
|
||||||
public void closeWriter() throws IOException {
|
public void closeWriter() throws IOException {
|
||||||
if (out==null) {
|
if (out==null) {
|
||||||
|
@ -168,15 +119,6 @@ public class ContentWriterXml implements ContentWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts and end then element.
|
|
||||||
* @see org.x4o.xml.io.sax.ContentWriter#startElementEnd(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
|
|
||||||
*/
|
|
||||||
public void startElementEnd(String uri, String localName, String name,Attributes atts) throws SAXException {
|
|
||||||
startElement(uri,localName,name,atts);
|
|
||||||
endElement(uri, localName, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param uri The xml namespace uri.
|
* @param uri The xml namespace uri.
|
||||||
* @param localName The local name of the xml tag.
|
* @param localName The local name of the xml tag.
|
||||||
|
@ -186,7 +128,7 @@ public class ContentWriterXml implements ContentWriter {
|
||||||
*/
|
*/
|
||||||
public void startElement(String uri, String localName, String name,Attributes atts) throws SAXException {
|
public void startElement(String uri, String localName, String name,Attributes atts) throws SAXException {
|
||||||
if (localName==null) {
|
if (localName==null) {
|
||||||
localName = "null"; // mmm rm ?
|
throw new SAXException("LocalName may not be null.");
|
||||||
}
|
}
|
||||||
if (XMLConstants.isNameString(localName)==false) {
|
if (XMLConstants.isNameString(localName)==false) {
|
||||||
throw new SAXException("LocalName of element is not valid in xml; '"+localName+"'");
|
throw new SAXException("LocalName of element is not valid in xml; '"+localName+"'");
|
||||||
|
@ -282,10 +224,15 @@ public class ContentWriterXml implements ContentWriter {
|
||||||
String attributeName = XMLConstants.escapeAttributeName(atts.getLocalName(i));
|
String attributeName = XMLConstants.escapeAttributeName(atts.getLocalName(i));
|
||||||
String attributeValue = atts.getValue(i);
|
String attributeValue = atts.getValue(i);
|
||||||
if (attributeValue==null) {
|
if (attributeValue==null) {
|
||||||
attributeValue = "null";
|
attributeValue = "null"; // TODO: Add null value key to config.
|
||||||
}
|
}
|
||||||
|
String attributeValueSafe = XMLConstants.escapeAttributeValue(attributeValue);
|
||||||
|
boolean printNewLine = attributeValueSafe.length()>80; // TODO add config
|
||||||
|
if (i==0) {
|
||||||
startElement.append(' ');
|
startElement.append(' ');
|
||||||
|
} else if (!printNewLine) {
|
||||||
|
startElement.append(' ');
|
||||||
|
}
|
||||||
if (XMLConstants.NULL_NS_URI.equals(attributeUri) | attributeUri ==null) {
|
if (XMLConstants.NULL_NS_URI.equals(attributeUri) | attributeUri ==null) {
|
||||||
startElement.append(attributeName);
|
startElement.append(attributeName);
|
||||||
} else {
|
} else {
|
||||||
|
@ -293,10 +240,15 @@ public class ContentWriterXml implements ContentWriter {
|
||||||
startElement.append(XMLConstants.XMLNS_ASSIGN);
|
startElement.append(XMLConstants.XMLNS_ASSIGN);
|
||||||
startElement.append(attributeName);
|
startElement.append(attributeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
startElement.append("=\"");
|
startElement.append("=\"");
|
||||||
startElement.append(XMLConstants.escapeAttributeValue(attributeValue));
|
startElement.append(attributeValueSafe);
|
||||||
startElement.append('"');
|
startElement.append('"');
|
||||||
|
if (printNewLine) {
|
||||||
|
startElement.append(XMLConstants.CHAR_NEWLINE);
|
||||||
|
for (int ii = 0; ii < indent+1; ii++) {
|
||||||
|
startElement.append(charTab);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,7 +334,7 @@ public class ContentWriterXml implements ContentWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints xml characters.
|
* Prints xml characters and uses characters(java.lang.String) method.
|
||||||
*
|
*
|
||||||
* @param ch Character buffer.
|
* @param ch Character buffer.
|
||||||
* @param start The start index of the chars in the ch buffer.
|
* @param start The start index of the chars in the ch buffer.
|
||||||
|
@ -395,20 +347,18 @@ public class ContentWriterXml implements ContentWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.io.sax.ContentWriter#characters(java.lang.String)
|
* Escape and prints xml characters.
|
||||||
|
* @see org.x4o.xml.io.sax.ext.ContentWriter#characters(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void characters(String text) throws SAXException {
|
public void characters(String text) throws SAXException {
|
||||||
if (text==null) {
|
if (text==null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
autoCloseStartElement();
|
charactersRaw(XMLConstants.escapeCharacters(text));
|
||||||
checkPrintedReturn(text);
|
|
||||||
if (printCDATA) {
|
|
||||||
text = XMLConstants.escapeCharactersCdata(text,"","");
|
|
||||||
} else {
|
|
||||||
text = XMLConstants.escapeCharacters(text);
|
|
||||||
}
|
}
|
||||||
write(text);
|
|
||||||
|
public void characters(char c) throws SAXException {
|
||||||
|
characters(new char[]{c},0,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// move or remove ?
|
// move or remove ?
|
||||||
|
@ -435,7 +385,7 @@ public class ContentWriterXml implements ContentWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.io.sax.ContentWriter#ignorableWhitespace(java.lang.String)
|
* @see org.x4o.xml.io.sax.ext.ContentWriter#ignorableWhitespace(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void ignorableWhitespace(String text) throws SAXException {
|
public void ignorableWhitespace(String text) throws SAXException {
|
||||||
if (text==null) {
|
if (text==null) {
|
||||||
|
@ -445,6 +395,10 @@ public class ContentWriterXml implements ContentWriter {
|
||||||
write(text); // TODO: check chars
|
write(text); // TODO: check chars
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ignorableWhitespace(char c) throws SAXException {
|
||||||
|
ignorableWhitespace(new char[]{c},0,1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints xml instructions.
|
* Prints xml instructions.
|
||||||
*
|
*
|
||||||
|
@ -453,14 +407,26 @@ public class ContentWriterXml implements ContentWriter {
|
||||||
* @param data The data.
|
* @param data The data.
|
||||||
*/
|
*/
|
||||||
public void processingInstruction(String target, String data) throws SAXException {
|
public void processingInstruction(String target, String data) throws SAXException {
|
||||||
|
String targetLow = target.toLowerCase();
|
||||||
|
if (targetLow.startsWith(XMLConstants.XML)) {
|
||||||
|
throw new SAXException("Processing instruction may not start with xml.");
|
||||||
|
}
|
||||||
|
if (XMLConstants.isNameString(target)==false) {
|
||||||
|
throw new SAXException("Processing instruction target is invalid name; '"+target+"'");
|
||||||
|
}
|
||||||
|
if (XMLConstants.isCharString(data)==false) {
|
||||||
|
throw new SAXException("Processing instruction data is invalid char; '"+data+"'");
|
||||||
|
}
|
||||||
|
autoCloseStartElement();
|
||||||
|
write(charNewline);
|
||||||
writeIndent();
|
writeIndent();
|
||||||
write(XMLConstants.PROCESS_START);
|
write(XMLConstants.PROCESS_START);
|
||||||
write(target);
|
write(target);
|
||||||
write(' ');
|
write(' ');
|
||||||
write(data);
|
write(data);
|
||||||
write(XMLConstants.PROCESS_END);
|
write(XMLConstants.PROCESS_END);
|
||||||
write(charNewline);
|
|
||||||
writeFlush();
|
writeFlush();
|
||||||
|
printReturn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -496,7 +462,7 @@ public class ContentWriterXml implements ContentWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.io.sax.ContentWriter#comment(java.lang.String)
|
* @see org.x4o.xml.io.sax.ext.ContentWriter#comment(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void comment(String text) throws SAXException {
|
public void comment(String text) throws SAXException {
|
||||||
if (text==null) {
|
if (text==null) {
|
||||||
|
@ -514,65 +480,8 @@ public class ContentWriterXml implements ContentWriter {
|
||||||
printReturn = true;
|
printReturn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.xml.sax.ext.LexicalHandler#startCDATA()
|
|
||||||
*/
|
|
||||||
public void startCDATA() throws SAXException {
|
|
||||||
autoCloseStartElement();
|
|
||||||
write(XMLConstants.CDATA_START);
|
|
||||||
printCDATA = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.xml.sax.ext.LexicalHandler#endCDATA()
|
|
||||||
*/
|
|
||||||
public void endCDATA() throws SAXException {
|
|
||||||
write(XMLConstants.CDATA_END);
|
|
||||||
printCDATA = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String, java.lang.String, java.lang.String)
|
|
||||||
*/
|
|
||||||
public void startDTD(String name, String publicId, String systemId) throws SAXException {
|
|
||||||
write(XMLConstants.XML_DOCTYPE);
|
|
||||||
write(" ");
|
|
||||||
write(name);
|
|
||||||
if (publicId!=null) {
|
|
||||||
write(" ");
|
|
||||||
write(publicId);
|
|
||||||
}
|
|
||||||
if (systemId!=null) {
|
|
||||||
write(" \"");
|
|
||||||
write(systemId);
|
|
||||||
write("\"");
|
|
||||||
}
|
|
||||||
write(XMLConstants.TAG_CLOSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.xml.sax.ext.LexicalHandler#endDTD()
|
|
||||||
*/
|
|
||||||
public void endDTD() throws SAXException {
|
|
||||||
writeFlush();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.xml.sax.ext.LexicalHandler#startEntity(java.lang.String)
|
|
||||||
*/
|
|
||||||
public void startEntity(String arg0) throws SAXException {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.xml.sax.ext.LexicalHandler#endEntity(java.lang.String)
|
|
||||||
*/
|
|
||||||
public void endEntity(String arg0) throws SAXException {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void checkPrintedReturn(String value) {
|
private void checkPrintedReturn(String value) {
|
||||||
if (value.indexOf('\n')>0) {
|
if (value.indexOf(XMLConstants.CHAR_NEWLINE)>0) {
|
||||||
printReturn = true;
|
printReturn = true;
|
||||||
} else {
|
} else {
|
||||||
printReturn = false;
|
printReturn = false;
|
||||||
|
@ -583,7 +492,7 @@ public class ContentWriterXml implements ContentWriter {
|
||||||
* Auto close the start element if working in printing event.
|
* Auto close the start element if working in printing event.
|
||||||
* @throws IOException When prints gives exception.
|
* @throws IOException When prints gives exception.
|
||||||
*/
|
*/
|
||||||
private void autoCloseStartElement() throws SAXException {
|
protected void autoCloseStartElement() throws SAXException {
|
||||||
if (startElement==null) {
|
if (startElement==null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -601,7 +510,7 @@ public class ContentWriterXml implements ContentWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeFlush() throws SAXException {
|
protected void writeFlush() throws SAXException {
|
||||||
try {
|
try {
|
||||||
out.flush();
|
out.flush();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
|
@ -0,0 +1,123 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.io.sax.ext;
|
||||||
|
|
||||||
|
import java.io.Writer;
|
||||||
|
|
||||||
|
import org.x4o.xml.io.XMLConstants;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
import org.xml.sax.ext.LexicalHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ContentWriterXml writes SAX content handler events to XML.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 3, 2013
|
||||||
|
*/
|
||||||
|
public abstract class AbstractContentWriterLexical extends AbstractContentWriterHandler implements LexicalHandler {
|
||||||
|
|
||||||
|
protected boolean printCDATA = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates XmlWriter which prints to the Writer interface.
|
||||||
|
* @param out The writer to print the xml to.
|
||||||
|
*/
|
||||||
|
public AbstractContentWriterLexical(Writer out,String encoding,String charNewLine,String charTab) {
|
||||||
|
super(out, encoding, charNewLine, charTab);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.xml.sax.ext.LexicalHandler#startCDATA()
|
||||||
|
*/
|
||||||
|
public void startCDATA() throws SAXException {
|
||||||
|
autoCloseStartElement();
|
||||||
|
charactersRaw(XMLConstants.CDATA_START);
|
||||||
|
printCDATA = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.xml.sax.ext.LexicalHandler#endCDATA()
|
||||||
|
*/
|
||||||
|
public void endCDATA() throws SAXException {
|
||||||
|
charactersRaw(XMLConstants.CDATA_END);
|
||||||
|
printCDATA = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String, java.lang.String, java.lang.String)
|
||||||
|
*/
|
||||||
|
public void startDTD(String name, String publicId, String systemId) throws SAXException {
|
||||||
|
charactersRaw(XMLConstants.XML_DOCTYPE);
|
||||||
|
charactersRaw(" ");
|
||||||
|
charactersRaw(name);
|
||||||
|
if (publicId!=null) {
|
||||||
|
charactersRaw(" ");
|
||||||
|
charactersRaw(publicId);
|
||||||
|
}
|
||||||
|
if (systemId!=null) {
|
||||||
|
charactersRaw(" \"");
|
||||||
|
charactersRaw(systemId);
|
||||||
|
charactersRaw("\"");
|
||||||
|
}
|
||||||
|
charactersRaw(XMLConstants.TAG_CLOSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.xml.sax.ext.LexicalHandler#endDTD()
|
||||||
|
*/
|
||||||
|
public void endDTD() throws SAXException {
|
||||||
|
writeFlush();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.xml.sax.ext.LexicalHandler#startEntity(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void startEntity(String arg0) throws SAXException {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.xml.sax.ext.LexicalHandler#endEntity(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void endEntity(String arg0) throws SAXException {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.x4o.xml.io.sax.ext.AbstractContentWriterHandler#characters(char[], int, int)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void characters(char[] ch, int start, int length) throws SAXException {
|
||||||
|
characters(new String(ch, start, length));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.x4o.xml.io.sax.ext.AbstractContentWriterHandler#characters(java.lang.String)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void characters(String text) throws SAXException {
|
||||||
|
if (printCDATA) {
|
||||||
|
charactersRaw(XMLConstants.escapeCharactersCdata(text,"",""));
|
||||||
|
} else {
|
||||||
|
super.characters(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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.sax;
|
package org.x4o.xml.io.sax.ext;
|
||||||
|
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
|
@ -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.sax;
|
package org.x4o.xml.io.sax.ext;
|
||||||
|
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
import org.xml.sax.ContentHandler;
|
import org.xml.sax.ContentHandler;
|
||||||
|
@ -50,5 +50,9 @@ public interface ContentWriter extends ContentHandler,LexicalHandler {
|
||||||
|
|
||||||
void ignorableWhitespace(String text) throws SAXException;
|
void ignorableWhitespace(String text) throws SAXException;
|
||||||
|
|
||||||
|
void ignorableWhitespace(char c) throws SAXException;
|
||||||
|
|
||||||
void characters(String text) throws SAXException;
|
void characters(String text) throws SAXException;
|
||||||
|
|
||||||
|
void characters(char c) throws SAXException;
|
||||||
}
|
}
|
|
@ -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.sax;
|
package org.x4o.xml.io.sax.ext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ContentWriterConfig Defines config options for ContentWriter.
|
* ContentWriterConfig Defines config options for ContentWriter.
|
|
@ -20,12 +20,11 @@
|
||||||
* 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.sax;
|
package org.x4o.xml.io.sax.ext;
|
||||||
|
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
import org.xml.sax.Attributes;
|
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import org.xml.sax.helpers.AttributesImpl;
|
import org.xml.sax.helpers.AttributesImpl;
|
||||||
|
|
||||||
|
@ -35,7 +34,7 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Apr 30, 2013
|
* @version 1.0 Apr 30, 2013
|
||||||
*/
|
*/
|
||||||
public class ContentWriterHtml extends ContentWriterXml {
|
public class ContentWriterHtml extends ContentWriterXmlTag<ContentWriterHtml.Tag> {
|
||||||
|
|
||||||
public ContentWriterHtml(Writer out,String encoding,String charNewLine,String charTab) {
|
public ContentWriterHtml(Writer out,String encoding,String charNewLine,String charTab) {
|
||||||
super(out,encoding,charNewLine,charTab);
|
super(out,encoding,charNewLine,charTab);
|
||||||
|
@ -63,7 +62,7 @@ public class ContentWriterHtml extends ContentWriterXml {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printHeadTitle(String title) throws SAXException {
|
public void printHeadTitle(String title) throws SAXException {
|
||||||
printTagText("title",title);
|
printTagCharacters(Tag.title,title);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printHeadMetaContentType() throws SAXException {
|
public void printHeadMetaContentType() throws SAXException {
|
||||||
|
@ -157,23 +156,12 @@ public class ContentWriterHtml extends ContentWriterXml {
|
||||||
printTagEnd(Tag.a);
|
printTagEnd(Tag.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void printTagCharacters(Tag tag,String text,String tagClass) throws SAXException {
|
||||||
private void printTagText(String tag,String text) throws SAXException {
|
printTagCharacters(tag,text,tagClass,null);
|
||||||
startElement ("", tag, "", EMPTY_ATTRIBUTES);
|
|
||||||
characters(text);
|
|
||||||
endElement ("",tag , "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printTagText(Tag tag,String text) throws SAXException {
|
public void printTagCharacters(Tag tag,String text,String tagClass,String tagId) throws SAXException {
|
||||||
printTagText(tag,text,null);
|
printTagStart(tag,tagClass,tagId,null);
|
||||||
}
|
|
||||||
|
|
||||||
public void printTagText(Tag tag,String text,String tagClass) throws SAXException {
|
|
||||||
printTagText(tag,text,tagClass,null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void printTagText(Tag tag,String text,String tagClass,String tagId) throws SAXException {
|
|
||||||
printTagStart(tag,tagClass,tagId);
|
|
||||||
if (text==null) {
|
if (text==null) {
|
||||||
text = " ";
|
text = " ";
|
||||||
}
|
}
|
||||||
|
@ -181,21 +169,21 @@ public class ContentWriterHtml extends ContentWriterXml {
|
||||||
printTagEnd(tag);
|
printTagEnd(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printTagStartEnd(Tag tag) throws SAXException {
|
|
||||||
printTagStart(tag,null,null);
|
|
||||||
printTagEnd(tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void printTagStart(Tag tag) throws SAXException {
|
|
||||||
printTagStart(tag,null,null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void printTagStart(Tag tag,String tagClass) throws SAXException {
|
public void printTagStart(Tag tag,String tagClass) throws SAXException {
|
||||||
printTagStart(tag,tagClass,null);
|
printTagStart(tag,tagClass,null,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printTagStart(Tag tag,String tagClass,String tagId) throws SAXException {
|
public void printTagStart(Tag tag,Enum<?> tagClassEnum) throws SAXException {
|
||||||
printTagStart(tag,tagClass,tagId,null);
|
printTagStart(tag,tagClassEnum,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void printTagStart(Tag tag,Enum<?> tagClassEnum,String tagId) throws SAXException {
|
||||||
|
printTagStart(tag,tagClassEnum,tagId,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void printTagStart(Tag tag,Enum<?> tagClassEnum,String tagId,String typeId) throws SAXException {
|
||||||
|
printTagStart(tag,tagClassEnum.name(),tagId,typeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printTagStart(Tag tag,String tagClass,String tagId,String typeId) throws SAXException {
|
public void printTagStart(Tag tag,String tagClass,String tagId,String typeId) throws SAXException {
|
||||||
|
@ -212,14 +200,6 @@ public class ContentWriterHtml extends ContentWriterXml {
|
||||||
printTagStart(tag,atts);
|
printTagStart(tag,atts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printTagStart(Tag tag,Attributes atts) throws SAXException {
|
|
||||||
startElement ("", tag.name(), "", atts);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void printTagEnd(Tag tag) throws SAXException {
|
|
||||||
endElement ("",tag.name() , "");
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Tag {
|
public enum Tag {
|
||||||
|
|
||||||
/* Deprecated TAGS */
|
/* Deprecated TAGS */
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.io.sax.ext;
|
||||||
|
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ContentWriterTag writes enum tags as xml.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 3, 2013
|
||||||
|
*/
|
||||||
|
public interface ContentWriterTag<T extends Enum<?>> extends ContentWriter {
|
||||||
|
|
||||||
|
String getTagNamespaceUri();
|
||||||
|
|
||||||
|
void printTagStartEnd(T tag) throws SAXException;
|
||||||
|
|
||||||
|
void printTagStartEnd(T tag,Attributes atts) throws SAXException;
|
||||||
|
|
||||||
|
void printTagStart(T tag) throws SAXException;
|
||||||
|
|
||||||
|
void printTagStart(T tag,Attributes atts) throws SAXException;
|
||||||
|
|
||||||
|
void printTagEnd(T tag) throws SAXException;
|
||||||
|
|
||||||
|
void printTagCharacters(T tag,String text) throws SAXException;
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.io.sax.ext;
|
||||||
|
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.io.Writer;
|
||||||
|
|
||||||
|
import org.x4o.xml.io.XMLConstants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ContentWriterXml writes SAX content handler events to XML.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Apr 17, 2005
|
||||||
|
*/
|
||||||
|
public class ContentWriterXml extends AbstractContentWriter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates XmlWriter which prints to the Writer interface.
|
||||||
|
* @param out The writer to print the xml to.
|
||||||
|
*/
|
||||||
|
public ContentWriterXml(Writer out,String encoding,String charNewLine,String charTab) {
|
||||||
|
super(out, encoding, charNewLine, charTab);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates XmlWriter which prints to the Writer interface.
|
||||||
|
* @param out The writer to print the xml to.
|
||||||
|
*/
|
||||||
|
public ContentWriterXml(Writer out,String encoding) {
|
||||||
|
this(out,encoding,null,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates XmlWriter which prints to the OutputStream interface.
|
||||||
|
* @param out The OutputStream to write to.
|
||||||
|
* @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed.
|
||||||
|
*/
|
||||||
|
public ContentWriterXml(OutputStream out,String encoding) throws UnsupportedEncodingException {
|
||||||
|
this(new OutputStreamWriter(out, encoding),encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates XmlWriter which prints to the Writer interface.
|
||||||
|
* @param out The writer to print the xml to.
|
||||||
|
*/
|
||||||
|
public ContentWriterXml(Writer out) {
|
||||||
|
this(out,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates XmlWriter which prints to the OutputStream interface.
|
||||||
|
* @param out The OutputStream to write to.
|
||||||
|
* @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed.
|
||||||
|
*/
|
||||||
|
public ContentWriterXml(OutputStream out) throws UnsupportedEncodingException {
|
||||||
|
this(new OutputStreamWriter(out, XMLConstants.XML_DEFAULT_ENCODING),XMLConstants.XML_DEFAULT_ENCODING);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates XmlWriter which prints to the OutputStream interface.
|
||||||
|
* @param out The OutputStream to write to.
|
||||||
|
* @param encoding The OutputStream encoding.
|
||||||
|
* @param charNewLine The newline char.
|
||||||
|
* @param charTab The tab char.
|
||||||
|
* @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed.
|
||||||
|
*/
|
||||||
|
public ContentWriterXml(OutputStream out,String encoding,String charNewLine,String charTab) throws UnsupportedEncodingException {
|
||||||
|
this(new OutputStreamWriter(out, encoding),encoding,charNewLine,charTab);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.io.sax.ext;
|
||||||
|
|
||||||
|
import java.io.Writer;
|
||||||
|
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ContentWriterXml writes SAX content handler events to XML.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 3, 2013
|
||||||
|
*/
|
||||||
|
public class ContentWriterXmlTag<T extends Enum<?>> extends ContentWriterXml implements ContentWriterTag<T> {
|
||||||
|
|
||||||
|
public ContentWriterXmlTag(Writer out,String encoding,String charNewLine,String charTab) {
|
||||||
|
super(out, encoding, charNewLine, charTab);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTagNamespaceUri() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void printTagStartEnd(T tag,Attributes atts) throws SAXException {
|
||||||
|
printTagStart(tag,atts);
|
||||||
|
printTagEnd(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void printTagStartEnd(T tag) throws SAXException {
|
||||||
|
printTagStart(tag);
|
||||||
|
printTagEnd(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void printTagStart(T tag) throws SAXException {
|
||||||
|
printTagStart(tag,EMPTY_ATTRIBUTES);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void printTagStart(T tag,Attributes atts) throws SAXException {
|
||||||
|
startElement (getTagNamespaceUri(), tag.name(), "", atts);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void printTagEnd(T tag) throws SAXException {
|
||||||
|
endElement (getTagNamespaceUri(),tag.name() , "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void printTagCharacters(T tag,String text) throws SAXException {
|
||||||
|
printTagStart(tag);
|
||||||
|
if (text==null) {
|
||||||
|
text = " ";
|
||||||
|
}
|
||||||
|
characters(text);
|
||||||
|
printTagEnd(tag);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.io.sax.ext;
|
||||||
|
|
||||||
|
import java.io.Writer;
|
||||||
|
|
||||||
|
import org.x4o.xml.io.XMLConstants;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
import org.xml.sax.helpers.AttributesImpl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ContentWriterXsd writes XSD events as SAX events to XML.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 3, 2013
|
||||||
|
*/
|
||||||
|
public class ContentWriterXsd extends ContentWriterXmlTag<ContentWriterXsd.Tag> {
|
||||||
|
|
||||||
|
public ContentWriterXsd(Writer out,String encoding,String charNewLine,String charTab) {
|
||||||
|
super(out,encoding,charNewLine,charTab);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTagNamespaceUri() {
|
||||||
|
return XMLConstants.XML_SCHEMA_NS_URI;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void printXsdImport(String namespace,String schemaLocation) throws SAXException {
|
||||||
|
AttributesImpl atts = new AttributesImpl();
|
||||||
|
atts.addAttribute ("", "namespace", "", "", namespace);
|
||||||
|
atts.addAttribute ("", "schemaLocation", "", "", schemaLocation);
|
||||||
|
startElement (getTagNamespaceUri(), "import", "", atts);
|
||||||
|
endElement (getTagNamespaceUri(), "import", ""); // import is keyword
|
||||||
|
}
|
||||||
|
|
||||||
|
public void printXsdDocumentation(String description) throws SAXException {
|
||||||
|
if (description==null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
printTagStart(Tag.annotation);
|
||||||
|
AttributesImpl atts = new AttributesImpl();
|
||||||
|
atts.addAttribute ("", "xml:lang", "", "", "en");
|
||||||
|
printTagStart(Tag.documentation,atts);
|
||||||
|
characters(description);
|
||||||
|
printTagEnd(Tag.documentation);
|
||||||
|
printTagEnd(Tag.annotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void printXsdElementAttribute(String name,String type,String description) throws SAXException {
|
||||||
|
AttributesImpl atts = new AttributesImpl();
|
||||||
|
atts.addAttribute ("", "name", "", "", name);
|
||||||
|
atts.addAttribute ("", "type", "", "", type);
|
||||||
|
printTagStart(Tag.attribute,atts);
|
||||||
|
printXsdDocumentation(description);
|
||||||
|
printTagEnd(Tag.attribute);
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Tag {
|
||||||
|
all,annotation,any,anyAttribute,appinfo,attribute,attributeGroup,
|
||||||
|
choise,complexContent,complexType,documentation,element,extension,
|
||||||
|
field,group,/*_import,*/include,key,keyref,list,notation,
|
||||||
|
redefine,restriction,schema,selector,sequence,
|
||||||
|
simpleContent,simpleType,unoin,unique
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -22,7 +22,6 @@
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.lang.phase;
|
package org.x4o.xml.lang.phase;
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
@ -45,21 +44,16 @@ import org.x4o.xml.element.ElementConfiguratorGlobal;
|
||||||
import org.x4o.xml.element.ElementException;
|
import org.x4o.xml.element.ElementException;
|
||||||
import org.x4o.xml.element.ElementInterface;
|
import org.x4o.xml.element.ElementInterface;
|
||||||
import org.x4o.xml.element.ElementNamespaceContext;
|
import org.x4o.xml.element.ElementNamespaceContext;
|
||||||
import org.x4o.xml.io.sax.ContentWriter;
|
import org.x4o.xml.io.sax.X4OContentParser;
|
||||||
import org.x4o.xml.io.sax.X4ODebugWriter;
|
import org.x4o.xml.io.sax.X4ODebugWriter;
|
||||||
import org.x4o.xml.io.sax.X4OEntityResolver;
|
import org.x4o.xml.io.sax.ext.ContentWriter;
|
||||||
import org.x4o.xml.io.sax.X4OErrorHandler;
|
|
||||||
import org.x4o.xml.io.sax.X4OTagHandler;
|
|
||||||
import org.x4o.xml.lang.X4OLanguageModule;
|
import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
import org.x4o.xml.lang.X4OLanguageClassLoader;
|
import org.x4o.xml.lang.X4OLanguageClassLoader;
|
||||||
import org.x4o.xml.lang.X4OLanguageProperty;
|
import org.x4o.xml.lang.X4OLanguageProperty;
|
||||||
|
|
||||||
import org.xml.sax.InputSource;
|
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import org.xml.sax.XMLReader;
|
|
||||||
import org.xml.sax.helpers.AttributesImpl;
|
import org.xml.sax.helpers.AttributesImpl;
|
||||||
import org.xml.sax.helpers.XMLReaderFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory which can create X4OPhaseHandlers for all the predefined phases used in default x4o language parsing.
|
* Factory which can create X4OPhaseHandlers for all the predefined phases used in default x4o language parsing.
|
||||||
|
@ -144,8 +138,6 @@ public class X4OPhaseLanguageRead {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the startX4OPhase which is a empty meta phase.
|
* Creates the startX4OPhase which is a empty meta phase.
|
||||||
*/
|
*/
|
||||||
|
@ -198,94 +190,8 @@ public class X4OPhaseLanguageRead {
|
||||||
}
|
}
|
||||||
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException {
|
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException {
|
||||||
try {
|
try {
|
||||||
//XMLParserConfiguration config = new XIncludeAwareParserConfiguration();
|
X4OContentParser parser = new X4OContentParser();
|
||||||
//config.setProperty("http://apache.org/xml/properties/internal/grammar-pool",myFullGrammarPool);
|
parser.parse(languageContext);
|
||||||
//SAXParser parser = new SAXParser(config);
|
|
||||||
|
|
||||||
// Create Sax parser with x4o tag handler
|
|
||||||
X4OTagHandler xth = new X4OTagHandler(languageContext);
|
|
||||||
XMLReader saxParser = XMLReaderFactory.createXMLReader();
|
|
||||||
saxParser.setErrorHandler(new X4OErrorHandler(languageContext));
|
|
||||||
saxParser.setEntityResolver(new X4OEntityResolver(languageContext));
|
|
||||||
saxParser.setContentHandler(xth);
|
|
||||||
saxParser.setProperty("http://xml.org/sax/properties/lexical-handler", xth);
|
|
||||||
saxParser.setProperty("http://xml.org/sax/properties/declaration-handler",xth);
|
|
||||||
|
|
||||||
// Set properties and optional
|
|
||||||
Map<String,Object> saxParserProperties = languageContext.getLanguage().getLanguageConfiguration().getSAXParserProperties(languageContext);
|
|
||||||
for (Map.Entry<String,Object> entry:saxParserProperties.entrySet()) {
|
|
||||||
String name = entry.getKey();
|
|
||||||
Object value= entry.getValue();
|
|
||||||
saxParser.setProperty(name, value);
|
|
||||||
debugPhaseMessage("Set SAX property: "+name+" to: "+value,this,languageContext);
|
|
||||||
}
|
|
||||||
Map<String,Object> saxParserPropertiesOptional = languageContext.getLanguage().getLanguageConfiguration().getSAXParserPropertiesOptional(languageContext);
|
|
||||||
for (Map.Entry<String,Object> entry:saxParserPropertiesOptional.entrySet()) {
|
|
||||||
String name = entry.getKey();
|
|
||||||
Object value= entry.getValue();
|
|
||||||
try {
|
|
||||||
saxParser.setProperty(name, value);
|
|
||||||
debugPhaseMessage("Set SAX optional property: "+name+" to: "+value,this,languageContext);
|
|
||||||
} catch (SAXException e) {
|
|
||||||
debugPhaseMessage("Could not set optional SAX property: "+name+" to: "+value+" error: "+e.getMessage(),this,languageContext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set sax features and optional
|
|
||||||
Map<String, Boolean> features = languageContext.getLanguage().getLanguageConfiguration().getSAXParserFeatures(languageContext);
|
|
||||||
for (String key:features.keySet()) {
|
|
||||||
Boolean value=features.get(key);
|
|
||||||
saxParser.setFeature(key, value);
|
|
||||||
debugPhaseMessage("Set SAX feature: "+key+" to: "+value,this,languageContext);
|
|
||||||
}
|
|
||||||
Map<String, Boolean> featuresOptional = languageContext.getLanguage().getLanguageConfiguration().getSAXParserFeaturesOptional(languageContext);
|
|
||||||
for (String key:featuresOptional.keySet()) {
|
|
||||||
Boolean value=featuresOptional.get(key);
|
|
||||||
try {
|
|
||||||
saxParser.setFeature(key, value);
|
|
||||||
debugPhaseMessage("Set SAX optional feature: "+key+" to: "+value,this,languageContext);
|
|
||||||
} catch (SAXException e) {
|
|
||||||
debugPhaseMessage("Could not set optional SAX feature: "+key+" to: "+value+" error: "+e.getMessage(),this,languageContext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// check for required features
|
|
||||||
List<String> requiredFeatures = languageContext.getLanguage().getLanguageConfiguration().getSAXParserFeaturesRequired(languageContext);
|
|
||||||
for (String requiredFeature:requiredFeatures) {
|
|
||||||
debugPhaseMessage("Checking required SAX feature: "+requiredFeature,this,languageContext);
|
|
||||||
if (saxParser.getFeature(requiredFeature)==false) {
|
|
||||||
Exception e = new IllegalStateException("Missing required feature: "+requiredFeature);
|
|
||||||
throw new X4OPhaseException(this,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally start parsing the xml input stream
|
|
||||||
Object requestInputSource = languageContext.getLanguageProperty(X4OLanguageProperty.READER_INPUT_SOURCE);
|
|
||||||
InputSource input = null;
|
|
||||||
InputStream inputStream = null;
|
|
||||||
if (requestInputSource instanceof InputSource) {
|
|
||||||
input = (InputSource)requestInputSource;
|
|
||||||
} else {
|
|
||||||
inputStream = (InputStream)languageContext.getLanguageProperty(X4OLanguageProperty.READER_INPUT_STREAM);
|
|
||||||
input = new InputSource(inputStream);
|
|
||||||
}
|
|
||||||
|
|
||||||
Object requestInputEncoding = languageContext.getLanguageProperty(X4OLanguageProperty.READER_INPUT_ENCODING);
|
|
||||||
if (requestInputEncoding!=null && requestInputEncoding instanceof String) {
|
|
||||||
input.setEncoding(requestInputEncoding.toString());
|
|
||||||
}
|
|
||||||
Object requestSystemId = languageContext.getLanguageProperty(X4OLanguageProperty.READER_INPUT_SYSTEM_ID);
|
|
||||||
if (requestSystemId!=null && requestSystemId instanceof String) {
|
|
||||||
input.setSystemId(requestSystemId.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
saxParser.parse(input);
|
|
||||||
} finally {
|
|
||||||
if (inputStream!=null) {
|
|
||||||
inputStream.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new X4OPhaseException(this,e);
|
throw new X4OPhaseException(this,e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@ import java.io.OutputStream;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -42,7 +44,7 @@ import org.x4o.xml.element.ElementNamespaceContext;
|
||||||
import org.x4o.xml.element.ElementNamespaceInstanceProviderException;
|
import org.x4o.xml.element.ElementNamespaceInstanceProviderException;
|
||||||
import org.x4o.xml.element.ElementObjectPropertyValueException;
|
import org.x4o.xml.element.ElementObjectPropertyValueException;
|
||||||
import org.x4o.xml.io.XMLConstants;
|
import org.x4o.xml.io.XMLConstants;
|
||||||
import org.x4o.xml.io.sax.ContentWriterXml;
|
import org.x4o.xml.io.sax.ext.ContentWriterXml;
|
||||||
import org.x4o.xml.lang.X4OLanguageModule;
|
import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
import org.x4o.xml.lang.X4OLanguageProperty;
|
import org.x4o.xml.lang.X4OLanguageProperty;
|
||||||
|
@ -189,8 +191,11 @@ public class X4OPhaseLanguageWrite {
|
||||||
}
|
}
|
||||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||||
}
|
}
|
||||||
boolean schemaUriPrint;
|
|
||||||
String schemaUriRoot;
|
private AttributeEntryComparator attributeEntryComparator = new AttributeEntryComparator();
|
||||||
|
private boolean schemaUriPrint;
|
||||||
|
private String schemaUriRoot;
|
||||||
|
|
||||||
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException {
|
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException {
|
||||||
OutputStream out = (OutputStream)languageContext.getLanguageProperty(X4OLanguageProperty.WRITER_OUTPUT_STREAM);
|
OutputStream out = (OutputStream)languageContext.getLanguageProperty(X4OLanguageProperty.WRITER_OUTPUT_STREAM);
|
||||||
try {
|
try {
|
||||||
|
@ -200,8 +205,8 @@ public class X4OPhaseLanguageWrite {
|
||||||
schemaUriPrint = languageContext.getLanguagePropertyBoolean(X4OLanguageProperty.WRITER_SCHEMA_URI_PRINT);
|
schemaUriPrint = languageContext.getLanguagePropertyBoolean(X4OLanguageProperty.WRITER_SCHEMA_URI_PRINT);
|
||||||
schemaUriRoot = languageContext.getLanguagePropertyString(X4OLanguageProperty.WRITER_SCHEMA_URI_ROOT);
|
schemaUriRoot = languageContext.getLanguagePropertyString(X4OLanguageProperty.WRITER_SCHEMA_URI_ROOT);
|
||||||
if (encoding==null) { encoding = XMLConstants.XML_DEFAULT_ENCODING; }
|
if (encoding==null) { encoding = XMLConstants.XML_DEFAULT_ENCODING; }
|
||||||
if (charNew==null) { charNew = XMLConstants.CHAR_NEWLINE; }
|
if (charNew==null) { charNew = XMLConstants.CHAR_NEWLINE+""; }
|
||||||
if (charTab==null) { charTab = XMLConstants.CHAR_TAB; }
|
if (charTab==null) { charTab = XMLConstants.CHAR_TAB+""; }
|
||||||
|
|
||||||
Element root = languageContext.getRootElement();
|
Element root = languageContext.getRootElement();
|
||||||
if (schemaUriRoot==null) {
|
if (schemaUriRoot==null) {
|
||||||
|
@ -272,15 +277,18 @@ public class X4OPhaseLanguageWrite {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
class AttributeEntry {
|
||||||
private void writeTree(ContentWriterXml writer,Element element,boolean isRoot) throws SAXException, ElementObjectPropertyValueException {
|
String id;
|
||||||
AttributesImpl atts = new AttributesImpl();
|
String value;
|
||||||
|
Integer writeOrder;
|
||||||
if (isRoot && schemaUriPrint) {
|
|
||||||
String rootUri = findElementUri(element);
|
|
||||||
writer.startPrefixMapping("xsi", XMLConstants.XML_SCHEMA_INSTANCE_NS_URI);
|
|
||||||
atts.addAttribute ("xsi", "schemaLocation", "", "", rootUri+" "+schemaUriRoot);
|
|
||||||
}
|
}
|
||||||
|
class AttributeEntryComparator implements Comparator<AttributeEntry> {
|
||||||
|
public int compare(AttributeEntry o1, AttributeEntry o2) {
|
||||||
|
return o1.writeOrder.compareTo(o2.writeOrder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void writeTree(ContentWriterXml writer,Element element,boolean isRoot) throws SAXException, ElementObjectPropertyValueException {
|
||||||
|
List<AttributeEntry> attr = new ArrayList<AttributeEntry>(20);
|
||||||
if (element.getElementClass().getAutoAttributes()!=null && element.getElementClass().getAutoAttributes()==false) {
|
if (element.getElementClass().getAutoAttributes()!=null && element.getElementClass().getAutoAttributes()==false) {
|
||||||
for (ElementClassAttribute eca:element.getElementClass().getElementClassAttributes()) {
|
for (ElementClassAttribute eca:element.getElementClass().getElementClassAttributes()) {
|
||||||
if (eca.getRunBeanValue()!=null && eca.getRunBeanValue()==false) {
|
if (eca.getRunBeanValue()!=null && eca.getRunBeanValue()==false) {
|
||||||
|
@ -291,19 +299,29 @@ public class X4OPhaseLanguageWrite {
|
||||||
if (value==null) {
|
if (value==null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
atts.addAttribute ("", eca.getId(), "", "", ""+value);
|
AttributeEntry e = new AttributeEntry();
|
||||||
|
e.id = eca.getId();
|
||||||
|
e.value = ""+value;
|
||||||
|
e.writeOrder = calcOrderNumber(e.id,eca.getWriteOrder());
|
||||||
|
attr.add(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for (String p:getProperties(element.getElementObject().getClass())) {
|
for (String p:getProperties(element.getElementObject().getClass())) {
|
||||||
|
Integer writeOrder = null;
|
||||||
ElementClassAttribute eca = element.getElementClass().getElementClassAttributeByName(p);
|
ElementClassAttribute eca = element.getElementClass().getElementClassAttributeByName(p);
|
||||||
|
if (eca!=null) {
|
||||||
|
writeOrder = eca.getWriteOrder();
|
||||||
|
}
|
||||||
if (eca!=null && eca.getRunBeanValue()!=null && eca.getRunBeanValue()) {
|
if (eca!=null && eca.getRunBeanValue()!=null && eca.getRunBeanValue()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean writeValue = true;
|
boolean writeValue = true;
|
||||||
for (ElementInterface ei:element.getLanguageContext().getLanguage().findElementInterfaces(element.getElementObject().getClass())) {
|
for (ElementInterface ei:element.getLanguageContext().getLanguage().findElementInterfaces(element.getElementObject().getClass())) {
|
||||||
eca = ei.getElementClassAttributeByName(p);
|
eca = ei.getElementClassAttributeByName(p);
|
||||||
|
if (eca!=null && writeOrder==null) {
|
||||||
|
writeOrder = eca.getWriteOrder(); // add interface but allow override local
|
||||||
|
}
|
||||||
if (eca!=null && eca.getRunBeanValue()!=null && eca.getRunBeanValue()==false) {
|
if (eca!=null && eca.getRunBeanValue()!=null && eca.getRunBeanValue()==false) {
|
||||||
writeValue = false;
|
writeValue = false;
|
||||||
break;
|
break;
|
||||||
|
@ -321,10 +339,30 @@ public class X4OPhaseLanguageWrite {
|
||||||
if (value instanceof List || value instanceof Collection) {
|
if (value instanceof List || value instanceof Collection) {
|
||||||
continue; // TODO; filter on type of childeren
|
continue; // TODO; filter on type of childeren
|
||||||
}
|
}
|
||||||
atts.addAttribute ("", p, "", "", ""+value);
|
AttributeEntry e = new AttributeEntry();
|
||||||
|
e.id = p;
|
||||||
|
e.value = ""+value;
|
||||||
|
e.writeOrder = calcOrderNumber(e.id,writeOrder);
|
||||||
|
attr.add(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create atts to write and append schema first.
|
||||||
|
AttributesImpl atts = new AttributesImpl();
|
||||||
|
if (isRoot && schemaUriPrint) {
|
||||||
|
String rootUri = findElementUri(element);
|
||||||
|
writer.startPrefixMapping("xsi", XMLConstants.XML_SCHEMA_INSTANCE_NS_URI);
|
||||||
|
atts.addAttribute ("xsi", "schemaLocation", "", "", rootUri+" "+schemaUriRoot);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort attributes in natural order of localName and add to attributes
|
||||||
|
Collections.sort(attr, attributeEntryComparator);
|
||||||
|
for (int i=0;i<attr.size();i++) {
|
||||||
|
AttributeEntry a = attr.get(i);
|
||||||
|
atts.addAttribute ("", a.id, "", "", a.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write Element tree recursive.
|
||||||
String elementUri = findElementUri(element);
|
String elementUri = findElementUri(element);
|
||||||
writer.startElement(elementUri, element.getElementClass().getId(), "", atts);
|
writer.startElement(elementUri, element.getElementClass().getId(), "", atts);
|
||||||
for (Element e:element.getChilderen()) {
|
for (Element e:element.getChilderen()) {
|
||||||
|
@ -333,6 +371,30 @@ public class X4OPhaseLanguageWrite {
|
||||||
writer.endElement(elementUri, element.getElementClass().getId(), "");
|
writer.endElement(elementUri, element.getElementClass().getId(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: move to defaults layer so visible in docs.
|
||||||
|
private Integer calcOrderNumber(String name,Integer orderNumberOverride) {
|
||||||
|
if (orderNumberOverride!=null) {
|
||||||
|
return orderNumberOverride;
|
||||||
|
}
|
||||||
|
if (name==null) {
|
||||||
|
throw new NullPointerException("Can't calculate order of null name.");
|
||||||
|
}
|
||||||
|
int nameSize = name.length();
|
||||||
|
if (nameSize==1) {
|
||||||
|
return (name.charAt(0) * 1000);
|
||||||
|
}
|
||||||
|
if (nameSize==2) {
|
||||||
|
return (name.charAt(0) * 1000) + (name.charAt(1) * 100);
|
||||||
|
}
|
||||||
|
if (nameSize==3) {
|
||||||
|
return (name.charAt(0) * 1000) + (name.charAt(1) * 100) + (name.charAt(2) * 10);
|
||||||
|
}
|
||||||
|
if (nameSize>3) {
|
||||||
|
return (name.charAt(0) * 1000) + (name.charAt(1) * 100) + (name.charAt(2) * 10) + (name.charAt(3) * 1);
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Can't calculate order of empty name.");
|
||||||
|
}
|
||||||
|
|
||||||
private String findElementUri(Element e) {
|
private String findElementUri(Element e) {
|
||||||
for (X4OLanguageModule mod:e.getLanguageContext().getLanguage().getLanguageModules()) {
|
for (X4OLanguageModule mod:e.getLanguageContext().getLanguage().getLanguageModules()) {
|
||||||
for (ElementNamespaceContext c:mod.getElementNamespaceContexts()) {
|
for (ElementNamespaceContext c:mod.getElementNamespaceContexts()) {
|
||||||
|
|
|
@ -22,25 +22,6 @@
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.eld;
|
package org.x4o.xml.eld;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.x4o.xml.X4ODriver;
|
|
||||||
import org.x4o.xml.X4ODriverManager;
|
|
||||||
import org.x4o.xml.eld.EldDriver;
|
|
||||||
import org.x4o.xml.element.Element;
|
|
||||||
import org.x4o.xml.element.Element.ElementType;
|
|
||||||
import org.x4o.xml.element.ElementClass;
|
|
||||||
import org.x4o.xml.element.ElementNamespaceContext;
|
|
||||||
import org.x4o.xml.io.X4OReader;
|
|
||||||
import org.x4o.xml.io.X4OSchemaWriter;
|
|
||||||
import org.x4o.xml.io.X4OWriter;
|
|
||||||
import org.x4o.xml.lang.X4OLanguageModule;
|
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
|
||||||
import org.x4o.xml.lang.X4OLanguagePropertyKeys;
|
|
||||||
import org.x4o.xml.test.TestDriver;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,17 +60,16 @@ public class EldParserTest extends TestCase {
|
||||||
|
|
||||||
public void testRunEldParserCore() throws Exception {
|
public void testRunEldParserCore() throws Exception {
|
||||||
|
|
||||||
X4ODriver<X4OLanguageModule> driver = (X4ODriver<X4OLanguageModule>)X4ODriverManager.getX4ODriver(EldDriver.LANGUAGE_NAME);
|
//X4ODriver<X4OLanguageModule> driver = (X4ODriver<X4OLanguageModule>)X4ODriverManager.getX4ODriver(EldDriver.LANGUAGE_NAME);
|
||||||
|
//X4OReader<X4OLanguageModule> reader = driver.createReader();
|
||||||
X4OReader<X4OLanguageModule> reader = driver.createReader();
|
|
||||||
//EldDriver parser = new EldDriver(true);
|
//EldDriver parser = new EldDriver(true);
|
||||||
reader.setProperty(X4OLanguagePropertyKeys.PHASE_SKIP_RELEASE, true);
|
//reader.setProperty(X4OLanguagePropertyKeys.PHASE_SKIP_RELEASE, true);
|
||||||
try {
|
try {
|
||||||
X4OLanguageModule module = reader.readResource("META-INF/eld/eld-lang.eld");
|
//X4OLanguageModule module = reader.readResource("META-INF/eld/eld-lang.eld");
|
||||||
List<String> resultTags = new ArrayList<String>(50);
|
//List<String> resultTags = new ArrayList<String>(50);
|
||||||
for (ElementNamespaceContext ns:module.getElementNamespaceContexts()) {
|
//for (ElementNamespaceContext ns:module.getElementNamespaceContexts()) {
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
/*
|
/*
|
||||||
for (Element e:parser.getDriver().getElementLanguage().getRootElement().getAllChilderen()) {
|
for (Element e:parser.getDriver().getElementLanguage().getRootElement().getAllChilderen()) {
|
||||||
//System.out.println("obj: "+e.getElementObject());
|
//System.out.println("obj: "+e.getElementObject());
|
||||||
|
@ -117,8 +97,8 @@ public class EldParserTest extends TestCase {
|
||||||
public void testRunEldParser() throws Exception {
|
public void testRunEldParser() throws Exception {
|
||||||
//EldDriver parser = new EldDriver(false);
|
//EldDriver parser = new EldDriver(false);
|
||||||
//parser.parseResource("META-INF/test/test-lang.eld");
|
//parser.parseResource("META-INF/test/test-lang.eld");
|
||||||
X4ODriver<X4OLanguageModule> driver = (X4ODriver<X4OLanguageModule>)X4ODriverManager.getX4ODriver(EldDriver.LANGUAGE_NAME);
|
//X4ODriver<X4OLanguageModule> driver = (X4ODriver<X4OLanguageModule>)X4ODriverManager.getX4ODriver(EldDriver.LANGUAGE_NAME);
|
||||||
X4OReader<X4OLanguageModule> reader = driver.createReader();
|
//X4OReader<X4OLanguageModule> reader = driver.createReader();
|
||||||
reader.readResource("META-INF/test/test-lang.eld");
|
//reader.readResource("META-INF/test/test-lang.eld");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.io;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
import org.x4o.xml.X4ODriver;
|
||||||
|
import org.x4o.xml.io.X4OReader;
|
||||||
|
import org.x4o.xml.test.TestDriver;
|
||||||
|
import org.x4o.xml.test.models.TestObjectRoot;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OWriterAttributeTest tests xml write attribute write order.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 19, 2013
|
||||||
|
*/
|
||||||
|
public class X4OWriterAttributeTest extends TestCase {
|
||||||
|
|
||||||
|
|
||||||
|
private File createOutputFile() throws IOException {
|
||||||
|
File outputFile = File.createTempFile("test-writer-attr", ".xml");
|
||||||
|
outputFile.deleteOnExit();
|
||||||
|
return outputFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testWriteAttrNatural() throws Exception {
|
||||||
|
File outputFile = createOutputFile();
|
||||||
|
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||||
|
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||||
|
X4OWriter<TestObjectRoot> writer = driver.createWriter();
|
||||||
|
|
||||||
|
TestObjectRoot root = reader.readResource("tests/writer/test-attribute-order.xml");
|
||||||
|
writer.writeFile(root, outputFile);
|
||||||
|
String text = new Scanner( outputFile ).useDelimiter("\\A").next();
|
||||||
|
outputFile.delete();
|
||||||
|
|
||||||
|
assertTrue(text.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
|
||||||
|
assertTrue(text.contains("TestAttributeOrderChildNatural"+
|
||||||
|
" aaaName=\"NAME_1\" aabName=\"NAME_2\" aacName=\"NAME_3\""+
|
||||||
|
" abaName=\"NAME_4\" abbName=\"NAME_5\" abcName=\"NAME_6\""+
|
||||||
|
" caaName=\"NAME_7\" cabName=\"NAME_8\" cacName=\"NAME_9\""));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testWriteAttrOrdered() throws Exception {
|
||||||
|
File outputFile = createOutputFile();
|
||||||
|
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||||
|
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||||
|
X4OWriter<TestObjectRoot> writer = driver.createWriter();
|
||||||
|
|
||||||
|
TestObjectRoot root = reader.readResource("tests/writer/test-attribute-order.xml");
|
||||||
|
writer.writeFile(root, outputFile);
|
||||||
|
String text = new Scanner( outputFile ).useDelimiter("\\A").next();
|
||||||
|
outputFile.delete();
|
||||||
|
|
||||||
|
assertTrue(text.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
|
||||||
|
assertTrue(text.contains("custom-ordered-child"+
|
||||||
|
" cacName=\"NAME_9\" cabName=\"NAME_8\" caaName=\"NAME_7\""+
|
||||||
|
" abcName=\"NAME_6\" abbName=\"NAME_5\" abaName=\"NAME_4\""+
|
||||||
|
" aaaName=\"NAME_1\" aabName=\"NAME_2\" aacName=\"NAME_3\""));
|
||||||
|
}
|
||||||
|
}
|
|
@ -40,10 +40,10 @@ import org.x4o.xml.test.swixml.SwingEngine;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* X4OWriterTest runs parser with debug output.
|
* X4OWriterTest test xml writer output.
|
||||||
*
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Aug 26, 2012
|
* @version 1.0 Apr 28, 2013
|
||||||
*/
|
*/
|
||||||
public class X4OWriterTest extends TestCase {
|
public class X4OWriterTest extends TestCase {
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ package org.x4o.xml.io.sax;
|
||||||
|
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
|
||||||
|
import org.x4o.xml.io.sax.ext.ContentWriterXml;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import org.xml.sax.helpers.AttributesImpl;
|
import org.xml.sax.helpers.AttributesImpl;
|
||||||
|
|
||||||
|
@ -292,4 +293,121 @@ public class ContentWriterXmlTest extends TestCase {
|
||||||
assertTrue(e.getMessage().contains("2"));
|
assertTrue(e.getMessage().contains("2"));
|
||||||
assertTrue(e.getMessage().contains("open"));
|
assertTrue(e.getMessage().contains("open"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testProcessingInstruction() throws Exception {
|
||||||
|
StringWriter outputWriter = new StringWriter();
|
||||||
|
ContentWriterXml writer = new ContentWriterXml(outputWriter);
|
||||||
|
AttributesImpl atts = new AttributesImpl();
|
||||||
|
|
||||||
|
Exception e = null;
|
||||||
|
try {
|
||||||
|
writer.startDocument();
|
||||||
|
writer.processingInstruction("target", "data");
|
||||||
|
writer.startElement("", "test", "", atts);
|
||||||
|
writer.endElement("", "test", "");
|
||||||
|
writer.endDocument();
|
||||||
|
} catch (Exception catchE) {
|
||||||
|
e = catchE;
|
||||||
|
}
|
||||||
|
String output = outputWriter.toString();
|
||||||
|
assertNull(e);
|
||||||
|
assertNotNull(output);
|
||||||
|
assertTrue(output.length()>0);
|
||||||
|
assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?target data?>\n<test/>"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testProcessingInstructionInline() throws Exception {
|
||||||
|
StringWriter outputWriter = new StringWriter();
|
||||||
|
ContentWriterXml writer = new ContentWriterXml(outputWriter);
|
||||||
|
AttributesImpl atts = new AttributesImpl();
|
||||||
|
|
||||||
|
Exception e = null;
|
||||||
|
try {
|
||||||
|
writer.startDocument();
|
||||||
|
writer.processingInstruction("target", "data");
|
||||||
|
writer.startElement("", "test", "", atts);
|
||||||
|
writer.processingInstruction("target-doc", "data-doc");
|
||||||
|
writer.endElement("", "test", "");
|
||||||
|
writer.endDocument();
|
||||||
|
} catch (Exception catchE) {
|
||||||
|
e = catchE;
|
||||||
|
}
|
||||||
|
String output = outputWriter.toString();
|
||||||
|
assertNull(e);
|
||||||
|
assertNotNull(output);
|
||||||
|
assertTrue(output.length()>0);
|
||||||
|
assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?target data?>\n<test>\n\t<?target-doc data-doc?>\n</test>"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testProcessingInstructionTargetXmlPrefix() throws Exception {
|
||||||
|
StringWriter outputWriter = new StringWriter();
|
||||||
|
ContentWriterXml writer = new ContentWriterXml(outputWriter);
|
||||||
|
Exception e = null;
|
||||||
|
try {
|
||||||
|
writer.startDocument();
|
||||||
|
writer.processingInstruction("xmlPrefix", "isInvalid");
|
||||||
|
} catch (Exception catchE) {
|
||||||
|
e = catchE;
|
||||||
|
}
|
||||||
|
assertNotNull(e);
|
||||||
|
assertEquals(SAXException.class, e.getClass());
|
||||||
|
assertTrue(e.getMessage().contains("instruction"));
|
||||||
|
assertTrue(e.getMessage().contains("start with xml"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testProcessingInstructionTargetNoneNameChar() throws Exception {
|
||||||
|
StringWriter outputWriter = new StringWriter();
|
||||||
|
ContentWriterXml writer = new ContentWriterXml(outputWriter);
|
||||||
|
Exception e = null;
|
||||||
|
try {
|
||||||
|
writer.startDocument();
|
||||||
|
writer.processingInstruction("4Prefix", "isInvalid");
|
||||||
|
} catch (Exception catchE) {
|
||||||
|
e = catchE;
|
||||||
|
}
|
||||||
|
assertNotNull(e);
|
||||||
|
assertEquals(SAXException.class, e.getClass());
|
||||||
|
assertTrue(e.getMessage().contains("instruction"));
|
||||||
|
assertTrue(e.getMessage().contains("invalid name"));
|
||||||
|
assertTrue(e.getMessage().contains("4Prefix"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testProcessingInstructionDataNoneChar() throws Exception {
|
||||||
|
StringWriter outputWriter = new StringWriter();
|
||||||
|
ContentWriterXml writer = new ContentWriterXml(outputWriter);
|
||||||
|
Exception e = null;
|
||||||
|
try {
|
||||||
|
writer.startDocument();
|
||||||
|
writer.processingInstruction("target", "isInvalidChar="+0xD800);
|
||||||
|
} catch (Exception catchE) {
|
||||||
|
e = catchE;
|
||||||
|
}
|
||||||
|
assertNotNull(e);
|
||||||
|
assertEquals(SAXException.class, e.getClass());
|
||||||
|
assertTrue(e.getMessage().contains("instruction"));
|
||||||
|
assertTrue(e.getMessage().contains("invalid char"));
|
||||||
|
assertTrue(e.getMessage().contains("isInvalidChar=55296"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAttributeValueLongData() throws Exception {
|
||||||
|
StringWriter outputWriter = new StringWriter();
|
||||||
|
ContentWriterXml writer = new ContentWriterXml(outputWriter);
|
||||||
|
|
||||||
|
AttributesImpl atts = new AttributesImpl();
|
||||||
|
String data = "_FOR_FOO_BAR";
|
||||||
|
String dataValue = "LOOP";
|
||||||
|
for (int i=0;i<15;i++) {
|
||||||
|
atts.addAttribute("", "attr"+i, "", "", dataValue+=data);
|
||||||
|
}
|
||||||
|
writer.startDocument();
|
||||||
|
writer.startElement("", "test", "", atts);
|
||||||
|
writer.startElement("", "testNode", "", new AttributesImpl());
|
||||||
|
writer.endElement("", "testNode", "");
|
||||||
|
writer.endElement("", "test", "");
|
||||||
|
writer.endDocument();
|
||||||
|
|
||||||
|
String output = outputWriter.toString();
|
||||||
|
assertNotNull(output);
|
||||||
|
assertTrue(output.split("\n").length==13);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,12 +22,8 @@
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.test;
|
package org.x4o.xml.test;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
|
|
||||||
import org.x4o.xml.X4ODriver;
|
import org.x4o.xml.X4ODriver;
|
||||||
import org.x4o.xml.io.X4OReader;
|
import org.x4o.xml.io.X4OReader;
|
||||||
import org.x4o.xml.lang.X4OLanguagePropertyKeys;
|
|
||||||
import org.x4o.xml.test.models.TestObjectRoot;
|
import org.x4o.xml.test.models.TestObjectRoot;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ import java.io.StringWriter;
|
||||||
|
|
||||||
import org.x4o.xml.element.AbstractElement;
|
import org.x4o.xml.element.AbstractElement;
|
||||||
import org.x4o.xml.element.ElementException;
|
import org.x4o.xml.element.ElementException;
|
||||||
import org.x4o.xml.io.sax.ContentWriterXml;
|
import org.x4o.xml.io.sax.ext.ContentWriterXml;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* InlinePropertiesElement to test
|
* InlinePropertiesElement to test
|
||||||
|
|
|
@ -0,0 +1,148 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.test.models;
|
||||||
|
|
||||||
|
public class TestAttributeOrderChild extends TestObjectChild {
|
||||||
|
|
||||||
|
private String aaaName = null;
|
||||||
|
private String aabName = null;
|
||||||
|
private String aacName = null;
|
||||||
|
|
||||||
|
private String abaName = null;
|
||||||
|
private String abbName = null;
|
||||||
|
private String abcName = null;
|
||||||
|
|
||||||
|
private String caaName = null;
|
||||||
|
private String cabName = null;
|
||||||
|
private String cacName = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the caaName
|
||||||
|
*/
|
||||||
|
public String getCaaName() {
|
||||||
|
return caaName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param caaName the caaName to set
|
||||||
|
*/
|
||||||
|
public void setCaaName(String caaName) {
|
||||||
|
this.caaName = caaName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return the cabName
|
||||||
|
*/
|
||||||
|
public String getCabName() {
|
||||||
|
return cabName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param cabName the cabName to set
|
||||||
|
*/
|
||||||
|
public void setCabName(String cabName) {
|
||||||
|
this.cabName = cabName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return the cacName
|
||||||
|
*/
|
||||||
|
public String getCacName() {
|
||||||
|
return cacName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param cacName the cacName to set
|
||||||
|
*/
|
||||||
|
public void setCacName(String cacName) {
|
||||||
|
this.cacName = cacName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the aaaName
|
||||||
|
*/
|
||||||
|
public String getAaaName() {
|
||||||
|
return aaaName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param aaaName the aaaName to set
|
||||||
|
*/
|
||||||
|
public void setAaaName(String aaaName) {
|
||||||
|
this.aaaName = aaaName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return the aabName
|
||||||
|
*/
|
||||||
|
public String getAabName() {
|
||||||
|
return aabName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param aabName the aabName to set
|
||||||
|
*/
|
||||||
|
public void setAabName(String aabName) {
|
||||||
|
this.aabName = aabName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return the aacName
|
||||||
|
*/
|
||||||
|
public String getAacName() {
|
||||||
|
return aacName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param aacName the aacName to set
|
||||||
|
*/
|
||||||
|
public void setAacName(String aacName) {
|
||||||
|
this.aacName = aacName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return the abaName
|
||||||
|
*/
|
||||||
|
public String getAbaName() {
|
||||||
|
return abaName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param abaName the abaName to set
|
||||||
|
*/
|
||||||
|
public void setAbaName(String abaName) {
|
||||||
|
this.abaName = abaName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return the abbName
|
||||||
|
*/
|
||||||
|
public String getAbbName() {
|
||||||
|
return abbName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param abbName the abbName to set
|
||||||
|
*/
|
||||||
|
public void setAbbName(String abbName) {
|
||||||
|
this.abbName = abbName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return the abcName
|
||||||
|
*/
|
||||||
|
public String getAbcName() {
|
||||||
|
return abcName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param abcName the abcName to set
|
||||||
|
*/
|
||||||
|
public void setAbcName(String abcName) {
|
||||||
|
this.abcName = abcName;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.test.models;
|
||||||
|
|
||||||
|
public class TestAttributeOrderChildNatural extends TestAttributeOrderChild {
|
||||||
|
|
||||||
|
}
|
|
@ -22,8 +22,6 @@
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.test.models;
|
package org.x4o.xml.test.models;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bean for property testing.
|
* Bean for property testing.
|
||||||
*
|
*
|
||||||
|
|
|
@ -45,41 +45,6 @@ public class SwiXmlDriver extends X4ODriver<Component> {
|
||||||
public static final String[] LANGUAGE_VERSIONS = new String[]{LANGUAGE_VERSION_2,LANGUAGE_VERSION_3};
|
public static final String[] LANGUAGE_VERSIONS = new String[]{LANGUAGE_VERSION_2,LANGUAGE_VERSION_3};
|
||||||
public static final String LANGUAGE_EL_SWING_ENGINE = "swingEngine";
|
public static final String LANGUAGE_EL_SWING_ENGINE = "swingEngine";
|
||||||
|
|
||||||
/*
|
|
||||||
* Protected constructor for write schema api.
|
|
||||||
* @param xmlVersion The xml version.
|
|
||||||
|
|
||||||
protected SwiXmlDriver(SwiXmlVersion xmlVersion) {
|
|
||||||
|
|
||||||
// Create language by version
|
|
||||||
super(LANGUAGE_NAME,xmlVersion.getLanguageVersion());
|
|
||||||
|
|
||||||
// Sets empty namespace uri for version 2 xml documents
|
|
||||||
if (SwiXmlVersion.VERSION_2.equals(xmlVersion)) {
|
|
||||||
setProperty(X4OLanguagePropertyKeys.INPUT_EMPTY_NAMESPACE_URI, VERSION_2_NS_URI);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Creates an SwiXmlParser with an SwingEngine and a xml version.
|
|
||||||
* @param engine The SwingEngine to parse for.
|
|
||||||
* @param xmlVersion The xml language version to parse.
|
|
||||||
|
|
||||||
public SwiXmlDriver(SwingEngine engine,SwiXmlVersion xmlVersion) {
|
|
||||||
|
|
||||||
// Create language
|
|
||||||
this(xmlVersion);
|
|
||||||
|
|
||||||
// Check engine
|
|
||||||
if (engine==null) {
|
|
||||||
throw new NullPointerException("Can't parse with null SwingEngine.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add engine for callback
|
|
||||||
addELBeanInstance(SWING_ENGINE_EL_NAME,engine);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper for while parsing to get the SwingEngine.
|
* Helper for while parsing to get the SwingEngine.
|
||||||
* @param elementLanguage The elementLanguage to get the swingEngine out.
|
* @param elementLanguage The elementLanguage to get the swingEngine out.
|
||||||
|
@ -91,7 +56,6 @@ public class SwiXmlDriver extends X4ODriver<Component> {
|
||||||
return se;
|
return se;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static public SwiXmlDriver getInstance() {
|
static public SwiXmlDriver getInstance() {
|
||||||
return (SwiXmlDriver)X4ODriverManager.getX4ODriver(LANGUAGE_NAME);
|
return (SwiXmlDriver)X4ODriverManager.getX4ODriver(LANGUAGE_NAME);
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,6 +150,21 @@
|
||||||
-->
|
-->
|
||||||
</eld:element>
|
</eld:element>
|
||||||
|
|
||||||
|
<eld:element objectClass="org.x4o.xml.test.models.TestAttributeOrderChildNatural"/>
|
||||||
|
|
||||||
|
<eld:element id="custom-ordered-child" objectClass="org.x4o.xml.test.models.TestAttributeOrderChild">
|
||||||
|
<eld:attribute id="aaaName" writeOrder="5000"/>
|
||||||
|
<eld:attribute id="aabName" writeOrder="5010"/>
|
||||||
|
<eld:attribute id="aacName" writeOrder="5020"/>
|
||||||
|
<eld:attribute id="abaName" writeOrder="3002"/>
|
||||||
|
<eld:attribute id="abbName" writeOrder="3001"/>
|
||||||
|
<eld:attribute id="abcName" writeOrder="3000"/>
|
||||||
|
<eld:attribute id="caaName" writeOrder="1003"/>
|
||||||
|
<eld:attribute id="cabName" writeOrder="1002"/>
|
||||||
|
<eld:attribute id="cacName" writeOrder="1000"/>
|
||||||
|
</eld:element>
|
||||||
|
|
||||||
|
|
||||||
<eld:element tag="JFrame" objectClass="javax.swing.JFrame">
|
<eld:element tag="JFrame" objectClass="javax.swing.JFrame">
|
||||||
<eld:elementParent tag="root" uri="http://test.x4o.org/xml/ns/test-root"/>
|
<eld:elementParent tag="root" uri="http://test.x4o.org/xml/ns/test-root"/>
|
||||||
</eld:element>
|
</eld:element>
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
-->
|
||||||
|
<root:root
|
||||||
|
xmlns:root="http://test.x4o.org/xml/ns/test-root"
|
||||||
|
xmlns="http://test.x4o.org/xml/ns/test-lang"
|
||||||
|
>
|
||||||
|
<TestAttributeOrderChildNatural
|
||||||
|
aaaName="NAME_1"
|
||||||
|
aabName="NAME_2"
|
||||||
|
aacName="NAME_3"
|
||||||
|
abaName="NAME_4"
|
||||||
|
abbName="NAME_5"
|
||||||
|
abcName="NAME_6"
|
||||||
|
caaName="NAME_7"
|
||||||
|
cabName="NAME_8"
|
||||||
|
cacName="NAME_9"
|
||||||
|
/>
|
||||||
|
<custom-ordered-child
|
||||||
|
aaaName="NAME_1"
|
||||||
|
aabName="NAME_2"
|
||||||
|
aacName="NAME_3"
|
||||||
|
abaName="NAME_4"
|
||||||
|
abbName="NAME_5"
|
||||||
|
abcName="NAME_6"
|
||||||
|
caaName="NAME_7"
|
||||||
|
cabName="NAME_8"
|
||||||
|
cacName="NAME_9"
|
||||||
|
/>
|
||||||
|
</root:root>
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<projectDescription>
|
<projectDescription>
|
||||||
<name>x4o-elddoc</name>
|
<name>x4o-eld-doc</name>
|
||||||
<comment>x4o-elddoc</comment>
|
<comment>x4o-eld-doc</comment>
|
||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
<buildSpec>
|
<buildSpec>
|
|
@ -5,10 +5,10 @@
|
||||||
<groupId>org.x4o</groupId>
|
<groupId>org.x4o</groupId>
|
||||||
<version>0.8.5-SNAPSHOT</version>
|
<version>0.8.5-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>x4o-elddoc</artifactId>
|
<artifactId>x4o-eld-doc</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>x4o-elddoc</name>
|
<name>x4o-eld-doc</name>
|
||||||
<description>x4o-elddoc</description>
|
<description>x4o-eld-doc</description>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.x4o</groupId>
|
<groupId>org.x4o</groupId>
|
271
x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriter.java
Normal file
|
@ -0,0 +1,271 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.eld.doc;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.x4o.xml.eld.doc.api.ApiDocContentWriter;
|
||||||
|
import org.x4o.xml.eld.doc.api.ApiDocNodeWriterBean;
|
||||||
|
import org.x4o.xml.eld.doc.api.ApiDocNodeWriterMethod;
|
||||||
|
import org.x4o.xml.eld.doc.api.ApiDocWriter;
|
||||||
|
import org.x4o.xml.eld.doc.api.DefaultPageWriterHelp;
|
||||||
|
import org.x4o.xml.eld.doc.api.DefaultPageWriterIndexAll;
|
||||||
|
import org.x4o.xml.eld.doc.api.DefaultPageWriterTree;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDoc;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocConcept;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocNode;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocNodeBody;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
|
||||||
|
import org.x4o.xml.element.ElementAttributeHandler;
|
||||||
|
import org.x4o.xml.element.ElementBindingHandler;
|
||||||
|
import org.x4o.xml.element.ElementClass;
|
||||||
|
import org.x4o.xml.element.ElementConfigurator;
|
||||||
|
import org.x4o.xml.element.ElementInterface;
|
||||||
|
import org.x4o.xml.element.ElementException;
|
||||||
|
import org.x4o.xml.element.ElementNamespaceContext;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EldDocWriter writes the x4o eld documentation.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Aug 26, 2010
|
||||||
|
*/
|
||||||
|
public class EldDocWriter {
|
||||||
|
|
||||||
|
private X4OLanguageContext context = null;
|
||||||
|
private static final String[] C_CONTEXT = {"language","Overview","All language modules.","The loaded language modules.."};
|
||||||
|
private static final String[] C_MODULE = {"module","Module","The Language Modules.","The language is build by the modules and provides the namespaces."};
|
||||||
|
private static final String[] C_NAMESPACE = {"namespace","Namespace","The Language Namespace.","The language namespace holds all the xml elements."};
|
||||||
|
private static final String[] C_ELEMENT = {"element","Element","The Language Element.","The xml language element description."};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an EldDocGenerator for this langauge context.
|
||||||
|
* @param context The language context to generate doc for.
|
||||||
|
*/
|
||||||
|
public EldDocWriter(X4OLanguageContext context) {
|
||||||
|
this.context=context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes the language documentation to the base path.
|
||||||
|
* @param basePath The path to write to documentation to.
|
||||||
|
* @throws ElementException Is thrown when error is done.
|
||||||
|
*/
|
||||||
|
public void writeDoc(File basePath) throws ElementException {
|
||||||
|
try {
|
||||||
|
ApiDocWriter writer = new ApiDocWriter();
|
||||||
|
ApiDoc doc = buildLanguageDoc();
|
||||||
|
doc.checkModel();
|
||||||
|
writer.write(doc, basePath);
|
||||||
|
} catch (SAXException e) {
|
||||||
|
throw new ElementException(e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new ElementException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApiDoc buildLanguageDoc() {
|
||||||
|
ApiDoc doc = new ApiDoc();
|
||||||
|
doc.setName("X4O ELD DOC");
|
||||||
|
doc.setDescription("X4O Meta Language Description");
|
||||||
|
doc.setDocAbout(createLanguageAbout());
|
||||||
|
doc.setDocCopyright(createLanguageCopyright());
|
||||||
|
doc.addDocKeywordAll(createLanguageKeywords());
|
||||||
|
doc.setFrameNavPrintParent(true);
|
||||||
|
doc.setFrameNavPrintParentId(true);
|
||||||
|
|
||||||
|
doc.setFrameNavConceptClass(ElementClass.class);
|
||||||
|
ApiDocNodeWriterBean.addAnnotatedNodeContentWriters(doc,new EldDocWriterLanguage());
|
||||||
|
ApiDocNodeWriterBean.addAnnotatedNodeContentWriters(doc,new EldDocWriterElementClass());
|
||||||
|
ApiDocNodeWriterBean.addAnnotatedNodeContentWriters(doc,this);
|
||||||
|
|
||||||
|
ApiDocConcept adc1 = doc.addConcept(new ApiDocConcept(null,C_CONTEXT,X4OLanguageContext.class));
|
||||||
|
ApiDocConcept adc2 = doc.addConcept(new ApiDocConcept(adc1,C_MODULE,X4OLanguageModule.class,
|
||||||
|
ElementAttributeHandler.class,ElementConfigurator.class,ElementInterface.class,ElementBindingHandler.class));
|
||||||
|
ApiDocConcept adc3 = doc.addConcept(new ApiDocConcept(adc2,C_NAMESPACE,ElementNamespaceContext.class));
|
||||||
|
doc.addConcept(new ApiDocConcept(adc3,C_ELEMENT,ElementClass.class));
|
||||||
|
|
||||||
|
doc.addDocPage(EldDocXTreePageWriter.createDocPage());
|
||||||
|
doc.addDocPage(DefaultPageWriterTree.createDocPage());
|
||||||
|
doc.addDocPage(DefaultPageWriterIndexAll.createDocPage());
|
||||||
|
doc.addDocPage(DefaultPageWriterHelp.createDocPage());
|
||||||
|
|
||||||
|
ApiDocNode rootNode = new ApiDocNode(context,"language","Language","The X4O Language");
|
||||||
|
doc.setRootNode(rootNode);
|
||||||
|
for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) { ApiDocNode modNode = rootNode.addNode(createNodeLanguageModule(mod));
|
||||||
|
for (ElementBindingHandler bind:mod.getElementBindingHandlers()) { modNode.addNode(createNodeElementBindingHandler(bind)); }
|
||||||
|
for (ElementAttributeHandler attr:mod.getElementAttributeHandlers()) { modNode.addNode(createNodeElementAttributeHandler(attr)); }
|
||||||
|
for (ElementConfigurator conf:mod.getElementConfiguratorGlobals()) { modNode.addNode(createNodeElementConfigurator(conf)); }
|
||||||
|
for (ElementInterface iface:mod.getElementInterfaces()) { ApiDocNode ifaceNode = modNode.addNode(createNodeElementInterface(iface));
|
||||||
|
for (ElementBindingHandler bind:iface.getElementBindingHandlers()) { ifaceNode.addNode(createNodeElementBindingHandler(bind)); }
|
||||||
|
for (ElementConfigurator conf:iface.getElementConfigurators()) { ifaceNode.addNode(createNodeElementConfigurator(conf)); } }
|
||||||
|
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) { ApiDocNode nsNode = modNode.addNode(createNodeElementNamespaceContext(ns));
|
||||||
|
for (ElementClass ec:ns.getElementClasses()) { ApiDocNode ecNode = nsNode.addNode(createNodeElementClass(ec));
|
||||||
|
for (ElementConfigurator conf:ec.getElementConfigurators()) { ecNode.addNode(createNodeElementConfigurator(conf)); } } }
|
||||||
|
}
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApiDocNode createNodeElementBindingHandler(ElementBindingHandler bind) {
|
||||||
|
return new ApiDocNode(bind,bind.getId(),bind.getId(),bind.getDescription());
|
||||||
|
}
|
||||||
|
private ApiDocNode createNodeElementAttributeHandler(ElementAttributeHandler attr) {
|
||||||
|
return new ApiDocNode(attr,attr.getId(),attr.getId(),attr.getDescription());
|
||||||
|
}
|
||||||
|
private ApiDocNode createNodeElementConfigurator(ElementConfigurator conf) {
|
||||||
|
return new ApiDocNode(conf,conf.getId(),conf.getId(),conf.getDescription());
|
||||||
|
}
|
||||||
|
private ApiDocNode createNodeLanguageModule(X4OLanguageModule mod) {
|
||||||
|
return new ApiDocNode(mod,mod.getId(),mod.getId(),mod.getDescription());
|
||||||
|
}
|
||||||
|
private ApiDocNode createNodeElementInterface(ElementInterface iface) {
|
||||||
|
return new ApiDocNode(iface,iface.getId(),iface.getId(),iface.getDescription());
|
||||||
|
}
|
||||||
|
private ApiDocNode createNodeElementNamespaceContext(ElementNamespaceContext ns) {
|
||||||
|
return new ApiDocNode(ns,ns.getId(),ns.getUri(),ns.getDescription());
|
||||||
|
}
|
||||||
|
private ApiDocNode createNodeElementClass(ElementClass ec) {
|
||||||
|
return new ApiDocNode(ec,ec.getId(),ec.getId(),ec.getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String createLanguageAbout() {
|
||||||
|
StringBuffer buf = new StringBuffer(100);
|
||||||
|
buf.append("XML X4O Language\n");
|
||||||
|
buf.append(context.getLanguage().getLanguageName().toUpperCase());
|
||||||
|
buf.append("™ ");
|
||||||
|
buf.append(context.getLanguage().getLanguageVersion());
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String createLanguageCopyright() {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
StringBuffer buf = new StringBuffer(100);
|
||||||
|
buf.append("Copyright © ");
|
||||||
|
buf.append(calendar.get(Calendar.YEAR));
|
||||||
|
buf.append(" ");
|
||||||
|
buf.append(context.getLanguage().getLanguageName().toUpperCase());
|
||||||
|
buf.append(" ");
|
||||||
|
buf.append("All Rights Reserved.");
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> createLanguageKeywords() {
|
||||||
|
List<String> keywords = new ArrayList<String>(10);
|
||||||
|
keywords.add(context.getLanguage().getLanguageName());
|
||||||
|
keywords.add("x4o");
|
||||||
|
keywords.add("xml");
|
||||||
|
keywords.add("language");
|
||||||
|
keywords.add("documentation");
|
||||||
|
return keywords;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void printBeanProperties(ApiDocContentWriter writer,Object bean) throws SAXException {
|
||||||
|
writer.docTableStart("Bean Properties", "Bean properties overview.");
|
||||||
|
writer.docTableHeader("Name", "Value");
|
||||||
|
for (Method m:bean.getClass().getMethods()) {
|
||||||
|
if (m.getName().startsWith("get")) {
|
||||||
|
String n = m.getName().substring(3);
|
||||||
|
if (m.getParameterTypes().length!=0) {
|
||||||
|
continue; // set without parameters
|
||||||
|
}
|
||||||
|
if (n.length()<2) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
n = n.substring(0,1).toLowerCase()+n.substring(1,n.length());
|
||||||
|
Object value = null;
|
||||||
|
try {
|
||||||
|
value = m.invoke(bean, new Object[] {});
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
writer.docTableRow(n,printValue(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
writer.docTableEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String printValue(Object value) {
|
||||||
|
if (value==null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
if (value instanceof String) {
|
||||||
|
return (String)value;
|
||||||
|
}
|
||||||
|
if (value instanceof Class) {
|
||||||
|
return "class "+((Class<?>)value).getName();
|
||||||
|
}
|
||||||
|
if (value instanceof List) {
|
||||||
|
StringBuffer buf = new StringBuffer(100);
|
||||||
|
buf.append("[L: ");
|
||||||
|
List<?> l = (List<?>)value;
|
||||||
|
if (l.isEmpty()) {
|
||||||
|
buf.append("Empty");
|
||||||
|
}
|
||||||
|
for (Object o:l) {
|
||||||
|
buf.append(""+o);
|
||||||
|
buf.append(" ");
|
||||||
|
}
|
||||||
|
buf.append("]");
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
if (value instanceof Object[]) {
|
||||||
|
StringBuffer buf = new StringBuffer(100);
|
||||||
|
buf.append("[A: ");
|
||||||
|
Object[] l = (Object[])value;
|
||||||
|
if (l.length==0) {
|
||||||
|
buf.append("Empty");
|
||||||
|
}
|
||||||
|
for (Object o:l) {
|
||||||
|
buf.append(""+o);
|
||||||
|
buf.append(" ");
|
||||||
|
}
|
||||||
|
buf.append("]");
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return value.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementBindingHandler.class})
|
||||||
|
public void writeElementBindingHandlerBeanProperties(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||||
|
printBeanProperties(event.getWriter(),event.getEvent().getUserData());
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementConfigurator.class})
|
||||||
|
public void writeElementConfiguratorBeanProperties(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||||
|
printBeanProperties(event.getWriter(),event.getEvent().getUserData());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,189 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.eld.doc;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.x4o.xml.eld.doc.EldDocXTreePageWriter.TreeNode;
|
||||||
|
import org.x4o.xml.eld.doc.api.ApiDocContentWriter;
|
||||||
|
import org.x4o.xml.eld.doc.api.ApiDocNodeWriterMethod;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocNode;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocNodeBody;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
|
||||||
|
import org.x4o.xml.element.ElementClass;
|
||||||
|
import org.x4o.xml.element.ElementClassAttribute;
|
||||||
|
import org.x4o.xml.element.ElementNamespaceContext;
|
||||||
|
import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EldDocWriterElementClass writer all content parts for the ElementClass.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 29, 2013
|
||||||
|
*/
|
||||||
|
public class EldDocWriterElementClass {
|
||||||
|
|
||||||
|
private String printList(List<String> list) {
|
||||||
|
StringBuffer buf = new StringBuffer(40);
|
||||||
|
buf.append("[L: ");
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
buf.append("Empty.");
|
||||||
|
}
|
||||||
|
for (String s:list) {
|
||||||
|
buf.append(s);
|
||||||
|
buf.append(' ');
|
||||||
|
}
|
||||||
|
buf.append("]");
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementClass.class})
|
||||||
|
public void writeElementX4OSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||||
|
ApiDocContentWriter writer = event.getWriter();
|
||||||
|
ElementClass ec = (ElementClass)event.getEvent().getUserData();
|
||||||
|
writer.docTableStart("Element X4O Properties", "Element X4O Property Overview");
|
||||||
|
writer.docTableHeader("Name", "Value");
|
||||||
|
writer.docTableRow("id",""+ec.getId());
|
||||||
|
writer.docTableRow("objectClass",""+ec.getObjectClass());
|
||||||
|
writer.docTableRow("elementClass",""+ec.getElementClass());
|
||||||
|
writer.docTableRow("autoAttributes",""+ec.getAutoAttributes());
|
||||||
|
writer.docTableRow("skipPhases",printList(ec.getSkipPhases()));
|
||||||
|
writer.docTableRow("schemaContentBase",""+ec.getSchemaContentBase());
|
||||||
|
writer.docTableRow("schemaContentComplex",""+ec.getSchemaContentComplex());
|
||||||
|
writer.docTableRow("schemaContentMixed",""+ec.getSchemaContentMixed());
|
||||||
|
writer.docTableEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementClass.class})
|
||||||
|
public void writeElementX4OAttributeSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||||
|
ApiDocContentWriter writer = event.getWriter();
|
||||||
|
ElementClass ec = (ElementClass)event.getEvent().getUserData();
|
||||||
|
writer.docTableStart("Element X4O Attributes", "All Element X4O Attributes Overview");
|
||||||
|
writer.docTableHeader("URI", "Name");
|
||||||
|
for (ElementClassAttribute attr:ec.getElementClassAttributes()) {
|
||||||
|
writer.docTableRow(attr.getId(),attr.getDescription());
|
||||||
|
}
|
||||||
|
writer.docTableEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementClass.class})
|
||||||
|
public void writeElementObjectPropertiesSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||||
|
ApiDocContentWriter writer = event.getWriter();
|
||||||
|
ElementClass ec = (ElementClass)event.getEvent().getUserData();
|
||||||
|
Class<?> beanClass = ec.getElementClass();
|
||||||
|
if (beanClass==null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
writer.docTableStart("Class Properties", "Bean class properties overview.");
|
||||||
|
writer.docTableHeader("Name", "Value");
|
||||||
|
for (Method m:beanClass.getMethods()) {
|
||||||
|
if (m.getName().startsWith("set")) {
|
||||||
|
String n = m.getName().substring(3);
|
||||||
|
if (m.getParameterTypes().length==0) {
|
||||||
|
continue; // set without parameters
|
||||||
|
}
|
||||||
|
if (n.length()<2) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
n = n.substring(0,1).toLowerCase()+n.substring(1,n.length());
|
||||||
|
Class<?> type = m.getParameterTypes()[0]; // TODO make full list for auto attribute type resolving.
|
||||||
|
writer.docTableRow(n,""+type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
writer.docTableEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DESCRIPTION_LINKS,targetClasses={ElementClass.class})
|
||||||
|
public void writeElementRelationLinks(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||||
|
ApiDocContentWriter writer = event.getWriter();
|
||||||
|
ElementClass ec = (ElementClass)event.getEvent().getUserData();
|
||||||
|
ElementNamespaceContext ns = (ElementNamespaceContext)event.getEvent().getParent().getUserData();
|
||||||
|
X4OLanguageModule mod = (X4OLanguageModule)event.getEvent().getParent().getParent().getUserData();
|
||||||
|
X4OLanguageContext context = (X4OLanguageContext)event.getEvent().getParent().getParent().getParent().getUserData();
|
||||||
|
|
||||||
|
// TODO: this is hacky
|
||||||
|
EldDocXTreePageWriter xtree = (EldDocXTreePageWriter)event.getDoc().findDocPageById("overview-xtree").getPageWriters().get(0);
|
||||||
|
|
||||||
|
TreeNode node = xtree.new TreeNode();
|
||||||
|
node.context=context;
|
||||||
|
node.module=mod;
|
||||||
|
node.namespace=ns;
|
||||||
|
node.elementClass=ec;
|
||||||
|
|
||||||
|
String pathPrefix = "../../../../language/";
|
||||||
|
|
||||||
|
List<TreeNode> parents = xtree.findParents(node);
|
||||||
|
writer.printTagStart(Tag.dl);
|
||||||
|
writer.printTagCharacters(Tag.dt,"Element Parents:");
|
||||||
|
writer.printTagStart(Tag.dd);
|
||||||
|
if (parents.isEmpty()) {
|
||||||
|
writer.characters("No parent.");
|
||||||
|
}
|
||||||
|
for (int i=0;i<parents.size();i++) {
|
||||||
|
TreeNode n = parents.get(i);
|
||||||
|
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
|
||||||
|
writer.printHref(uri, n.namespace.getId()+":"+n.elementClass.getId());
|
||||||
|
if (i<parents.size()-1) {
|
||||||
|
writer.charactersRaw(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
writer.printTagEnd(Tag.dd);
|
||||||
|
writer.printTagEnd(Tag.dl);
|
||||||
|
|
||||||
|
List<TreeNode> childs = xtree.findChilderen(node);
|
||||||
|
writer.printTagStart(Tag.dl);
|
||||||
|
writer.printTagCharacters(Tag.dt,"Element Childeren:");
|
||||||
|
writer.printTagStart(Tag.dd);
|
||||||
|
if (childs.isEmpty()) {
|
||||||
|
writer.characters("No childeren.");
|
||||||
|
}
|
||||||
|
for (int i=0;i<childs.size();i++) {
|
||||||
|
TreeNode n = childs.get(i);
|
||||||
|
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
|
||||||
|
writer.printHref(uri, n.namespace.getId()+":"+n.elementClass.getId());
|
||||||
|
if (i<childs.size()-1) {
|
||||||
|
writer.charactersRaw(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
writer.printTagEnd(Tag.dd);
|
||||||
|
writer.printTagEnd(Tag.dl);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String toElementUri(String pathPrefix,X4OLanguageModule mod,ElementNamespaceContext namespace,ElementClass ec) {
|
||||||
|
StringBuffer buf = new StringBuffer(100);
|
||||||
|
if (pathPrefix!=null) {
|
||||||
|
buf.append(pathPrefix);
|
||||||
|
}
|
||||||
|
buf.append(ApiDocContentWriter.toSafeUri(mod.getId()));
|
||||||
|
buf.append("/");
|
||||||
|
buf.append(ApiDocContentWriter.toSafeUri(namespace.getId()));
|
||||||
|
buf.append("/");
|
||||||
|
buf.append(ApiDocContentWriter.toSafeUri(ec.getId()));
|
||||||
|
buf.append("/index.html");
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.eld.doc;
|
||||||
|
|
||||||
|
import org.x4o.xml.eld.doc.api.ApiDocContentWriter;
|
||||||
|
import org.x4o.xml.eld.doc.api.ApiDocNodeWriterMethod;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocNode;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocNodeBody;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
|
||||||
|
import org.x4o.xml.element.ElementNamespaceContext;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EldDocWriterLanguage writer all content parts for the x4o language.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 29, 2013
|
||||||
|
*/
|
||||||
|
public class EldDocWriterLanguage {
|
||||||
|
|
||||||
|
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguageContext.class})
|
||||||
|
public void writeLanguageSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||||
|
ApiDocContentWriter writer = event.getWriter();
|
||||||
|
ApiDocNode node = event.getEvent();
|
||||||
|
X4OLanguageContext context = (X4OLanguageContext)node.getUserData();
|
||||||
|
int attrHandlers = 0;
|
||||||
|
int bindHandlers = 0;
|
||||||
|
int interFaces = 0;
|
||||||
|
int eleConfigs = 0;
|
||||||
|
int elements = 0;
|
||||||
|
int namespaces = 0;
|
||||||
|
for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) {
|
||||||
|
attrHandlers += mod.getElementAttributeHandlers().size();
|
||||||
|
bindHandlers += mod.getElementBindingHandlers().size();
|
||||||
|
interFaces += mod.getElementInterfaces().size();
|
||||||
|
eleConfigs += mod.getElementConfiguratorGlobals().size();
|
||||||
|
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
|
||||||
|
namespaces++;
|
||||||
|
elements += ns.getElementClasses().size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
writer.docTableStart("Language Summary", "Language Stats Summary.");
|
||||||
|
writer.docTableHeader("Name", "Value");
|
||||||
|
writer.docTableRow("LanguageName:", ""+context.getLanguage().getLanguageName(), null);
|
||||||
|
writer.docTableRow("LanguageVersion:",""+context.getLanguage().getLanguageVersion(),null);
|
||||||
|
writer.docTableRow("Modules:",""+context.getLanguage().getLanguageModules().size(),null);
|
||||||
|
writer.docTableRow("Namespaces:",""+namespaces,null);
|
||||||
|
writer.docTableRow("Elements:",""+elements,null);
|
||||||
|
writer.docTableRow("ElementInterfaces:",""+interFaces,null);
|
||||||
|
writer.docTableRow("ElementAttributeHandlers:",""+attrHandlers,null);
|
||||||
|
writer.docTableRow("ElementBindingHandlers:",""+bindHandlers,null);
|
||||||
|
writer.docTableRow("ElementConfigurators:",""+eleConfigs,null);
|
||||||
|
writer.docTableEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguageContext.class})
|
||||||
|
public void writeModulesSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||||
|
ApiDocContentWriter writer = event.getWriter();
|
||||||
|
ApiDocNode node = event.getEvent();
|
||||||
|
writer.docTableStart("Modules Summary", "All modules.");
|
||||||
|
writer.docTableHeader("Name", "Description");
|
||||||
|
for (ApiDocNode child:node.getNodes()) {
|
||||||
|
String link = ApiDocContentWriter.toSafeUri(child.getId())+"/index.html";
|
||||||
|
if (node.getParent()==null) {
|
||||||
|
link = ApiDocContentWriter.toSafeUri(node.getId())+"/"+link; // root node
|
||||||
|
}
|
||||||
|
writer.docTableRowHref(link,child.getName(),child.getDescription(),null);
|
||||||
|
}
|
||||||
|
writer.docTableEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguageContext.class})
|
||||||
|
public void writeNamespaceSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||||
|
ApiDocContentWriter writer = event.getWriter();
|
||||||
|
ApiDocNode node = event.getEvent();
|
||||||
|
X4OLanguageContext context = (X4OLanguageContext)node.getUserData();
|
||||||
|
writer.docTableStart("Namespace Summary", "All Language Namespaces Overview");
|
||||||
|
writer.docTableHeader("ID", "URI");
|
||||||
|
for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) {
|
||||||
|
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
|
||||||
|
writer.docTableRowHref("language/"+ApiDocContentWriter.toSafeUri(mod.getId())+"/"+ApiDocContentWriter.toSafeUri(ns.getId())+"/index.html",ns.getId(),ns.getUri(),null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
writer.docTableEnd();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,332 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.eld.doc;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.x4o.xml.eld.doc.api.ApiDocContentWriter;
|
||||||
|
import org.x4o.xml.eld.doc.api.DefaultPageWriterTree;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDoc;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocNode;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocPage;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocPageWriter;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
|
||||||
|
import org.x4o.xml.element.ElementBindingHandler;
|
||||||
|
import org.x4o.xml.element.ElementClass;
|
||||||
|
import org.x4o.xml.element.ElementInterface;
|
||||||
|
import org.x4o.xml.element.ElementNamespaceContext;
|
||||||
|
import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EldDocXTreePageWriter for dom overview of tree but as seperate page.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 29, 2013
|
||||||
|
*/
|
||||||
|
public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiDocPageWriter {
|
||||||
|
|
||||||
|
public static ApiDocPage createDocPage() {
|
||||||
|
return new ApiDocPage("overview-xtree","XTree","XTree of dom elements.",new EldDocXTreePageWriter());
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: rm this old tree code;
|
||||||
|
private void walkTree(TreeNode node,ApiDocContentWriter writer,String pathPrefix) throws SAXException {
|
||||||
|
String href = toElementUri(pathPrefix,node.module,node.namespace,node.elementClass);
|
||||||
|
|
||||||
|
writer.printTagStart(Tag.ul);
|
||||||
|
writer.printTagStart(Tag.li,"",null,"circle");
|
||||||
|
writer.characters(node.namespace.getId());
|
||||||
|
writer.characters(":");
|
||||||
|
writer.printHref(href, node.elementClass.getId(), node.elementClass.getId(), "strong");
|
||||||
|
writer.printTagEnd(Tag.li);
|
||||||
|
|
||||||
|
List<TreeNode> childs = findChilderen(node);
|
||||||
|
for (TreeNode child:childs) {
|
||||||
|
walkTree(child,writer,pathPrefix);
|
||||||
|
}
|
||||||
|
writer.printTagEnd(Tag.ul);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: remove this
|
||||||
|
* @see org.x4o.xml.eld.doc.api.DefaultPageWriterTree#writePageContent(org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException {
|
||||||
|
//selectRootNode(e.getDoc()); // create
|
||||||
|
ApiDoc doc = e.getDoc();
|
||||||
|
X4OLanguageContext context = (X4OLanguageContext)doc.getRootNode().getUserData();
|
||||||
|
|
||||||
|
String pathPrefix = "language/";
|
||||||
|
|
||||||
|
// temp print old way
|
||||||
|
List<TreeNode> rootNodes = new ArrayList<TreeNode>(3);
|
||||||
|
for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) {
|
||||||
|
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
|
||||||
|
if (ns.getLanguageRoot()!=null && ns.getLanguageRoot()) {
|
||||||
|
// found language root elements.
|
||||||
|
for (ElementClass ec:ns.getElementClasses()) {
|
||||||
|
TreeNode node = new TreeNode();
|
||||||
|
node.context=context;
|
||||||
|
node.module=mod;
|
||||||
|
node.namespace=ns;
|
||||||
|
node.elementClass=ec;
|
||||||
|
rootNodes.add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Collections.sort(rootNodes,new TreeNodeComparator());
|
||||||
|
for (TreeNode rootNode:rootNodes) {
|
||||||
|
walkTree(rootNode,e.getWriter(),pathPrefix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private String toElementUri(String pathPrefix,X4OLanguageModule mod,ElementNamespaceContext namespace,ElementClass ec) {
|
||||||
|
StringBuffer buf = new StringBuffer(100);
|
||||||
|
if (pathPrefix!=null) {
|
||||||
|
buf.append(pathPrefix);
|
||||||
|
}
|
||||||
|
buf.append(ApiDocContentWriter.toSafeUri(mod.getId()));
|
||||||
|
buf.append("/");
|
||||||
|
buf.append(ApiDocContentWriter.toSafeUri(namespace.getId()));
|
||||||
|
buf.append("/");
|
||||||
|
buf.append(ApiDocContentWriter.toSafeUri(ec.getId()));
|
||||||
|
buf.append("/index.html");
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overrided to select the dom view of the tree.
|
||||||
|
* @see org.x4o.xml.eld.doc.api.DefaultPageWriterTree#selectRootNode(org.x4o.xml.eld.doc.api.dom.ApiDoc)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected ApiDocNode selectRootNode(ApiDoc doc) {
|
||||||
|
try {
|
||||||
|
return createXTree(doc);
|
||||||
|
} catch (SAXException e) {
|
||||||
|
throw new IllegalStateException("Could not create XTree for: "+doc.getName()+" error: "+e.getMessage(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApiDocNode createXTree(ApiDoc doc) throws SAXException {
|
||||||
|
|
||||||
|
X4OLanguageContext context = (X4OLanguageContext)doc.getRootNode().getUserData();
|
||||||
|
ApiDocNode root = new ApiDocNode(context,"root","Root","Language root");
|
||||||
|
|
||||||
|
List<TreeNode> rootNodes = new ArrayList<TreeNode>(3);
|
||||||
|
for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) {
|
||||||
|
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
|
||||||
|
if (ns.getLanguageRoot()!=null && ns.getLanguageRoot()) {
|
||||||
|
// found language root elements.
|
||||||
|
for (ElementClass ec:ns.getElementClasses()) {
|
||||||
|
TreeNode node = new TreeNode();
|
||||||
|
node.context=context;
|
||||||
|
node.module=mod;
|
||||||
|
node.namespace=ns;
|
||||||
|
node.elementClass=ec;
|
||||||
|
rootNodes.add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Collections.sort(rootNodes,new TreeNodeComparator());
|
||||||
|
for (TreeNode rootNode:rootNodes) {
|
||||||
|
walkTree(rootNode,"../");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void walkTree(TreeNode node,String pathPrefix) throws SAXException {
|
||||||
|
//String href = toElementUri(pathPrefix,node.module,node.namespace,node.elementClass);
|
||||||
|
List<TreeNode> childs = findChilderen(node);
|
||||||
|
for (TreeNode child:childs) {
|
||||||
|
walkTree(child,pathPrefix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class TreeNode {
|
||||||
|
X4OLanguageContext context;
|
||||||
|
X4OLanguageModule module;
|
||||||
|
ElementNamespaceContext namespace;
|
||||||
|
ElementClass elementClass;
|
||||||
|
TreeNode parent;
|
||||||
|
int indent = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TreeNode> findChilderen(TreeNode node) {
|
||||||
|
List<TreeNode> result = new ArrayList<TreeNode>(10);
|
||||||
|
|
||||||
|
if (node.indent>20) {
|
||||||
|
return result; // hard fail limit
|
||||||
|
}
|
||||||
|
for (X4OLanguageModule mod:node.context.getLanguage().getLanguageModules()) {
|
||||||
|
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
|
||||||
|
for (ElementClass ec:ns.getElementClasses()) {
|
||||||
|
TreeNode n=null;
|
||||||
|
List<String> tags = ec.getElementParents(node.namespace.getUri());
|
||||||
|
if (tags!=null && tags.contains(node.elementClass.getId())) {
|
||||||
|
n = new TreeNode();
|
||||||
|
n.context=node.context;
|
||||||
|
n.module=mod;
|
||||||
|
n.namespace=ns;
|
||||||
|
n.elementClass=ec;
|
||||||
|
n.indent=node.indent+1;
|
||||||
|
n.parent=node;
|
||||||
|
} else {
|
||||||
|
if (ec.getObjectClass()==null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Check interfaces of parent , and see if child tag is there.
|
||||||
|
for (ElementInterface ei:node.context.getLanguage().findElementInterfaces(ec.getObjectClass())) {
|
||||||
|
List<String> eiTags = ei.getElementParents(node.namespace.getUri());
|
||||||
|
if (eiTags!=null && eiTags.contains(node.elementClass.getId())) {
|
||||||
|
n = new TreeNode();
|
||||||
|
n.context=node.context;
|
||||||
|
n.module=mod;
|
||||||
|
n.namespace=ns;
|
||||||
|
n.elementClass=ec;
|
||||||
|
n.indent=node.indent+1;
|
||||||
|
n.parent=node;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.elementClass.getObjectClass()==null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
List<ElementBindingHandler> binds = node.context.getLanguage().findElementBindingHandlers(node.elementClass.getObjectClass(), ec.getObjectClass());
|
||||||
|
if (binds.isEmpty()==false) {
|
||||||
|
n = new TreeNode();
|
||||||
|
n.context=node.context;
|
||||||
|
n.module=mod;
|
||||||
|
n.namespace=ns;
|
||||||
|
n.elementClass=ec;
|
||||||
|
n.indent=node.indent+1;
|
||||||
|
n.parent=node;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (n!=null && isInTree(node,n)==false) {
|
||||||
|
result.add(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Collections.sort(result,new TreeNodeComparator());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isInTree(TreeNode node,TreeNode checkNode) {
|
||||||
|
|
||||||
|
if ( node.namespace.getUri().equals(checkNode.namespace.getUri()) &&
|
||||||
|
node.elementClass.getId().equals(checkNode.elementClass.getId())
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (node.parent!=null) {
|
||||||
|
return isInTree(node.parent,checkNode);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TreeNode> findParents(TreeNode node) {
|
||||||
|
List<TreeNode> result = new ArrayList<TreeNode>(10);
|
||||||
|
TreeNode n=null;
|
||||||
|
for (X4OLanguageModule mod:node.context.getLanguage().getLanguageModules()) {
|
||||||
|
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
|
||||||
|
|
||||||
|
List<String> tags = node.elementClass.getElementParents(ns.getUri());
|
||||||
|
if (tags!=null) {
|
||||||
|
for (ElementClass ec:ns.getElementClasses()) {
|
||||||
|
if (tags.contains(ec.getId())) {
|
||||||
|
n = new TreeNode();
|
||||||
|
n.context=node.context;
|
||||||
|
n.module=mod;
|
||||||
|
n.namespace=ns;
|
||||||
|
n.elementClass=ec;
|
||||||
|
n.indent=node.indent+1;
|
||||||
|
n.parent=node;
|
||||||
|
result.add(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (ElementClass ec:ns.getElementClasses()) {
|
||||||
|
|
||||||
|
// Check interfaces of parent , and see if child tag is there.
|
||||||
|
if (node.elementClass.getObjectClass()!=null) {
|
||||||
|
for (ElementInterface ei:node.context.getLanguage().findElementInterfaces(node.elementClass.getObjectClass())) {
|
||||||
|
List<String> eiTags = ei.getElementParents(ns.getUri());
|
||||||
|
if (eiTags!=null && eiTags.contains(ec.getId())) {
|
||||||
|
n = new TreeNode();
|
||||||
|
n.context=node.context;
|
||||||
|
n.module=mod;
|
||||||
|
n.namespace=ns;
|
||||||
|
n.elementClass=ec;
|
||||||
|
n.indent=node.indent+1;
|
||||||
|
n.parent=node;
|
||||||
|
result.add(n);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ec.getObjectClass()==null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (node.elementClass.getObjectClass()==null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
List<ElementBindingHandler> binds = node.context.getLanguage().findElementBindingHandlers(ec.getObjectClass(),node.elementClass.getObjectClass());
|
||||||
|
if (binds.isEmpty()==false) {
|
||||||
|
n = new TreeNode();
|
||||||
|
n.context=node.context;
|
||||||
|
n.module=mod;
|
||||||
|
n.namespace=ns;
|
||||||
|
n.elementClass=ec;
|
||||||
|
n.indent=node.indent+1;
|
||||||
|
n.parent=node;
|
||||||
|
if (isInTree(node,n)==false) {
|
||||||
|
result.add(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Collections.sort(result,new TreeNodeComparator());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
class TreeNodeComparator implements Comparator<TreeNode> {
|
||||||
|
public int compare(TreeNode o1,TreeNode o2) {
|
||||||
|
return o1.elementClass.getId().compareTo(o2.elementClass.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -97,9 +97,9 @@ public class X4OWriteLanguageDocExecutor {
|
||||||
X4ODriver<?> driver = X4ODriverManager.getX4ODriver(getLanguageName());
|
X4ODriver<?> driver = X4ODriverManager.getX4ODriver(getLanguageName());
|
||||||
X4OLanguageContext context = driver.createLanguageContext(getLanguageVersion());
|
X4OLanguageContext context = driver.createLanguageContext(getLanguageVersion());
|
||||||
|
|
||||||
// Start doc generator
|
// Run doc writer
|
||||||
EldDocGenerator generator = new EldDocGenerator(context);
|
EldDocWriter docWriter = new EldDocWriter(context);
|
||||||
generator.writeDoc(getBasePath());
|
docWriter.writeDoc(getBasePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.eld.doc.api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApiDocContentCss defines the css style names used in api docs.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 20, 2013
|
||||||
|
*/
|
||||||
|
public enum ApiDocContentCss {
|
||||||
|
|
||||||
|
indexHeader,
|
||||||
|
indexContainer,
|
||||||
|
|
||||||
|
bar,
|
||||||
|
block,
|
||||||
|
blockList,
|
||||||
|
strong,
|
||||||
|
|
||||||
|
topNav,
|
||||||
|
bottomNav,
|
||||||
|
navList,
|
||||||
|
navBarCell1Rev,
|
||||||
|
subNav,
|
||||||
|
subNavList,
|
||||||
|
|
||||||
|
subTitle,
|
||||||
|
tabEnd,
|
||||||
|
|
||||||
|
aboutLanguage,
|
||||||
|
legalCopy,
|
||||||
|
|
||||||
|
inheritance,
|
||||||
|
header,
|
||||||
|
description,
|
||||||
|
summary,
|
||||||
|
details,
|
||||||
|
docSummary,
|
||||||
|
contentContainer,
|
||||||
|
packageSummary,
|
||||||
|
|
||||||
|
colOne,
|
||||||
|
colFirst,
|
||||||
|
colLast,
|
||||||
|
|
||||||
|
altColor,
|
||||||
|
rowColor,
|
||||||
|
|
||||||
|
// frame names maybe can be used to create frame-less html5 JS version
|
||||||
|
frameNavOverview,
|
||||||
|
frameNavDetail,
|
||||||
|
frameContent
|
||||||
|
}
|
|
@ -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.doc;
|
package org.x4o.xml.eld.doc.api;
|
||||||
|
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -29,7 +29,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.x4o.xml.io.sax.ContentWriterHtml;
|
import org.x4o.xml.io.sax.ext.ContentWriterHtml;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import org.xml.sax.helpers.AttributesImpl;
|
import org.xml.sax.helpers.AttributesImpl;
|
||||||
|
|
||||||
|
@ -39,16 +39,16 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Apr 30, 2013
|
* @version 1.0 Apr 30, 2013
|
||||||
*/
|
*/
|
||||||
public class ContentWriterDoc extends ContentWriterHtml {
|
public class ApiDocContentWriter extends ContentWriterHtml {
|
||||||
|
|
||||||
private boolean isAltRow = true;
|
private boolean isAltRow = true;
|
||||||
|
|
||||||
public ContentWriterDoc(Writer out,String encoding,String charNewLine,String charTab) {
|
public ApiDocContentWriter(Writer out,String encoding,String charNewLine,String charTab) {
|
||||||
super(out,encoding,charNewLine,charTab);
|
super(out,encoding,charNewLine,charTab);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void docCommentGenerated() throws SAXException {
|
public void docCommentGenerated() throws SAXException {
|
||||||
comment("Generated by "+ContentWriterDoc.class.getSimpleName()+" on "+new Date());
|
comment("Generated by "+ApiDocContentWriter.class.getSimpleName()+" on "+new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void docHtmlStart(NavBarConfig conf,String title,List<String> keywords) throws SAXException {
|
public void docHtmlStart(NavBarConfig conf,String title,List<String> keywords) throws SAXException {
|
||||||
|
@ -84,7 +84,7 @@ public class ContentWriterDoc extends ContentWriterHtml {
|
||||||
|
|
||||||
public void docHtmlEnd(NavBarConfig conf,String copyright) throws SAXException {
|
public void docHtmlEnd(NavBarConfig conf,String copyright) throws SAXException {
|
||||||
docNavBar(conf,false);
|
docNavBar(conf,false);
|
||||||
printTagStart(Tag.p,"legalCopy");
|
printTagStart(Tag.p,ApiDocContentCss.legalCopy);
|
||||||
printTagStart(Tag.small);
|
printTagStart(Tag.small);
|
||||||
charactersRaw(copyright);
|
charactersRaw(copyright);
|
||||||
printTagEnd(Tag.small);
|
printTagEnd(Tag.small);
|
||||||
|
@ -172,37 +172,47 @@ public class ContentWriterDoc extends ContentWriterHtml {
|
||||||
String selectedCss = null;
|
String selectedCss = null;
|
||||||
if (navKey.equals(conf.navSelected)) {
|
if (navKey.equals(conf.navSelected)) {
|
||||||
selectedCss = "navBarCell1Rev";
|
selectedCss = "navBarCell1Rev";
|
||||||
|
navLink = null; // disables link
|
||||||
}
|
}
|
||||||
if (navLink==null) {
|
if (navLink==null) {
|
||||||
printTagText(Tag.li, navName, selectedCss);
|
printTagCharacters(Tag.li, navName, selectedCss);
|
||||||
} else {
|
} else {
|
||||||
docNavBarListItemHref(pathPrefix+navLink,navName,selectedCss);
|
docNavBarListItemHref(pathPrefix+navLink,navName,selectedCss);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
endElement("", "ul", "");
|
endElement("", "ul", "");
|
||||||
|
|
||||||
printTagStart(Tag.div,"aboutLanguage"); // Print about language
|
printTagStart(Tag.div,ApiDocContentCss.aboutLanguage); // Print about language
|
||||||
printTagStart(Tag.em);
|
printTagStart(Tag.em);
|
||||||
printTagStart(Tag.strong);charactersRaw(conf.aboutLanguage);printTagEnd(Tag.strong);
|
printTagStart(Tag.strong);
|
||||||
|
for (int i=0;i<conf.aboutLanguage.length();i++) {
|
||||||
|
char c = conf.aboutLanguage.charAt(i);
|
||||||
|
if (c=='\n') {
|
||||||
|
printTagStartEnd(Tag.br);
|
||||||
|
} else {
|
||||||
|
characters(c);// TODO: use buffer so char entities are not escaped.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printTagEnd(Tag.strong);
|
||||||
printTagEnd(Tag.em);
|
printTagEnd(Tag.em);
|
||||||
printTagEnd(Tag.div);
|
printTagEnd(Tag.div);
|
||||||
printTagEnd(Tag.div); // end barCssDiv
|
printTagEnd(Tag.div); // end barCssDiv
|
||||||
|
|
||||||
printTagStart(Tag.div,"subNav");
|
printTagStart(Tag.div,ApiDocContentCss.subNav);
|
||||||
printTagStart(Tag.ul,"navList");
|
printTagStart(Tag.ul,ApiDocContentCss.navList);
|
||||||
if (conf.prev==null) {
|
if (conf.prev==null) {
|
||||||
printTagText(Tag.li, "Prev");
|
printTagCharacters(Tag.li, "Prev");
|
||||||
} else {
|
} else {
|
||||||
docNavBarListItemHref(pathPrefix+conf.prev,"Prev",null,"strong",null);
|
docNavBarListItemHref(pathPrefix+conf.prev,"Prev",null,"strong",null);
|
||||||
}
|
}
|
||||||
if (conf.next==null) {
|
if (conf.next==null) {
|
||||||
printTagText(Tag.li, "Next");
|
printTagCharacters(Tag.li, "Next");
|
||||||
} else {
|
} else {
|
||||||
docNavBarListItemHref(pathPrefix+conf.next,"Next",null,"strong",null);
|
docNavBarListItemHref(pathPrefix+conf.next,"Next",null,"strong",null);
|
||||||
}
|
}
|
||||||
printTagEnd(Tag.ul);
|
printTagEnd(Tag.ul);
|
||||||
if (conf.frame!=null) {
|
if (conf.frame!=null) {
|
||||||
printTagStart(Tag.ul,"navList");
|
printTagStart(Tag.ul,ApiDocContentCss.navList);
|
||||||
printTagStart(Tag.li);
|
printTagStart(Tag.li);
|
||||||
printHrefTarget(pathPrefix+"index.html?"+conf.frame, "Frames", "_top");
|
printHrefTarget(pathPrefix+"index.html?"+conf.frame, "Frames", "_top");
|
||||||
printTagEnd(Tag.li);
|
printTagEnd(Tag.li);
|
||||||
|
@ -212,7 +222,7 @@ public class ContentWriterDoc extends ContentWriterHtml {
|
||||||
printTagEnd(Tag.ul);
|
printTagEnd(Tag.ul);
|
||||||
}
|
}
|
||||||
if (conf.noFrameAllName!=null && conf.noFrameAllLink!=null) {
|
if (conf.noFrameAllName!=null && conf.noFrameAllLink!=null) {
|
||||||
printTagStart(Tag.ul,"navList","allclasses_"+barId);
|
printTagStart(Tag.ul,ApiDocContentCss.navList,"allclasses_"+barId);
|
||||||
docNavBarListItemHref(pathPrefix+conf.noFrameAllLink,conf.noFrameAllName,null,null,null);
|
docNavBarListItemHref(pathPrefix+conf.noFrameAllLink,conf.noFrameAllName,null,null,null);
|
||||||
printTagEnd(Tag.ul);
|
printTagEnd(Tag.ul);
|
||||||
printTagStart(Tag.div);
|
printTagStart(Tag.div);
|
||||||
|
@ -227,44 +237,44 @@ public class ContentWriterDoc extends ContentWriterHtml {
|
||||||
boolean printLink = conf.linkConstructors || conf.linkFields || conf.linkMethods;
|
boolean printLink = conf.linkConstructors || conf.linkFields || conf.linkMethods;
|
||||||
if (printLink) {
|
if (printLink) {
|
||||||
printTagStart(Tag.div);
|
printTagStart(Tag.div);
|
||||||
printTagStart(Tag.ul,"subNavList");
|
printTagStart(Tag.ul,ApiDocContentCss.subNavList);
|
||||||
printTagStart(Tag.li);charactersRaw("Summary: ");printTagEnd(Tag.li);
|
printTagStart(Tag.li);charactersRaw("Summary: ");printTagEnd(Tag.li);
|
||||||
//printTagText(Tag.li,"Nested | "); // TODO: Nested
|
//printTagText(Tag.li,"Nested | "); // TODO: Nested
|
||||||
if (conf.linkFields) {
|
if (conf.linkFields) {
|
||||||
docNavBarListItemHref("#field_summary",conf.linkFieldName,null,null,tabSpace);
|
docNavBarListItemHref("#field_summary",conf.linkFieldName,null,null,tabSpace);
|
||||||
} else {
|
} else {
|
||||||
printTagText(Tag.li,conf.linkFieldName);charactersRaw(tabSpace);
|
printTagCharacters(Tag.li,conf.linkFieldName);charactersRaw(tabSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conf.linkConstructors) {
|
if (conf.linkConstructors) {
|
||||||
docNavBarListItemHref("#constructor_summary",conf.linkConstructorName,null,null,tabSpace);
|
docNavBarListItemHref("#constructor_summary",conf.linkConstructorName,null,null,tabSpace);
|
||||||
} else {
|
} else {
|
||||||
printTagText(Tag.li,conf.linkConstructorName);charactersRaw(tabSpace);
|
printTagCharacters(Tag.li,conf.linkConstructorName);charactersRaw(tabSpace);
|
||||||
}
|
}
|
||||||
if (conf.linkMethods) {
|
if (conf.linkMethods) {
|
||||||
docNavBarListItemHref("#method_summary",conf.linkMethodName,null);
|
docNavBarListItemHref("#method_summary",conf.linkMethodName,null);
|
||||||
} else {
|
} else {
|
||||||
printTagText(Tag.li,conf.linkMethodName);
|
printTagCharacters(Tag.li,conf.linkMethodName);
|
||||||
}
|
}
|
||||||
printTagEnd(Tag.ul);
|
printTagEnd(Tag.ul);
|
||||||
if (conf.linkDetails){
|
if (conf.linkDetails){
|
||||||
printTagStart(Tag.ul,"subNavList");
|
printTagStart(Tag.ul,ApiDocContentCss.subNavList);
|
||||||
printTagStart(Tag.li);charactersRaw("Detail: ");printTagEnd(Tag.li);
|
printTagStart(Tag.li);charactersRaw("Detail: ");printTagEnd(Tag.li);
|
||||||
//printTagText(Tag.li,"Nested | ");
|
//printTagText(Tag.li,"Nested | ");
|
||||||
if (conf.linkFields) {
|
if (conf.linkFields) {
|
||||||
docNavBarListItemHref("#field_detail",conf.linkFieldName,null,null,tabSpace);
|
docNavBarListItemHref("#field_detail",conf.linkFieldName,null,null,tabSpace);
|
||||||
} else {
|
} else {
|
||||||
printTagText(Tag.li,conf.linkFieldName);charactersRaw(tabSpace);
|
printTagCharacters(Tag.li,conf.linkFieldName);charactersRaw(tabSpace);
|
||||||
}
|
}
|
||||||
if (conf.linkConstructors) {
|
if (conf.linkConstructors) {
|
||||||
docNavBarListItemHref("#constructor_detail",conf.linkConstructorName,null,null,tabSpace);
|
docNavBarListItemHref("#constructor_detail",conf.linkConstructorName,null,null,tabSpace);
|
||||||
} else {
|
} else {
|
||||||
printTagText(Tag.li,conf.linkConstructorName);charactersRaw(tabSpace);
|
printTagCharacters(Tag.li,conf.linkConstructorName);charactersRaw(tabSpace);
|
||||||
}
|
}
|
||||||
if (conf.linkMethods) {
|
if (conf.linkMethods) {
|
||||||
docNavBarListItemHref("#method_detail",conf.linkMethodName,null);
|
docNavBarListItemHref("#method_detail",conf.linkMethodName,null);
|
||||||
} else {
|
} else {
|
||||||
printTagText(Tag.li,conf.linkMethodName);
|
printTagCharacters(Tag.li,conf.linkMethodName);
|
||||||
}
|
}
|
||||||
printTagEnd(Tag.ul);
|
printTagEnd(Tag.ul);
|
||||||
}
|
}
|
||||||
|
@ -287,35 +297,34 @@ public class ContentWriterDoc extends ContentWriterHtml {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void docPagePackageTitle(String title,String summary) throws SAXException {
|
public void docPagePackageTitle(String title,String summary) throws SAXException {
|
||||||
printTagStart(Tag.div,"header");
|
printTagStart(Tag.div,ApiDocContentCss.header);
|
||||||
printTagText(Tag.h1, title,"title");
|
printTagCharacters(Tag.h1, title,"title");
|
||||||
printTagStart(Tag.div,"docSummary");
|
printTagStart(Tag.div,ApiDocContentCss.docSummary);
|
||||||
printTagText(Tag.div, summary,"block");
|
printTagCharacters(Tag.div, summary,ApiDocContentCss.block.name());
|
||||||
printTagEnd(Tag.div);
|
printTagEnd(Tag.div);
|
||||||
printTagStart(Tag.p);
|
printTagStart(Tag.p);
|
||||||
charactersRaw("See: ");
|
charactersRaw("See: ");
|
||||||
printHref("#package_description", "Description");
|
printHref("#package_description", "Description");
|
||||||
printTagEnd(Tag.p);
|
printTagEnd(Tag.p);
|
||||||
printTagEnd(Tag.div);
|
printTagEnd(Tag.div);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void docPagePackageDescription(String title,String summary,String description) throws SAXException {
|
public void docPagePackageDescription(String title,String summary,String description) throws SAXException {
|
||||||
printHrefNamed("package_description");
|
printHrefNamed("package_description");
|
||||||
printTagText(Tag.h2, title);
|
printTagCharacters(Tag.h2, title);
|
||||||
printTagText(Tag.div, summary,"block");
|
printTagCharacters(Tag.div, summary,ApiDocContentCss.block.name());
|
||||||
characters(description);
|
characters(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void docPageClassStart(String title,String subTitle) throws SAXException {
|
public void docPageClassStart(String title,String subTitle) throws SAXException {
|
||||||
comment("======== START OF CLASS DATA ========");
|
comment("======== START OF CLASS DATA ========");
|
||||||
printTagStart(Tag.div,"header");
|
printTagStart(Tag.div,ApiDocContentCss.header);
|
||||||
if (subTitle!=null) {
|
if (subTitle!=null) {
|
||||||
printTagStart(Tag.div,"subTitle");
|
printTagStart(Tag.div,ApiDocContentCss.subTitle);
|
||||||
characters(subTitle);
|
characters(subTitle);
|
||||||
printTagEnd(Tag.div);
|
printTagEnd(Tag.div);
|
||||||
}
|
}
|
||||||
printTagText(Tag.h2, title, "title");
|
printTagCharacters(Tag.h2, title, "title");
|
||||||
printTagEnd(Tag.div);
|
printTagEnd(Tag.div);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,7 +333,7 @@ public class ContentWriterDoc extends ContentWriterHtml {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void docPageContentStart() throws SAXException {
|
public void docPageContentStart() throws SAXException {
|
||||||
printTagStart(Tag.div,"contentContainer");
|
printTagStart(Tag.div,ApiDocContentCss.contentContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void docPageContentEnd() throws SAXException {
|
public void docPageContentEnd() throws SAXException {
|
||||||
|
@ -337,12 +346,12 @@ public class ContentWriterDoc extends ContentWriterHtml {
|
||||||
}
|
}
|
||||||
docPageBlockStart();
|
docPageBlockStart();
|
||||||
printHrefNamed(namedLink);
|
printHrefNamed(namedLink);
|
||||||
printTagText(Tag.h3, title);
|
printTagCharacters(Tag.h3, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void docPageBlockStart() throws SAXException {
|
public void docPageBlockStart() throws SAXException {
|
||||||
printTagStart(Tag.ul,"blockList");
|
printTagStart(Tag.ul,ApiDocContentCss.blockList);
|
||||||
printTagStart(Tag.li,"blockList");
|
printTagStart(Tag.li,ApiDocContentCss.blockList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void docPageBlockEnd() throws SAXException {
|
public void docPageBlockEnd() throws SAXException {
|
||||||
|
@ -352,7 +361,7 @@ public class ContentWriterDoc extends ContentWriterHtml {
|
||||||
|
|
||||||
public void docPageBlockNext() throws SAXException {
|
public void docPageBlockNext() throws SAXException {
|
||||||
printTagEnd(Tag.li);
|
printTagEnd(Tag.li);
|
||||||
printTagStart(Tag.li,"blockList");
|
printTagStart(Tag.li,ApiDocContentCss.blockList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void docTableStart(String tableTitle,String tableDescription) throws SAXException {
|
public void docTableStart(String tableTitle,String tableDescription) throws SAXException {
|
||||||
|
@ -368,7 +377,7 @@ public class ContentWriterDoc extends ContentWriterHtml {
|
||||||
|
|
||||||
printTagStart(Tag.caption);
|
printTagStart(Tag.caption);
|
||||||
printTagStart(Tag.span);characters(tableTitle);printTagEnd(Tag.span);
|
printTagStart(Tag.span);characters(tableTitle);printTagEnd(Tag.span);
|
||||||
printTagStart(Tag.span,"tabEnd");charactersRaw(" ");printTagEnd(Tag.span);
|
printTagStart(Tag.span,ApiDocContentCss.tabEnd);charactersRaw(" ");printTagEnd(Tag.span);
|
||||||
printTagEnd(Tag.caption);
|
printTagEnd(Tag.caption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,18 +419,17 @@ public class ContentWriterDoc extends ContentWriterHtml {
|
||||||
docTableRowHref(null,dataFirst,dataLast,dataBlock);
|
docTableRowHref(null,dataFirst,dataLast,dataBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void docTableRowHref(String dataFirstHref,String dataFirst,String dataLast,String dataBlock) throws SAXException {
|
public void docTableRowHref(String dataFirstHref,String dataFirst,String dataLast,String dataBlock) throws SAXException {
|
||||||
if (isAltRow) {
|
if (isAltRow) {
|
||||||
printTagStart(Tag.tr,"altColor");
|
printTagStart(Tag.tr,ApiDocContentCss.altColor);
|
||||||
} else {
|
} else {
|
||||||
printTagStart(Tag.tr,"rowColor");
|
printTagStart(Tag.tr,ApiDocContentCss.rowColor);
|
||||||
}
|
}
|
||||||
isAltRow = !isAltRow;
|
isAltRow = !isAltRow;
|
||||||
if (dataLast==null) {
|
if (dataLast==null) {
|
||||||
printTagStart(Tag.td,"colOne");
|
printTagStart(Tag.td,ApiDocContentCss.colOne);
|
||||||
} else {
|
} else {
|
||||||
printTagStart(Tag.td,"colFirst");
|
printTagStart(Tag.td,ApiDocContentCss.colFirst);
|
||||||
}
|
}
|
||||||
printTagStart(Tag.code);
|
printTagStart(Tag.code);
|
||||||
if (dataFirstHref==null) {
|
if (dataFirstHref==null) {
|
||||||
|
@ -437,13 +445,62 @@ public class ContentWriterDoc extends ContentWriterHtml {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printTagStart(Tag.td,"colLast");
|
printTagStart(Tag.td,ApiDocContentCss.colLast);
|
||||||
printTagStart(Tag.code);characters(dataLast);printTagEnd(Tag.code);
|
printTagStart(Tag.code);characters(dataLast);printTagEnd(Tag.code);
|
||||||
if (dataBlock!=null) {
|
if (dataBlock!=null) {
|
||||||
printTagStart(Tag.div,"block");characters(dataBlock);printTagEnd(Tag.div);
|
printTagStart(Tag.div,ApiDocContentCss.block);characters(dataBlock);printTagEnd(Tag.div);
|
||||||
}
|
}
|
||||||
printTagEnd(Tag.td);
|
printTagEnd(Tag.td);
|
||||||
|
|
||||||
printTagEnd(Tag.tr);
|
printTagEnd(Tag.tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static public String toSafeUri(List<String> paths) {
|
||||||
|
return toSafeUri(paths.toArray(new String[]{}));
|
||||||
|
}
|
||||||
|
|
||||||
|
static public String toSafeUri(String...paths) {
|
||||||
|
StringBuffer result = new StringBuffer(100);
|
||||||
|
for (int i=0;i<paths.length;i++) {
|
||||||
|
String path=paths[i];
|
||||||
|
result.append(toSafeUri(path));
|
||||||
|
if (i<(paths.length-1)) {
|
||||||
|
result.append('/');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
static public String toSafeUri(String uri) {
|
||||||
|
StringBuilder buf = new StringBuilder(20);
|
||||||
|
for (char c:uri.toLowerCase().toCharArray()) {
|
||||||
|
if (Character.isLetter(c)) {
|
||||||
|
buf.append(c);
|
||||||
|
}
|
||||||
|
if (Character.isDigit(c)) {
|
||||||
|
buf.append(c);
|
||||||
|
}
|
||||||
|
if ('.'==c) {
|
||||||
|
buf.append(c);
|
||||||
|
}
|
||||||
|
if ('-'==c) {
|
||||||
|
buf.append(c);
|
||||||
|
}
|
||||||
|
if ('_'==c) {
|
||||||
|
buf.append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String prefix = buf.toString();
|
||||||
|
if (prefix.startsWith("http")) {
|
||||||
|
prefix = prefix.substring(4);
|
||||||
|
}
|
||||||
|
if (prefix.startsWith("uri")) {
|
||||||
|
prefix = prefix.substring(3);
|
||||||
|
}
|
||||||
|
if (prefix.startsWith("url")) {
|
||||||
|
prefix = prefix.substring(3);
|
||||||
|
}
|
||||||
|
return prefix;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,198 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.eld.doc.api;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDoc;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocNode;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocNodeBody;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocNodeWriter;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApiDocNodeWriterBean wraps the ApiDocNodeWriterEvent to a single method of a bean.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 1, 2013
|
||||||
|
*/
|
||||||
|
public class ApiDocNodeWriterBean implements ApiDocNodeWriter {
|
||||||
|
|
||||||
|
private ApiDocNodeBody nodeBody = null;
|
||||||
|
private Integer nodeBodyOrder = null;
|
||||||
|
private Object bean = null;
|
||||||
|
private String method = null;
|
||||||
|
private List<Class<?>> targetClasses = null;
|
||||||
|
private String contentGroup = null;
|
||||||
|
private String contentGroupType = null;
|
||||||
|
|
||||||
|
public ApiDocNodeWriterBean() {
|
||||||
|
targetClasses = new ArrayList<Class<?>>(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiDocNodeWriterBean(ApiDocNodeBody nodeBody,Object bean,String method,Class<?>...classes) {
|
||||||
|
this();
|
||||||
|
this.nodeBody=nodeBody;
|
||||||
|
this.bean=bean;
|
||||||
|
this.method=method;
|
||||||
|
if (classes!=null && classes.length>0) {
|
||||||
|
targetClasses.addAll(Arrays.asList(classes));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addAnnotatedNodeContentWriters(ApiDoc doc,Object bean) {
|
||||||
|
if (doc==null) {
|
||||||
|
throw new NullPointerException("Can't add to null ApiDoc.");
|
||||||
|
}
|
||||||
|
if (bean==null) {
|
||||||
|
throw new NullPointerException("Can't scan null bean.");
|
||||||
|
}
|
||||||
|
for (Method method:bean.getClass().getMethods()) {
|
||||||
|
ApiDocNodeWriterMethod ammo = method.getAnnotation(ApiDocNodeWriterMethod.class);
|
||||||
|
if (ammo==null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ApiDocNodeWriterBean methodWriter = new ApiDocNodeWriterBean(ammo.nodeBody(), bean, method.getName(), ammo.targetClasses());
|
||||||
|
if (ammo.nodeBodyOrder()!=-1) {
|
||||||
|
methodWriter.setNodeBodyOrder(ammo.nodeBodyOrder());
|
||||||
|
}
|
||||||
|
if (!ammo.contentGroup().isEmpty()) {
|
||||||
|
methodWriter.setContentGroup(ammo.contentGroup());
|
||||||
|
}
|
||||||
|
if (!ammo.contentGroupType().isEmpty()) {
|
||||||
|
methodWriter.setContentGroupType(ammo.contentGroupType());
|
||||||
|
}
|
||||||
|
doc.addNodeBodyWriter(methodWriter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeNodeContent(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||||
|
Class<?> beanClass = bean.getClass();
|
||||||
|
try {
|
||||||
|
Method methodBean = beanClass.getMethod(method, new Class[]{ApiDocWriteEvent.class});
|
||||||
|
methodBean.invoke(bean, new Object[]{event});
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new SAXException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addtargetClass(Class<?> targetClass) {
|
||||||
|
targetClasses.add(targetClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removetargetClass(Class<?> targetClass) {
|
||||||
|
targetClasses.remove(targetClasses);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Class<?>> getTargetClasses() {
|
||||||
|
return targetClasses;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the nodeBody
|
||||||
|
*/
|
||||||
|
public ApiDocNodeBody getNodeBody() {
|
||||||
|
return nodeBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param nodeBody the nodeBody to set
|
||||||
|
*/
|
||||||
|
public void setNodeBody(ApiDocNodeBody nodeBody) {
|
||||||
|
this.nodeBody = nodeBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the bean
|
||||||
|
*/
|
||||||
|
public Object getBean() {
|
||||||
|
return bean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bean the bean to set
|
||||||
|
*/
|
||||||
|
public void setBean(Object bean) {
|
||||||
|
this.bean = bean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the method
|
||||||
|
*/
|
||||||
|
public String getMethod() {
|
||||||
|
return method;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param method the method to set
|
||||||
|
*/
|
||||||
|
public void setMethod(String method) {
|
||||||
|
this.method = method;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the nodeBodyOrder
|
||||||
|
*/
|
||||||
|
public Integer getNodeBodyOrder() {
|
||||||
|
return nodeBodyOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param nodeBodyOrder the nodeBodyOrder to set
|
||||||
|
*/
|
||||||
|
public void setNodeBodyOrder(Integer nodeBodyOrder) {
|
||||||
|
this.nodeBodyOrder = nodeBodyOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the contentGroup
|
||||||
|
*/
|
||||||
|
public String getContentGroup() {
|
||||||
|
return contentGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param contentGroup the contentGroup to set
|
||||||
|
*/
|
||||||
|
public void setContentGroup(String contentGroup) {
|
||||||
|
this.contentGroup = contentGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the contentGroupType
|
||||||
|
*/
|
||||||
|
public String getContentGroupType() {
|
||||||
|
return contentGroupType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param contentGroupType the contentGroupType to set
|
||||||
|
*/
|
||||||
|
public void setContentGroupType(String contentGroupType) {
|
||||||
|
this.contentGroupType = contentGroupType;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.x4o.xml.eld.doc.api;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocNodeBody;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApiDocNodeBodyWriterMethod wraps api doc file writer events to a method.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 19, 2013
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target({ElementType.METHOD})
|
||||||
|
public @interface ApiDocNodeWriterMethod {
|
||||||
|
|
||||||
|
Class<?>[] targetClasses();
|
||||||
|
|
||||||
|
ApiDocNodeBody nodeBody();
|
||||||
|
|
||||||
|
int nodeBodyOrder() default -1;
|
||||||
|
|
||||||
|
String contentGroup() default "";
|
||||||
|
|
||||||
|
String contentGroupType() default "";
|
||||||
|
}
|
|
@ -0,0 +1,810 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.eld.doc.api;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.x4o.xml.eld.doc.api.ApiDocContentWriter.NavBarConfig;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDoc;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocConcept;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocNode;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocNodeBody;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocNodeWriter;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocPage;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocPageWriter;
|
||||||
|
import org.x4o.xml.io.XMLConstants;
|
||||||
|
import org.x4o.xml.io.sax.ext.ContentWriterHtml.DocType;
|
||||||
|
import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageClassLoader;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
import org.xml.sax.helpers.AttributesImpl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApiDocWriter creates all output files for the ApiDoc.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 1, 2013
|
||||||
|
*/
|
||||||
|
public class ApiDocWriter {
|
||||||
|
|
||||||
|
private ApiDoc doc = null;
|
||||||
|
private File basePath = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes full api doc tree files to the base path.
|
||||||
|
* @param doc The ApiDoc to writer.
|
||||||
|
* @param basePath The bath path to write into.
|
||||||
|
* @throws IOException When file exception happens.
|
||||||
|
* @throws SAXException when xml exception happens.
|
||||||
|
*/
|
||||||
|
public void write(ApiDoc doc,File basePath) throws IOException,SAXException {
|
||||||
|
if (doc==null) {
|
||||||
|
throw new NullPointerException("Can't write with null ApiDoc.");
|
||||||
|
}
|
||||||
|
if (basePath==null) {
|
||||||
|
throw new NullPointerException("Can't write with null basePath.");
|
||||||
|
}
|
||||||
|
this.doc=doc;
|
||||||
|
this.basePath=basePath;
|
||||||
|
|
||||||
|
// Write root and resource files
|
||||||
|
writeStyleSheet();
|
||||||
|
writeIndex();
|
||||||
|
writeOverviewFrame();
|
||||||
|
writeAllFrameNav(true);
|
||||||
|
writeAllFrameNav(false);
|
||||||
|
|
||||||
|
// Write pages
|
||||||
|
for (ApiDocPage page:doc.getDocPages()) {
|
||||||
|
writePage(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write api doc tree
|
||||||
|
writeNode(doc.getRootNode());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeNode(ApiDocNode node) throws SAXException {
|
||||||
|
ApiDocConcept concept = findConceptByClass(node.getUserData().getClass());
|
||||||
|
if (concept==null) {
|
||||||
|
//System.out.println("----- no concept found for: "+node.getId()+" data: "+node.getUserData());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<String> path = new ArrayList<String>(10);
|
||||||
|
buildParentPath(node,path);
|
||||||
|
if (path.size()==1) {
|
||||||
|
path.remove(path.size()-1);
|
||||||
|
path.add("overview-"+node.getId()+".html");
|
||||||
|
} else {
|
||||||
|
path.add("index.html");
|
||||||
|
}
|
||||||
|
String pathPrefix = "";
|
||||||
|
for (int i=1;i<path.size();i++) {
|
||||||
|
pathPrefix += "../";
|
||||||
|
}
|
||||||
|
File outputFile = createOutputPathFile(basePath,path.toArray(new String[]{}));
|
||||||
|
ApiDocContentWriter writer = createContentWriter(outputFile);
|
||||||
|
NavBarConfig config = createNavBarConfig(pathPrefix, outputFile, writer);
|
||||||
|
|
||||||
|
config.navSelected=concept.getId();
|
||||||
|
configActiveNavConceptLinks(config,node,concept,"/..");
|
||||||
|
configNextPrevLinks(config,node);
|
||||||
|
|
||||||
|
ApiDocWriteEvent<ApiDocNode> bodyEvent = new ApiDocWriteEvent<ApiDocNode>(doc,writer,node);
|
||||||
|
String title = node.getId();
|
||||||
|
String titleSub = null;
|
||||||
|
if (node.getParent()!=null) {
|
||||||
|
titleSub = node.getParent().getId()+":"+node.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write node file
|
||||||
|
writer.docHtmlStart(config,title, doc.getDocKeywords());
|
||||||
|
writer.docPageClassStart(title, titleSub);
|
||||||
|
writer.docPageContentStart();
|
||||||
|
writeNodeTreePath(bodyEvent);
|
||||||
|
writeNodeDescription(bodyEvent);
|
||||||
|
writeNodeSummary(bodyEvent);
|
||||||
|
writeNodeDetails(bodyEvent);
|
||||||
|
writer.docPageContentEnd();
|
||||||
|
writer.docPageClassEnd();
|
||||||
|
writer.docHtmlEnd(config,doc.getDocCopyright());
|
||||||
|
writer.closeWriterSafe();
|
||||||
|
|
||||||
|
// Writer other files
|
||||||
|
writeAllFrameNavNode(node);
|
||||||
|
for (ApiDocNode child:node.getNodes()) {
|
||||||
|
writeNode(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeNodeTreePath(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||||
|
List<ApiDocNodeWriter> bodyWriterTreePath = findNodeBodyWriters(event.getEvent(),ApiDocNodeBody.TREE_PATH);
|
||||||
|
if (bodyWriterTreePath.isEmpty()) {
|
||||||
|
defaultWriteTreePath(event.getEvent(),event.getWriter());
|
||||||
|
}
|
||||||
|
for (int i=0;i<bodyWriterTreePath.size();i++) {
|
||||||
|
ApiDocNodeWriter nodeWriter = bodyWriterTreePath.get(i);
|
||||||
|
nodeWriter.writeNodeContent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void defaultWriteNodeDescription(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||||
|
event.getWriter().characters(event.getEvent().getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeNodeDescription(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||||
|
ApiDocContentWriter writer = event.getWriter();
|
||||||
|
List<ApiDocNodeWriter> bodyWriterDescriptionLinks = findNodeBodyWriters(event.getEvent(),ApiDocNodeBody.DESCRIPTION_LINKS);
|
||||||
|
List<ApiDocNodeWriter> bodyWriterDescriptionNode = findNodeBodyWriters(event.getEvent(),ApiDocNodeBody.DESCRIPTION_NODE);
|
||||||
|
writer.printTagStart(Tag.div, ApiDocContentCss.description);
|
||||||
|
writer.docPageBlockStart();
|
||||||
|
if (bodyWriterDescriptionLinks.isEmpty()) {
|
||||||
|
//defaultWriteTreePath(node,writer);
|
||||||
|
}
|
||||||
|
for (int i=0;i<bodyWriterDescriptionLinks.size();i++) {
|
||||||
|
ApiDocNodeWriter nodeWriter = bodyWriterDescriptionLinks.get(i);
|
||||||
|
nodeWriter.writeNodeContent(event);
|
||||||
|
}
|
||||||
|
writer.printTagStartEnd(Tag.hr);
|
||||||
|
writer.printTagStartEnd(Tag.br); // mmm
|
||||||
|
if (bodyWriterDescriptionNode.isEmpty()) {
|
||||||
|
defaultWriteNodeDescription(event);
|
||||||
|
}
|
||||||
|
for (int i=0;i<bodyWriterDescriptionNode.size();i++) {
|
||||||
|
ApiDocNodeWriter nodeWriter = bodyWriterDescriptionNode.get(i);
|
||||||
|
nodeWriter.writeNodeContent(event);
|
||||||
|
}
|
||||||
|
writer.docPageBlockEnd();
|
||||||
|
writer.printTagEnd(Tag.div); // description
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeNodeSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||||
|
ApiDocContentWriter writer = event.getWriter();
|
||||||
|
List<ApiDocNodeWriter> bodyWriterSummary = findNodeBodyWriters(event.getEvent(),ApiDocNodeBody.SUMMARY);
|
||||||
|
writer.printTagStart(Tag.div, ApiDocContentCss.summary);
|
||||||
|
writer.docPageBlockStart();
|
||||||
|
if (bodyWriterSummary.isEmpty()) {
|
||||||
|
writer.docPageBlockStart();
|
||||||
|
defaultWriteSummary(event.getEvent(),writer);
|
||||||
|
writer.docPageBlockEnd();
|
||||||
|
}
|
||||||
|
for (int i=0;i<bodyWriterSummary.size();i++) {
|
||||||
|
writer.docPageBlockStart();
|
||||||
|
writer.printTagCharacters(Tag.h3, "Summary");
|
||||||
|
ApiDocNodeWriter nodeWriter = bodyWriterSummary.get(i);
|
||||||
|
nodeWriter.writeNodeContent(event);
|
||||||
|
writer.docPageBlockEnd();
|
||||||
|
}
|
||||||
|
writer.docPageBlockEnd();
|
||||||
|
writer.printTagEnd(Tag.div); // Summary
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeNodeDetails(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||||
|
ApiDocContentWriter writer = event.getWriter();
|
||||||
|
List<ApiDocNodeWriter> bodyWriterDetail = findNodeBodyWriters(event.getEvent(),ApiDocNodeBody.DETAIL);
|
||||||
|
if (bodyWriterDetail.isEmpty()) {
|
||||||
|
return;// no default ..
|
||||||
|
}
|
||||||
|
writer.printTagStart(Tag.div, ApiDocContentCss.details);
|
||||||
|
writer.docPageBlockStart();
|
||||||
|
//if (bodyWriterDetail.isEmpty()) {
|
||||||
|
// writer.docPageBlockStart();
|
||||||
|
// defaultWriteDetailNode(node,writer);
|
||||||
|
// writer.docPageBlockEnd();
|
||||||
|
//}
|
||||||
|
for (int i=0;i<bodyWriterDetail.size();i++) {
|
||||||
|
writer.docPageBlockStart();
|
||||||
|
writer.printTagCharacters(Tag.h3, "Detail");
|
||||||
|
ApiDocNodeWriter nodeWriter = bodyWriterDetail.get(i);
|
||||||
|
nodeWriter.writeNodeContent(event);
|
||||||
|
writer.docPageBlockEnd();
|
||||||
|
}
|
||||||
|
writer.docPageBlockEnd();
|
||||||
|
writer.printTagEnd(Tag.div); // details
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void configActiveNavConceptLinks(NavBarConfig conf,ApiDocNode node,ApiDocConcept concept,String prefix) {
|
||||||
|
List<String> pathClean = new ArrayList<String>(10);
|
||||||
|
buildParentPath(node,pathClean);
|
||||||
|
|
||||||
|
if (concept.getParent()!=null && !concept.getParent().getId().equals(doc.getRootNode().getId())) {
|
||||||
|
ApiDocConcept conceptParent = concept.getParent();
|
||||||
|
conf.navLinks.put(conceptParent.getId(), ApiDocContentWriter.toSafeUri(pathClean)+prefix+"/index.html");
|
||||||
|
configActiveNavConceptLinks(conf,node,concept.getParent(),prefix+"/..");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void configNextPrevLinks(NavBarConfig conf,ApiDocNode node) {
|
||||||
|
if (node.getParent()==null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<ApiDocNode> pn = node.getParent().getNodes();
|
||||||
|
int pnSize = pn.size();
|
||||||
|
int nodeIdx = pn.indexOf(node);
|
||||||
|
if (nodeIdx>0) {
|
||||||
|
List<String> pathClean = new ArrayList<String>(10);
|
||||||
|
ApiDocNode prevNode = pn.get(nodeIdx-1);
|
||||||
|
if (node.getUserData().getClass().equals(prevNode.getUserData().getClass())) {
|
||||||
|
buildParentPath(prevNode,pathClean);
|
||||||
|
conf.prev = ApiDocContentWriter.toSafeUri(pathClean)+"/index.html";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((nodeIdx+1)<pnSize) {
|
||||||
|
List<String> pathClean = new ArrayList<String>(10);
|
||||||
|
ApiDocNode nextNode = pn.get(nodeIdx+1);
|
||||||
|
if (node.getUserData().getClass().equals(nextNode.getUserData().getClass())) {
|
||||||
|
buildParentPath(nextNode,pathClean);
|
||||||
|
conf.next = ApiDocContentWriter.toSafeUri(pathClean)+"/index.html";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void defaultWriteSummary(ApiDocNode node,ApiDocContentWriter writer) throws SAXException {
|
||||||
|
ApiDocConcept concept = findConceptByClass(node.getUserData().getClass());
|
||||||
|
writer.docTableStart(concept.getName()+" Summary", "All childeren in "+concept.getName());
|
||||||
|
writer.docTableHeader("Name", "Description");
|
||||||
|
for (ApiDocNode child:node.getNodes()) {
|
||||||
|
String link = ApiDocContentWriter.toSafeUri(child.getId())+"/index.html";
|
||||||
|
if (node.getParent()==null) {
|
||||||
|
link = ApiDocContentWriter.toSafeUri(node.getId())+"/"+link; // root node
|
||||||
|
}
|
||||||
|
writer.docTableRowHref(link,child.getName(),child.getDescription(),null);
|
||||||
|
}
|
||||||
|
writer.docTableEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void defaultWriteTreePath(ApiDocNode node,ApiDocContentWriter writer) throws SAXException {
|
||||||
|
if (node.getParent()==null) {
|
||||||
|
return; // no tree for root
|
||||||
|
}
|
||||||
|
List<ApiDocNode> rootPath = new ArrayList<ApiDocNode>(8);
|
||||||
|
defaultWriteTreePathBuildPath(node,rootPath);
|
||||||
|
defaultWriteTreePathWalker(rootPath.iterator(),writer,rootPath.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void defaultWriteTreePathWalker(Iterator<ApiDocNode> nodes,ApiDocContentWriter writer,int linkPrefixCount) throws SAXException {
|
||||||
|
if (nodes.hasNext()==false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ApiDocNode node = nodes.next();
|
||||||
|
writer.printTagStart(Tag.ul, ApiDocContentCss.inheritance);
|
||||||
|
String nodeTitle = node.getId();
|
||||||
|
if (nodes.hasNext()==false) {
|
||||||
|
writer.printTagStart(Tag.li);
|
||||||
|
writer.characters(nodeTitle);
|
||||||
|
writer.printTagEnd(Tag.li);
|
||||||
|
} else {
|
||||||
|
writer.printTagStart(Tag.li);
|
||||||
|
StringBuffer buf = new StringBuffer(20);
|
||||||
|
for (int i=1;i<linkPrefixCount;i++) {
|
||||||
|
buf.append("../");
|
||||||
|
}
|
||||||
|
String linkHref = buf+"index.html";
|
||||||
|
if (doc.getRootNode().equals(node)) {
|
||||||
|
ApiDocConcept concept = findConceptByClass(node.getUserData().getClass());
|
||||||
|
linkHref = buf+"../overview-"+concept.getId()+".html";
|
||||||
|
}
|
||||||
|
writer.printHref(linkHref, node.getDescription(), nodeTitle);
|
||||||
|
writer.printTagEnd(Tag.li);
|
||||||
|
|
||||||
|
writer.printTagStart(Tag.li);
|
||||||
|
defaultWriteTreePathWalker(nodes,writer,(linkPrefixCount-1));
|
||||||
|
writer.printTagEnd(Tag.li);
|
||||||
|
}
|
||||||
|
writer.printTagEnd(Tag.ul);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void defaultWriteTreePathBuildPath(ApiDocNode node,List<ApiDocNode> result) {
|
||||||
|
if (node.getParent()!=null) {
|
||||||
|
defaultWriteTreePathBuildPath(node.getParent(),result);
|
||||||
|
}
|
||||||
|
result.add(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApiDocContentWriter createContentWriter(File outputFile) throws SAXException {
|
||||||
|
String encoding = XMLConstants.XML_DEFAULT_ENCODING;
|
||||||
|
try {
|
||||||
|
Writer out = new OutputStreamWriter(new FileOutputStream(outputFile), encoding);
|
||||||
|
String charNewLine = XMLConstants.CHAR_NEWLINE+"";
|
||||||
|
String charTab = " ";
|
||||||
|
ApiDocContentWriter result = new ApiDocContentWriter(out,encoding,charNewLine,charTab);
|
||||||
|
return result;
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
throw new SAXException(e);
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
throw new SAXException(e);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
throw new SAXException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected NavBarConfig createNavBarConfig(String pathPrefix,File frame,ApiDocContentWriter writer) throws SAXException {
|
||||||
|
return createNavBarConfig(pathPrefix, null, null, frame, writer);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected NavBarConfig createNavBarConfig(String pathPrefix,String prev,String next,File frame,ApiDocContentWriter writer) throws SAXException {
|
||||||
|
String framePath = null;
|
||||||
|
try {
|
||||||
|
String rootPath = new File(frame.getParentFile().getPath()+File.separatorChar+pathPrefix).getCanonicalPath();
|
||||||
|
framePath = frame.getPath().substring(rootPath.length()+1);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new SAXException(e);
|
||||||
|
}
|
||||||
|
NavBarConfig conf = writer.new NavBarConfig(pathPrefix,prev,next,framePath,doc.getDocAbout());
|
||||||
|
conf.noFrameAllLink="allelements-noframe.html";
|
||||||
|
conf.noFrameAllName="All Elements";
|
||||||
|
conf.linkConstructorName="Tag";
|
||||||
|
conf.linkFieldName="Attributes";
|
||||||
|
conf.linkMethodName="Config";
|
||||||
|
|
||||||
|
for (ApiDocConcept concept:doc.getConcepts()) {
|
||||||
|
String navLink = "overview-"+concept.getId()+".html";
|
||||||
|
if (concept.getParent()!=null) {
|
||||||
|
navLink = null;
|
||||||
|
}
|
||||||
|
conf.addNavItem(concept.getId(), navLink, concept.getName());
|
||||||
|
}
|
||||||
|
for (ApiDocPage page:doc.getDocPages()) {
|
||||||
|
String navLink = page.getId()+".html";
|
||||||
|
conf.addNavItem(page.getId(), navLink, page.getName());
|
||||||
|
}
|
||||||
|
return conf;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ApiDocNodeWriter> findNodeBodyWriters(ApiDocNode node,ApiDocNodeBody nodeBody) {
|
||||||
|
List<ApiDocNodeWriter> result = new ArrayList<ApiDocNodeWriter>();
|
||||||
|
Class<?> objClass = node.getUserData().getClass();
|
||||||
|
for (ApiDocNodeWriter writer:doc.getNodeBodyWriters()) {
|
||||||
|
if (!nodeBody.equals(writer.getNodeBody())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (Class<?> c:writer.getTargetClasses()) {
|
||||||
|
if (c.isAssignableFrom(objClass)) {
|
||||||
|
result.add(writer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApiDocConcept findConceptByClass(Class<?> objClass) {
|
||||||
|
for (ApiDocConcept concept:doc.getConcepts()) {
|
||||||
|
if (concept.getConceptClass().isAssignableFrom(objClass)) {
|
||||||
|
return concept;
|
||||||
|
}
|
||||||
|
for (Class<?> c:concept.getConceptChildClasses()) {
|
||||||
|
if (c.isAssignableFrom(objClass)) {
|
||||||
|
return concept;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildParentPath(ApiDocNode node,List<String> path) {
|
||||||
|
if (node.getParent()==null) {
|
||||||
|
path.add(node.getId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
buildParentPath(node.getParent(),path);
|
||||||
|
path.add(node.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeStyleSheet() throws IOException {
|
||||||
|
try {
|
||||||
|
StringBuffer cssData = new StringBuffer();
|
||||||
|
appendResourceToBuffer(cssData,"org/x4o/xml/eld/doc/theme/base/api-html.css");
|
||||||
|
appendResourceToBuffer(cssData,"org/x4o/xml/eld/doc/theme/base/api-layout.css");
|
||||||
|
appendResourceToBuffer(cssData,"org/x4o/xml/eld/doc/theme/base/api-inset.css");
|
||||||
|
appendResourceToBuffer(cssData,"org/x4o/xml/eld/doc/theme/base/api-font.css");
|
||||||
|
appendResourceToBuffer(cssData,"org/x4o/xml/eld/doc/theme/base/api-color.css");
|
||||||
|
|
||||||
|
//appendResourceToBuffer(cssData,"org/x4o/xml/eld/doc/theme/jdk6/stylesheet.css");
|
||||||
|
appendResourceToBuffer(cssData,"org/x4o/xml/eld/doc/theme/jdk7/stylesheet.css");
|
||||||
|
|
||||||
|
String css = cssData.toString();
|
||||||
|
css = css.replaceAll("\\s+"," ");
|
||||||
|
css = css.replaceAll("\\s*:\\s*",":");
|
||||||
|
css = css.replaceAll("\\s*\\;\\s*",";");
|
||||||
|
css = css.replaceAll("\\s*\\,\\s*",",");
|
||||||
|
css = css.replaceAll("\\s*\\{\\s*","{");
|
||||||
|
css = css.replaceAll("\\s*\\}\\s*","}\n"); // add return to have multi line file.
|
||||||
|
|
||||||
|
writeFileString(css,basePath,"resources","stylesheet.css");
|
||||||
|
|
||||||
|
copyResourceToFile("org/x4o/xml/eld/doc/theme/jdk7/background.png",basePath,"resources","background.png");
|
||||||
|
copyResourceToFile("org/x4o/xml/eld/doc/theme/jdk7/tab.png",basePath,"resources","tab.png");
|
||||||
|
copyResourceToFile("org/x4o/xml/eld/doc/theme/jdk7/titlebar_end.png",basePath,"resources","titlebar_end.png");
|
||||||
|
copyResourceToFile("org/x4o/xml/eld/doc/theme/jdk7/titlebar.png",basePath,"resources","titlebar.png");
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
throw new IOException(e.getMessage());
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new IOException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeHeader(ApiDocContentWriter writer,String resourcePrefix,String title) throws SAXException {
|
||||||
|
writer.printTagStart(Tag.head);
|
||||||
|
writer.docCommentGenerated();
|
||||||
|
writer.printHeadMetaContentType();
|
||||||
|
writer.printHeadTitle(title);
|
||||||
|
writer.printHeadMetaDate();
|
||||||
|
writer.printHeadLinkCss(resourcePrefix+"resources/stylesheet.css");
|
||||||
|
writer.printTagEnd(Tag.head);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String FRAME_JS = "\n"+
|
||||||
|
"targetPage = \"\" + window.location.search;\n"+
|
||||||
|
"if (targetPage != \"\" && targetPage != \"undefined\")\n"+
|
||||||
|
"\t { targetPage = targetPage.substring(1); }\n"+
|
||||||
|
"if (targetPage.indexOf(\":\") != -1)\n"+
|
||||||
|
"\t { targetPage = \"undefined\"; }\n"+
|
||||||
|
"function loadFrames() {\n"+
|
||||||
|
"\tif (targetPage != \"\" && targetPage != \"undefined\")\n"+
|
||||||
|
"\t\t { top."+ApiDocContentCss.frameContent.name()+".location = top.targetPage; }\n"+
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
public void writeIndex() throws SAXException {
|
||||||
|
File outputFile = createOutputPathFile(basePath,"index.html");
|
||||||
|
ApiDocContentWriter writer = createContentWriter(outputFile);
|
||||||
|
try {
|
||||||
|
writer.printDocType(DocType.HTML_4_FRAMESET);
|
||||||
|
writer.comment("NewPage");
|
||||||
|
writer.printHtmlStart("en");
|
||||||
|
writeHeader(writer,"",doc.getName());
|
||||||
|
writer.printScriptInline(FRAME_JS);
|
||||||
|
|
||||||
|
AttributesImpl atts = new AttributesImpl();
|
||||||
|
atts.addAttribute ("", "cols", "", "", "20%,80%");
|
||||||
|
atts.addAttribute ("", "title", "", "", "Documentation frame");
|
||||||
|
atts.addAttribute ("", "onload", "", "", "top.loadFrames()");
|
||||||
|
writer.printTagStart(Tag.frameset, atts);
|
||||||
|
|
||||||
|
ApiDocConcept rootConcept = findConceptByClass(doc.getFrameNavConceptClass());
|
||||||
|
atts = new AttributesImpl();
|
||||||
|
atts.addAttribute ("", "rows", "", "", "30%,70%");
|
||||||
|
atts.addAttribute ("", "title", "", "", "Left frames");
|
||||||
|
atts.addAttribute ("", "onload", "", "", "top.loadFrames()");
|
||||||
|
writer.printTagStart(Tag.frameset, atts);
|
||||||
|
atts = new AttributesImpl();
|
||||||
|
atts.addAttribute ("", "src", "", "", "overview-frame.html");
|
||||||
|
atts.addAttribute ("", "title", "", "", "All Namspaces");
|
||||||
|
atts.addAttribute ("", "name", "", "", ApiDocContentCss.frameNavOverview.name());
|
||||||
|
writer.printTagStart(Tag.frame, atts);
|
||||||
|
writer.printTagEnd(Tag.frame);
|
||||||
|
atts = new AttributesImpl();
|
||||||
|
atts.addAttribute ("", "src", "", "", "all"+rootConcept.getId()+"-frame.html");
|
||||||
|
atts.addAttribute ("", "title", "", "", "All Elements");
|
||||||
|
atts.addAttribute ("", "name", "", "", ApiDocContentCss.frameNavDetail.name());
|
||||||
|
writer.printTagStart(Tag.frame, atts);
|
||||||
|
writer.printTagEnd(Tag.frame);
|
||||||
|
writer.printTagEnd(Tag.frameset);
|
||||||
|
|
||||||
|
String rootLink = "overview-"+ApiDocContentWriter.toSafeUri(doc.getRootNode().getId())+".html";
|
||||||
|
|
||||||
|
atts = new AttributesImpl();
|
||||||
|
atts.addAttribute ("", "src", "", "", rootLink);
|
||||||
|
atts.addAttribute ("", "title", "", "", "All Language Components");
|
||||||
|
atts.addAttribute ("", "name", "", "", ApiDocContentCss.frameContent.name());
|
||||||
|
atts.addAttribute ("", "scrolling", "", "", "yes");
|
||||||
|
writer.printTagStart(Tag.frame, atts);
|
||||||
|
writer.printTagEnd(Tag.frame);
|
||||||
|
|
||||||
|
writer.printTagStart(Tag.noframes);
|
||||||
|
writer.printScriptNoDiv();
|
||||||
|
writer.printTagCharacters(Tag.h2, "Frame Alert");
|
||||||
|
writer.printTagStart(Tag.p);
|
||||||
|
writer.characters("This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to ");
|
||||||
|
writer.printHref(rootLink, "Non-frame version");
|
||||||
|
writer.characters(".");
|
||||||
|
writer.printTagEnd(Tag.p);
|
||||||
|
writer.printTagEnd(Tag.noframes);
|
||||||
|
|
||||||
|
writer.printTagEnd(Tag.frameset);
|
||||||
|
writer.printHtmlEnd();
|
||||||
|
} finally {
|
||||||
|
writer.closeWriterSafe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void findNodeByUserDataClass(ApiDocNode node,Class<?> userDataClass,List<ApiDocNode> result) {
|
||||||
|
if (userDataClass.isAssignableFrom(node.getUserData().getClass())) {
|
||||||
|
result.add(node);
|
||||||
|
}
|
||||||
|
for (ApiDocNode child:node.getNodes()) {
|
||||||
|
findNodeByUserDataClass((ApiDocNode)child,userDataClass,result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeOverviewFrame() throws SAXException {
|
||||||
|
ApiDocConcept concept = findConceptByClass(doc.getFrameNavConceptClass());
|
||||||
|
ApiDocConcept conceptParent = concept.getParent();
|
||||||
|
List<ApiDocNode> nodes = new ArrayList<ApiDocNode>(50);
|
||||||
|
findNodeByUserDataClass(doc.getRootNode(),conceptParent.getConceptClass(),nodes);
|
||||||
|
|
||||||
|
File outputFile = createOutputPathFile(basePath,"overview-frame.html");
|
||||||
|
ApiDocContentWriter writer = createContentWriter(outputFile);
|
||||||
|
try {
|
||||||
|
String conceptPlural = concept.getName()+"s";
|
||||||
|
String conceptParentPlural = conceptParent.getName()+"s";
|
||||||
|
|
||||||
|
writer.printDocType(DocType.HTML_4_TRANSITIONAL);
|
||||||
|
writer.comment("NewPage");
|
||||||
|
writer.printHtmlStart("en");
|
||||||
|
writeHeader(writer,"","All "+conceptPlural+" of "+doc.getName());
|
||||||
|
writer.printTagStart(Tag.body);
|
||||||
|
|
||||||
|
writer.printTagStart(Tag.div,ApiDocContentCss.indexHeader);
|
||||||
|
writer.printHrefTarget("all"+concept.getId()+"-frame.html", "All "+conceptPlural,ApiDocContentCss.frameNavDetail.name());
|
||||||
|
writer.printTagEnd(Tag.div);
|
||||||
|
|
||||||
|
writer.printTagStart(Tag.div,ApiDocContentCss.indexContainer);
|
||||||
|
writer.printTagCharacters(Tag.h2, conceptParentPlural);
|
||||||
|
writer.printTagStart(Tag.ul);
|
||||||
|
for (ApiDocNode node:nodes) {
|
||||||
|
String linkName = node.getName();
|
||||||
|
if (doc.getFrameNavOverviewPrintParent()) {
|
||||||
|
if (doc.getFrameNavPrintParentId()) {
|
||||||
|
linkName = node.getParent().getId()+":"+node.getName();
|
||||||
|
} else {
|
||||||
|
linkName = node.getParent().getName()+":"+node.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
writer.printTagStart(Tag.li);
|
||||||
|
writer.printHrefTarget(doc.getRootNode().getId()+"/"+ApiDocContentWriter.toSafeUri(node.getParent().getId())+"/"+node.getId()+"/"+node.getId()+"-frame.html", linkName,ApiDocContentCss.frameNavDetail.name());
|
||||||
|
writer.printTagEnd(Tag.li);
|
||||||
|
}
|
||||||
|
writer.printTagEnd(Tag.ul);
|
||||||
|
writer.printTagEnd(Tag.div);
|
||||||
|
|
||||||
|
writer.printTagEnd(Tag.body);
|
||||||
|
writer.printHtmlEnd();
|
||||||
|
} finally {
|
||||||
|
writer.closeWriterSafe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeAllFrameNav(boolean isFrame) throws SAXException {
|
||||||
|
ApiDocConcept concept = findConceptByClass(doc.getFrameNavConceptClass());
|
||||||
|
if (isFrame) {
|
||||||
|
writeAllFrameNav("",true,null,"all"+concept.getId()+"-frame.html");
|
||||||
|
} else {
|
||||||
|
writeAllFrameNav("",false,null,"all"+concept.getId()+"-noframe.html");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeAllFrameNavNode(ApiDocNode node) throws SAXException {
|
||||||
|
ApiDocConcept concept = findConceptByClass(doc.getFrameNavConceptClass());
|
||||||
|
ApiDocConcept conceptParent = concept.getParent();
|
||||||
|
if (!conceptParent.getConceptClass().isAssignableFrom(node.getUserData().getClass())) {
|
||||||
|
return; // only frame nav nodes.
|
||||||
|
}
|
||||||
|
List<String> path = new ArrayList<String>(10);
|
||||||
|
buildParentPath(node,path);
|
||||||
|
String pathS = "";
|
||||||
|
for (int i=0;i<path.size();i++) {
|
||||||
|
pathS = "../"+pathS;
|
||||||
|
}
|
||||||
|
path.add(node.getId()+"-frame.html");
|
||||||
|
writeAllFrameNav(pathS,true,node,path.toArray(new String[]{}));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeAllFrameNav(String pathPrefix,boolean isFrame,ApiDocNode searchNode,String...fileName) throws SAXException {
|
||||||
|
ApiDocConcept concept = findConceptByClass(doc.getFrameNavConceptClass());
|
||||||
|
//ApiDocConcept conceptParent = concept.getParent();
|
||||||
|
List<ApiDocNode> nodes = new ArrayList<ApiDocNode>(50);
|
||||||
|
findNodeByUserDataClass(doc.getRootNode(),concept.getConceptClass(),nodes);
|
||||||
|
|
||||||
|
File outputFile = createOutputPathFile(basePath,fileName);
|
||||||
|
ApiDocContentWriter writer = createContentWriter(outputFile);
|
||||||
|
try {
|
||||||
|
String conceptPlural = concept.getName()+"s";
|
||||||
|
//String conceptParentPlural = conceptParent.getName()+"s";
|
||||||
|
|
||||||
|
writer.printDocType(DocType.HTML_4_TRANSITIONAL);
|
||||||
|
writer.comment("NewPage");
|
||||||
|
writer.printHtmlStart("en");
|
||||||
|
writeHeader(writer,pathPrefix,"All "+conceptPlural+" of "+doc.getName());
|
||||||
|
writer.printTagStart(Tag.body);
|
||||||
|
if (searchNode==null) {
|
||||||
|
writer.printTagCharacters(Tag.h1, "All "+conceptPlural, "bar");
|
||||||
|
} else {
|
||||||
|
writer.printTagStart(Tag.h1,ApiDocContentCss.bar);
|
||||||
|
writer.printHrefTarget("index.html", searchNode.getId(),ApiDocContentCss.frameContent.name());
|
||||||
|
writer.printTagEnd(Tag.h1);
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.printTagStart(Tag.div,ApiDocContentCss.indexContainer);
|
||||||
|
writer.printTagStart(Tag.ul);
|
||||||
|
|
||||||
|
boolean printParent = new Boolean(true).equals(doc.getFrameNavPrintParent());
|
||||||
|
boolean printParentParent = new Boolean(true).equals(doc.getFrameNavPrintParentParent());
|
||||||
|
|
||||||
|
for (ApiDocNode node:nodes) {
|
||||||
|
List<String> nodePath = new ArrayList<String>(10);
|
||||||
|
buildParentPath(node,nodePath);
|
||||||
|
if (searchNode!=null) {
|
||||||
|
// TODO: compare full tree paths.
|
||||||
|
if (!node.getParent().getId().equals(searchNode.getId())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (searchNode.getParent()!=null && !node.getParent().getParent().getId().equals(searchNode.getParent().getId())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (searchNode.getParent().getParent()!=null && !node.getParent().getParent().getParent().getId().equals(searchNode.getParent().getParent().getId())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String linkName = node.getName();
|
||||||
|
String linkUrl = ApiDocContentWriter.toSafeUri(nodePath)+"/index.html";
|
||||||
|
if (searchNode!=null) {
|
||||||
|
linkUrl = ApiDocContentWriter.toSafeUri(node.getId(),"index.html");
|
||||||
|
}
|
||||||
|
if (printParent) {
|
||||||
|
if (printParentParent) {
|
||||||
|
if (doc.getFrameNavPrintParentId()) {
|
||||||
|
linkName = node.getParent().getParent().getId()+":"+linkName;
|
||||||
|
} else {
|
||||||
|
linkName = node.getParent().getParent().getName()+":"+linkName;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (doc.getFrameNavPrintParentId()) {
|
||||||
|
linkName = node.getParent().getId()+":"+linkName;
|
||||||
|
} else {
|
||||||
|
linkName = node.getParent().getName()+":"+linkName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
writer.printTagStart(Tag.li);
|
||||||
|
if (isFrame) {
|
||||||
|
writer.printHrefTarget(linkUrl, linkName,ApiDocContentCss.frameContent.name());
|
||||||
|
} else {
|
||||||
|
writer.printHref(linkUrl, linkName);
|
||||||
|
}
|
||||||
|
writer.printTagEnd(Tag.li);
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.printTagEnd(Tag.ul);
|
||||||
|
writer.printTagEnd(Tag.div);
|
||||||
|
|
||||||
|
writer.printTagEnd(Tag.body);
|
||||||
|
writer.printHtmlEnd();
|
||||||
|
} finally {
|
||||||
|
writer.closeWriterSafe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writePage(ApiDocPage page) throws SAXException {
|
||||||
|
File outputFile = createOutputPathFile(basePath,page.getId()+".html");
|
||||||
|
ApiDocContentWriter writer = createContentWriter(outputFile);
|
||||||
|
String pathPrefix = "";
|
||||||
|
try {
|
||||||
|
NavBarConfig conf = createNavBarConfig(pathPrefix, outputFile, writer);
|
||||||
|
conf.navSelected=page.getId();
|
||||||
|
String title = page.getName();
|
||||||
|
writer.docHtmlStart(conf,title, doc.getDocKeywords());
|
||||||
|
writer.docPageClassStart(title, page.getDescription());
|
||||||
|
|
||||||
|
ApiDocWriteEvent<ApiDocPage> e = new ApiDocWriteEvent<ApiDocPage>(doc,writer,page);
|
||||||
|
|
||||||
|
//writer.docPageContentStart();
|
||||||
|
for (ApiDocPageWriter pageWriter:page.getPageWriters()) {
|
||||||
|
pageWriter.writePageContent(e);
|
||||||
|
}
|
||||||
|
//writer.docPageContentEnd();
|
||||||
|
|
||||||
|
writer.docPageClassEnd();
|
||||||
|
writer.docHtmlEnd(conf, doc.getDocCopyright());
|
||||||
|
} finally {
|
||||||
|
writer.closeWriterSafe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void appendResourceToBuffer(StringBuffer buffer,String resource) throws IOException {
|
||||||
|
ClassLoader cl = X4OLanguageClassLoader.getClassLoader();
|
||||||
|
BufferedReader reader = null;
|
||||||
|
try {
|
||||||
|
InputStream inputStream = cl.getResourceAsStream(resource);
|
||||||
|
reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
|
||||||
|
for (int c = reader.read(); c != -1; c = reader.read()) {
|
||||||
|
buffer.append((char)c);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (reader!=null) {
|
||||||
|
reader.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeFileString(String text,File basePath,String...argu) throws SecurityException, IOException, InterruptedException {
|
||||||
|
OutputStream outputStream = new FileOutputStream(createOutputPathFile(basePath,argu));
|
||||||
|
try {
|
||||||
|
for (int i=0;i<text.length();i++) {
|
||||||
|
char c = text.charAt(i);
|
||||||
|
outputStream.write(c);
|
||||||
|
if (Thread.interrupted()) {
|
||||||
|
throw new InterruptedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
outputStream.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void copyResourceToFile(String resource,File basePath,String...argu) throws SecurityException, IOException, InterruptedException {
|
||||||
|
ClassLoader cl = X4OLanguageClassLoader.getClassLoader();
|
||||||
|
InputStream inputStream = cl.getResourceAsStream(resource);
|
||||||
|
OutputStream outputStream = new FileOutputStream(createOutputPathFile(basePath,argu));
|
||||||
|
try {
|
||||||
|
byte[] buffer = new byte[4096];
|
||||||
|
int len = inputStream.read(buffer);
|
||||||
|
while (len != -1) {
|
||||||
|
outputStream.write(buffer, 0, len);
|
||||||
|
len = inputStream.read(buffer);
|
||||||
|
if (Thread.interrupted()) {
|
||||||
|
throw new InterruptedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
inputStream.close();
|
||||||
|
outputStream.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private File createOutputPathFile(File basePath,String...argu) {
|
||||||
|
StringBuffer buf = new StringBuffer(200);
|
||||||
|
buf.append(basePath.getAbsolutePath());
|
||||||
|
buf.append(File.separatorChar);
|
||||||
|
for (int i=0;i<argu.length-1;i++) {
|
||||||
|
buf.append(ApiDocContentWriter.toSafeUri(argu[i]));
|
||||||
|
buf.append(File.separatorChar);
|
||||||
|
}
|
||||||
|
File outputPath = new File(buf.toString());
|
||||||
|
if (outputPath.exists()==false) {
|
||||||
|
//System.out.println("Creating path: "+outputPath);
|
||||||
|
outputPath.mkdirs();
|
||||||
|
}
|
||||||
|
buf.append(File.separatorChar);
|
||||||
|
buf.append(ApiDocContentWriter.toSafeUri(argu[argu.length-1]));
|
||||||
|
File outputFile = new File(buf.toString());
|
||||||
|
if (outputFile.exists()) {
|
||||||
|
outputFile.delete();
|
||||||
|
}
|
||||||
|
//System.out.println("Creating file: "+outputFile);
|
||||||
|
return outputFile;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.eld.doc.api;
|
||||||
|
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDoc;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocConcept;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocPage;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocPageWriter;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
|
||||||
|
import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DefaultPageWriterHelp creates the help page content.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 22, 2013
|
||||||
|
*/
|
||||||
|
public class DefaultPageWriterHelp implements ApiDocPageWriter {
|
||||||
|
|
||||||
|
public static ApiDocPage createDocPage() {
|
||||||
|
return new ApiDocPage("doc-help","Help","This help file applies to the API documentation generated using the standard format.",new DefaultPageWriterHelp());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException {
|
||||||
|
ApiDoc doc = e.getDoc();
|
||||||
|
//ApiDocPage page = e.getEvent();
|
||||||
|
ApiDocContentWriter writer = e.getWriter();
|
||||||
|
|
||||||
|
writer.printTagStart(Tag.div,"header");
|
||||||
|
writer.printTagCharacters(Tag.h1, "How This API Document Is Organized", "title");
|
||||||
|
writer.printTagStart(Tag.div,"subTitle");
|
||||||
|
writer.characters("This ApiDoc document has pages corresponding to the items in the navigation bar, described as follows.");
|
||||||
|
writer.printTagEnd(Tag.div);
|
||||||
|
writer.printTagEnd(Tag.div);
|
||||||
|
|
||||||
|
writer.docPageContentStart();
|
||||||
|
writer.docPageBlockStart();
|
||||||
|
for (ApiDocConcept concept:doc.getConcepts()) {
|
||||||
|
writer.printTagCharacters(Tag.h2, concept.getName());
|
||||||
|
writer.printTagStart(Tag.p);
|
||||||
|
writer.charactersRaw(concept.getDescriptionHelp());
|
||||||
|
writer.printTagEnd(Tag.p);
|
||||||
|
writer.docPageBlockNext();
|
||||||
|
}
|
||||||
|
for (ApiDocPage docPage:doc.getDocPages()) {
|
||||||
|
writer.printTagCharacters(Tag.h2, docPage.getName());
|
||||||
|
writer.printTagStart(Tag.p);
|
||||||
|
writer.charactersRaw(docPage.getDescription());
|
||||||
|
writer.printTagEnd(Tag.p);
|
||||||
|
writer.docPageBlockNext();
|
||||||
|
}
|
||||||
|
writer.docPageBlockEnd();
|
||||||
|
writer.docPageContentEnd();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.eld.doc.api;
|
||||||
|
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocPage;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocPageWriter;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
|
||||||
|
import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DefaultPageWriterIndexAll creates the index-all page content.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 22, 2013
|
||||||
|
*/
|
||||||
|
public class DefaultPageWriterIndexAll implements ApiDocPageWriter {
|
||||||
|
|
||||||
|
public static ApiDocPage createDocPage() {
|
||||||
|
return new ApiDocPage("index-all","Index","Index of all api ketwords.",new DefaultPageWriterIndexAll());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException {
|
||||||
|
// ApiDoc doc = e.getDoc();
|
||||||
|
// ApiDocPage page = e.getEvent();
|
||||||
|
ApiDocContentWriter writer = e.getWriter();
|
||||||
|
writer.docPageContentStart();
|
||||||
|
for (char i='A';i<='Z';i++) {
|
||||||
|
writer.printHref("#_"+i+"_", ""+i);
|
||||||
|
writer.charactersRaw(" ");
|
||||||
|
}
|
||||||
|
for (char i='A';i<='Z';i++) {
|
||||||
|
writer.printHrefNamed("_"+i+"_");
|
||||||
|
writer.printTagCharacters(Tag.h2, ""+i);
|
||||||
|
writer.characters("TODO");
|
||||||
|
}
|
||||||
|
writer.docPageContentEnd();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.eld.doc.api;
|
||||||
|
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDoc;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocNode;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocPage;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocPageWriter;
|
||||||
|
import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
|
||||||
|
import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DefaultPageWriterTree creates the default tree overview page content.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 22, 2013
|
||||||
|
*/
|
||||||
|
public class DefaultPageWriterTree implements ApiDocPageWriter {
|
||||||
|
|
||||||
|
public static ApiDocPage createDocPage() {
|
||||||
|
return new ApiDocPage("overview-tree","Tree","Tree of api concepts.",new DefaultPageWriterTree());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ApiDocNode selectRootNode(ApiDoc doc) {
|
||||||
|
ApiDocNode rootNode = doc.getRootNodeTreePage();
|
||||||
|
if (rootNode==null) {
|
||||||
|
rootNode = doc.getRootNode();
|
||||||
|
}
|
||||||
|
return rootNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException {
|
||||||
|
ApiDoc doc = e.getDoc();
|
||||||
|
ApiDocPage page = e.getEvent();
|
||||||
|
ApiDocContentWriter writer = e.getWriter();
|
||||||
|
//writer.docPagePackageTitle(title, "Overview Tree");
|
||||||
|
writer.docPageContentStart();
|
||||||
|
writeTree(doc,selectRootNode(doc),writer,"");
|
||||||
|
writer.docPagePackageDescription(page.getName(), "Tree","All Language elements as tree.");
|
||||||
|
writer.docPageContentEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeTree(ApiDoc doc, ApiDocNode node,ApiDocContentWriter writer,String pathPrefix) throws SAXException {
|
||||||
|
|
||||||
|
for (Class<?> excludeClass:doc.getTreeNodeClassExcludes()) {
|
||||||
|
if (excludeClass.isAssignableFrom(node.getUserData().getClass())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String href = ApiDocContentWriter.toSafeUri("todo");// toElementUri(pathPrefix,node.module,node.namespace,node.elementClass);
|
||||||
|
|
||||||
|
writer.printTagStart(Tag.ul);
|
||||||
|
writer.printTagStart(Tag.li,"",null,"circle");
|
||||||
|
if (node.getParent()!=null) {
|
||||||
|
writer.characters(node.getParent().getId());
|
||||||
|
writer.characters(":");
|
||||||
|
}
|
||||||
|
writer.printHref(href, node.getName(), node.getName(), "strong");
|
||||||
|
writer.printTagEnd(Tag.li);
|
||||||
|
|
||||||
|
for (ApiDocNode child:node.getNodes()) {
|
||||||
|
writeTree(doc,child,writer,pathPrefix);
|
||||||
|
}
|
||||||
|
writer.printTagEnd(Tag.ul);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,350 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.eld.doc.api.dom;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApiDoc holds all config and data to write a full api doc structure.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 12, 2013
|
||||||
|
*/
|
||||||
|
public class ApiDoc {
|
||||||
|
|
||||||
|
private String name = null;
|
||||||
|
private String description = null;
|
||||||
|
private ApiDocNode rootNode = null;
|
||||||
|
private ApiDocNode rootNodeTreePage = null;
|
||||||
|
private List<ApiDocNodeWriter> nodeBodyWriters = null;
|
||||||
|
private List<ApiDocConcept> concepts = null;
|
||||||
|
private String docCopyright = null;
|
||||||
|
private String docAbout = null;
|
||||||
|
private List<String> docKeywords = null;
|
||||||
|
private List<ApiDocPage> docPages = null;
|
||||||
|
private Class<?> frameNavConceptClass = null;
|
||||||
|
private Boolean frameNavOverviewPrintParent = null;
|
||||||
|
private Boolean frameNavPrintParentId = null;
|
||||||
|
private Boolean frameNavPrintParent = null;
|
||||||
|
private Boolean frameNavPrintParentParent = null;
|
||||||
|
private List<Class<?>> treeNodeClassExcludes = null;
|
||||||
|
|
||||||
|
public ApiDoc() {
|
||||||
|
nodeBodyWriters = new ArrayList<ApiDocNodeWriter>(20);
|
||||||
|
concepts = new ArrayList<ApiDocConcept>(10);
|
||||||
|
docKeywords = new ArrayList<String>(5);
|
||||||
|
docPages = new ArrayList<ApiDocPage>(5);
|
||||||
|
treeNodeClassExcludes = new ArrayList<Class<?>>(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiDoc(ApiDocNode rootNode) {
|
||||||
|
this();
|
||||||
|
setRootNode(rootNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkModel() throws NullPointerException,IllegalArgumentException {
|
||||||
|
checkNull(name,"name");
|
||||||
|
checkNull(description,"description");
|
||||||
|
checkNull(docAbout,"docAbout");
|
||||||
|
checkNull(docCopyright,"docCopyright");
|
||||||
|
checkNull(rootNode,"rootNode");
|
||||||
|
checkNull(frameNavConceptClass,"frameNavConceptClass");
|
||||||
|
if (concepts.isEmpty()) {
|
||||||
|
throw new IllegalStateException("Can't work with empty concepts");
|
||||||
|
}
|
||||||
|
if (nodeBodyWriters.isEmpty()) {
|
||||||
|
throw new IllegalStateException("Can't work with empty nodeBodyWriters");
|
||||||
|
}
|
||||||
|
if (frameNavOverviewPrintParent==null) {
|
||||||
|
frameNavOverviewPrintParent=false;
|
||||||
|
}
|
||||||
|
if (frameNavPrintParent==null) {
|
||||||
|
frameNavPrintParent=false;
|
||||||
|
}
|
||||||
|
if (frameNavPrintParentParent==null) {
|
||||||
|
frameNavPrintParentParent=false;
|
||||||
|
}
|
||||||
|
if (frameNavPrintParentId==null) {
|
||||||
|
frameNavPrintParentId=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkNull(Object obj,String objName) {
|
||||||
|
if (obj==null) {
|
||||||
|
throw new NullPointerException("Can't work with null "+objName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiDocNodeWriter addNodeBodyWriter(ApiDocNodeWriter writer) {
|
||||||
|
nodeBodyWriters.add(writer);
|
||||||
|
return writer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean removeNodeBodyWriter(ApiDocNodeWriter writer) {
|
||||||
|
return nodeBodyWriters.remove(writer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ApiDocNodeWriter> getNodeBodyWriters() {
|
||||||
|
return nodeBodyWriters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiDocConcept addConcept(ApiDocConcept concept) {
|
||||||
|
concepts.add(concept);
|
||||||
|
return concept;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean removeConcept(ApiDocConcept concept) {
|
||||||
|
return concepts.remove(concept);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ApiDocConcept> getConcepts() {
|
||||||
|
return concepts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addDocKeyword(String keyword) {
|
||||||
|
docKeywords.add(keyword);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addDocKeywordAll(Collection<String> keywords) {
|
||||||
|
docKeywords.addAll(keywords);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean removeDocKeyword(String keyword) {
|
||||||
|
return docKeywords.remove(keyword);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getDocKeywords() {
|
||||||
|
return docKeywords;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the docCopyright
|
||||||
|
*/
|
||||||
|
public String getDocCopyright() {
|
||||||
|
return docCopyright;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param docCopyright the docCopyright to set
|
||||||
|
*/
|
||||||
|
public void setDocCopyright(String docCopyright) {
|
||||||
|
this.docCopyright = docCopyright;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates default copyright message for owner.
|
||||||
|
* @param owner The owner of the copyright.
|
||||||
|
*/
|
||||||
|
public void createDocCopyright(String owner) {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
StringBuffer buf = new StringBuffer(100);
|
||||||
|
buf.append("Copyright © ");
|
||||||
|
buf.append(calendar.get(Calendar.YEAR));
|
||||||
|
buf.append(" ");
|
||||||
|
buf.append(owner.toUpperCase());
|
||||||
|
buf.append(" ");
|
||||||
|
buf.append("All Rights Reserved.");
|
||||||
|
setDocCopyright(buf.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the docAbout
|
||||||
|
*/
|
||||||
|
public String getDocAbout() {
|
||||||
|
return docAbout;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param docAbout the docAbout to set
|
||||||
|
*/
|
||||||
|
public void setDocAbout(String docAbout) {
|
||||||
|
this.docAbout = docAbout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiDocPage addDocPage(ApiDocPage page) {
|
||||||
|
docPages.add(page);
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean removeDocPage(ApiDocPage page) {
|
||||||
|
return docPages.remove(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ApiDocPage> getDocPages() {
|
||||||
|
return docPages;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiDocPage findDocPageById(String docPageId) {
|
||||||
|
if (docPageId==null) {
|
||||||
|
throw new NullPointerException("Can't search for null id.");
|
||||||
|
}
|
||||||
|
for (ApiDocPage page:docPages) {
|
||||||
|
if (page.getId().equals(docPageId)) {
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<?> addTreeNodeClassExclude(Class<?> excludeClass) {
|
||||||
|
treeNodeClassExcludes.add(excludeClass);
|
||||||
|
return excludeClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean removeTreeNodeClassExclude(Class<?> excludeClass) {
|
||||||
|
return treeNodeClassExcludes.remove(excludeClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Class<?>> getTreeNodeClassExcludes() {
|
||||||
|
return treeNodeClassExcludes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name the name to set
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the description
|
||||||
|
*/
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param description the description to set
|
||||||
|
*/
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the rootNodeTreePage
|
||||||
|
*/
|
||||||
|
public ApiDocNode getRootNodeTreePage() {
|
||||||
|
return rootNodeTreePage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param rootNodeTreePage the rootNodeTreePage to set
|
||||||
|
*/
|
||||||
|
public void setRootNodeTreePage(ApiDocNode rootNodeTreePage) {
|
||||||
|
this.rootNodeTreePage = rootNodeTreePage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the rootNode
|
||||||
|
*/
|
||||||
|
public ApiDocNode getRootNode() {
|
||||||
|
return rootNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param rootNode the rootNode to set
|
||||||
|
*/
|
||||||
|
public void setRootNode(ApiDocNode rootNode) {
|
||||||
|
this.rootNode = rootNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the frameNavConceptClass
|
||||||
|
*/
|
||||||
|
public Class<?> getFrameNavConceptClass() {
|
||||||
|
return frameNavConceptClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param frameNavConceptClass the frameNavConceptClass to set
|
||||||
|
*/
|
||||||
|
public void setFrameNavConceptClass(Class<?> frameNavConceptClass) {
|
||||||
|
this.frameNavConceptClass = frameNavConceptClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the frameNavPrintParent
|
||||||
|
*/
|
||||||
|
public Boolean getFrameNavPrintParent() {
|
||||||
|
return frameNavPrintParent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param frameNavPrintParent the frameNavPrintParent to set
|
||||||
|
*/
|
||||||
|
public void setFrameNavPrintParent(Boolean frameNavPrintParent) {
|
||||||
|
this.frameNavPrintParent = frameNavPrintParent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the frameNavPrintParentParent
|
||||||
|
*/
|
||||||
|
public Boolean getFrameNavPrintParentParent() {
|
||||||
|
return frameNavPrintParentParent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param frameNavPrintParentParent the frameNavPrintParentParent to set
|
||||||
|
*/
|
||||||
|
public void setFrameNavPrintParentParent(Boolean frameNavPrintParentParent) {
|
||||||
|
this.frameNavPrintParentParent = frameNavPrintParentParent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the frameNavOverviewPrintParent
|
||||||
|
*/
|
||||||
|
public Boolean getFrameNavOverviewPrintParent() {
|
||||||
|
return frameNavOverviewPrintParent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param frameNavOverviewPrintParent the frameNavOverviewPrintParent to set
|
||||||
|
*/
|
||||||
|
public void setFrameNavOverviewPrintParent(Boolean frameNavOverviewPrintParent) {
|
||||||
|
this.frameNavOverviewPrintParent = frameNavOverviewPrintParent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the frameNavPrintParentId
|
||||||
|
*/
|
||||||
|
public Boolean getFrameNavPrintParentId() {
|
||||||
|
return frameNavPrintParentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param frameNavPrintParentId the frameNavPrintParentId to set
|
||||||
|
*/
|
||||||
|
public void setFrameNavPrintParentId(Boolean frameNavPrintParentId) {
|
||||||
|
this.frameNavPrintParentId = frameNavPrintParentId;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,167 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.eld.doc.api.dom;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApiDocConcept defines the prime concepts which for which we write documents.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 12, 2013
|
||||||
|
*/
|
||||||
|
public class ApiDocConcept {
|
||||||
|
|
||||||
|
private String id = null;
|
||||||
|
private String name = null;
|
||||||
|
private String descriptionName = null;
|
||||||
|
private String descriptionHelp = null;
|
||||||
|
private ApiDocConcept parent = null;
|
||||||
|
private Class<?> conceptClass = null;
|
||||||
|
private List<Class<?>> conceptChildClasses = null;
|
||||||
|
|
||||||
|
public ApiDocConcept() {
|
||||||
|
conceptChildClasses = new ArrayList<Class<?>>(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiDocConcept(ApiDocConcept parent,String id,Class<?> conceptClass) {
|
||||||
|
this();
|
||||||
|
setId(id);
|
||||||
|
setConceptClass(conceptClass);
|
||||||
|
setParent(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiDocConcept(ApiDocConcept parent,String[] text,Class<?> conceptClass,Class<?>...classes) {
|
||||||
|
this(parent,text[0],text[1],text[2],text[3],conceptClass,classes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiDocConcept(ApiDocConcept parent,String id,String name,String descriptionName,String descriptionHelp,Class<?> conceptClass,Class<?>...classes) {
|
||||||
|
this(parent,id,conceptClass);
|
||||||
|
setName(name);
|
||||||
|
setDescriptionName(descriptionName);
|
||||||
|
setDescriptionHelp(descriptionHelp);
|
||||||
|
for (Class<?> cl:classes) {
|
||||||
|
addConceptChildClass(cl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the id
|
||||||
|
*/
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param id the id to set
|
||||||
|
*/
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name the name to set
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the descriptionName
|
||||||
|
*/
|
||||||
|
public String getDescriptionName() {
|
||||||
|
return descriptionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param descriptionName the descriptionName to set
|
||||||
|
*/
|
||||||
|
public void setDescriptionName(String descriptionName) {
|
||||||
|
this.descriptionName = descriptionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the descriptionHelp
|
||||||
|
*/
|
||||||
|
public String getDescriptionHelp() {
|
||||||
|
return descriptionHelp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param descriptionHelp the descriptionHelp to set
|
||||||
|
*/
|
||||||
|
public void setDescriptionHelp(String descriptionHelp) {
|
||||||
|
this.descriptionHelp = descriptionHelp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the conceptClass
|
||||||
|
*/
|
||||||
|
public Class<?> getConceptClass() {
|
||||||
|
return conceptClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param conceptClass the conceptClass to set
|
||||||
|
*/
|
||||||
|
public void setConceptClass(Class<?> conceptClass) {
|
||||||
|
this.conceptClass = conceptClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addConceptChildClass(Class<?> targetClass) {
|
||||||
|
conceptChildClasses.add(targetClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeConceptChildClass(Class<?> targetClass) {
|
||||||
|
conceptChildClasses.remove(conceptChildClasses);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Class<?>> getConceptChildClasses() {
|
||||||
|
return conceptChildClasses;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the parent
|
||||||
|
*/
|
||||||
|
public ApiDocConcept getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param parent the parent to set
|
||||||
|
*/
|
||||||
|
public void setParent(ApiDocConcept parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,164 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.eld.doc.api.dom;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApiDocNode defines the concept impl data tree nodes for which we write documents.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 12, 2013
|
||||||
|
*/
|
||||||
|
public class ApiDocNode {
|
||||||
|
|
||||||
|
private Object userData = null;
|
||||||
|
private String id = null;
|
||||||
|
private String name = null;
|
||||||
|
private String description = null;
|
||||||
|
private ApiDocNode parent = null;
|
||||||
|
private List<ApiDocNode> nodes = null;
|
||||||
|
private Map<String,String> contentGroupTypes = null;
|
||||||
|
|
||||||
|
public ApiDocNode() {
|
||||||
|
nodes = new ArrayList<ApiDocNode>(30);
|
||||||
|
contentGroupTypes = new HashMap<String,String>(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiDocNode(Object userData,String id,String name,String description) {
|
||||||
|
this();
|
||||||
|
setUserData(userData);
|
||||||
|
setId(id);
|
||||||
|
setName(name);
|
||||||
|
if (description==null) {
|
||||||
|
description = name;
|
||||||
|
}
|
||||||
|
setDescription(description);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiDocNode addNode(ApiDocNode node) {
|
||||||
|
node.setParent(this);
|
||||||
|
nodes.add(node);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean removeNode(ApiDocNode node) {
|
||||||
|
return nodes.remove(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ApiDocNode> getNodes() {
|
||||||
|
return nodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addContentGroupType(String id,String name) {
|
||||||
|
contentGroupTypes.put(id, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeContentGroupType(String id) {
|
||||||
|
contentGroupTypes.remove(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContentGroupTypeName(String id) {
|
||||||
|
return contentGroupTypes.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getContentGroupTypeKeys() {
|
||||||
|
return contentGroupTypes.keySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the userData
|
||||||
|
*/
|
||||||
|
public Object getUserData() {
|
||||||
|
return userData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param userData the userData to set
|
||||||
|
*/
|
||||||
|
public void setUserData(Object userData) {
|
||||||
|
this.userData = userData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the id
|
||||||
|
*/
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param id the id to set
|
||||||
|
*/
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name the name to set
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the description
|
||||||
|
*/
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param description the description to set
|
||||||
|
*/
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the parent
|
||||||
|
*/
|
||||||
|
public ApiDocNode getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param parent the parent to set
|
||||||
|
*/
|
||||||
|
public void setParent(ApiDocNode parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.eld.doc.api.dom;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApiDocNodeBody are the parts from which the content body is created.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 12, 2013
|
||||||
|
*/
|
||||||
|
public enum ApiDocNodeBody {
|
||||||
|
|
||||||
|
TREE_PATH,
|
||||||
|
DESCRIPTION_LINKS,
|
||||||
|
DESCRIPTION_NODE,
|
||||||
|
SUMMARY,
|
||||||
|
DETAIL
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.eld.doc.api.dom;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApiDocNodeWriter are the parts from which the content body is created.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 12, 2013
|
||||||
|
*/
|
||||||
|
public interface ApiDocNodeWriter {
|
||||||
|
|
||||||
|
ApiDocNodeBody getNodeBody();
|
||||||
|
List<Class<?>> getTargetClasses();
|
||||||
|
|
||||||
|
void writeNodeContent(ApiDocWriteEvent<ApiDocNode> e) throws SAXException;
|
||||||
|
}
|
|
@ -0,0 +1,117 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.eld.doc.api.dom;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApiDocPage defines seperate pages for the documentation.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 12, 2013
|
||||||
|
*/
|
||||||
|
public class ApiDocPage {
|
||||||
|
|
||||||
|
private String id = null;
|
||||||
|
private String name = null;
|
||||||
|
private String description = null;
|
||||||
|
private List<ApiDocPageWriter> pageWriters = null;
|
||||||
|
|
||||||
|
public ApiDocPage() {
|
||||||
|
pageWriters = new ArrayList<ApiDocPageWriter>(30);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiDocPage(String id,String name,String description,ApiDocPageWriter...writers) {
|
||||||
|
this();
|
||||||
|
setId(id);
|
||||||
|
setName(name);
|
||||||
|
setDescription(description);
|
||||||
|
for (ApiDocPageWriter writer:writers) {
|
||||||
|
addPageWriter(writer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the id
|
||||||
|
*/
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param id the id to set
|
||||||
|
*/
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name the name to set
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the description
|
||||||
|
*/
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param description the description to set
|
||||||
|
*/
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the page writers.
|
||||||
|
*/
|
||||||
|
public List<ApiDocPageWriter> getPageWriters() {
|
||||||
|
return pageWriters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param writer the writer to add.
|
||||||
|
*/
|
||||||
|
public void addPageWriter(ApiDocPageWriter writer) {
|
||||||
|
pageWriters.add(writer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param writer the writer to add.
|
||||||
|
*/
|
||||||
|
public void removePageWriter(ApiDocPageWriter writer) {
|
||||||
|
pageWriters.remove(writer);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.eld.doc.api.dom;
|
||||||
|
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApiDocPageWriter writes a page content part.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 12, 2013
|
||||||
|
*/
|
||||||
|
public interface ApiDocPageWriter {
|
||||||
|
|
||||||
|
void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException;
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.eld.doc.api.dom;
|
||||||
|
|
||||||
|
import org.x4o.xml.eld.doc.api.ApiDocContentWriter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApiDocWriteEvent holds the needed objects to process write events of content parts.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 12, 2013
|
||||||
|
*/
|
||||||
|
public class ApiDocWriteEvent<T> {
|
||||||
|
|
||||||
|
private ApiDoc doc = null;
|
||||||
|
private T event = null;
|
||||||
|
private ApiDocContentWriter writer = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an ApiDocNodeBodyEvent.
|
||||||
|
* @param doc The ApiDoc we are writing.
|
||||||
|
* @param writer The content writer to write to.
|
||||||
|
* @param event The event we are firing this event for.
|
||||||
|
*/
|
||||||
|
public ApiDocWriteEvent(ApiDoc doc,ApiDocContentWriter writer,T event) {
|
||||||
|
this.doc=doc;
|
||||||
|
this.writer=writer;
|
||||||
|
this.event=event;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the doc
|
||||||
|
*/
|
||||||
|
public ApiDoc getDoc() {
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the event
|
||||||
|
*/
|
||||||
|
public T getEvent() {
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the writer
|
||||||
|
*/
|
||||||
|
public ApiDocContentWriter getWriter() {
|
||||||
|
return writer;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Api Doc Dom classes.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @since 1.0 May 12,2013
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.eld.doc.api.dom;
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Api Doc Writer classes.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @since 1.0 May 12,2013
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.eld.doc.api;
|
|
@ -20,10 +20,12 @@
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The X4O ELD documentation classes.
|
* The X4O ELD documentation classes.
|
||||||
*
|
*
|
||||||
* @since 1.0
|
* @author Willem Cazander
|
||||||
|
* @since 1.0 Aug 26, 2010
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.x4o.xml.eld.doc;
|
package org.x4o.xml.eld.doc;
|
127
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-color.css
vendored
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
|
||||||
|
/* Color style sheet */
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color:#ffffff;
|
||||||
|
color:#353833;
|
||||||
|
}
|
||||||
|
a:link, a:visited {
|
||||||
|
color:#4c6b87;
|
||||||
|
}
|
||||||
|
a:hover, a:focus {
|
||||||
|
color:#bb7a2a;
|
||||||
|
}
|
||||||
|
a:active {
|
||||||
|
color:#4c6b87;
|
||||||
|
}
|
||||||
|
a[name] {
|
||||||
|
color:#353833;
|
||||||
|
}
|
||||||
|
a[name]:hover {
|
||||||
|
color:#353833;
|
||||||
|
}
|
||||||
|
.bar a, .bar a:link, .bar a:visited, .bar a:active {
|
||||||
|
color:#FFFFFF;
|
||||||
|
}
|
||||||
|
.bar a:hover, .bar a:focus {
|
||||||
|
color:#bb7a2a;
|
||||||
|
}
|
||||||
|
.tab {
|
||||||
|
background-color:#0066FF;
|
||||||
|
color:#ffffff;
|
||||||
|
}
|
||||||
|
.bar {
|
||||||
|
color:#FFFFFF;
|
||||||
|
}
|
||||||
|
.topNav {
|
||||||
|
color:#FFFFFF;
|
||||||
|
}
|
||||||
|
.bottomNav {
|
||||||
|
color:#FFFFFF;
|
||||||
|
}
|
||||||
|
.subNav {
|
||||||
|
background-color:#dee3e9;
|
||||||
|
border-bottom:1px solid #9eadc0;
|
||||||
|
}
|
||||||
|
.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited {
|
||||||
|
color:#FFFFFF;
|
||||||
|
}
|
||||||
|
.topNav a:hover, .bottomNav a:hover {
|
||||||
|
color:#bb7a2a;
|
||||||
|
}
|
||||||
|
.navBarCell1Rev {
|
||||||
|
color:#FFFFFF;
|
||||||
|
border:1px solid #c9aa44;
|
||||||
|
}
|
||||||
|
.title {
|
||||||
|
color:#2c4557;
|
||||||
|
}
|
||||||
|
div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 {
|
||||||
|
background-color:#dee3e9;
|
||||||
|
border-top:1px solid #9eadc0;
|
||||||
|
border-bottom:1px solid #9eadc0;
|
||||||
|
}
|
||||||
|
ul.blockList ul.blockList ul.blockList li.blockList h3 {
|
||||||
|
background-color:#dee3e9;
|
||||||
|
border-top:1px solid #9eadc0;
|
||||||
|
border-bottom:1px solid #9eadc0;
|
||||||
|
}
|
||||||
|
.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt {
|
||||||
|
color:#4E4E4E;
|
||||||
|
}
|
||||||
|
ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList {
|
||||||
|
border:1px solid #9eadc0;
|
||||||
|
background-color:#f9f9f9;
|
||||||
|
}
|
||||||
|
ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList {
|
||||||
|
background-color:#ffffff;
|
||||||
|
border:1px solid #9eadc0;
|
||||||
|
border-top:none;
|
||||||
|
}
|
||||||
|
ul.blockList ul.blockList ul.blockList ul.blockList li.blockList {
|
||||||
|
border:none;
|
||||||
|
border-bottom:1px solid #9eadc0;
|
||||||
|
}
|
||||||
|
ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast {
|
||||||
|
border-bottom:none;
|
||||||
|
}
|
||||||
|
.contentContainer table, .classUseContainer table, .constantValuesContainer table {
|
||||||
|
border-bottom:1px solid #9eadc0;
|
||||||
|
}
|
||||||
|
.contentContainer .description table, .contentContainer .details table {
|
||||||
|
border-bottom:none;
|
||||||
|
}
|
||||||
|
.overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption {
|
||||||
|
color:#FFFFFF;
|
||||||
|
}
|
||||||
|
caption a:link, caption a:hover, caption a:active, caption a:visited {
|
||||||
|
color:#FFFFFF;
|
||||||
|
}
|
||||||
|
.tableSubHeadingColor {
|
||||||
|
background-color: #EEEEFF;
|
||||||
|
}
|
||||||
|
.altColor {
|
||||||
|
background-color:#eeeeef;
|
||||||
|
}
|
||||||
|
.rowColor {
|
||||||
|
background-color:#ffffff;
|
||||||
|
}
|
||||||
|
th.colFirst, th.colLast, th.colOne, .constantValuesContainer th {
|
||||||
|
background:#dee3e9;
|
||||||
|
border-top:1px solid #9eadc0;
|
||||||
|
border-bottom:1px solid #9eadc0;
|
||||||
|
}
|
||||||
|
td.colFirst, th.colFirst {
|
||||||
|
border-left:1px solid #9eadc0;
|
||||||
|
}
|
||||||
|
td.colLast, th.colLast {
|
||||||
|
border-right:1px solid #9eadc0;
|
||||||
|
}
|
||||||
|
td.colOne, th.colOne {
|
||||||
|
border-right:1px solid #9eadc0;
|
||||||
|
border-left:1px solid #9eadc0;
|
||||||
|
}
|
||||||
|
.sourceLineNo {
|
||||||
|
color:green;
|
||||||
|
}
|
||||||
|
|
92
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-font.css
vendored
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family:Arial, Helvetica, sans-serif;
|
||||||
|
font-size:76%;
|
||||||
|
}
|
||||||
|
pre {
|
||||||
|
font-size:1.3em;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
font-size:1.8em;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
font-size:1.5em;
|
||||||
|
}
|
||||||
|
h3 {
|
||||||
|
font-size:1.4em;
|
||||||
|
}
|
||||||
|
h4 {
|
||||||
|
font-size:1.3em;
|
||||||
|
}
|
||||||
|
h5 {
|
||||||
|
font-size:1.2em;
|
||||||
|
}
|
||||||
|
h6 {
|
||||||
|
font-size:1.1em;
|
||||||
|
}
|
||||||
|
code, tt {
|
||||||
|
font-size:1.2em;
|
||||||
|
}
|
||||||
|
dt code {
|
||||||
|
font-size:1.2em;
|
||||||
|
}
|
||||||
|
table tr td dt code {
|
||||||
|
font-size:1.2em;
|
||||||
|
vertical-align:top;
|
||||||
|
}
|
||||||
|
sup {
|
||||||
|
font-size:0.6em;
|
||||||
|
}
|
||||||
|
.aboutLanguage {
|
||||||
|
font-size:0.8em;
|
||||||
|
}
|
||||||
|
.tab {
|
||||||
|
font-weight:bold;
|
||||||
|
}
|
||||||
|
.bar {
|
||||||
|
font-size:1.0em;
|
||||||
|
}
|
||||||
|
ul.subNavList li{
|
||||||
|
font-size:90%;
|
||||||
|
}
|
||||||
|
.indexHeader h1 {
|
||||||
|
font-size:1.3em;
|
||||||
|
}
|
||||||
|
.header ul li, .footer ul li {
|
||||||
|
font-size:1.2em;
|
||||||
|
}
|
||||||
|
.indexContainer {
|
||||||
|
font-size:1.0em;
|
||||||
|
}
|
||||||
|
.indexContainer h2 {
|
||||||
|
font-size:1.1em;
|
||||||
|
}
|
||||||
|
.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt {
|
||||||
|
font-size:1.1em;
|
||||||
|
font-weight:bold;
|
||||||
|
}
|
||||||
|
.serializedFormContainer dl.nameValue dt {
|
||||||
|
font-size:1.1em;
|
||||||
|
font-weight:bold;
|
||||||
|
}
|
||||||
|
.serializedFormContainer dl.nameValue dd {
|
||||||
|
font-size:1.1em;
|
||||||
|
}
|
||||||
|
ul.horizontal li {
|
||||||
|
font-size:0.9em;
|
||||||
|
}
|
||||||
|
.overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption {
|
||||||
|
font-weight:bold;
|
||||||
|
}
|
||||||
|
td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover {
|
||||||
|
font-weight:bold;
|
||||||
|
}
|
||||||
|
h1.hidden {
|
||||||
|
font-size:0.9em;
|
||||||
|
}
|
||||||
|
.strong {
|
||||||
|
font-weight:bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
53
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-html.css
vendored
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
a:link, a:visited {
|
||||||
|
text-decoration:none;
|
||||||
|
}
|
||||||
|
a:hover, a:focus {
|
||||||
|
text-decoration:none;
|
||||||
|
}
|
||||||
|
a:active {
|
||||||
|
text-decoration:none;
|
||||||
|
}
|
||||||
|
a[name] {
|
||||||
|
}
|
||||||
|
a[name]:hover {
|
||||||
|
text-decoration:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul {
|
||||||
|
list-style-type:disc;
|
||||||
|
}
|
||||||
|
.bar a, .bar a:link, .bar a:visited, .bar a:active {
|
||||||
|
text-decoration:none;
|
||||||
|
}
|
||||||
|
ul.navList li{
|
||||||
|
list-style:none;
|
||||||
|
}
|
||||||
|
ul.subNavList li{
|
||||||
|
list-style:none;
|
||||||
|
}
|
||||||
|
.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited {
|
||||||
|
text-decoration:none;
|
||||||
|
}
|
||||||
|
.topNav a:hover, .bottomNav a:hover {
|
||||||
|
text-decoration:none;
|
||||||
|
}
|
||||||
|
.header ul li, .footer ul li {
|
||||||
|
list-style:none;
|
||||||
|
}
|
||||||
|
.indexContainer ul li {
|
||||||
|
list-style:none;
|
||||||
|
}
|
||||||
|
ul.inheritance li {
|
||||||
|
list-style:none;
|
||||||
|
}
|
||||||
|
ul.blockList li.blockList, ul.blockListLast li.blockList {
|
||||||
|
list-style:none;
|
||||||
|
}
|
||||||
|
ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast {
|
||||||
|
list-style:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
183
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-inset.css
vendored
Normal file
|
@ -0,0 +1,183 @@
|
||||||
|
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin:0px;
|
||||||
|
padding:0px;
|
||||||
|
}
|
||||||
|
.aboutLanguage {
|
||||||
|
padding:0px 21px;
|
||||||
|
margin-top:-7px;
|
||||||
|
}
|
||||||
|
.legalCopy {
|
||||||
|
margin-left:0.5em;
|
||||||
|
}
|
||||||
|
.tab {
|
||||||
|
padding:8px;
|
||||||
|
}
|
||||||
|
.bar {
|
||||||
|
padding:0.8em 0.5em 0.4em 0.8em;
|
||||||
|
margin:0px;
|
||||||
|
}
|
||||||
|
.topNav {
|
||||||
|
padding:0px;
|
||||||
|
padding-top:10px;
|
||||||
|
}
|
||||||
|
.bottomNav {
|
||||||
|
margin-top:10px;
|
||||||
|
padding:0px;
|
||||||
|
padding-top:10px;
|
||||||
|
}
|
||||||
|
.subNav div {
|
||||||
|
padding:0px 0px 5px 6px;
|
||||||
|
}
|
||||||
|
ul.navList, ul.subNavList {
|
||||||
|
margin:0px 25px 0px 0px;
|
||||||
|
padding:0px;
|
||||||
|
}
|
||||||
|
ul.navList li{
|
||||||
|
padding:3px 6px;
|
||||||
|
}
|
||||||
|
.navBarCell1Rev {
|
||||||
|
margin: auto 5px;
|
||||||
|
}
|
||||||
|
.header, .footer {
|
||||||
|
margin:0px 20px;
|
||||||
|
padding:5px 0px 0px 0px;
|
||||||
|
}
|
||||||
|
.indexHeader {
|
||||||
|
margin:10px;
|
||||||
|
}
|
||||||
|
.title {
|
||||||
|
margin:10px 0px;
|
||||||
|
}
|
||||||
|
.subTitle {
|
||||||
|
margin:5px 0px 0px 0px;
|
||||||
|
}
|
||||||
|
.header ul {
|
||||||
|
margin:0px 0px 25px 0px;
|
||||||
|
padding:0px;
|
||||||
|
}
|
||||||
|
.footer ul {
|
||||||
|
margin:20px 0 5px 0;
|
||||||
|
}
|
||||||
|
div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 {
|
||||||
|
margin:0px 0px 6px -8px;
|
||||||
|
padding:2px 5px;
|
||||||
|
}
|
||||||
|
ul.blockList ul.blockList ul.blockList li.blockList h3 {
|
||||||
|
margin:0px 0px 6px -8px;
|
||||||
|
padding:2px 5px;
|
||||||
|
}
|
||||||
|
ul.blockList ul.blockList li.blockList h3 {
|
||||||
|
padding:0px;
|
||||||
|
margin:15px 0px;
|
||||||
|
}
|
||||||
|
ul.blockList li.blockList h2 {
|
||||||
|
padding:0px 0px 20px 0px;
|
||||||
|
}
|
||||||
|
.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer {
|
||||||
|
padding:10px 20px;
|
||||||
|
}
|
||||||
|
.indexContainer {
|
||||||
|
margin:10px;
|
||||||
|
}
|
||||||
|
.indexContainer h2 {
|
||||||
|
padding:0px 0px 3px 0px;
|
||||||
|
}
|
||||||
|
.indexContainer ul {
|
||||||
|
margin:0px;
|
||||||
|
padding:0px;
|
||||||
|
}
|
||||||
|
.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt {
|
||||||
|
margin:10px 0px 0px 0px;
|
||||||
|
}
|
||||||
|
.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd {
|
||||||
|
margin:10px 0px 10px 20px;
|
||||||
|
}
|
||||||
|
.serializedFormContainer dl.nameValue dt {
|
||||||
|
margin-left:1px;
|
||||||
|
}
|
||||||
|
.serializedFormContainer dl.nameValue dd {
|
||||||
|
margin:0px 0px 0px 1px;
|
||||||
|
}
|
||||||
|
ul.inheritance {
|
||||||
|
margin:0px;
|
||||||
|
padding:0px;
|
||||||
|
}
|
||||||
|
ul.inheritance li ul.inheritance {
|
||||||
|
margin-left:15px;
|
||||||
|
padding-left:15px;
|
||||||
|
padding-top:1px;
|
||||||
|
}
|
||||||
|
ul.blockList, ul.blockListLast {
|
||||||
|
margin:10px 0px 10px 0px;
|
||||||
|
padding:0px;
|
||||||
|
}
|
||||||
|
ul.blockList li.blockList, ul.blockListLast li.blockList {
|
||||||
|
margin-bottom:25px;
|
||||||
|
}
|
||||||
|
ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList {
|
||||||
|
padding:0px 20px 5px 10px;
|
||||||
|
}
|
||||||
|
ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList {
|
||||||
|
padding:0px 0px 5px 8px;
|
||||||
|
}
|
||||||
|
ul.blockList ul.blockList ul.blockList ul.blockList li.blockList {
|
||||||
|
margin-left:0px;
|
||||||
|
padding-left:0px;
|
||||||
|
padding-bottom:15px;
|
||||||
|
}
|
||||||
|
ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast {
|
||||||
|
padding-bottom:0;
|
||||||
|
}
|
||||||
|
table tr td dl, table tr td dl dt, table tr td dl dd {
|
||||||
|
margin-top:0px;
|
||||||
|
margin-bottom:1px;
|
||||||
|
}
|
||||||
|
.contentContainer ul li table th.colOne, .contentContainer ul li table th.colFirst, .contentContainer ul li table th.colLast, .classUseContainer ul li table th, .constantValuesContainer ul li table th, .contentContainer ul li table td.colOne, .contentContainer ul li table td.colFirst, .contentContainer ul li table td.colLast, .classUseContainer ul li table td, .constantValuesContainer ul li table td{
|
||||||
|
padding-right:20px;
|
||||||
|
}
|
||||||
|
.contentContainer ul li table th.colLast, .classUseContainer ul li table th.colLast,.constantValuesContainer ul li table th.colLast,
|
||||||
|
.contentContainer ul li table td.colLast, .classUseContainer ul li table td.colLast,.constantValuesContainer ul li table td.colLast,
|
||||||
|
.contentContainer ul li table th.colOne, .classUseContainer ul li table th.colOne,
|
||||||
|
.contentContainer ul li table td.colOne, .classUseContainer ul li table td.colOne {
|
||||||
|
padding-right:3px;
|
||||||
|
}
|
||||||
|
.overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption {
|
||||||
|
padding:0px;
|
||||||
|
margin:0px;
|
||||||
|
}
|
||||||
|
.overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span {
|
||||||
|
padding-top:8px;
|
||||||
|
padding-left:8px;
|
||||||
|
}
|
||||||
|
ul.blockList ul.blockList li.blockList table {
|
||||||
|
margin:0px 0px 12px 0px;
|
||||||
|
}
|
||||||
|
.overviewSummary td, .packageSummary td, .contentContainer ul.blockList li.blockList td, .summary td, .classUseContainer td, .constantValuesContainer td {
|
||||||
|
padding:3px 3px 3px 7px;
|
||||||
|
}
|
||||||
|
th.colFirst, th.colLast, th.colOne, .constantValuesContainer th {
|
||||||
|
padding:3px 3px 3px 7px;
|
||||||
|
}
|
||||||
|
table.overviewSummary {
|
||||||
|
padding:0px;
|
||||||
|
margin-left:0px;
|
||||||
|
}
|
||||||
|
.description pre {
|
||||||
|
margin-top:0px;
|
||||||
|
}
|
||||||
|
.deprecatedContent {
|
||||||
|
margin:0px;
|
||||||
|
padding:10px 0px;
|
||||||
|
}
|
||||||
|
.docSummary {
|
||||||
|
padding:0px;
|
||||||
|
}
|
||||||
|
.sourceLineNo {
|
||||||
|
padding:0px 30px 0px 0px;
|
||||||
|
}
|
||||||
|
.block {
|
||||||
|
margin:3px 0px 0px 0px;
|
||||||
|
}
|
||||||
|
|
131
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-layout.css
vendored
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
|
||||||
|
|
||||||
|
.clear {
|
||||||
|
clear:both;
|
||||||
|
height:0px;
|
||||||
|
overflow:hidden;
|
||||||
|
}
|
||||||
|
.aboutLanguage {
|
||||||
|
float:right;
|
||||||
|
z-index:200;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab {
|
||||||
|
width:5em;
|
||||||
|
}
|
||||||
|
.bar {
|
||||||
|
height:auto;
|
||||||
|
}
|
||||||
|
.topNav {
|
||||||
|
float:left;
|
||||||
|
width:100%;
|
||||||
|
clear:right;
|
||||||
|
height:2.8em;
|
||||||
|
overflow:hidden;
|
||||||
|
}
|
||||||
|
.bottomNav {
|
||||||
|
float:left;
|
||||||
|
width:100%;
|
||||||
|
clear:right;
|
||||||
|
height:2.8em;
|
||||||
|
overflow:hidden;
|
||||||
|
}
|
||||||
|
.subNav {
|
||||||
|
float:left;
|
||||||
|
width:100%;
|
||||||
|
overflow:hidden;
|
||||||
|
}
|
||||||
|
.subNav div {
|
||||||
|
clear:left;
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
ul.navList, ul.subNavList {
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
ul.navList li, ul.subNavList li {
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
.header, .footer {
|
||||||
|
clear:both;
|
||||||
|
}
|
||||||
|
.indexHeader {
|
||||||
|
position:relative;
|
||||||
|
}
|
||||||
|
.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer {
|
||||||
|
clear:both;
|
||||||
|
position:relative;
|
||||||
|
}
|
||||||
|
.indexContainer {
|
||||||
|
position:relative;
|
||||||
|
}
|
||||||
|
.serializedFormContainer dl.nameValue dt {
|
||||||
|
display:inline;
|
||||||
|
}
|
||||||
|
.serializedFormContainer dl.nameValue dd {
|
||||||
|
display:inline;
|
||||||
|
}
|
||||||
|
ul.horizontal li {
|
||||||
|
display:inline;
|
||||||
|
}
|
||||||
|
ul.inheritance li {
|
||||||
|
display:inline;
|
||||||
|
}
|
||||||
|
.contentContainer table, .classUseContainer table, .constantValuesContainer table {
|
||||||
|
width:100%;
|
||||||
|
}
|
||||||
|
.contentContainer ul li table, .classUseContainer ul li table, .constantValuesContainer ul li table {
|
||||||
|
width:100%;
|
||||||
|
}
|
||||||
|
.contentContainer ul li table th.colOne, .contentContainer ul li table th.colFirst, .contentContainer ul li table th.colLast, .classUseContainer ul li table th, .constantValuesContainer ul li table th, .contentContainer ul li table td.colOne, .contentContainer ul li table td.colFirst, .contentContainer ul li table td.colLast, .classUseContainer ul li table td, .constantValuesContainer ul li table td{
|
||||||
|
vertical-align:top;
|
||||||
|
}
|
||||||
|
.overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption {
|
||||||
|
position:relative;
|
||||||
|
text-align:left;
|
||||||
|
clear:none;
|
||||||
|
overflow:hidden;
|
||||||
|
}
|
||||||
|
.overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span {
|
||||||
|
white-space:nowrap;
|
||||||
|
display:block;
|
||||||
|
float:left;
|
||||||
|
height:18px;
|
||||||
|
}
|
||||||
|
.overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd {
|
||||||
|
width:10px;
|
||||||
|
position:relative;
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
ul.blockList ul.blockList li.blockList table {
|
||||||
|
width:100%;
|
||||||
|
}
|
||||||
|
.overviewSummary td, .packageSummary td, .contentContainer ul.blockList li.blockList td, .summary td, .classUseContainer td, .constantValuesContainer td {
|
||||||
|
text-align:left;
|
||||||
|
}
|
||||||
|
th.colFirst, th.colLast, th.colOne, .constantValuesContainer th {
|
||||||
|
text-align:left;
|
||||||
|
}
|
||||||
|
td.colFirst, th.colFirst {
|
||||||
|
white-space:nowrap;
|
||||||
|
}
|
||||||
|
table.overviewSummary td.colFirst, table.overviewSummary th.colFirst,
|
||||||
|
table.overviewSummary td.colOne, table.overviewSummary th.colOne {
|
||||||
|
width:25%;
|
||||||
|
vertical-align:middle;
|
||||||
|
}
|
||||||
|
table.packageSummary td.colFirst, table.overviewSummary th.colFirst {
|
||||||
|
width:25%;
|
||||||
|
vertical-align:middle;
|
||||||
|
}
|
||||||
|
h1.hidden {
|
||||||
|
visibility:hidden;
|
||||||
|
overflow:hidden;
|
||||||
|
}
|
||||||
|
.block {
|
||||||
|
display:block;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
106
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk6/stylesheet.css
vendored
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
|
||||||
|
body {
|
||||||
|
padding:10px;
|
||||||
|
font-family:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topNav,
|
||||||
|
.bottomNav {
|
||||||
|
height:auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab {
|
||||||
|
background-color:#00CCFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bar,
|
||||||
|
.topNav,
|
||||||
|
.bottomNav {
|
||||||
|
background-color: #EEEEFF;
|
||||||
|
border-top: 2px solid #000;
|
||||||
|
padding-top: 0px;
|
||||||
|
padding-bottom: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subNav {
|
||||||
|
background-color: #FFF;
|
||||||
|
border-bottom: 2px solid #000;
|
||||||
|
font-size:0.8em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topNav a:link,
|
||||||
|
.topNav a:active,
|
||||||
|
.topNav a:visited,
|
||||||
|
.bottomNav a:link,
|
||||||
|
.bottomNav a:active,
|
||||||
|
.bottomNav a:visited {
|
||||||
|
color:#000;
|
||||||
|
text-decoration: underline;
|
||||||
|
font-weight:bold;
|
||||||
|
font-size:1.2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.aboutLanguage {
|
||||||
|
position:absolute;
|
||||||
|
right:10px;
|
||||||
|
text-align:right;
|
||||||
|
width:250px;
|
||||||
|
font-size: 0.9em;
|
||||||
|
color:#000;
|
||||||
|
margin:0px;
|
||||||
|
background-color: #FFF;
|
||||||
|
padding:1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
li {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topNav ul li,
|
||||||
|
.bottomNav ul li {
|
||||||
|
margin-top:3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navBarCell1Rev {
|
||||||
|
color:#FFF;
|
||||||
|
background-color:#00008B;
|
||||||
|
font-weight:bold;
|
||||||
|
border:none;
|
||||||
|
margin-top:3px;
|
||||||
|
margin-bottom:3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span {
|
||||||
|
background-color: #EEEEFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd {
|
||||||
|
background-color: #EEEEFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
th.colFirst,
|
||||||
|
th.colLast,
|
||||||
|
th.colOne,
|
||||||
|
.constantValuesContainer th {
|
||||||
|
background-color:#CCCCFF;
|
||||||
|
border-top: 1px solid #000;
|
||||||
|
border-bottom: 1px solid #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.altColor {
|
||||||
|
background-color: #FFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contentContainer table tbody tr td,
|
||||||
|
.classUseContainer table tbody tr td,
|
||||||
|
.constantValuesContainer table tbody tr td {
|
||||||
|
border-bottom: 1px solid #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.colFirst,
|
||||||
|
th.colFirst {
|
||||||
|
border-right: 1px solid #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
22
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/stylesheet.css
vendored
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
|
||||||
|
.tab {
|
||||||
|
background-image:url(titlebar.png);
|
||||||
|
background-position:left top;
|
||||||
|
background-repeat:no-repeat;
|
||||||
|
}
|
||||||
|
.bar,.topNav,.bottomNav {
|
||||||
|
background-image:url(background.png);
|
||||||
|
background-repeat:repeat-x;
|
||||||
|
}
|
||||||
|
.navBarCell1Rev {
|
||||||
|
background-image:url(tab.png);
|
||||||
|
}
|
||||||
|
.overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span {
|
||||||
|
background-image:url(titlebar.png);
|
||||||
|
}
|
||||||
|
.overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd {
|
||||||
|
background-image:url(titlebar_end.png);
|
||||||
|
background-repeat:no-repeat;
|
||||||
|
background-position:top right;
|
||||||
|
}
|
||||||
|
|
Before Width: | Height: | Size: 333 B After Width: | Height: | Size: 333 B |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 683 B After Width: | Height: | Size: 683 B |
|
@ -40,8 +40,9 @@ import junit.framework.TestCase;
|
||||||
*/
|
*/
|
||||||
public class X4OWriteLanguageDocExecutorTest extends TestCase {
|
public class X4OWriteLanguageDocExecutorTest extends TestCase {
|
||||||
|
|
||||||
private File getTempPath(String dir) throws Exception {
|
private File createOutputTargetPath(String dir) throws Exception {
|
||||||
File tempFile = File.createTempFile("test-path", ".tmp");
|
File tempFile = new File("target/path");
|
||||||
|
//File tempFile = File.createTempFile("junit", "test");
|
||||||
String absolutePath = tempFile.getAbsolutePath();
|
String absolutePath = tempFile.getAbsolutePath();
|
||||||
String tempPath = absolutePath.substring(0,absolutePath.lastIndexOf(File.separator)+1);
|
String tempPath = absolutePath.substring(0,absolutePath.lastIndexOf(File.separator)+1);
|
||||||
tempFile.delete();
|
tempFile.delete();
|
||||||
|
@ -54,28 +55,28 @@ public class X4OWriteLanguageDocExecutorTest extends TestCase {
|
||||||
|
|
||||||
public void testCelDoc() throws Exception {
|
public void testCelDoc() throws Exception {
|
||||||
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
|
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
|
||||||
writer.setBasePath(getTempPath("junit-cel"));
|
writer.setBasePath(createOutputTargetPath("junit-cel"));
|
||||||
writer.setLanguageName(CelDriver.LANGUAGE_NAME);
|
writer.setLanguageName(CelDriver.LANGUAGE_NAME);
|
||||||
writer.execute();
|
writer.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testEldDoc() throws Exception {
|
public void testEldDoc() throws Exception {
|
||||||
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
|
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
|
||||||
writer.setBasePath(getTempPath("junit-eld"));
|
writer.setBasePath(createOutputTargetPath("junit-eld"));
|
||||||
writer.setLanguageName(EldDriver.LANGUAGE_NAME);
|
writer.setLanguageName(EldDriver.LANGUAGE_NAME);
|
||||||
writer.execute();
|
writer.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUnitDoc() throws Exception {
|
public void testUnitDoc() throws Exception {
|
||||||
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
|
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
|
||||||
writer.setBasePath(getTempPath("junit-test"));
|
writer.setBasePath(createOutputTargetPath("junit-test"));
|
||||||
writer.setLanguageName(TestDriver.LANGUAGE_NAME);
|
writer.setLanguageName(TestDriver.LANGUAGE_NAME);
|
||||||
writer.execute();
|
writer.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSwiXml2Doc() throws Exception {
|
public void testSwiXml2Doc() throws Exception {
|
||||||
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
|
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
|
||||||
writer.setBasePath(getTempPath("junit-swixml2"));
|
writer.setBasePath(createOutputTargetPath("junit-swixml2"));
|
||||||
writer.setLanguageName(SwiXmlDriver.LANGUAGE_NAME);
|
writer.setLanguageName(SwiXmlDriver.LANGUAGE_NAME);
|
||||||
writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_2);
|
writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_2);
|
||||||
writer.execute();
|
writer.execute();
|
||||||
|
@ -83,7 +84,7 @@ public class X4OWriteLanguageDocExecutorTest extends TestCase {
|
||||||
|
|
||||||
public void testSwiXml3Doc() throws Exception {
|
public void testSwiXml3Doc() throws Exception {
|
||||||
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
|
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
|
||||||
writer.setBasePath(getTempPath("junit-swixml3"));
|
writer.setBasePath(createOutputTargetPath("junit-swixml3"));
|
||||||
writer.setLanguageName(SwiXmlDriver.LANGUAGE_NAME);
|
writer.setLanguageName(SwiXmlDriver.LANGUAGE_NAME);
|
||||||
writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_3);
|
writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_3);
|
||||||
writer.execute();
|
writer.execute();
|
||||||
|
@ -91,6 +92,6 @@ public class X4OWriteLanguageDocExecutorTest extends TestCase {
|
||||||
|
|
||||||
|
|
||||||
public void testEldDocMain() throws Exception {
|
public void testEldDocMain() throws Exception {
|
||||||
X4OWriteLanguageDocExecutor.main(new String[] {"-p",getTempPath("junit-test-main").getAbsolutePath(),"-l",EldDriver.LANGUAGE_NAME});
|
X4OWriteLanguageDocExecutor.main(new String[] {"-p",createOutputTargetPath("junit-test-main").getAbsolutePath(),"-l",EldDriver.LANGUAGE_NAME});
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,123 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2004-2013, Willem Cazander
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
|
||||||
* that the following conditions are met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
|
||||||
* following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
|
||||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
||||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
|
||||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package org.x4o.xml.eld.doc;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.x4o.xml.element.ElementAttributeHandler;
|
|
||||||
import org.x4o.xml.element.ElementBindingHandler;
|
|
||||||
import org.x4o.xml.element.ElementClass;
|
|
||||||
import org.x4o.xml.element.ElementConfigurator;
|
|
||||||
import org.x4o.xml.element.ElementInterface;
|
|
||||||
import org.x4o.xml.element.ElementException;
|
|
||||||
import org.x4o.xml.element.ElementNamespaceContext;
|
|
||||||
import org.x4o.xml.lang.X4OLanguageModule;
|
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
|
||||||
import org.xml.sax.SAXException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EldDocGenerator writes documentation.
|
|
||||||
*
|
|
||||||
* @author Willem Cazander
|
|
||||||
* @version 1.0 Aug 26, 2010
|
|
||||||
*/
|
|
||||||
public class EldDocGenerator {
|
|
||||||
|
|
||||||
private X4OLanguageContext context = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an EldDocGenerator for this langauge context.
|
|
||||||
* @param context The language context to generate doc for.
|
|
||||||
*/
|
|
||||||
public EldDocGenerator(X4OLanguageContext context) {
|
|
||||||
this.context=context;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes the language documentation to the base path.
|
|
||||||
* @param basePath The path to write to documentation to.
|
|
||||||
* @throws ElementException Is thrown when error is done.
|
|
||||||
*/
|
|
||||||
public void writeDoc(File basePath) throws ElementException {
|
|
||||||
EldDocHtmlWriter writer = new EldDocHtmlWriter();
|
|
||||||
try {
|
|
||||||
|
|
||||||
writer.writeTheme(basePath);
|
|
||||||
writer.writeIndex(basePath, context);
|
|
||||||
writer.writeIndexAll(basePath, context);
|
|
||||||
writer.writeDocHelp(basePath, context);
|
|
||||||
writer.writeAllElementsFrame(basePath, context, true);
|
|
||||||
writer.writeAllElementsFrame(basePath, context, false);
|
|
||||||
writer.writeOverviewFrame(basePath, context);
|
|
||||||
writer.writeOverviewLanguage(basePath, context);
|
|
||||||
writer.writeOverviewTree(basePath, context);
|
|
||||||
|
|
||||||
for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) {
|
|
||||||
|
|
||||||
writer.writeOverviewModule(basePath, mod, context);
|
|
||||||
|
|
||||||
|
|
||||||
for (ElementBindingHandler bind:mod.getElementBindingHandlers()) {
|
|
||||||
writer.writeBindingHandler(basePath,bind,mod,context);
|
|
||||||
}
|
|
||||||
for (ElementAttributeHandler attr:mod.getElementAttributeHandlers()) {
|
|
||||||
writer.writeAttributeHandler(basePath,attr,mod,context);
|
|
||||||
}
|
|
||||||
for (ElementConfigurator conf:mod.getElementConfiguratorGlobals()) {
|
|
||||||
writer.writeElementConfigurator(basePath,conf,mod,context);
|
|
||||||
}
|
|
||||||
for (ElementInterface iface:mod.getElementInterfaces()) {
|
|
||||||
writer.writeElementInterface(basePath,iface,mod,context);
|
|
||||||
|
|
||||||
for (ElementBindingHandler bind:iface.getElementBindingHandlers()) {
|
|
||||||
writer.writeBindingHandler(basePath,bind,mod,iface,context);
|
|
||||||
}
|
|
||||||
//for (ElementAttributeHandler attr:iface.getElementClassAttributes()) {
|
|
||||||
// writer.writeAttributeHandler(basePath,attr,mod,true);
|
|
||||||
//}
|
|
||||||
for (ElementConfigurator conf:iface.getElementConfigurators()) {
|
|
||||||
writer.writeElementConfigurator(basePath,conf,mod,iface,context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
|
|
||||||
|
|
||||||
writer.writeOverviewElement(basePath,ns,mod,context);
|
|
||||||
writer.writeNamespaceElementsFrame(basePath,ns,mod,context);
|
|
||||||
|
|
||||||
for (ElementClass ec:ns.getElementClasses()) {
|
|
||||||
writer.writeElement(basePath, ec, ns, mod,context);
|
|
||||||
for (ElementConfigurator conf:ec.getElementConfigurators()) {
|
|
||||||
writer.writeElementConfigurator(basePath,conf,mod,ns,ec,context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SAXException e) {
|
|
||||||
throw new ElementException(e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new ElementException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,447 +0,0 @@
|
||||||
/* Javadoc JDK7 like style sheet */
|
|
||||||
body {
|
|
||||||
background-color:#ffffff;
|
|
||||||
color:#353833;
|
|
||||||
font-family:Arial, Helvetica, sans-serif;
|
|
||||||
font-size:76%;
|
|
||||||
margin:0px;
|
|
||||||
}
|
|
||||||
a:link, a:visited {
|
|
||||||
text-decoration:none;
|
|
||||||
color:#4c6b87;
|
|
||||||
}
|
|
||||||
a:hover, a:focus {
|
|
||||||
text-decoration:none;
|
|
||||||
color:#bb7a2a;
|
|
||||||
}
|
|
||||||
a:active {
|
|
||||||
text-decoration:none;
|
|
||||||
color:#4c6b87;
|
|
||||||
}
|
|
||||||
a[name] {
|
|
||||||
color:#353833;
|
|
||||||
}
|
|
||||||
a[name]:hover {
|
|
||||||
text-decoration:none;
|
|
||||||
color:#353833;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
font-size:1.3em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size:1.8em;
|
|
||||||
}
|
|
||||||
h2 {
|
|
||||||
font-size:1.5em;
|
|
||||||
}
|
|
||||||
h3 {
|
|
||||||
font-size:1.4em;
|
|
||||||
}
|
|
||||||
h4 {
|
|
||||||
font-size:1.3em;
|
|
||||||
}
|
|
||||||
h5 {
|
|
||||||
font-size:1.2em;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-size:1.1em;
|
|
||||||
}
|
|
||||||
ul {
|
|
||||||
list-style-type:disc;
|
|
||||||
}
|
|
||||||
code, tt {
|
|
||||||
font-size:1.2em;
|
|
||||||
}
|
|
||||||
dt code {
|
|
||||||
font-size:1.2em;
|
|
||||||
}
|
|
||||||
table tr td dt code {
|
|
||||||
font-size:1.2em;
|
|
||||||
vertical-align:top;
|
|
||||||
}
|
|
||||||
sup {
|
|
||||||
font-size:0.6em;
|
|
||||||
}
|
|
||||||
.clear {
|
|
||||||
clear:both;
|
|
||||||
height:0px;
|
|
||||||
overflow:hidden;
|
|
||||||
}
|
|
||||||
.aboutLanguage {
|
|
||||||
float:right;
|
|
||||||
padding:0px 21px;
|
|
||||||
font-size:0.8em;
|
|
||||||
z-index:200;
|
|
||||||
margin-top:-7px;
|
|
||||||
}
|
|
||||||
.legalCopy {
|
|
||||||
margin-left:.5em;
|
|
||||||
}
|
|
||||||
.bar a, .bar a:link, .bar a:visited, .bar a:active {
|
|
||||||
color:#FFFFFF;
|
|
||||||
text-decoration:none;
|
|
||||||
}
|
|
||||||
.bar a:hover, .bar a:focus {
|
|
||||||
color:#bb7a2a;
|
|
||||||
}
|
|
||||||
.tab {
|
|
||||||
background-color:#0066FF;
|
|
||||||
background-image:url(titlebar.png);
|
|
||||||
background-position:left top;
|
|
||||||
background-repeat:no-repeat;
|
|
||||||
color:#ffffff;
|
|
||||||
padding:8px;
|
|
||||||
width:5em;
|
|
||||||
font-weight:bold;
|
|
||||||
}
|
|
||||||
.bar {
|
|
||||||
background-image:url(background.png);
|
|
||||||
background-repeat:repeat-x;
|
|
||||||
color:#FFFFFF;
|
|
||||||
padding:.8em .5em .4em .8em;
|
|
||||||
height:auto;/*height:1.8em;*/
|
|
||||||
font-size:1em;
|
|
||||||
margin:0px;
|
|
||||||
}
|
|
||||||
.topNav {
|
|
||||||
background-image:url(background.png);
|
|
||||||
background-repeat:repeat-x;
|
|
||||||
color:#FFFFFF;
|
|
||||||
float:left;
|
|
||||||
padding:0px;
|
|
||||||
width:100%;
|
|
||||||
clear:right;
|
|
||||||
height:2.8em;
|
|
||||||
padding-top:10px;
|
|
||||||
overflow:hidden;
|
|
||||||
}
|
|
||||||
.bottomNav {
|
|
||||||
margin-top:10px;
|
|
||||||
background-image:url(background.png);
|
|
||||||
background-repeat:repeat-x;
|
|
||||||
color:#FFFFFF;
|
|
||||||
float:left;
|
|
||||||
padding:0px;
|
|
||||||
width:100%;
|
|
||||||
clear:right;
|
|
||||||
height:2.8em;
|
|
||||||
padding-top:10px;
|
|
||||||
overflow:hidden;
|
|
||||||
}
|
|
||||||
.subNav {
|
|
||||||
background-color:#dee3e9;
|
|
||||||
border-bottom:1px solid #9eadc0;
|
|
||||||
float:left;
|
|
||||||
width:100%;
|
|
||||||
overflow:hidden;
|
|
||||||
}
|
|
||||||
.subNav div {
|
|
||||||
clear:left;
|
|
||||||
float:left;
|
|
||||||
padding:0 0 5px 6px;
|
|
||||||
}
|
|
||||||
ul.navList, ul.subNavList {
|
|
||||||
float:left;
|
|
||||||
margin:0px 25px 0px 0px;
|
|
||||||
padding:0px;
|
|
||||||
}
|
|
||||||
ul.navList li{
|
|
||||||
list-style:none;
|
|
||||||
float:left;
|
|
||||||
padding:3px 6px;
|
|
||||||
}
|
|
||||||
ul.subNavList li{
|
|
||||||
list-style:none;
|
|
||||||
float:left;
|
|
||||||
font-size:90%;
|
|
||||||
}
|
|
||||||
.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited {
|
|
||||||
color:#FFFFFF;
|
|
||||||
text-decoration:none;
|
|
||||||
}
|
|
||||||
.topNav a:hover, .bottomNav a:hover {
|
|
||||||
text-decoration:none;
|
|
||||||
color:#bb7a2a;
|
|
||||||
}
|
|
||||||
.navBarCell1Rev {
|
|
||||||
background-image:url(tab.png);
|
|
||||||
background-color:#a88834;
|
|
||||||
color:#FFFFFF;
|
|
||||||
margin: auto 5px;
|
|
||||||
border:1px solid #c9aa44;
|
|
||||||
}
|
|
||||||
.header, .footer {
|
|
||||||
clear:both;
|
|
||||||
margin:0 20px;
|
|
||||||
padding:5px 0px 0px 0px;
|
|
||||||
}
|
|
||||||
.indexHeader {
|
|
||||||
margin:10px;
|
|
||||||
position:relative;
|
|
||||||
}
|
|
||||||
.indexHeader h1 {
|
|
||||||
font-size:1.3em;
|
|
||||||
}
|
|
||||||
.title {
|
|
||||||
color:#2c4557;
|
|
||||||
margin:10px 0px;
|
|
||||||
}
|
|
||||||
.subTitle {
|
|
||||||
margin:5px 0px 0px 0px;
|
|
||||||
}
|
|
||||||
.header ul {
|
|
||||||
margin:0px 0px 25px 0px;
|
|
||||||
padding:0px;
|
|
||||||
}
|
|
||||||
.footer ul {
|
|
||||||
margin:20px 0px 5px 0px;
|
|
||||||
}
|
|
||||||
.header ul li, .footer ul li {
|
|
||||||
list-style:none;
|
|
||||||
font-size:1.2em;
|
|
||||||
}
|
|
||||||
div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 {
|
|
||||||
background-color:#dee3e9;
|
|
||||||
border-top:1px solid #9eadc0;
|
|
||||||
border-bottom:1px solid #9eadc0;
|
|
||||||
margin:0px 0px 6px -8px;
|
|
||||||
padding:2px 5px;
|
|
||||||
}
|
|
||||||
ul.blockList ul.blockList ul.blockList li.blockList h3 {
|
|
||||||
background-color:#dee3e9;
|
|
||||||
border-top:1px solid #9eadc0;
|
|
||||||
border-bottom:1px solid #9eadc0;
|
|
||||||
margin:0px 0px 6px -8px;
|
|
||||||
padding:2px 5px;
|
|
||||||
}
|
|
||||||
ul.blockList ul.blockList li.blockList h3 {
|
|
||||||
padding:0px;
|
|
||||||
margin:15px 0px;
|
|
||||||
}
|
|
||||||
ul.blockList li.blockList h2 {
|
|
||||||
padding:0px 0px 20px 0px;
|
|
||||||
}
|
|
||||||
.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer {
|
|
||||||
clear:both;
|
|
||||||
padding:10px 20px;
|
|
||||||
position:relative;
|
|
||||||
}
|
|
||||||
.indexContainer {
|
|
||||||
margin:10px;
|
|
||||||
position:relative;
|
|
||||||
font-size:1.0em;
|
|
||||||
}
|
|
||||||
.indexContainer h2 {
|
|
||||||
font-size:1.1em;
|
|
||||||
padding:0px 0px 3px 0px;
|
|
||||||
}
|
|
||||||
.indexContainer ul {
|
|
||||||
margin:0px;
|
|
||||||
padding:0px;
|
|
||||||
}
|
|
||||||
.indexContainer ul li {
|
|
||||||
list-style:none;
|
|
||||||
}
|
|
||||||
.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt {
|
|
||||||
font-size:1.1em;
|
|
||||||
font-weight:bold;
|
|
||||||
margin:10px 0 0 0;
|
|
||||||
color:#4E4E4E;
|
|
||||||
}
|
|
||||||
.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd {
|
|
||||||
margin:10px 0px 10px 20px;
|
|
||||||
}
|
|
||||||
.serializedFormContainer dl.nameValue dt {
|
|
||||||
margin-left:1px;
|
|
||||||
font-size:1.1em;
|
|
||||||
display:inline;
|
|
||||||
font-weight:bold;
|
|
||||||
}
|
|
||||||
.serializedFormContainer dl.nameValue dd {
|
|
||||||
margin:0px 0px 0px 1px;
|
|
||||||
font-size:1.1em;
|
|
||||||
display:inline;
|
|
||||||
}
|
|
||||||
ul.horizontal li {
|
|
||||||
display:inline;
|
|
||||||
font-size:0.9em;
|
|
||||||
}
|
|
||||||
ul.inheritance {
|
|
||||||
margin:0px;
|
|
||||||
padding:0px;
|
|
||||||
}
|
|
||||||
ul.inheritance li {
|
|
||||||
display:inline;
|
|
||||||
list-style:none;
|
|
||||||
}
|
|
||||||
ul.inheritance li ul.inheritance {
|
|
||||||
margin-left:15px;
|
|
||||||
padding-left:15px;
|
|
||||||
padding-top:1px;
|
|
||||||
}
|
|
||||||
ul.blockList, ul.blockListLast {
|
|
||||||
margin:10px 0px 10px 0px;
|
|
||||||
padding:0px;
|
|
||||||
}
|
|
||||||
ul.blockList li.blockList, ul.blockListLast li.blockList {
|
|
||||||
list-style:none;
|
|
||||||
margin-bottom:25px;
|
|
||||||
}
|
|
||||||
ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList {
|
|
||||||
padding:0px 20px 5px 10px;
|
|
||||||
border:1px solid #9eadc0;
|
|
||||||
background-color:#f9f9f9;
|
|
||||||
}
|
|
||||||
ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList {
|
|
||||||
padding:0px 0px 5px 8px;
|
|
||||||
background-color:#ffffff;
|
|
||||||
border:1px solid #9eadc0;
|
|
||||||
border-top:none;
|
|
||||||
}
|
|
||||||
ul.blockList ul.blockList ul.blockList ul.blockList li.blockList {
|
|
||||||
margin-left:0px;
|
|
||||||
padding-left:0px;
|
|
||||||
padding-bottom:15px;
|
|
||||||
border:none;
|
|
||||||
border-bottom:1px solid #9eadc0;
|
|
||||||
}
|
|
||||||
ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast {
|
|
||||||
list-style:none;
|
|
||||||
border-bottom:none;
|
|
||||||
padding-bottom:0px;
|
|
||||||
}
|
|
||||||
table tr td dl, table tr td dl dt, table tr td dl dd {
|
|
||||||
margin-top:0px;
|
|
||||||
margin-bottom:1px;
|
|
||||||
}
|
|
||||||
.contentContainer table, .classUseContainer table, .constantValuesContainer table {
|
|
||||||
border-bottom:1px solid #9eadc0;
|
|
||||||
width:100%;
|
|
||||||
}
|
|
||||||
.contentContainer ul li table, .classUseContainer ul li table, .constantValuesContainer ul li table {
|
|
||||||
width:100%;
|
|
||||||
}
|
|
||||||
.contentContainer .description table, .contentContainer .details table {
|
|
||||||
border-bottom:none;
|
|
||||||
}
|
|
||||||
.contentContainer ul li table th.colOne, .contentContainer ul li table th.colFirst, .contentContainer ul li table th.colLast, .classUseContainer ul li table th, .constantValuesContainer ul li table th, .contentContainer ul li table td.colOne, .contentContainer ul li table td.colFirst, .contentContainer ul li table td.colLast, .classUseContainer ul li table td, .constantValuesContainer ul li table td{
|
|
||||||
vertical-align:top;
|
|
||||||
padding-right:20px;
|
|
||||||
}
|
|
||||||
.contentContainer ul li table th.colLast, .classUseContainer ul li table th.colLast,.constantValuesContainer ul li table th.colLast,
|
|
||||||
.contentContainer ul li table td.colLast, .classUseContainer ul li table td.colLast,.constantValuesContainer ul li table td.colLast,
|
|
||||||
.contentContainer ul li table th.colOne, .classUseContainer ul li table th.colOne,
|
|
||||||
.contentContainer ul li table td.colOne, .classUseContainer ul li table td.colOne {
|
|
||||||
padding-right:3px;
|
|
||||||
}
|
|
||||||
.overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption {
|
|
||||||
position:relative;
|
|
||||||
text-align:left;
|
|
||||||
background-repeat:no-repeat;
|
|
||||||
color:#FFFFFF;
|
|
||||||
font-weight:bold;
|
|
||||||
clear:none;
|
|
||||||
overflow:hidden;
|
|
||||||
padding:0px;
|
|
||||||
margin:0px;
|
|
||||||
}
|
|
||||||
caption a:link, caption a:hover, caption a:active, caption a:visited {
|
|
||||||
color:#FFFFFF;
|
|
||||||
}
|
|
||||||
.overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span {
|
|
||||||
white-space:nowrap;
|
|
||||||
padding-top:8px;
|
|
||||||
padding-left:8px;
|
|
||||||
display:block;
|
|
||||||
float:left;
|
|
||||||
background-image:url(titlebar.png);
|
|
||||||
height:18px;
|
|
||||||
}
|
|
||||||
.overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd {
|
|
||||||
width:10px;
|
|
||||||
background-image:url(titlebar_end.png);
|
|
||||||
background-repeat:no-repeat;
|
|
||||||
background-position:top right;
|
|
||||||
position:relative;
|
|
||||||
float:left;
|
|
||||||
}
|
|
||||||
ul.blockList ul.blockList li.blockList table {
|
|
||||||
margin:0px 0px 12px 0px;
|
|
||||||
width:100%;
|
|
||||||
}
|
|
||||||
.tableSubHeadingColor {
|
|
||||||
background-color: #EEEEFF;
|
|
||||||
}
|
|
||||||
.altColor {
|
|
||||||
background-color:#eeeeef;
|
|
||||||
}
|
|
||||||
.rowColor {
|
|
||||||
background-color:#ffffff;
|
|
||||||
}
|
|
||||||
.overviewSummary td, .packageSummary td, .contentContainer ul.blockList li.blockList td, .summary td, .classUseContainer td, .constantValuesContainer td {
|
|
||||||
text-align:left;
|
|
||||||
padding:3px 3px 3px 7px;
|
|
||||||
}
|
|
||||||
th.colFirst, th.colLast, th.colOne, .constantValuesContainer th {
|
|
||||||
background:#dee3e9;
|
|
||||||
border-top:1px solid #9eadc0;
|
|
||||||
border-bottom:1px solid #9eadc0;
|
|
||||||
text-align:left;
|
|
||||||
padding:3px 3px 3px 7px;
|
|
||||||
}
|
|
||||||
td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover {
|
|
||||||
font-weight:bold;
|
|
||||||
}
|
|
||||||
td.colFirst, th.colFirst {
|
|
||||||
border-left:1px solid #9eadc0;
|
|
||||||
white-space:nowrap;
|
|
||||||
}
|
|
||||||
td.colLast, th.colLast {
|
|
||||||
border-right:1px solid #9eadc0;
|
|
||||||
}
|
|
||||||
td.colOne, th.colOne {
|
|
||||||
border-right:1px solid #9eadc0;
|
|
||||||
border-left:1px solid #9eadc0;
|
|
||||||
}
|
|
||||||
table.overviewSummary {
|
|
||||||
padding:0px;
|
|
||||||
margin-left:0px;
|
|
||||||
}
|
|
||||||
table.overviewSummary td.colFirst, table.overviewSummary th.colFirst,
|
|
||||||
table.overviewSummary td.colOne, table.overviewSummary th.colOne {
|
|
||||||
width:25%;
|
|
||||||
vertical-align:middle;
|
|
||||||
}
|
|
||||||
table.packageSummary td.colFirst, table.overviewSummary th.colFirst {
|
|
||||||
width:25%;
|
|
||||||
vertical-align:middle;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
Content styles
|
|
||||||
*/
|
|
||||||
.description pre {
|
|
||||||
margin-top:0px;
|
|
||||||
}
|
|
||||||
.deprecatedContent {
|
|
||||||
margin:0px;
|
|
||||||
padding:10px 0px;
|
|
||||||
}
|
|
||||||
.docSummary {
|
|
||||||
padding:0px;
|
|
||||||
}
|
|
||||||
.sourceLineNo {
|
|
||||||
color:green;
|
|
||||||
padding:0px 30px 0px 0px;
|
|
||||||
}
|
|
||||||
h1.hidden {
|
|
||||||
visibility:hidden;
|
|
||||||
overflow:hidden;
|
|
||||||
font-size:0.9em;
|
|
||||||
}
|
|
||||||
.block {
|
|
||||||
display:block;
|
|
||||||
margin:3px 0px 0px 0px;
|
|
||||||
}
|
|
||||||
.strong {
|
|
||||||
font-weight:bold;
|
|
||||||
}
|
|
|
@ -16,7 +16,7 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.x4o</groupId>
|
<groupId>org.x4o</groupId>
|
||||||
<artifactId>x4o-elddoc</artifactId>
|
<artifactId>x4o-eld-doc</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -192,7 +192,7 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.x4o</groupId>
|
<groupId>org.x4o</groupId>
|
||||||
<artifactId>x4o-elddoc</artifactId>
|
<artifactId>x4o-eld-doc</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.x4o</groupId>
|
<groupId>org.x4o</groupId>
|
||||||
<artifactId>x4o-elddoc</artifactId>
|
<artifactId>x4o-eld-doc</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -109,7 +109,7 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.x4o</groupId>
|
<groupId>org.x4o</groupId>
|
||||||
<artifactId>x4o-elddoc</artifactId>
|
<artifactId>x4o-eld-doc</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|