X4O: Formatted plugins and maisdoc

This commit is contained in:
Willem Cazander 2025-11-07 21:48:59 +01:00
parent a61ce241e1
commit bd4a04a813
63 changed files with 1690 additions and 1589 deletions

View file

@ -38,7 +38,7 @@ import org.x4o.xml.test.models.TestObjectRoot;
public class SwingTests {
public void setUp() throws Exception {
//X4OTesting.initLogging();
// X4OTesting.initLogging();
}
@Test
@ -46,10 +46,10 @@ public class SwingTests {
TestDriver driver = TestDriver.getInstance();
X4OReader<TestObjectRoot> reader = driver.createReader();
File f = File.createTempFile("test-swing", ".xml");
//f.deleteOnExit();
//reader.setProperty(X4OLanguagePropertyKeys.DEBUG_OUTPUT_STREAM, new FileOutputStream(f));
//reader.setProperty(X4OLanguagePropertyKeys.DEBUG_OUTPUT_ELD_PARSER, true);
//reader.readResource("tests/test-swing.xml");
//Thread.sleep(30000);
// f.deleteOnExit();
// reader.setProperty(X4OLanguagePropertyKeys.DEBUG_OUTPUT_STREAM, new FileOutputStream(f));
// reader.setProperty(X4OLanguagePropertyKeys.DEBUG_OUTPUT_ELD_PARSER, true);
// reader.readResource("tests/test-swing.xml");
// Thread.sleep(30000);
}
}

View file

@ -36,11 +36,11 @@ import org.x4o.xml.test.models.TestObjectRoot;
public class TagHandlerTest {
public void setUp() throws Exception {
//X4OTesting.initLogging();
// X4OTesting.initLogging();
}
private void printS(Throwable e) {
if (e.getCause()==null) {
if (e.getCause() == null) {
e.printStackTrace();
return;
}
@ -52,14 +52,8 @@ public class TagHandlerTest {
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
X4OReader<TestObjectRoot> reader = driver.createReader();
/*
File f = File.createTempFile("test-taghandlers", ".xml");
f.deleteOnExit();
reader.setProperty(X4OLanguagePropertyKeys.DEBUG_OUTPUT_STREAM, new FileOutputStream(f));
try {
reader.readResource("tests/test-taghandlers.xml");
} catch (Exception e) {
printS(e);
}
* File f = File.createTempFile("test-taghandlers", ".xml"); f.deleteOnExit(); reader.setProperty(X4OLanguagePropertyKeys.DEBUG_OUTPUT_STREAM, new
* FileOutputStream(f)); try { reader.readResource("tests/test-taghandlers.xml"); } catch (Exception e) { printS(e); }
*/
}
}

View file

@ -29,7 +29,7 @@ import org.x4o.xml.test.models.TestObjectRoot;
public class TestDriver extends X4ODriver<TestObjectRoot> {
static final public String LANGUAGE_NAME = "test";
static final public String[] LANGUAGE_VERSIONS = new String[]{X4ODriver.DEFAULT_LANGUAGE_VERSION};
static final public String[] LANGUAGE_VERSIONS = new String[] { X4ODriver.DEFAULT_LANGUAGE_VERSION };
@Override
public String getLanguageName() {
@ -42,6 +42,6 @@ public class TestDriver extends X4ODriver<TestObjectRoot> {
}
static public TestDriver getInstance() {
return (TestDriver)X4ODriverManager.getX4ODriver(LANGUAGE_NAME);
return (TestDriver) X4ODriverManager.getX4ODriver(LANGUAGE_NAME);
}
}

View file

@ -36,7 +36,7 @@ public class X4OTesting {
static public void initLogging() throws Exception {
// enable all logs
InputStream loggingProperties = Class.class.getClass().getResourceAsStream("/META-INF/logging.properties"); // todo: fix loading
LogManager.getLogManager().readConfiguration( loggingProperties );
LogManager.getLogManager().readConfiguration(loggingProperties);
loggingProperties.close();
}
}

View file

@ -43,13 +43,13 @@ public class XIncludeTest {
X4OReader<TestObjectRoot> reader = driver.createReader();
TestObjectRoot root = reader.readResource("tests/xinclude/include-base.xml");
Assertions.assertNotNull(root);
TestObjectRoot parentRoot = (TestObjectRoot)root;
if (parentRoot.getTestObjectParents().size()==0) {
TestObjectRoot parentRoot = (TestObjectRoot) root;
if (parentRoot.getTestObjectParents().size() == 0) {
return; // FIXME: don't fail, as on jdk7 it 'sometimes' fails ...
}
Assertions.assertEquals(1,parentRoot.getTestObjectParents().size());
Assertions.assertEquals(1, parentRoot.getTestObjectParents().size());
TestObjectParent parent = parentRoot.getTestObjectParents().get(0);
TestObjectChild child = parent.testObjectChilds.get(0);
Assertions.assertEquals("include-child.xml",child.getName());
Assertions.assertEquals("include-child.xml", child.getName());
}
}

View file

@ -26,7 +26,6 @@ import javax.swing.JFrame;
import org.x4o.xml.element.AbstractElement;
/**
*
* @author Willem Cazander
@ -39,6 +38,6 @@ public class ContentPaneElement extends AbstractElement {
*/
@Override
public Object getElementObject() {
return ((JFrame)this.getParent().getElementObject()).getContentPane();
return ((JFrame) this.getParent().getElementObject()).getContentPane();
}
}

View file

@ -22,12 +22,10 @@
*/
package org.x4o.xml.test.element;
import org.x4o.xml.element.AbstractElementConfigurator;
import org.x4o.xml.element.Element;
import org.x4o.xml.element.ElementConfiguratorException;
/**
* TestElementConfigurator
*

View file

@ -42,30 +42,35 @@ public class TestAttributeOrderChild extends TestObjectChild {
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
*/
@ -79,66 +84,77 @@ public class TestAttributeOrderChild extends TestObjectChild {
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
*/

View file

@ -45,7 +45,7 @@ public class TestBean {
public Float publicFloatObjectField = new Float(0);
public byte publicByteTypeField = 0;
public Byte publicByteObjectField = Byte.valueOf((byte)0);
public Byte publicByteObjectField = Byte.valueOf((byte) 0);
public boolean publicBooleanTypeField = false;
public Boolean publicBooleanObjectField = new Boolean(false);
@ -54,10 +54,10 @@ public class TestBean {
public Character publicCharObjectField = new Character(' ');
public String publicStringObjectField = "𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕";
//public String publicStringObjectFieldUnicodeᒡᒢᑊᒻᒻᓫᔿ = " ᒡᒢᑊᒻᒻᓫᔿ";
// public String publicStringObjectFieldUnicodeᒡᒢᑊᒻᒻᓫᔿ = " ᒡᒢᑊᒻᒻᓫᔿ";
public String publicStringObjectFieldUnicode仙上主天 = "仙上主天";
//public Date publicDateObjectField = new Date(0); // TODO add date converters
// public Date publicDateObjectField = new Date(0); // TODO add date converters
// private
@ -74,7 +74,7 @@ public class TestBean {
private Float privateFloatObjectField = new Float(0);
private byte privateByteTypeField = 0;
private Byte privateByteObjectField = Byte.valueOf((byte)0);
private Byte privateByteObjectField = Byte.valueOf((byte) 0);
private boolean privateBooleanTypeField = false;
private Boolean privateBooleanObjectField = new Boolean(false);
@ -83,10 +83,9 @@ public class TestBean {
private Character privateCharObjectField = new Character(' ');
private String privateStringObjectField = "𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕";
//private String privateStringObjectFieldUnicodeᒡᒢᑊᒻᒻᓫᔿ = " ᒡᒢᑊᒻᒻᓫᔿ";
// private String privateStringObjectFieldUnicodeᒡᒢᑊᒻᒻᓫᔿ = " ᒡᒢᑊᒻᒻᓫᔿ";
private String privateStringObjectFieldUnicode仙上主天 = "仙上主天";
//private Date privateDateObjectField = new Date(0);
// private Date privateDateObjectField = new Date(0);
// auto gen , get/set-ers
@ -96,180 +95,210 @@ public class TestBean {
public int getPublicIntegerTypeField() {
return publicIntegerTypeField;
}
/**
* @param publicIntegerTypeField the publicIntegerTypeField to set
*/
public void setPublicIntegerTypeField(int publicIntegerTypeField) {
this.publicIntegerTypeField = publicIntegerTypeField;
}
/**
* @return the publicIntegerObjectField
*/
public Integer getPublicIntegerObjectField() {
return publicIntegerObjectField;
}
/**
* @param publicIntegerObjectField the publicIntegerObjectField to set
*/
public void setPublicIntegerObjectField(Integer publicIntegerObjectField) {
this.publicIntegerObjectField = publicIntegerObjectField;
}
/**
* @return the publicLongTypeField
*/
public long getPublicLongTypeField() {
return publicLongTypeField;
}
/**
* @param publicLongTypeField the publicLongTypeField to set
*/
public void setPublicLongTypeField(long publicLongTypeField) {
this.publicLongTypeField = publicLongTypeField;
}
/**
* @return the publicLongObjectField
*/
public Long getPublicLongObjectField() {
return publicLongObjectField;
}
/**
* @param publicLongObjectField the publicLongObjectField to set
*/
public void setPublicLongObjectField(Long publicLongObjectField) {
this.publicLongObjectField = publicLongObjectField;
}
/**
* @return the publicDoubleTypeField
*/
public double getPublicDoubleTypeField() {
return publicDoubleTypeField;
}
/**
* @param publicDoubleTypeField the publicDoubleTypeField to set
*/
public void setPublicDoubleTypeField(double publicDoubleTypeField) {
this.publicDoubleTypeField = publicDoubleTypeField;
}
/**
* @return the publicDoubleObjectField
*/
public Double getPublicDoubleObjectField() {
return publicDoubleObjectField;
}
/**
* @param publicDoubleObjectField the publicDoubleObjectField to set
*/
public void setPublicDoubleObjectField(Double publicDoubleObjectField) {
this.publicDoubleObjectField = publicDoubleObjectField;
}
/**
* @return the publicFloatTypeField
*/
public float getPublicFloatTypeField() {
return publicFloatTypeField;
}
/**
* @param publicFloatTypeField the publicFloatTypeField to set
*/
public void setPublicFloatTypeField(float publicFloatTypeField) {
this.publicFloatTypeField = publicFloatTypeField;
}
/**
* @return the publicFloatObjectField
*/
public Float getPublicFloatObjectField() {
return publicFloatObjectField;
}
/**
* @param publicFloatObjectField the publicFloatObjectField to set
*/
public void setPublicFloatObjectField(Float publicFloatObjectField) {
this.publicFloatObjectField = publicFloatObjectField;
}
/**
* @return the publicByteTypeField
*/
public byte getPublicByteTypeField() {
return publicByteTypeField;
}
/**
* @param publicByteTypeField the publicByteTypeField to set
*/
public void setPublicByteTypeField(byte publicByteTypeField) {
this.publicByteTypeField = publicByteTypeField;
}
/**
* @return the publicByteObjectField
*/
public Byte getPublicByteObjectField() {
return publicByteObjectField;
}
/**
* @param publicByteObjectField the publicByteObjectField to set
*/
public void setPublicByteObjectField(Byte publicByteObjectField) {
this.publicByteObjectField = publicByteObjectField;
}
/**
* @return the publicBooleanTypeField
*/
public boolean isPublicBooleanTypeField() {
return publicBooleanTypeField;
}
/**
* @param publicBooleanTypeField the publicBooleanTypeField to set
*/
public void setPublicBooleanTypeField(boolean publicBooleanTypeField) {
this.publicBooleanTypeField = publicBooleanTypeField;
}
/**
* @return the publicBooleanObjectField
*/
public Boolean getPublicBooleanObjectField() {
return publicBooleanObjectField;
}
/**
* @param publicBooleanObjectField the publicBooleanObjectField to set
*/
public void setPublicBooleanObjectField(Boolean publicBooleanObjectField) {
this.publicBooleanObjectField = publicBooleanObjectField;
}
/**
* @return the publicCharTypeField
*/
public char getPublicCharTypeField() {
return publicCharTypeField;
}
/**
* @param publicCharTypeField the publicCharTypeField to set
*/
public void setPublicCharTypeField(char publicCharTypeField) {
this.publicCharTypeField = publicCharTypeField;
}
/**
* @return the publicCharObjectField
*/
public Character getPublicCharObjectField() {
return publicCharObjectField;
}
/**
* @param publicCharObjectField the publicCharObjectField to set
*/
public void setPublicCharObjectField(Character publicCharObjectField) {
this.publicCharObjectField = publicCharObjectField;
}
/**
* @return the publicStringObjectField
*/
public String getPublicStringObjectField() {
return publicStringObjectField;
}
/**
* @param publicStringObjectField the publicStringObjectField to set
*/
public void setPublicStringObjectField(String publicStringObjectField) {
this.publicStringObjectField = publicStringObjectField;
}
// /**
// * @return the publicStringObjectFieldUnicodeᒡᒢᑊᒻᒻᓫᔿ
// */
@ -288,204 +317,234 @@ public class TestBean {
public String getPublicStringObjectFieldUnicode仙上主天() {
return publicStringObjectFieldUnicode仙上主天;
}
/**
* @param publicStringObjectFieldUnicode仙上主天 the publicStringObjectFieldUnicode仙上主天 to set
*/
public void setPublicStringObjectFieldUnicode仙上主天(String publicStringObjectFieldUnicode仙上主天) {
this.publicStringObjectFieldUnicode仙上主天 = publicStringObjectFieldUnicode仙上主天;
}
/*
* @return the publicDateObjectField
public Date getPublicDateObjectField() {
return publicDateObjectField;
}*/
*
* public Date getPublicDateObjectField() { return publicDateObjectField; }
*/
/*
* @param publicDateObjectField the publicDateObjectField to set
public void setPublicDateObjectField(Date publicDateObjectField) {
this.publicDateObjectField = publicDateObjectField;
}*/
*
* public void setPublicDateObjectField(Date publicDateObjectField) { this.publicDateObjectField = publicDateObjectField; }
*/
/**
* @return the privateIntegerTypeField
*/
public int getPrivateIntegerTypeField() {
return privateIntegerTypeField;
}
/**
* @param privateIntegerTypeField the privateIntegerTypeField to set
*/
public void setPrivateIntegerTypeField(int privateIntegerTypeField) {
this.privateIntegerTypeField = privateIntegerTypeField;
}
/**
* @return the privateIntegerObjectField
*/
public Integer getPrivateIntegerObjectField() {
return privateIntegerObjectField;
}
/**
* @param privateIntegerObjectField the privateIntegerObjectField to set
*/
public void setPrivateIntegerObjectField(Integer privateIntegerObjectField) {
this.privateIntegerObjectField = privateIntegerObjectField;
}
/**
* @return the privateLongTypeField
*/
public long getPrivateLongTypeField() {
return privateLongTypeField;
}
/**
* @param privateLongTypeField the privateLongTypeField to set
*/
public void setPrivateLongTypeField(long privateLongTypeField) {
this.privateLongTypeField = privateLongTypeField;
}
/**
* @return the privateLongObjectField
*/
public Long getPrivateLongObjectField() {
return privateLongObjectField;
}
/**
* @param privateLongObjectField the privateLongObjectField to set
*/
public void setPrivateLongObjectField(Long privateLongObjectField) {
this.privateLongObjectField = privateLongObjectField;
}
/**
* @return the privateDoubleTypeField
*/
public double getPrivateDoubleTypeField() {
return privateDoubleTypeField;
}
/**
* @param privateDoubleTypeField the privateDoubleTypeField to set
*/
public void setPrivateDoubleTypeField(double privateDoubleTypeField) {
this.privateDoubleTypeField = privateDoubleTypeField;
}
/**
* @return the privateDoubleObjectField
*/
public Double getPrivateDoubleObjectField() {
return privateDoubleObjectField;
}
/**
* @param privateDoubleObjectField the privateDoubleObjectField to set
*/
public void setPrivateDoubleObjectField(Double privateDoubleObjectField) {
this.privateDoubleObjectField = privateDoubleObjectField;
}
/**
* @return the privateFloatTypeField
*/
public float getPrivateFloatTypeField() {
return privateFloatTypeField;
}
/**
* @param privateFloatTypeField the privateFloatTypeField to set
*/
public void setPrivateFloatTypeField(float privateFloatTypeField) {
this.privateFloatTypeField = privateFloatTypeField;
}
/**
* @return the privateFloatObjectField
*/
public Float getPrivateFloatObjectField() {
return privateFloatObjectField;
}
/**
* @param privateFloatObjectField the privateFloatObjectField to set
*/
public void setPrivateFloatObjectField(Float privateFloatObjectField) {
this.privateFloatObjectField = privateFloatObjectField;
}
/**
* @return the privateByteTypeField
*/
public byte getPrivateByteTypeField() {
return privateByteTypeField;
}
/**
* @param privateByteTypeField the privateByteTypeField to set
*/
public void setPrivateByteTypeField(byte privateByteTypeField) {
this.privateByteTypeField = privateByteTypeField;
}
/**
* @return the privateByteObjectField
*/
public Byte getPrivateByteObjectField() {
return privateByteObjectField;
}
/**
* @param privateByteObjectField the privateByteObjectField to set
*/
public void setPrivateByteObjectField(Byte privateByteObjectField) {
this.privateByteObjectField = privateByteObjectField;
}
/**
* @return the privateBooleanTypeField
*/
public boolean isPrivateBooleanTypeField() {
return privateBooleanTypeField;
}
/**
* @param privateBooleanTypeField the privateBooleanTypeField to set
*/
public void setPrivateBooleanTypeField(boolean privateBooleanTypeField) {
this.privateBooleanTypeField = privateBooleanTypeField;
}
/**
* @return the privateBooleanObjectField
*/
public Boolean getPrivateBooleanObjectField() {
return privateBooleanObjectField;
}
/**
* @param privateBooleanObjectField the privateBooleanObjectField to set
*/
public void setPrivateBooleanObjectField(Boolean privateBooleanObjectField) {
this.privateBooleanObjectField = privateBooleanObjectField;
}
/**
* @return the privateCharTypeField
*/
public char getPrivateCharTypeField() {
return privateCharTypeField;
}
/**
* @param privateCharTypeField the privateCharTypeField to set
*/
public void setPrivateCharTypeField(char privateCharTypeField) {
this.privateCharTypeField = privateCharTypeField;
}
/**
* @return the privateCharObjectField
*/
public Character getPrivateCharObjectField() {
return privateCharObjectField;
}
/**
* @param privateCharObjectField the privateCharObjectField to set
*/
public void setPrivateCharObjectField(Character privateCharObjectField) {
this.privateCharObjectField = privateCharObjectField;
}
/**
* @return the privateStringObjectField
*/
public String getPrivateStringObjectField() {
return privateStringObjectField;
}
/**
* @param privateStringObjectField the privateStringObjectField to set
*/
public void setPrivateStringObjectField(String privateStringObjectField) {
this.privateStringObjectField = privateStringObjectField;
}
// /**
// * @return the privateStringObjectFieldUnicodeᒡᒢᑊᒻᒻᓫᔿ
// */
@ -504,6 +563,7 @@ public class TestBean {
public String getPrivateStringObjectFieldUnicode仙上主天() {
return privateStringObjectFieldUnicode仙上主天;
}
/**
* @param privateStringObjectFieldUnicode仙上主天 the privateStringObjectFieldUnicode仙上主天 to set
*/
@ -512,14 +572,12 @@ public class TestBean {
}
/*
* @return the privateDateObjectField
public Date getPrivateDateObjectField() {
return privateDateObjectField;
}*/
*
* public Date getPrivateDateObjectField() { return privateDateObjectField; }
*/
/*
* @param privateDateObjectField the privateDateObjectField to set
public void setPrivateDateObjectField(Date privateDateObjectField) {
this.privateDateObjectField = privateDateObjectField;
}*/
*
* public void setPrivateDateObjectField(Date privateDateObjectField) { this.privateDateObjectField = privateDateObjectField; }
*/
}

View file

@ -30,12 +30,35 @@ public class TestObjectChild {
private Object parent = null;
// Some test methods
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public Integer getPrice() { return price; }
public void setPrice(Integer price) { this.price = price; }
public Double getSize() { return size; }
public void setSize(Double size) { this.size = size; }
public Object getParent() { return parent; }
public void setParent(Object parent) { this.parent = parent; }
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getPrice() {
return price;
}
public void setPrice(Integer price) {
this.price = price;
}
public Double getSize() {
return size;
}
public void setSize(Double size) {
this.size = size;
}
public Object getParent() {
return parent;
}
public void setParent(Object parent) {
this.parent = parent;
}
}

View file

@ -76,5 +76,4 @@ public class TestObjectRoot {
return testObjects;
}
}

View file

@ -31,8 +31,7 @@ import javax.swing.JOptionPane;
/**
* Accelerator2 test demo.
*
* see swixml sample; http://www.swixml.org/samples/src/Accelerator.java
* Added exitMethod and render boolean for unit testing.
* see swixml sample; http://www.swixml.org/samples/src/Accelerator.java Added exitMethod and render boolean for unit testing.
*
* @author Willem Cazander
* @version 1.0 Aug 15, 2012
@ -40,36 +39,36 @@ import javax.swing.JOptionPane;
public class Accelerator2 {
protected static final String DESCRIPTOR = "tests/swixml/swixml-accelerator-2.0.xml";
protected SwingEngine swix = new SwingEngine( this );
protected SwingEngine swix = new SwingEngine(this);
public Accelerator2(boolean render) throws Exception {
if (render) {
swix.render( Accelerator2.DESCRIPTOR, SwiXmlDriver.LANGUAGE_VERSION_2 ).setVisible( true );
swix.render(Accelerator2.DESCRIPTOR, SwiXmlDriver.LANGUAGE_VERSION_2).setVisible(true);
}
}
@SuppressWarnings("serial")
public Action newAction = new AbstractAction() {
public void actionPerformed( ActionEvent e ) {
JOptionPane.showMessageDialog( swix.getRootComponent(), "Sorry, not implemented yet." );
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(swix.getRootComponent(), "Sorry, not implemented yet.");
}
};
@SuppressWarnings("serial")
public Action aboutAction = new AbstractAction() {
public void actionPerformed( ActionEvent e ) {
JOptionPane.showMessageDialog( swix.getRootComponent(), "This is the Accelerator Example." );
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(swix.getRootComponent(), "This is the Accelerator Example.");
}
};
@SuppressWarnings("serial")
public Action exitAction = new AbstractAction() {
public void actionPerformed( ActionEvent e ) {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
};
public static void main( String[] args ) {
public static void main(String[] args) {
try {
new Accelerator2(true);
} catch (Exception e) {

View file

@ -35,11 +35,11 @@ public class Accelerator3 extends Accelerator2 {
public Accelerator3(boolean render) throws Exception {
super(false);
if (render) {
swix.render( Accelerator3.DESCRIPTOR, SwiXmlDriver.LANGUAGE_VERSION_3 ).setVisible( true );
swix.render(Accelerator3.DESCRIPTOR, SwiXmlDriver.LANGUAGE_VERSION_3).setVisible(true);
}
}
public static void main( String[] args ) {
public static void main(String[] args) {
try {
new Accelerator3(true);
} catch (Exception e) {

View file

@ -49,12 +49,12 @@ public class Accelerator3Test {
reader.addELBeanInstance(SwiXmlDriver.LANGUAGE_EL_SWING_ENGINE, engine);
Component root = reader.readResource(Accelerator3.DESCRIPTOR);
Assertions.assertNotNull(root);
JFrame frame = (JFrame)root;
Assertions.assertTrue(frame.getJMenuBar().getMenuCount()>0);
JFrame frame = (JFrame) root;
Assertions.assertTrue(frame.getJMenuBar().getMenuCount() > 0);
JMenu helpMenu = frame.getJMenuBar().getMenu(1);
Assertions.assertEquals("Help",helpMenu.getText());
Assertions.assertTrue(helpMenu.getMenuComponentCount()>0);
JMenuItem about = (JMenuItem)helpMenu.getMenuComponent(0);
Assertions.assertEquals("Help", helpMenu.getText());
Assertions.assertTrue(helpMenu.getMenuComponentCount() > 0);
JMenuItem about = (JMenuItem) helpMenu.getMenuComponent(0);
Assertions.assertEquals("mi_about", about.getName());
}
}

View file

@ -39,14 +39,14 @@ public class SwiXmlActionConfigurator extends AbstractElementConfigurator {
public void doConfigElement(Element element) throws ElementConfiguratorException {
String actionName = element.getAttributes().get("Action");
if (actionName==null) {
if (actionName == null) {
return;
}
SwingEngine se = SwiXmlDriver.getSwingEngine(element.getLanguageSession());
Action action = se.getUIActionByName(actionName);
Object object = element.getElementObject();
if (object instanceof JMenuItem) {
((JMenuItem)object).setAction(action);
((JMenuItem) object).setAction(action);
}
// etc
}

View file

@ -42,22 +42,24 @@ public class SwiXmlDriver extends X4ODriver<Component> {
public static final String LANGUAGE_VERSION_2 = "2.0";
public static final String LANGUAGE_VERSION_2_NSURI = "http://swixml.junit.x4o.org/xml/ns/junit-swixml-lang";
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_VERSIONS = new String[] { LANGUAGE_VERSION_2, LANGUAGE_VERSION_3 };
public static final String LANGUAGE_EL_SWING_ENGINE = "swingEngine";
/**
* Helper for while parsing to get the SwingEngine.
*
* @param elementLanguage The elementLanguage to get the swingEngine out.
* @return Returns the SwingEngine for this elementLanguage.
*/
static public SwingEngine getSwingEngine(X4OLanguageSession elementLanguage) {
ValueExpression ee = elementLanguage.getExpressionLanguageFactory().createValueExpression(elementLanguage.getExpressionLanguageContext(),"${"+SwiXmlDriver.LANGUAGE_EL_SWING_ENGINE+"}",Object.class);
SwingEngine se = (SwingEngine)ee.getValue(elementLanguage.getExpressionLanguageContext());
ValueExpression ee = elementLanguage.getExpressionLanguageFactory().createValueExpression(elementLanguage.getExpressionLanguageContext(),
"${" + SwiXmlDriver.LANGUAGE_EL_SWING_ENGINE + "}", Object.class);
SwingEngine se = (SwingEngine) ee.getValue(elementLanguage.getExpressionLanguageContext());
return se;
}
static public SwiXmlDriver getInstance() {
return (SwiXmlDriver)X4ODriverManager.getX4ODriver(LANGUAGE_NAME);
return (SwiXmlDriver) X4ODriverManager.getX4ODriver(LANGUAGE_NAME);
}
@Override

View file

@ -42,22 +42,22 @@ public class SwingEngine {
private Component rootComponent = null;
public SwingEngine(Object uiHandler) {
this.uiHandler=uiHandler;
this.uiHandler = uiHandler;
}
public Action getUIActionByName(String name) {
if (name==null) {
if (name == null) {
return null;
}
if (uiHandler==null) {
if (uiHandler == null) {
return null;
}
try {
for (Field f:uiHandler.getClass().getFields()) {
for (Field f : uiHandler.getClass().getFields()) {
if (name.equals(f.getName())) {
Object value = f.get(uiHandler);
if (value instanceof Action) {
return (Action)value;
return (Action) value;
} else {
return null;
}
@ -69,7 +69,7 @@ public class SwingEngine {
return null;
}
public Component render(String resource,String languageVersion) {
public Component render(String resource, String languageVersion) {
SwiXmlDriver driver = SwiXmlDriver.getInstance();
X4OReader<Component> reader = driver.createReader(languageVersion);
if (SwiXmlDriver.LANGUAGE_VERSION_2.equals(languageVersion)) {

View file

@ -52,19 +52,19 @@ public class JFrameBindingHandler extends AbstractElementBindingHandler<JFrame>
* @see org.x4o.xml.element.ElementBindingHandler#getBindChildClasses()
*/
public Class<?>[] getBindChildClasses() {
return new Class[] {JMenuBar.class,JComponent.class};
return new Class[] { JMenuBar.class, JComponent.class };
}
/**
* @see org.x4o.xml.element.ElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
*/
public void bindChild(Element childElement, JFrame parentObject, Object childObject) throws ElementBindingHandlerException {
JFrame frame = (JFrame)parentObject;
JFrame frame = (JFrame) parentObject;
if (childObject instanceof JMenuBar) {
JMenuBar child = (JMenuBar)childObject;
JMenuBar child = (JMenuBar) childObject;
frame.getRootPane().setJMenuBar(child);
} else if (childObject instanceof JComponent) {
JComponent child = (JComponent)childObject;
JComponent child = (JComponent) childObject;
String c = childElement.getAttributes().get("constraints");
Object con = null;
@ -78,10 +78,10 @@ public class JFrameBindingHandler extends AbstractElementBindingHandler<JFrame>
con = BorderLayout.SOUTH;
}
if (con==null) {
if (con == null) {
frame.getContentPane().add(child);
} else {
frame.getContentPane().add(child,con);
frame.getContentPane().add(child, con);
}
}
}
@ -90,9 +90,9 @@ public class JFrameBindingHandler extends AbstractElementBindingHandler<JFrame>
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
*/
@Override
public void createChilderen(Element parentElement,JFrame parent) throws ElementBindingHandlerException {
public void createChilderen(Element parentElement, JFrame parent) throws ElementBindingHandlerException {
createChild(parentElement, parent.getMenuBar());
for (Component c:parent.getComponents()) {
for (Component c : parent.getComponents()) {
if (c instanceof JComponent) {
createChild(parentElement, c);
}

View file

@ -51,14 +51,14 @@ public class JInternalFrameBindingHandler extends AbstractElementBindingHandler<
* @see org.x4o.xml.element.ElementBindingHandler#getBindChildClasses()
*/
public Class<?>[] getBindChildClasses() {
return new Class[] {JComponent.class};
return new Class[] { JComponent.class };
}
/**
* @see org.x4o.xml.element.ElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
*/
public void bindChild(Element childElement, JInternalFrame frame, Object childObject) throws ElementBindingHandlerException {
JComponent child = (JComponent)childObject;
JComponent child = (JComponent) childObject;
String c = childElement.getAttributes().get("constraints");
Object con = null;
@ -71,10 +71,10 @@ public class JInternalFrameBindingHandler extends AbstractElementBindingHandler<
} else if ("BorderLayout.SOUTH".equals(c)) {
con = BorderLayout.SOUTH;
}
if (con==null) {
if (con == null) {
frame.getContentPane().add(child);
} else {
frame.getContentPane().add(child,con);
frame.getContentPane().add(child, con);
}
}
@ -82,8 +82,8 @@ public class JInternalFrameBindingHandler extends AbstractElementBindingHandler<
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
*/
@Override
public void createChilderen(Element parentElement,JInternalFrame parent) throws ElementBindingHandlerException {
for (Component c:parent.getComponents()) {
public void createChilderen(Element parentElement, JInternalFrame parent) throws ElementBindingHandlerException {
for (Component c : parent.getComponents()) {
if (c instanceof JComponent) {
if (c.getClass().getName().startsWith("javax.swing.plaf")) {
return;

View file

@ -51,14 +51,14 @@ public class JPanelBindingHandler extends AbstractElementBindingHandler<JPanel>
* @see org.x4o.xml.element.ElementBindingHandler#getBindChildClasses()
*/
public Class<?>[] getBindChildClasses() {
return new Class[] {JComponent.class};
return new Class[] { JComponent.class };
}
/**
* @see org.x4o.xml.element.ElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
*/
public void bindChild(Element childElement, JPanel parent, Object childObject) throws ElementBindingHandlerException {
JComponent child = (JComponent)childObject;
JComponent child = (JComponent) childObject;
String c = childElement.getAttributes().get("constraints");
Object con = null;
@ -71,10 +71,10 @@ public class JPanelBindingHandler extends AbstractElementBindingHandler<JPanel>
} else if ("BorderLayout.SOUTH".equals(c)) {
con = BorderLayout.SOUTH;
}
if (con==null) {
if (con == null) {
parent.add(child);
} else {
parent.add(child,con);
parent.add(child, con);
}
}
@ -82,8 +82,8 @@ public class JPanelBindingHandler extends AbstractElementBindingHandler<JPanel>
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
*/
@Override
public void createChilderen(Element parentElement,JPanel parent) throws ElementBindingHandlerException {
for (Component c:parent.getComponents()) {
public void createChilderen(Element parentElement, JPanel parent) throws ElementBindingHandlerException {
for (Component c : parent.getComponents()) {
if (c instanceof JComponent) {
createChild(parentElement, c);
}

View file

@ -49,14 +49,14 @@ public class JSplitPaneBindingHandler extends AbstractElementBindingHandler<JSpl
* @see org.x4o.xml.element.ElementBindingHandler#getBindChildClasses()
*/
public Class<?>[] getBindChildClasses() {
return new Class[] {JComponent.class};
return new Class[] { JComponent.class };
}
/**
* @see org.x4o.xml.element.ElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object, )
*/
public void bindChild(Element childElement, JSplitPane pane, Object childObject) throws ElementBindingHandlerException {
JComponent child = (JComponent)childObject;
JComponent child = (JComponent) childObject;
if (pane.getLeftComponent() instanceof JButton) { // strange swing constructor for splitpane
pane.setLeftComponent(child);
} else if (pane.getRightComponent() instanceof JButton) {
@ -70,7 +70,7 @@ public class JSplitPaneBindingHandler extends AbstractElementBindingHandler<JSpl
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
*/
@Override
public void createChilderen(Element parentElement,JSplitPane parentObject) throws ElementBindingHandlerException {
public void createChilderen(Element parentElement, JSplitPane parentObject) throws ElementBindingHandlerException {
createChild(parentElement, parentObject.getLeftComponent());
createChild(parentElement, parentObject.getRightComponent());
}

View file

@ -45,8 +45,8 @@ public class BorderConverter extends AbstractStringObjectConverter {
return Border.class;
}
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Border)obj).toString();
public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException {
return ((Border) obj).toString();
}
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
@ -57,14 +57,14 @@ public class BorderConverter extends AbstractStringObjectConverter {
return BorderFactory.createEmptyBorder();
}
} catch (Exception e) {
throw new ObjectConverterException(this,e.getMessage(),e);
throw new ObjectConverterException(this, e.getMessage(), e);
}
}
@Override
public ObjectConverter clone() throws CloneNotSupportedException {
BorderConverter result = new BorderConverter();
result.converters=cloneConverters();
result.converters = cloneConverters();
return result;
}
}

View file

@ -43,14 +43,14 @@ public class ColorConverter extends AbstractStringObjectConverter {
return Color.class;
}
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Color)obj).toString();
public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException {
return ((Color) obj).toString();
}
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
try {
if (str.length()==0) {
throw new ObjectConverterException(this,"Can't convert empty color.");
if (str.length() == 0) {
throw new ObjectConverterException(this, "Can't convert empty color.");
}
if (Character.isDigit(str.charAt(0))) {
return Color.decode(str);
@ -62,19 +62,18 @@ public class ColorConverter extends AbstractStringObjectConverter {
} else if ("red".equalsIgnoreCase(str)) {
return Color.RED;
}
throw new ObjectConverterException(this,"Can't convert color: "+str);
throw new ObjectConverterException(this, "Can't convert color: " + str);
}
} catch (Exception e) {
throw new ObjectConverterException(this,e.getMessage(),e);
throw new ObjectConverterException(this, e.getMessage(), e);
}
}
@Override
public ObjectConverter clone() throws CloneNotSupportedException {
ColorConverter result = new ColorConverter();
result.converters=cloneConverters();
result.converters = cloneConverters();
return result;
}
}

View file

@ -45,26 +45,24 @@ public class IconConverter extends AbstractStringObjectConverter {
return Icon.class;
}
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Icon)obj).toString();
public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException {
return ((Icon) obj).toString();
}
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
try {
Icon icon = UIManager.getIcon("OptionPane.questionIcon");
return icon;
} catch (Exception e) {
throw new ObjectConverterException(this,e.getMessage(),e);
throw new ObjectConverterException(this, e.getMessage(), e);
}
}
@Override
public ObjectConverter clone() throws CloneNotSupportedException {
IconConverter result = new IconConverter();
result.converters=cloneConverters();
result.converters = cloneConverters();
return result;
}
}

View file

@ -44,8 +44,8 @@ public class JSplitPaneOrientationConverter extends AbstractStringObjectConverte
return Integer.class;
}
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((Integer)obj).toString();
public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException {
return ((Integer) obj).toString();
}
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
@ -55,17 +55,17 @@ public class JSplitPaneOrientationConverter extends AbstractStringObjectConverte
} else if ("VERTICAL".equals(str)) {
return JSplitPane.VERTICAL_SPLIT;
} else {
throw new ObjectConverterException(this,"Unknown orientation: "+str);
throw new ObjectConverterException(this, "Unknown orientation: " + str);
}
} catch (Exception e) {
throw new ObjectConverterException(this,e.getMessage(),e);
throw new ObjectConverterException(this, e.getMessage(), e);
}
}
@Override
public ObjectConverter clone() throws CloneNotSupportedException {
JSplitPaneOrientationConverter result = new JSplitPaneOrientationConverter();
result.converters=cloneConverters();
result.converters = cloneConverters();
return result;
}
}

View file

@ -44,8 +44,8 @@ public class KeyStrokeConverter extends AbstractStringObjectConverter {
return KeyStroke.class;
}
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((KeyStroke)obj).toString();
public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException {
return ((KeyStroke) obj).toString();
}
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
@ -54,16 +54,15 @@ public class KeyStrokeConverter extends AbstractStringObjectConverter {
return key;
} catch (Exception e) {
throw new ObjectConverterException(this,e.getMessage(),e);
throw new ObjectConverterException(this, e.getMessage(), e);
}
}
@Override
public ObjectConverter clone() throws CloneNotSupportedException {
KeyStrokeConverter result = new KeyStrokeConverter();
result.converters=cloneConverters();
result.converters = cloneConverters();
return result;
}
}

View file

@ -47,8 +47,8 @@ public class LayoutConverter extends AbstractStringObjectConverter {
return LayoutManager.class;
}
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ((LayoutManager)obj).toString();
public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException {
return ((LayoutManager) obj).toString();
}
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
@ -76,15 +76,15 @@ public class LayoutConverter extends AbstractStringObjectConverter {
int indexStart = str.indexOf('(');
int indexMid = str.indexOf(',');
int indexEnd = str.indexOf(')');
if (indexStart>0 && indexMid>0 && indexEnd>0) {
if (indexStart > 0 && indexMid > 0 && indexEnd > 0) {
Integer rows = new Integer(str.substring(indexStart+1,indexMid));
Integer cols = new Integer(str.substring(indexMid+1,indexEnd));
Integer rows = new Integer(str.substring(indexStart + 1, indexMid));
Integer cols = new Integer(str.substring(indexMid + 1, indexEnd));
return new GridLayout(rows,cols);
return new GridLayout(rows, cols);
} else {
throw new ObjectConverterException(this,"Could not parse arguments: "+str);
throw new ObjectConverterException(this, "Could not parse arguments: " + str);
}
} else if (str.startsWith("GridBagLayout")) {
@ -92,19 +92,18 @@ public class LayoutConverter extends AbstractStringObjectConverter {
return new GridBagLayout();
} else {
throw new ObjectConverterException(this,"Unknow layout requested: "+str);
throw new ObjectConverterException(this, "Unknow layout requested: " + str);
}
} catch (Exception e) {
throw new ObjectConverterException(this,e.getMessage(),e);
throw new ObjectConverterException(this, e.getMessage(), e);
}
}
@Override
public ObjectConverter clone() throws CloneNotSupportedException {
LayoutConverter result = new LayoutConverter();
result.converters=cloneConverters();
result.converters = cloneConverters();
return result;
}
}

View file

@ -39,6 +39,5 @@ public interface MaisDocProjectPerspectiveWing {
// use: doc.addConcept
// use: doc.addDocPage
// use: waspNode.addNode
}

View file

@ -52,9 +52,10 @@ public class MaisDocWriter {
// NOTE: this class is unused, and is waiting for ApiDocProject code and replaces most code in EldDocWriter to here.
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"api-doc/";
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX + "api-doc/";
public final static SAX3PropertyConfig DEFAULT_PROPERTY_CONFIG;
//@formatter:off
public final static String OUTPUT_PATH = PROPERTY_CONTEXT_PREFIX+"output/path";
public final static String DOC_NAME = PROPERTY_CONTEXT_PREFIX+"doc/name";
public final static String DOC_DESCRIPTION = PROPERTY_CONTEXT_PREFIX+"doc/description";
@ -92,17 +93,19 @@ public class MaisDocWriter {
new PropertyConfigItem(PAGE_PRINT_HELP,Boolean.class,true)
);
}
//@formatter:on
/** The config of this writer. */
private final SAX3PropertyConfig propertyConfig;
public MaisDocWriter(SAX3PropertyConfig parentConfig) {
this.propertyConfig=new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG,PROPERTY_CONTEXT_PREFIX);
this.propertyConfig = new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG, PROPERTY_CONTEXT_PREFIX);
this.propertyConfig.copyParentProperties(parentConfig);
}
/**
* Writes the language documentation to the base path.
*
* @throws IOException Is thrown when error is done.
*/
public void writeDocumentation() throws IOException {
@ -114,37 +117,38 @@ public class MaisDocWriter {
/**
* Creates a fully configured ApiDoc object.
*
* @return The ApiDoc configured to write eld documentation.
*/
private MaisDoc buildLanguageDoc() {
// Generic config
MaisDoc doc = new MaisDoc();
doc.setName( propertyConfig.getPropertyString(DOC_NAME));
doc.setDescription( propertyConfig.getPropertyString(DOC_DESCRIPTION));
doc.setDocAbout( propertyConfig.getPropertyString(DOC_ABOUT, () -> createDefaultAbout(doc.getName())));
doc.setDocCopyright( propertyConfig.getPropertyString(DOC_COPYRIGHT, () -> createForeverCopyright()));
doc.setDocPageSubTitle( propertyConfig.getPropertyString(DOC_PAGE_SUB_TITLE, () -> createDefaultPageSubTitle(doc.getName())));
doc.setMetaStyleSheetThema( propertyConfig.getPropertyString(META_STYLESHEET_THEMA));
doc.setMetaStyleSheet( propertyConfig.getPropertyFile(META_STYLESHEET));
doc.addMetaKeywordAll( propertyConfig.getPropertyList(META_KEYWORDS, () -> createDefaultKeywords()));
doc.setNoFrameAllName( propertyConfig.getPropertyString(DOC_NO_FRAME_ALL_NAME));
doc.setName(propertyConfig.getPropertyString(DOC_NAME));
doc.setDescription(propertyConfig.getPropertyString(DOC_DESCRIPTION));
doc.setDocAbout(propertyConfig.getPropertyString(DOC_ABOUT, () -> createDefaultAbout(doc.getName())));
doc.setDocCopyright(propertyConfig.getPropertyString(DOC_COPYRIGHT, () -> createForeverCopyright()));
doc.setDocPageSubTitle(propertyConfig.getPropertyString(DOC_PAGE_SUB_TITLE, () -> createDefaultPageSubTitle(doc.getName())));
doc.setMetaStyleSheetThema(propertyConfig.getPropertyString(META_STYLESHEET_THEMA));
doc.setMetaStyleSheet(propertyConfig.getPropertyFile(META_STYLESHEET));
doc.addMetaKeywordAll(propertyConfig.getPropertyList(META_KEYWORDS, () -> createDefaultKeywords()));
doc.setNoFrameAllName(propertyConfig.getPropertyString(DOC_NO_FRAME_ALL_NAME));
doc.setFrameNavPrintParent(true);
doc.setFrameNavPrintParentId(true);
doc.setGroupTypeName("summary", "Summary",1);
doc.setGroupTypeName("overview", "Overview",2);
doc.setGroupTypeName("summary", "Summary", 1);
doc.setGroupTypeName("overview", "Overview", 2);
// Javadoc linking config
List<String> javadocLinkList = propertyConfig.getPropertyList(JAVADOC_LINK);
Map<String,String> javadocLinkOfflineMap = propertyConfig.getPropertyMap(JAVADOC_LINK_OFFLINE);
if (javadocLinkList!=null) {
for (String javadocUrl:javadocLinkList) {
Map<String, String> javadocLinkOfflineMap = propertyConfig.getPropertyMap(JAVADOC_LINK_OFFLINE);
if (javadocLinkList != null) {
for (String javadocUrl : javadocLinkList) {
doc.addRemoteClass(new MaisDocRemoteClass(javadocUrl));
}
}
if (javadocLinkOfflineMap!=null) {
for (Map.Entry<String,String> offlineLink:javadocLinkOfflineMap.entrySet()) {
doc.addRemoteClass(new MaisDocRemoteClass(offlineLink.getKey(),offlineLink.getValue()));
if (javadocLinkOfflineMap != null) {
for (Map.Entry<String, String> offlineLink : javadocLinkOfflineMap.entrySet()) {
doc.addRemoteClass(new MaisDocRemoteClass(offlineLink.getKey(), offlineLink.getValue()));
}
}

View file

@ -40,31 +40,33 @@ import org.x4o.sax3.SAX3WriterHtml.Tag;
public class DefaultPageWriterHelp implements MaisDocPageWriter {
public static MaisDocPage createDocPage() {
return new MaisDocPage("doc-help","Help","This help file applies to the API documentation generated using the standard format.",new DefaultPageWriterHelp());
return new MaisDocPage("doc-help", "Help", "This help file applies to the API documentation generated using the standard format.",
new DefaultPageWriterHelp());
}
public void writePageContent(MaisDocWriteEvent<MaisDocPage> e) throws IOException {
MaisDoc doc = e.getDoc();
//ApiDocPage page = e.getEvent();
// ApiDocPage page = e.getEvent();
MaisDocContentWriter writer = e.getWriter();
//@formatter:off
writer.printTagStart(Tag.div,"header");
writer.printTagCharacters(Tag.h1, "How This API Document Is Organized", "title");
writer.printTagStart(Tag.div,"subTitle");
writer.printTagStart(Tag.div, "subTitle");
writer.printCharacters("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 (MaisDocConcept concept:doc.getConcepts()) {
for (MaisDocConcept concept : doc.getConcepts()) {
writer.printTagCharacters(Tag.h2, concept.getName());
writer.printTagStart(Tag.p);
writer.printCharacters(concept.getDescriptionHelp());
writer.printTagEnd(Tag.p);
writer.docPageBlockNext();
}
for (MaisDocPage docPage:doc.getDocPages()) {
for (MaisDocPage docPage : doc.getDocPages()) {
writer.printTagCharacters(Tag.h2, docPage.getName());
writer.printTagStart(Tag.p);
writer.printCharacters(docPage.getDescription());
@ -73,5 +75,6 @@ public class DefaultPageWriterHelp implements MaisDocPageWriter {
}
writer.docPageBlockEnd();
writer.docPageContentEnd();
//@formatter:on
}
}

View file

@ -38,7 +38,7 @@ import org.x4o.sax3.SAX3WriterHtml.Tag;
public class DefaultPageWriterIndexAll implements MaisDocPageWriter {
public static MaisDocPage createDocPage() {
return new MaisDocPage("index-all","Index","Index of all api ketwords.",new DefaultPageWriterIndexAll());
return new MaisDocPage("index-all", "Index", "Index of all api ketwords.", new DefaultPageWriterIndexAll());
}
public void writePageContent(MaisDocWriteEvent<MaisDocPage> e) throws IOException {
@ -46,13 +46,13 @@ public class DefaultPageWriterIndexAll implements MaisDocPageWriter {
// ApiDocPage page = e.getEvent();
MaisDocContentWriter writer = e.getWriter();
writer.docPageContentStart();
for (char i='A';i<='Z';i++) {
writer.printHref("#_"+i+"_", ""+i);
for (char i = 'A'; i <= 'Z'; i++) {
writer.printHref("#_" + i + "_", "" + i);
writer.printCharacters("&nbsp;");
}
for (char i='A';i<='Z';i++) {
writer.printHrefNamed("_"+i+"_");
writer.printTagCharacters(Tag.h2, ""+i);
for (char i = 'A'; i <= 'Z'; i++) {
writer.printHrefNamed("_" + i + "_");
writer.printTagCharacters(Tag.h2, "" + i);
writer.printCharacters("TODO");
}
writer.docPageContentEnd();

View file

@ -40,12 +40,12 @@ import org.x4o.sax3.SAX3WriterHtml.Tag;
public class DefaultPageWriterTree implements MaisDocPageWriter {
public static MaisDocPage createDocPage() {
return new MaisDocPage("overview-tree","Tree","Tree of api concepts.",new DefaultPageWriterTree());
return new MaisDocPage("overview-tree", "Tree", "Tree of api concepts.", new DefaultPageWriterTree());
}
protected MaisDocNode selectRootNode(MaisDoc doc) {
MaisDocNode rootNode = doc.getRootNodeTreePage();
if (rootNode==null) {
if (rootNode == null) {
rootNode = doc.getRootNode();
}
return rootNode;
@ -55,16 +55,16 @@ public class DefaultPageWriterTree implements MaisDocPageWriter {
MaisDoc doc = e.getDoc();
MaisDocPage page = e.getEventObject();
MaisDocContentWriter writer = e.getWriter();
//writer.docPagePackageTitle(title, "Overview Tree");
// writer.docPagePackageTitle(title, "Overview Tree");
writer.docPageContentStart();
writeTree(doc,selectRootNode(doc),writer,"");
writer.docPagePackageDescription(page.getName(), "Tree","All Language elements as tree.");
writeTree(doc, selectRootNode(doc), writer, "");
writer.docPagePackageDescription(page.getName(), "Tree", "All Language elements as tree.");
writer.docPageContentEnd();
}
private void writeTree(MaisDoc doc, MaisDocNode node,MaisDocContentWriter writer,String pathPrefix) throws IOException {
private void writeTree(MaisDoc doc, MaisDocNode node, MaisDocContentWriter writer, String pathPrefix) throws IOException {
for (Class<?> excludeClass:doc.getTreeNodeClassExcludes()) {
for (Class<?> excludeClass : doc.getTreeNodeClassExcludes()) {
if (excludeClass.isAssignableFrom(node.getUserData().getClass())) {
return;
}
@ -72,34 +72,34 @@ public class DefaultPageWriterTree implements MaisDocPageWriter {
StringBuilder buf = new StringBuilder();
if (!doc.getRootNode().equals(node)) {
buildParentPath(node,buf);
buildParentPath(node, buf);
}
buf.append("index.html");
String href = buf.toString();
writer.printTagStart(Tag.ul);
writer.printTagStart(Tag.li,"",null,"circle");
if (node.getParent()!=null) {
writer.printTagStart(Tag.li, "", null, "circle");
if (node.getParent() != null) {
writer.printCharacters(node.getParent().getId());
writer.printCharacters(":");
}
writer.printHref(href, node.getName(), node.getName(), "strong");
writer.printTagEnd(Tag.li);
for (MaisDocNode child:node.getNodes()) {
writeTree(doc,child,writer,pathPrefix);
for (MaisDocNode child : node.getNodes()) {
writeTree(doc, child, writer, pathPrefix);
}
writer.printTagEnd(Tag.ul);
}
private void buildParentPath(MaisDocNode node,StringBuilder buf) {
if (node.getParent()==null) {
private void buildParentPath(MaisDocNode node, StringBuilder buf) {
if (node.getParent() == null) {
buf.append(MaisDocContentWriter.toSafeUri(node.getId()));
buf.append('/');
return;
}
buildParentPath(node.getParent(),buf);
buildParentPath(node.getParent(), buf);
buf.append(MaisDocContentWriter.toSafeUri(node.getId()));
buf.append('/');
}

View file

@ -71,8 +71,7 @@ public enum MaisDocContentCss {
// frame names maybe can be used to create frame-less html5 JS version
frameNavOverview,
frameNavDetail,
frameContent,
;
frameContent,;
//
// TODO: write new CSS spec for html root tag to have tag+style class guards in CSS.
// because this sun css of above defines the allowed (styled) html tree structure.

View file

@ -42,50 +42,45 @@ import org.x4o.maisdoc.model.MaisDocWriteEvent;
*/
public interface MaisDocContentPrinter {
default void clearHrefContentGroup(MaisDoc doc,MaisDocNode node,String groupType,String group,Class<?> filterClass) {
boolean doClear = filterUserDataClassType(node,filterClass).isEmpty();
if (doClear==false) {
default void clearHrefContentGroup(MaisDoc doc, MaisDocNode node, String groupType, String group, Class<?> filterClass) {
boolean doClear = filterUserDataClassType(node, filterClass).isEmpty();
if (doClear == false) {
return;
}
clearHrefContentGroupAlways(doc,groupType,group);
clearHrefContentGroupAlways(doc, groupType, group);
}
default void clearHrefContentGroupAlways(MaisDoc doc,String groupType,String group) {
MaisDocNavLink link = doc.getNodeData().getGroupTypeLink(groupType,group);
if (link==null) {
default void clearHrefContentGroupAlways(MaisDoc doc, String groupType, String group) {
MaisDocNavLink link = doc.getNodeData().getGroupTypeLink(groupType, group);
if (link == null) {
return;
}
link.setHref(null);
}
default void printApiTable(MaisDocWriteEvent<MaisDocNode> event,String name,Class<?> interfaceClass) throws IOException {
printApiTable(
event.getEventObject(),
filterUserDataClassType(event.getEventObject(),interfaceClass),
event.getWriter(),
name
);
default void printApiTable(MaisDocWriteEvent<MaisDocNode> event, String name, Class<?> interfaceClass) throws IOException {
printApiTable(event.getEventObject(), filterUserDataClassType(event.getEventObject(), interfaceClass), event.getWriter(), name);
}
default void printApiTable(MaisDocNode parent,List<MaisDocNode> nodes,MaisDocContentWriter writer,String name) throws IOException {
default void printApiTable(MaisDocNode parent, List<MaisDocNode> nodes, MaisDocContentWriter writer, String name) throws IOException {
if (nodes.isEmpty()) {
return;
}
writer.docTableStart(name, "All childeren in "+name,MaisDocContentCss.overviewSummary);
writer.docTableStart(name, "All childeren in " + name, MaisDocContentCss.overviewSummary);
writer.docTableHeader("Name", "Description");
for (MaisDocNode child:nodes) {
String link = MaisDocContentWriter.toSafeUri(child.getId())+"/index.html";
if (parent.getParent()==null) {
link = MaisDocContentWriter.toSafeUri(parent.getId())+"/"+link; // root node
for (MaisDocNode child : nodes) {
String link = MaisDocContentWriter.toSafeUri(child.getId()) + "/index.html";
if (parent.getParent() == null) {
link = MaisDocContentWriter.toSafeUri(parent.getId()) + "/" + link; // root node
}
writer.docTableRowLink(link,child.getName(),child.getDescription());
writer.docTableRowLink(link, child.getName(), child.getDescription());
}
writer.docTableEnd();
}
private List<MaisDocNode> filterUserDataClassType(MaisDocNode filterNode,Class<?> interfaceClass) {
List<MaisDocNode> result = new ArrayList<MaisDocNode>(filterNode.getNodes().size()/2);
for (MaisDocNode node:filterNode.getNodes()) {
private List<MaisDocNode> filterUserDataClassType(MaisDocNode filterNode, Class<?> interfaceClass) {
List<MaisDocNode> result = new ArrayList<MaisDocNode>(filterNode.getNodes().size() / 2);
for (MaisDocNode node : filterNode.getNodes()) {
if (interfaceClass.isAssignableFrom(node.getUserData().getClass())) {
result.add(node);
}
@ -93,33 +88,34 @@ public interface MaisDocContentPrinter {
return result;
}
default void printApiTableBean(MaisDocWriteEvent<MaisDocNode> event,String name,String...skipProperties) throws IOException {
default void printApiTableBean(MaisDocWriteEvent<MaisDocNode> event, String name, String... skipProperties) throws IOException {
printApiTableBean(event.getDoc(), event.getWriter(), event.getEventObject().getUserData(), name, skipProperties);
}
default void printApiTableBean(MaisDoc doc,MaisDocContentWriter writer,Object bean,String name,String...skipProperties) throws IOException {
default void printApiTableBean(MaisDoc doc, MaisDocContentWriter writer, Object bean, String name, String... skipProperties) throws IOException {
printApiTableBeanClass(doc, writer, bean, bean.getClass(), name, skipProperties);
}
default void printApiTableBeanClass(MaisDocWriteEvent<MaisDocNode> event,Class<?> beanClass,String name,String...skipProperties) throws IOException {
printApiTableBeanClass(event.getDoc(), event.getWriter(), null,beanClass, name, skipProperties);
default void printApiTableBeanClass(MaisDocWriteEvent<MaisDocNode> event, Class<?> beanClass, String name, String... skipProperties) throws IOException {
printApiTableBeanClass(event.getDoc(), event.getWriter(), null, beanClass, name, skipProperties);
}
private void printApiTableBeanClass(MaisDoc doc,MaisDocContentWriter writer,Object bean,Class<?> beanClass,String name,String...skipProperties) throws IOException {
writer.docTableStart(name+" Properties", name+" properties overview.",MaisDocContentCss.overviewSummary);
private void printApiTableBeanClass(MaisDoc doc, MaisDocContentWriter writer, Object bean, Class<?> beanClass, String name, String... skipProperties)
throws IOException {
writer.docTableStart(name + " Properties", name + " properties overview.", MaisDocContentCss.overviewSummary);
writer.docTableHeader("Name", "Value");
for (Method m:beanClass.getMethods()) {
for (Method m : beanClass.getMethods()) {
if (m.getName().startsWith("get")) {
String n = m.getName().substring(3);
if (m.getParameterTypes().length!=0) {
if (m.getParameterTypes().length != 0) {
continue; // set without parameters
}
if (n.length()<2) {
if (n.length() < 2) {
continue;
}
n = n.substring(0,1).toLowerCase()+n.substring(1,n.length());
n = n.substring(0, 1).toLowerCase() + n.substring(1, n.length());
boolean skipNext = false;
for (String skip:skipProperties) {
for (String skip : skipProperties) {
if (n.equals(skip)) {
skipNext = true;
break;
@ -130,7 +126,7 @@ public interface MaisDocContentPrinter {
}
Object value = null;
if (bean!=null) {
if (bean != null) {
try {
value = m.invoke(bean, new Object[] {});
} catch (IllegalArgumentException e) {
@ -143,10 +139,10 @@ public interface MaisDocContentPrinter {
} else {
value = m.getReturnType();
}
//writer.docTableRow(n,);
// writer.docTableRow(n,);
writer.docTableRowLastStart(n, null);
String c = printValue(doc,writer,value);
if (c!=null) {
String c = printValue(doc, writer, value);
if (c != null) {
writer.printCharacters(c);
}
writer.docTableRowLastEnd();
@ -155,36 +151,36 @@ public interface MaisDocContentPrinter {
writer.docTableEnd();
}
private String printValue(MaisDoc doc,MaisDocContentWriter writer,Object value) throws IOException {
if (value==null) {
private String printValue(MaisDoc doc, MaisDocContentWriter writer, Object value) throws IOException {
if (value == null) {
return "null";
}
if (value instanceof String) {
return (String)value;
return (String) value;
}
if (value instanceof Class) {
Class<?> cls = (Class<?>)value;
Class<?> cls = (Class<?>) value;
for (MaisDocRemoteClass rc:doc.getRemoteClasses()) {
for (MaisDocRemoteClass rc : doc.getRemoteClasses()) {
String remoteUrl = rc.getRemoteUrl(cls);
if (remoteUrl==null) {
if (remoteUrl == null) {
continue;
}
writer.printHref(remoteUrl, cls.getSimpleName(), cls.getName());
return null;
}
return "class "+cls.getName();
return "class " + cls.getName();
}
if (value instanceof List) {
StringBuilder buf = new StringBuilder(100);
buf.append("[L: ");
List<?> l = (List<?>)value;
List<?> l = (List<?>) value;
if (l.isEmpty()) {
buf.append("Empty");
}
for (Object o:l) {
buf.append(""+o);
for (Object o : l) {
buf.append("" + o);
buf.append(" ");
}
buf.append("]");
@ -193,12 +189,12 @@ public interface MaisDocContentPrinter {
if (value instanceof Object[]) {
StringBuilder buf = new StringBuilder(100);
buf.append("[A: ");
Object[] l = (Object[])value;
if (l.length==0) {
Object[] l = (Object[]) value;
if (l.length == 0) {
buf.append("Empty");
}
for (Object o:l) {
buf.append(""+o);
for (Object o : l) {
buf.append("" + o);
buf.append(" ");
}
buf.append("]");

View file

@ -43,19 +43,20 @@ public class MaisDocContentWriter extends SAX3WriterHtml {
private boolean isRowAlt = false;
public MaisDocContentWriter(Writer out, String encoding) {
super(out,encoding);
super(out, encoding);
}
public void docCommentGenerated() throws IOException {
printComment("Generated by " + MaisDocContentWriter.class.getSimpleName( )+ " on " + new Date());
printComment("Generated by " + MaisDocContentWriter.class.getSimpleName() + " on " + new Date());
}
public void docHtmlStart(String title,List<String> keywords, String pathPrefix) throws IOException {
public void docHtmlStart(String title, List<String> keywords, String pathPrefix) throws IOException {
printDocType(DocType.HTML_4_TRANSITIONAL);
printComment("NewPage");
printHtmlStart("en");
// ====== Write head
//@formatter:off
printTagStart(Tag.head);
docCommentGenerated();
printHeadMetaContentType();
@ -67,6 +68,7 @@ public class MaisDocContentWriter extends SAX3WriterHtml {
printHeadLinkCss(pathPrefix+"resources/stylesheet.css");
printScriptSrc(pathPrefix+"resources/api-theme.js");
printTagEnd(Tag.head);
//@formatter:on
// ======= Write body
printTagStart(Tag.body);
@ -75,7 +77,9 @@ public class MaisDocContentWriter extends SAX3WriterHtml {
script.append("\n");
script.append("\tif (location.href.indexOf('is-external=true') == -1) {\n");
script.append("\t\ttry {\n");
script.append("\t\t\tparent.document.title=\"");script.append(title);script.append("\";\n");
script.append("\t\t\tparent.document.title=\"");
script.append(title);
script.append("\";\n");
script.append("\t\t} catch (e) {}\n");
script.append("\t}\n");
printScriptInline(script.toString());
@ -83,11 +87,13 @@ public class MaisDocContentWriter extends SAX3WriterHtml {
}
public void docHtmlEnd(String copyright, String statsJS) throws IOException {
//@formatter:off
printTagStart(Tag.p,MaisDocContentCss.legalCopy);
printTagStart(Tag.small);
printCharacters(copyright);
printTagEnd(Tag.small);
printTagEnd(Tag.p);
//@formatter:on
if (statsJS != null) {
printScriptInline(statsJS);
}
@ -96,7 +102,7 @@ public class MaisDocContentWriter extends SAX3WriterHtml {
}
public void docNavBarAbout(String about) throws IOException {
printTagStart(Tag.div,MaisDocContentCss.aboutLanguage); // Print about language
printTagStart(Tag.div, MaisDocContentCss.aboutLanguage); // Print about language
printTagStart(Tag.em);
printTagStart(Tag.strong);
String[] lines = about.split("\n");
@ -113,30 +119,32 @@ public class MaisDocContentWriter extends SAX3WriterHtml {
}
public void docPagePackageTitle(String title, String summary) throws IOException {
printTagStart(Tag.div,MaisDocContentCss.header);
printTagCharacters(Tag.h1, title,"title");
printTagStart(Tag.div,MaisDocContentCss.docSummary);
printTagCharacters(Tag.div, summary,MaisDocContentCss.block.name());
//@formatter:off
printTagStart(Tag.div, MaisDocContentCss.header);
printTagCharacters(Tag.h1, title, "title");
printTagStart(Tag.div, MaisDocContentCss.docSummary);
printTagCharacters(Tag.div, summary, MaisDocContentCss.block.name());
printTagEnd(Tag.div);
printTagStart(Tag.p);
printCharacters("See:&nbsp;");
printHref("#package_description", "Description");
printTagEnd(Tag.p);
printTagEnd(Tag.div);
//@formatter:on
}
public void docPagePackageDescription(String title, String summary, String description) throws IOException {
printHrefNamed("package_description");
printTagCharacters(Tag.h2, title);
printTagCharacters(Tag.div, summary,MaisDocContentCss.block.name());
printTagCharacters(Tag.div, summary, MaisDocContentCss.block.name());
printCharacters(description);
}
public void docPageClassStart(String title, String subTitle, Tag titleTag) throws IOException {
printComment("======== START OF CLASS DATA ========");
printTagStart(Tag.div,MaisDocContentCss.header);
printTagStart(Tag.div, MaisDocContentCss.header);
if (subTitle != null) {
printTagStart(Tag.div,MaisDocContentCss.subTitle);
printTagStart(Tag.div, MaisDocContentCss.subTitle);
printCharacters(subTitle);
printTagEnd(Tag.div);
}
@ -154,7 +162,7 @@ public class MaisDocContentWriter extends SAX3WriterHtml {
}
public void docPageContentStart() throws IOException {
printTagStart(Tag.div,MaisDocContentCss.contentContainer);
printTagStart(Tag.div, MaisDocContentCss.contentContainer);
}
public void docPageContentEnd() throws IOException {
@ -171,8 +179,8 @@ public class MaisDocContentWriter extends SAX3WriterHtml {
}
public void docPageBlockStart() throws IOException {
printTagStart(Tag.ul,MaisDocContentCss.blockList);
printTagStart(Tag.li,MaisDocContentCss.blockList);
printTagStart(Tag.ul, MaisDocContentCss.blockList);
printTagStart(Tag.li, MaisDocContentCss.blockList);
}
public void docPageBlockEnd() throws IOException {
@ -182,7 +190,7 @@ public class MaisDocContentWriter extends SAX3WriterHtml {
public void docPageBlockNext() throws IOException {
printTagEnd(Tag.li);
printTagStart(Tag.li,MaisDocContentCss.blockList);
printTagStart(Tag.li, MaisDocContentCss.blockList);
}
public ContentCloseable docTable(String tableTitle, String tableDescription, MaisDocContentCss tableCss) throws IOException {
@ -194,7 +202,7 @@ public class MaisDocContentWriter extends SAX3WriterHtml {
isRowAlt = false;
AttributesImpl atts = new AttributesImpl();
if (tableCss != null) {
atts.addAttribute ("", "class", "", "", tableCss.name());
atts.addAttribute("", "class", "", "", tableCss.name());
}
atts.addAttribute("", "border", "", "", "0");
atts.addAttribute("", "cellpadding", "", "", "3");
@ -202,12 +210,14 @@ public class MaisDocContentWriter extends SAX3WriterHtml {
if (tableDescription != null) {
atts.addAttribute("", "summary", "", "", tableDescription);
}
printTagStart(Tag.table,atts);
printTagStart(Tag.table, atts);
//@formatter:off
printTagStart(Tag.caption);
printTagStart(Tag.span);printCharacters(tableTitle);printTagEnd(Tag.span);
printTagStart(Tag.span,MaisDocContentCss.tabEnd);printCharacters("&nbsp;");printTagEnd(Tag.span);
printTagEnd(Tag.caption);
//@formatter:on
}
public void docTableEnd() throws IOException {
@ -223,7 +233,7 @@ public class MaisDocContentWriter extends SAX3WriterHtml {
atts.addAttribute("", "class", "", "", MaisDocContentCss.colFirst.name());
}
atts.addAttribute("", "scope", "", "", "col");
printTagStart(Tag.th,atts);
printTagStart(Tag.th, atts);
printCharacters(titleFirst);
printTagEnd(Tag.th);
if (titleLast == null) {
@ -233,7 +243,7 @@ public class MaisDocContentWriter extends SAX3WriterHtml {
atts = new AttributesImpl();
atts.addAttribute("", "class", "", "", MaisDocContentCss.colLast.name());
atts.addAttribute("", "scope", "", "", "col");
printTagStart(Tag.th,atts);
printTagStart(Tag.th, atts);
printCharacters(titleLast);
printTagEnd(Tag.th);
printTagEnd(Tag.tr);
@ -262,20 +272,21 @@ public class MaisDocContentWriter extends SAX3WriterHtml {
public ContentCloseable docTableRow() throws IOException {
if (isRowAlt) {
printTagStart(Tag.tr,MaisDocContentCss.altColor);
printTagStart(Tag.tr, MaisDocContentCss.altColor);
} else {
printTagStart(Tag.tr,MaisDocContentCss.rowColor);
printTagStart(Tag.tr, MaisDocContentCss.rowColor);
}
isRowAlt = !isRowAlt;
return () -> printTagEnd(Tag.tr);
}
private void docTableRowHref(String dataFirstHref, String dataFirst, String dataLast, String dataBlock, boolean dataFirstCode, boolean dataLastCode, boolean skipLast) throws IOException {
private void docTableRowHref(String dataFirstHref, String dataFirst, String dataLast, String dataBlock, boolean dataFirstCode, boolean dataLastCode,
boolean skipLast) throws IOException {
Closeable tableRow = docTableRow();
if (dataLast == null) {
printTagStart(Tag.td,MaisDocContentCss.colOne);
printTagStart(Tag.td, MaisDocContentCss.colOne);
} else {
printTagStart(Tag.td,MaisDocContentCss.colFirst);
printTagStart(Tag.td, MaisDocContentCss.colFirst);
}
if (dataFirstCode) {
printTagStart(Tag.code);
@ -291,7 +302,7 @@ public class MaisDocContentWriter extends SAX3WriterHtml {
printTagEnd(Tag.td);
if (skipLast) {
printTagStart(Tag.td,MaisDocContentCss.colLast);
printTagStart(Tag.td, MaisDocContentCss.colLast);
return;
}
@ -300,31 +311,32 @@ public class MaisDocContentWriter extends SAX3WriterHtml {
return;
}
//@formatter:off
printTagStart(Tag.td,MaisDocContentCss.colLast);
if (dataLastCode) {
printTagStart(Tag.code);printCharacters(dataLast);printTagEnd(Tag.code);
} else {
printTagStart(Tag.div,MaisDocContentCss.block);printCharacters(dataLast);printTagEnd(Tag.div);
printTagStart(Tag.div, MaisDocContentCss.block);printCharacters(dataLast);printTagEnd(Tag.div);
}
if (dataBlock != null) {
printTagStart(Tag.div,MaisDocContentCss.block);printCharacters(dataBlock);printTagEnd(Tag.div);
printTagStart(Tag.div, MaisDocContentCss.block);printCharacters(dataBlock);printTagEnd(Tag.div);
}
printTagEnd(Tag.td);
//@formatter:on
tableRow.close();
}
static public String toSafeUri(List<String> paths) {
return toSafeUri(paths.toArray(new String[]{}));
return toSafeUri(paths.toArray(new String[] {}));
}
static public String toSafeUri(String...paths) {
static public String toSafeUri(String... paths) {
StringBuilder result = new StringBuilder(100);
for (int i = 0; i < paths.length; i++) {
String path = paths[i];
result.append(toSafeUri(path));
if (i < (paths.length -1)) {
if (i < (paths.length - 1)) {
result.append('/');
}
}
@ -340,13 +352,13 @@ public class MaisDocContentWriter extends SAX3WriterHtml {
if (Character.isDigit(c)) {
buf.append(c);
}
if ('.'==c) {
if ('.' == c) {
buf.append(c);
}
if ('-'==c) {
if ('-' == c) {
buf.append(c);
}
if ('_'==c) {
if ('_' == c) {
buf.append(c);
}
}

View file

@ -47,28 +47,28 @@ public class MaisDocNodeDataConfiguratorBean implements MaisDocNodeDataConfigura
targetClasses = new ArrayList<Class<?>>(5);
}
public MaisDocNodeDataConfiguratorBean(Object bean,String method,Class<?>...classes) {
public MaisDocNodeDataConfiguratorBean(Object bean, String method, Class<?>... classes) {
this();
setBean(bean);
setMethod(method);
for (Class<?> cl:classes) {
for (Class<?> cl : classes) {
addtargetClass(cl);
}
}
public static void addAnnotatedNodeDataConfigurators(MaisDoc doc,Object bean) {
if (doc==null) {
public static void addAnnotatedNodeDataConfigurators(MaisDoc doc, Object bean) {
if (doc == null) {
throw new NullPointerException("Can't add to null ApiDoc.");
}
if (bean==null) {
if (bean == null) {
throw new NullPointerException("Can't scan null bean.");
}
for (Method method:bean.getClass().getMethods()) {
for (Method method : bean.getClass().getMethods()) {
MaisDocNodeDataConfiguratorMethod ammo = method.getAnnotation(MaisDocNodeDataConfiguratorMethod.class);
if (ammo==null) {
if (ammo == null) {
continue;
}
if (ammo.targetClasses().length==0) {
if (ammo.targetClasses().length == 0) {
throw new IllegalArgumentException("Can't configure writer bean with empty 'targetClasses' parameter.");
}
MaisDocNodeDataConfiguratorBean methodConfig = new MaisDocNodeDataConfiguratorBean(bean, method.getName(), ammo.targetClasses());
@ -76,11 +76,11 @@ public class MaisDocNodeDataConfiguratorBean implements MaisDocNodeDataConfigura
}
}
public void configNodeData(MaisDoc doc, MaisDocNode node,MaisDocNodeData data) {
public void configNodeData(MaisDoc doc, MaisDocNode node, MaisDocNodeData data) {
Class<?> beanClass = getBean().getClass();
try {
Method methodBean = beanClass.getMethod(getMethod(), new Class[]{MaisDoc.class,MaisDocNode.class,MaisDocNodeData.class});
methodBean.invoke(getBean(), new Object[]{doc,node,data});
Method methodBean = beanClass.getMethod(getMethod(), new Class[] { MaisDoc.class, MaisDocNode.class, MaisDocNodeData.class });
methodBean.invoke(getBean(), new Object[] { doc, node, data });
} catch (Exception e) {
throw new IllegalStateException(e);
}

View file

@ -34,7 +34,7 @@ import java.lang.annotation.Target;
* @version 1.0 Aug 11, 2013
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
@Target({ ElementType.METHOD })
public @interface MaisDocNodeDataConfiguratorMethod {
Class<?>[] targetClasses();

View file

@ -53,44 +53,45 @@ public class MaisDocNodeWriterBean implements MaisDocNodeWriter {
targetClasses = new ArrayList<Class<?>>(5);
}
public MaisDocNodeWriterBean(MaisDocNodeBody nodeBody,Object bean,String method,Class<?>...classes) {
public MaisDocNodeWriterBean(MaisDocNodeBody nodeBody, Object bean, String method, Class<?>... classes) {
this();
setNodeBody(nodeBody);
setBean(bean);
setMethod(method);
for (Class<?> cl:classes) {
for (Class<?> cl : classes) {
addtargetClass(cl);
}
}
public static void addAnnotatedNodeContentWriters(MaisDoc doc,Object bean) {
if (doc==null) {
public static void addAnnotatedNodeContentWriters(MaisDoc doc, Object bean) {
if (doc == null) {
throw new NullPointerException("Can't add to null ApiDoc.");
}
if (bean==null) {
if (bean == null) {
throw new NullPointerException("Can't scan null bean.");
}
for (Method method:bean.getClass().getMethods()) {
for (Method method : bean.getClass().getMethods()) {
MaisDocNodeWriterMethod ammo = method.getAnnotation(MaisDocNodeWriterMethod.class);
if (ammo==null) {
if (ammo == null) {
continue;
}
if (ammo.targetClasses().length==0) {
if (ammo.targetClasses().length == 0) {
throw new IllegalArgumentException("Can't configure writer bean with empty 'targetClasses' parameter.");
}
if (ammo.targetClasses().length!=ammo.nodeBodyOrders().length) {
throw new IllegalArgumentException("Can't configure writer bean with non-equal array size of 'nodeBodyOrders'("+ammo.nodeBodyOrders().length+") and 'targetClasses'("+ammo.targetClasses().length+") parameters.");
if (ammo.targetClasses().length != ammo.nodeBodyOrders().length) {
throw new IllegalArgumentException("Can't configure writer bean with non-equal array size of 'nodeBodyOrders'(" + ammo.nodeBodyOrders().length
+ ") and 'targetClasses'(" + ammo.targetClasses().length + ") parameters.");
}
MaisDocNodeWriterBean methodWriter = new MaisDocNodeWriterBean(ammo.nodeBody(), bean, method.getName(), ammo.targetClasses());
List<Integer> nodeBodyOrder = new ArrayList<Integer>();
for (int order:ammo.nodeBodyOrders()) {
for (int order : ammo.nodeBodyOrders()) {
nodeBodyOrder.add(order);
}
methodWriter.setNodeBodyOrders(nodeBodyOrder);
if (ammo.contentGroup().length()>0) {
if (ammo.contentGroup().length() > 0) {
methodWriter.setContentGroup(ammo.contentGroup());
}
if (ammo.contentGroupType().length()>0) {
if (ammo.contentGroupType().length() > 0) {
methodWriter.setContentGroupType(ammo.contentGroupType());
}
doc.addNodeBodyWriter(methodWriter);
@ -100,8 +101,8 @@ public class MaisDocNodeWriterBean implements MaisDocNodeWriter {
public void writeNodeContent(MaisDocWriteEvent<MaisDocNode> event) throws IOException {
Class<?> beanClass = getBean().getClass();
try {
Method methodBean = beanClass.getMethod(getMethod(), new Class[]{MaisDocWriteEvent.class});
methodBean.invoke(getBean(), new Object[]{event});
Method methodBean = beanClass.getMethod(getMethod(), new Class[] { MaisDocWriteEvent.class });
methodBean.invoke(getBean(), new Object[] { event });
} catch (Exception e) {
throw new IOException(e);
}

View file

@ -36,14 +36,14 @@ import org.x4o.maisdoc.model.MaisDocNodeBody;
* @version 1.0 May 19, 2013
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
@Target({ ElementType.METHOD })
public @interface MaisDocNodeWriterMethod {
Class<?>[] targetClasses();
MaisDocNodeBody nodeBody();
int[] nodeBodyOrders() default {-1};
int[] nodeBodyOrders() default { -1 };
String contentGroup() default "";

View file

@ -75,8 +75,8 @@ public class MaisDoc {
private boolean skipRootTreePathNode = true;
private boolean printConceptTitle = true;
private boolean printConceptPrevNext = true;
private Map<String,String> groupTypeNames = null;
private Map<String,Integer> groupTypeOrder = null;
private Map<String, String> groupTypeNames = null;
private Map<String, Integer> groupTypeOrder = null;
private String docPageSubTitle = null;
public MaisDoc() {
@ -89,49 +89,49 @@ public class MaisDoc {
dataConfigurators = new ArrayList<MaisDocNodeDataConfigurator>(5);
annotatedClasses = new ArrayList<Class<?>>(5);
remoteClasses = new ArrayList<MaisDocRemoteClass>(5);
groupTypeNames = new HashMap<String,String>(3);
groupTypeOrder = new HashMap<String,Integer>(3);
groupTypeNames = new HashMap<String, String>(3);
groupTypeOrder = new HashMap<String, Integer>(3);
}
public void checkModel() throws NullPointerException,IllegalArgumentException {
checkNull(name,"name");
checkNull(description,"description");
checkNull(docAbout,"docAbout");
checkNull(docCopyright,"docCopyright");
checkNull(rootNode,"rootNode");
checkNull(frameNavConceptClass,"frameNavConceptClass");
checkNull(noFrameAllName,"noFrameAllName");
public void checkModel() throws NullPointerException, IllegalArgumentException {
checkNull(name, "name");
checkNull(description, "description");
checkNull(docAbout, "docAbout");
checkNull(docCopyright, "docCopyright");
checkNull(rootNode, "rootNode");
checkNull(frameNavConceptClass, "frameNavConceptClass");
checkNull(noFrameAllName, "noFrameAllName");
if (concepts.isEmpty()) {
throw new IllegalStateException("Can't work with empty concepts");
}
if (frameNavOverviewPrintParent==null) {
if (frameNavOverviewPrintParent == null) {
setFrameNavOverviewPrintParent(false);
}
if (frameNavPrintParent==null) {
if (frameNavPrintParent == null) {
setFrameNavPrintParent(false);
}
if (frameNavPrintParentParent==null) {
if (frameNavPrintParentParent == null) {
setFrameNavPrintParentParent(false);
}
if (frameNavPrintParentId==null) {
if (frameNavPrintParentId == null) {
setFrameNavPrintParentId(false);
}
if (metaStyleSheetThema==null) {
if (metaStyleSheetThema == null) {
setMetaStyleSheetThema("jdk7");
}
if (noFrameAllTopJS==null) {
noFrameAllTopJS = "\nallClassesLink = document.getElementById(\"allclasses_navbar_top\");\n"+
"if(window==top) {\n\tallClassesLink.style.display = \"block\";\n} else {\n\tallClassesLink.style.display = \"none\";\n}\n";
if (noFrameAllTopJS == null) {
noFrameAllTopJS = "\nallClassesLink = document.getElementById(\"allclasses_navbar_top\");\n"
+ "if(window==top) {\n\tallClassesLink.style.display = \"block\";\n} else {\n\tallClassesLink.style.display = \"none\";\n}\n";
}
if (noFrameAllBottomJS==null) {
noFrameAllBottomJS = "\nallClassesLink = document.getElementById(\"allclasses_navbar_bottom\");\n"+
"if(window==top) {\n\tallClassesLink.style.display = \"block\";\n} else {\n\tallClassesLink.style.display = \"none\";\n}\n";
if (noFrameAllBottomJS == null) {
noFrameAllBottomJS = "\nallClassesLink = document.getElementById(\"allclasses_navbar_bottom\");\n"
+ "if(window==top) {\n\tallClassesLink.style.display = \"block\";\n} else {\n\tallClassesLink.style.display = \"none\";\n}\n";
}
if (noFrameAllLink==null) {
if (noFrameAllLink == null) {
MaisDocConcept navConcept = findConceptByClass(getFrameNavConceptClass());
setNoFrameAllLink("all"+navConcept.getId()+"-noframe.html");
setNoFrameAllLink("all" + navConcept.getId() + "-noframe.html");
}
fillRuntimeData();
@ -149,9 +149,9 @@ public class MaisDoc {
}
setNodeData(new MaisDocNodeData());
try {
for (Class<?> annoClass:getAnnotatedClasses()) {
for (Class<?> annoClass : getAnnotatedClasses()) {
Object bean = annoClass.newInstance();
MaisDocNodeWriterBean.addAnnotatedNodeContentWriters(this,bean);
MaisDocNodeWriterBean.addAnnotatedNodeContentWriters(this, bean);
MaisDocNodeDataConfiguratorBean.addAnnotatedNodeDataConfigurators(this, bean);
}
} catch (InstantiationException e) {
@ -159,50 +159,50 @@ public class MaisDoc {
} catch (IllegalAccessException e) {
throw new IllegalArgumentException(e);
}
for (MaisDocConcept concept:getConcepts()) {
String navLink = "overview-"+concept.getId()+".html";
for (MaisDocConcept concept : getConcepts()) {
String navLink = "overview-" + concept.getId() + ".html";
boolean resetHref = true;
if (concept.getParent()==null) {
if (concept.getParent() == null) {
resetHref = false; // don't reset root node
} else {
navLink = null; // rest start with null href's
}
MaisDocNavLink link = new MaisDocNavLink(concept.getId(), navLink, concept.getName(),concept.getName(),resetHref);
MaisDocNavLink link = new MaisDocNavLink(concept.getId(), navLink, concept.getName(), concept.getName(), resetHref);
getNodeData().addNavLink(link);
}
for (MaisDocPage page:getDocPages()) {
String navLink = page.getId()+".html";
MaisDocNavLink link = new MaisDocNavLink(page.getId(), navLink, page.getName(),page.getName(),false);
for (MaisDocPage page : getDocPages()) {
String navLink = page.getId() + ".html";
MaisDocNavLink link = new MaisDocNavLink(page.getId(), navLink, page.getName(), page.getName(), false);
getNodeData().addNavLink(link);
}
for (MaisDocRemoteClass rc:getRemoteClasses()) {
for (MaisDocRemoteClass rc : getRemoteClasses()) {
try {
rc.parseRemotePackageList();
} catch (IOException e) {
throw new IllegalStateException("While parsing: "+rc.getDocUrl()+" got: "+e.getMessage(),e);
throw new IllegalStateException("While parsing: " + rc.getDocUrl() + " got: " + e.getMessage(), e);
}
}
fillOnce = true;
}
private void checkNull(Object obj,String objName) {
if (obj==null) {
throw new NullPointerException("Can't work with null "+objName);
private void checkNull(Object obj, String objName) {
if (obj == null) {
throw new NullPointerException("Can't work with null " + objName);
}
}
public MaisDocConcept findConceptByClass(Class<?> objClass) {
for (MaisDocConcept concept:getConcepts()) {
for (MaisDocConcept concept : getConcepts()) {
if (concept.getConceptClass().isAssignableFrom(objClass)) {
return concept;
}
// NOTE: only 2 level search for sub child concepts
for (MaisDocConcept c:concept.getChildConcepts()) {
for (MaisDocConcept c : concept.getChildConcepts()) {
if (c.getConceptClass().isAssignableFrom(objClass)) {
//return concept;
// return concept;
return c;
}
for (MaisDocConcept cc:c.getChildConcepts()) {
for (MaisDocConcept cc : c.getChildConcepts()) {
if (cc.getConceptClass().isAssignableFrom(objClass)) {
return cc;
}
@ -216,21 +216,9 @@ public class MaisDoc {
Class<?> objClass = node.getUserData().getClass();
return findConceptByClass(objClass);
/*
Class<?> parentClass = null;
if (node.getParent()!=null) {
parentClass = node.getParent().getUserData().getClass();
}
for (MaisDocConcept concept:getConcepts()) {
if (parentClass!=null && concept.getConceptClass().isAssignableFrom(parentClass)==false) {
continue;
}
for (MaisDocConcept c:concept.getChildConcepts()) {
if (c.getConceptClass().isAssignableFrom(objClass)) {
return c;
}
}
}
return null;
* Class<?> parentClass = null; if (node.getParent()!=null) { parentClass = node.getParent().getUserData().getClass(); } for (MaisDocConcept
* concept:getConcepts()) { if (parentClass!=null && concept.getConceptClass().isAssignableFrom(parentClass)==false) { continue; } for (MaisDocConcept
* c:concept.getChildConcepts()) { if (c.getConceptClass().isAssignableFrom(objClass)) { return c; } } } return null;
*/
}
@ -356,6 +344,7 @@ public class MaisDoc {
/**
* Creates default copyright message for owner.
*
* @param owner The owner of the copyright.
*/
public void createDocCopyright(String owner) {
@ -366,6 +355,7 @@ public class MaisDoc {
/**
* Creates default copyright message for owner and year.
*
* @param owner The owner of the copyright.
* @param year The year of the copyright.
*/
@ -408,10 +398,10 @@ public class MaisDoc {
}
public MaisDocPage findDocPageById(String docPageId) {
if (docPageId==null) {
if (docPageId == null) {
throw new NullPointerException("Can't search for null id.");
}
for (MaisDocPage page:docPages) {
for (MaisDocPage page : docPages) {
if (page.getId().equals(docPageId)) {
return page;
}
@ -698,8 +688,8 @@ public class MaisDoc {
}
public List<String> getGroupTypesOrdered() {
Map<Integer,String> orderedMap = new TreeMap<Integer,String>();
for (String key:groupTypeOrder.keySet()) {
Map<Integer, String> orderedMap = new TreeMap<Integer, String>();
for (String key : groupTypeOrder.keySet()) {
Integer order = groupTypeOrder.get(key);
orderedMap.put(order, key);
}
@ -708,14 +698,14 @@ public class MaisDoc {
public String getGroupTypeName(String groupTypeKey) {
String result = groupTypeNames.get(groupTypeKey);
if (result==null) {
if (result == null) {
result = groupTypeKey;
}
return result;
}
public void setGroupTypeName(String groupTypeKey,String name,int order) {
groupTypeNames.put(groupTypeKey,name);
public void setGroupTypeName(String groupTypeKey, String name, int order) {
groupTypeNames.put(groupTypeKey, name);
groupTypeOrder.put(groupTypeKey, order);
}

View file

@ -45,19 +45,19 @@ public class MaisDocConcept {
childConcepts = new ArrayList<MaisDocConcept>(5);
}
public MaisDocConcept(MaisDocConcept parent,String id,Class<?> conceptClass) {
public MaisDocConcept(MaisDocConcept parent, String id, Class<?> conceptClass) {
this();
setId(id);
setConceptClass(conceptClass);
setParent(parent);
}
public MaisDocConcept(MaisDocConcept parent,String[] text,Class<?> conceptClass) {
this(parent,text[0],text[1],text[2],text[3],conceptClass);
public MaisDocConcept(MaisDocConcept parent, String[] text, Class<?> conceptClass) {
this(parent, text[0], text[1], text[2], text[3], conceptClass);
}
public MaisDocConcept(MaisDocConcept parent,String id,String name,String descriptionName,String descriptionHelp,Class<?> conceptClass) {
this(parent,id,conceptClass);
public MaisDocConcept(MaisDocConcept parent, String id, String name, String descriptionName, String descriptionHelp, Class<?> conceptClass) {
this(parent, id, conceptClass);
setName(name);
setDescriptionName(descriptionName);
setDescriptionHelp(descriptionHelp);
@ -159,6 +159,4 @@ public class MaisDocConcept {
this.parent = parent;
}
}

View file

@ -39,7 +39,7 @@ public class MaisDocNavLink {
public MaisDocNavLink() {
}
public MaisDocNavLink(String id,String href,String title,String text,boolean resetHref) {
public MaisDocNavLink(String id, String href, String title, String text, boolean resetHref) {
setId(id);
setHref(href);
setTitle(title);

View file

@ -44,12 +44,12 @@ public class MaisDocNode {
nodes = new ArrayList<MaisDocNode>(30);
}
public MaisDocNode(Object userData,String id,String name,String description) {
public MaisDocNode(Object userData, String id, String name, String description) {
this();
setUserData(userData);
setId(id);
setName(name);
if (description==null) {
if (description == null) {
description = name;
}
setDescription(description);
@ -71,7 +71,7 @@ public class MaisDocNode {
@SuppressWarnings("unchecked")
public <T> T toUserData(Class<T> type) {
return (T)getUserData();
return (T) getUserData();
}
/**

View file

@ -29,10 +29,12 @@ package org.x4o.maisdoc.model;
* @version 1.0 May 12, 2013
*/
public enum MaisDocNodeBody {
//@formatter:off
TREE_PATH,
DESCRIPTION_LINKS,
DESCRIPTION_NODE,
SUMMARY,
DETAIL
DETAIL,
;
//@formatter:on
}

View file

@ -38,7 +38,7 @@ public class MaisDocNodeData {
private String prefixPath;
private String navSelected = null;
private List<String> groupTypeKeys = null;
private Map<String,List<MaisDocNavLink>> groupTypeLinks = null;
private Map<String, List<MaisDocNavLink>> groupTypeLinks = null;
private String prevLink = null;
private String nextLink = null;
private String framePath = null;;
@ -47,8 +47,8 @@ public class MaisDocNodeData {
public MaisDocNodeData() {
navLinks = new ArrayList<MaisDocNavLink>(12);
groupTypeKeys = new ArrayList<String>(navLinks.size()/3);
groupTypeLinks = new HashMap<String,List<MaisDocNavLink>>(groupTypeKeys.size());
groupTypeKeys = new ArrayList<String>(navLinks.size() / 3);
groupTypeLinks = new HashMap<String, List<MaisDocNavLink>>(groupTypeKeys.size());
indexItems = new ArrayList<MaisDocIndexItem>(500);
}
@ -68,9 +68,9 @@ public class MaisDocNodeData {
return groupTypeKeys;
}
public void addGroupTypeLink(String groupTypeKey,MaisDocNavLink link) {
public void addGroupTypeLink(String groupTypeKey, MaisDocNavLink link) {
List<MaisDocNavLink> result = groupTypeLinks.get(groupTypeKey);
if (result==null) {
if (result == null) {
result = new ArrayList<MaisDocNavLink>(10);
groupTypeLinks.put(groupTypeKey, result);
}
@ -79,15 +79,15 @@ public class MaisDocNodeData {
public List<MaisDocNavLink> getGroupTypeLinks(String groupTypeKey) {
List<MaisDocNavLink> result = groupTypeLinks.get(groupTypeKey);
if (result==null) {
if (result == null) {
result = new ArrayList<MaisDocNavLink>(0);
}
return result;
}
public MaisDocNavLink getGroupTypeLink(String groupTypeKey,String group) {
public MaisDocNavLink getGroupTypeLink(String groupTypeKey, String group) {
List<MaisDocNavLink> links = getGroupTypeLinks(groupTypeKey);
for (MaisDocNavLink link:links) {
for (MaisDocNavLink link : links) {
if (link.getId().equals(group)) {
return link;
}
@ -104,7 +104,7 @@ public class MaisDocNodeData {
}
public MaisDocNavLink getNavLinkById(String id) {
for (MaisDocNavLink link:navLinks) {
for (MaisDocNavLink link : navLinks) {
if (link.getId().equals(id)) {
return link;
}

View file

@ -34,5 +34,5 @@ public interface MaisDocNodeDataConfigurator {
List<Class<?>> getTargetClasses();
void configNodeData(MaisDoc doc,MaisDocNode node,MaisDocNodeData data);
void configNodeData(MaisDoc doc, MaisDocNode node, MaisDocNodeData data);
}

View file

@ -34,9 +34,13 @@ import java.util.List;
public interface MaisDocNodeWriter {
MaisDocNodeBody getNodeBody();
List<Class<?>> getTargetClasses();
List<Integer> getNodeBodyOrders();
String getContentGroup();
String getContentGroupType();
void writeNodeContent(MaisDocWriteEvent<MaisDocNode> e) throws IOException;

View file

@ -42,12 +42,12 @@ public class MaisDocPage {
pageWriters = new ArrayList<MaisDocPageWriter>(30);
}
public MaisDocPage(String id,String name,String description,MaisDocPageWriter...writers) {
public MaisDocPage(String id, String name, String description, MaisDocPageWriter... writers) {
this();
setId(id);
setName(name);
setDescription(description);
for (MaisDocPageWriter writer:writers) {
for (MaisDocPageWriter writer : writers) {
addPageWriter(writer);
}
}

View file

@ -56,6 +56,7 @@ public class MaisDocRemoteClass {
/**
* Creates the ApiDocRemoteClass with a javadoc url to fetch the package-list from.
*
* @param docUrl The remote javadoc base url.
*/
public MaisDocRemoteClass(String docUrl) {
@ -65,35 +66,37 @@ public class MaisDocRemoteClass {
/**
* Creates the ApiDocRemoteClass with a javadoc url. but fetched the package-list from the packageListUrl.
*
* @param docUrl The remote javadoc base url.
* @param packageListUrl The remote/local package-list url.
*/
public MaisDocRemoteClass(String docUrl,String packageListUrl) {
public MaisDocRemoteClass(String docUrl, String packageListUrl) {
this(docUrl);
setPackageListUrl(packageListUrl);
}
/**
* Returns remote url for a class or null if no remote package excists for the class.
*
* @param cls The class to get the remote url for.
* @return The remote url of the class requested or null if none if found.
*/
public String getRemoteUrl(Class<?> cls) {
if (cls==null) {
if (cls == null) {
return null;
}
if (cls.isArray()) {
return null;
}
if (cls.getPackage()==null) {
if (cls.getPackage() == null) {
return null;
}
String packageName = cls.getPackage().getName();
logger.fine("Search "+packageName+" in "+packageList.size()+" of "+docUrl);
logger.fine("Search " + packageName + " in " + packageList.size() + " of " + docUrl);
if (packageList.contains(packageName)) {
String baseUrl = getDocUrlClean();
String packagePath = packageName.replaceAll("\\.", "/");
String fullUrl = baseUrl+packagePath+"/"+cls.getSimpleName()+".html";
String fullUrl = baseUrl + packagePath + "/" + cls.getSimpleName() + ".html";
return fullUrl;
}
return null;
@ -101,11 +104,12 @@ public class MaisDocRemoteClass {
/**
* Cleans the docUrl by sometimes appending postfix slash.
*
* @return The cleaned doc url.
*/
private String getDocUrlClean() {
String baseUrl = getDocUrl();
if (baseUrl.endsWith("/")==false) {
if (baseUrl.endsWith("/") == false) {
baseUrl += "/";
}
return baseUrl;
@ -113,6 +117,7 @@ public class MaisDocRemoteClass {
/**
* Fetches and parses the package-list file.
*
* @throws IOException If error happend.
*/
public void parseRemotePackageList() throws IOException {
@ -128,21 +133,22 @@ public class MaisDocRemoteClass {
/**
* Parsed the inputStream into the packagList values.
*
* @param in The inputStream.
* @param enc The encoding of the inputStream.
* @throws IOException When error on inputStream.
*/
private void parseRemoteFile(InputStream in,String enc) throws IOException {
if (enc==null) {
private void parseRemoteFile(InputStream in, String enc) throws IOException {
if (enc == null) {
enc = "UTF-8";
}
BufferedReader br = new BufferedReader(new InputStreamReader(in,Charset.forName(enc)));
BufferedReader br = new BufferedReader(new InputStreamReader(in, Charset.forName(enc)));
try {
String line = null;
while ((line = br.readLine()) != null) {
String lineClean = line.trim();
packageList.add(lineClean);
logger.finer("Adding remote package: '"+lineClean+"'");
logger.finer("Adding remote package: '" + lineClean + "'");
}
} finally {
br.close();

View file

@ -39,14 +39,15 @@ public class MaisDocWriteEvent<T> {
/**
* Creates an ApiDocNodeBodyEvent.
*
* @param doc The ApiDoc we are writing.
* @param writer The content writer to write to.
* @param eventObject The event we are firing this event for.
*/
public MaisDocWriteEvent(MaisDoc doc,MaisDocContentWriter writer,T eventObject) {
this.doc=doc;
this.writer=writer;
this.eventObject=eventObject;
public MaisDocWriteEvent(MaisDoc doc, MaisDocContentWriter writer, T eventObject) {
this.doc = doc;
this.writer = writer;
this.eventObject = eventObject;
}
/**

View file

@ -32,7 +32,6 @@ import org.x4o.xml.lang.task.X4OLanguageTaskException;
import org.x4o.xml.lang.task.run.X4OTaskProperty;
import org.x4o.xml.lang.task.run.X4OTaskRunner;
/**
* AbstractX4OLanguageTask is base ant x4o language task executor.
*
@ -57,6 +56,7 @@ public class X4OTask extends Task {
/**
* Adds the ant child x4oTaskProperty element.
*
* @param property
*/
public void addX4oTaskProperty(X4OTaskProperty property) {
@ -65,17 +65,18 @@ public class X4OTask extends Task {
/**
* Executes the x4o eld schema task.
*
* @see org.apache.tools.ant.Task#execute()
*/
@Override
public void execute() throws BuildException {
try {
if (isVerbose()) {
log("Task location: "+getLocation());
log("X4O language name: "+getLanguageName());
log("X4O language version: "+getLanguageVersion());
log("Verbose: "+isVerbose());
log("Fail on error: "+isFailonerror());
log("Task location: " + getLocation());
log("X4O language name: " + getLanguageName());
log("X4O language version: " + getLanguageVersion());
log("Verbose: " + isVerbose());
log("Fail on error: " + isFailonerror());
}
executeLanguageTask();
} catch (BuildException e) {
@ -88,36 +89,36 @@ public class X4OTask extends Task {
}
private void executeLanguageTask() throws BuildException {
if (getLanguageName()==null) {
if (getLanguageName() == null) {
throw new BuildException("languageName attribute is not set.");
}
if (getLanguageName().length()==0) {
if (getLanguageName().length() == 0) {
throw new BuildException("languageName attribute is empty.");
}
if (getLanguageVersion()!=null && getLanguageVersion().length()==0) {
if (getLanguageVersion() != null && getLanguageVersion().length() == 0) {
throw new BuildException("languageVersion attribute is empty.");
}
if (getTaskId()==null) {
if (getTaskId() == null) {
throw new BuildException("taskId attribute is not set.");
}
if (getTaskId().length()==0) {
if (getTaskId().length() == 0) {
throw new BuildException("taskId attribute is empty.");
}
if (isVerbose()) {
log("Starting "+getTaskId());
log("Starting " + getTaskId());
}
long startTime = System.currentTimeMillis();
try {
X4OTaskRunner.runTask(getLanguageName(),getLanguageVersion(), getTaskId(), taskProperties);
X4OTaskRunner.runTask(getLanguageName(), getLanguageVersion(), getTaskId(), taskProperties);
} catch (X4OLanguageTaskException e) {
throw new BuildException(e);
}
long stopTime = System.currentTimeMillis();
String taskName = getLanguageName();
if (getLanguageVersion() != null) {
taskName += ":"+getLanguageVersion();
taskName += ":" + getLanguageVersion();
}
log("Done " + getTaskId() + " for " + taskName + " in " + (stopTime-startTime) + " ms.");
log("Done " + getTaskId() + " for " + taskName + " in " + (stopTime - startTime) + " ms.");
}
/**

View file

@ -43,25 +43,25 @@ public class X4OWriteLanguageDocTaskTest extends BuildFileTest {
executeTarget("test-elddoc-cel");
File testDir = new File("target/test-elddoc/cel");
int files = testDir.listFiles().length;
assertEquals("Should created more then two files", true, files>2);
assertEquals("Should created more then two files", true, files > 2);
}
public void testEldDocEld() {
executeTarget("test-elddoc-eld");
File testDir = new File("target/test-elddoc/eld");
int files = testDir.listFiles().length;
assertEquals("Should created more then two files", true, files>2);
assertEquals("Should created more then two files", true, files > 2);
///assertEquals("Message was logged but should not.", getLog(), "");
//expectLog("use.message", "attribute-text");
//assertLogContaining("Nested Element 1");
/// assertEquals("Message was logged but should not.", getLog(), "");
// expectLog("use.message", "attribute-text");
// assertLogContaining("Nested Element 1");
}
public void testEldDocEldCustom() {
executeTarget("test-elddoc-eld-custom");
File testDir = new File("target/test-elddoc/eld-custom");
int files = testDir.listFiles().length;
assertEquals("Should created more then two files", true, files>2);
assertEquals("Should created more then two files", true, files > 2);
}
public void testEldDocEldVerbose() {
@ -72,15 +72,19 @@ public class X4OWriteLanguageDocTaskTest extends BuildFileTest {
public void testFailAllMissing() {
expectBuildException("test-fail-all", "Should get exception with no attributes.");
}
public void testFailBasePath() {
expectBuildException("test-fail-destdir", "Should get exception id destdir is not set.");
}
public void testFailBasePathError() {
expectBuildException("test-fail-destdir-error", "Should get exception id destdir does not exists.");
}
public void testFailLanguage() {
expectBuildException("test-fail-language", "Should get exception id language is not set.");
}
public void testFailLanguageError() {
expectBuildException("test-fail-language-error", "Should get exception id language throws error.");
}

View file

@ -51,9 +51,9 @@ public class X4OWriteLanguageSchemaTaskTest extends BuildFileTest {
int files = testDir.listFiles().length;
assertEquals("Should created only one file", 1, files);
///assertEquals("Message was logged but should not.", getLog(), "");
//expectLog("use.message", "attribute-text");
//assertLogContaining("Nested Element 1");
/// assertEquals("Message was logged but should not.", getLog(), "");
// expectLog("use.message", "attribute-text");
// assertLogContaining("Nested Element 1");
}
public void testCelSchemaVerbose() {
@ -64,15 +64,19 @@ public class X4OWriteLanguageSchemaTaskTest extends BuildFileTest {
public void testFailAllMissing() {
expectBuildException("test-fail-all", "Should get exception if no attributes are set.");
}
public void testFailBasePath() {
expectBuildException("test-fail-destdir", "Should get exception id destdir is not set.");
}
public void testFailBasePathError() {
expectBuildException("test-fail-destdir-error", "Should get exception id destdir does not exists.");
}
public void testFailLanguage() {
expectBuildException("test-fail-language", "Should get exception id language is not set.");
}
public void testFailLanguageError() {
expectBuildException("test-fail-language-error", "Should get exception id language throws error.");
}

View file

@ -40,56 +40,56 @@ import org.x4o.xml.lang.task.run.X4OTaskRunner;
* @author Willem Cazander
* @version 1.0 Apr 9, 2013
*/
@Mojo( name = X4OLanguageTaskMojo.GOAL,requiresProject=true,requiresDependencyResolution=ResolutionScope.COMPILE)
@Mojo(name = X4OLanguageTaskMojo.GOAL, requiresProject = true, requiresDependencyResolution = ResolutionScope.COMPILE)
public class X4OLanguageTaskMojo extends AbstractMojo {
static public final String GOAL = "x4o-language-task";
@Parameter(property="languageName")
@Parameter(property = "languageName")
private String languageName = null;
@Parameter(property="languageVersion")
@Parameter(property = "languageVersion")
private String languageVersion = null;
@Parameter(property="taskId")
@Parameter(property = "taskId")
private String taskId = null;
@Parameter(property="taskPropertyValues")
@Parameter(property = "taskPropertyValues")
private List<String> taskPropertyValues;
@Parameter(defaultValue="false",property="verbose")
@Parameter(defaultValue = "false", property = "verbose")
private boolean verbose = false;
@Parameter(defaultValue="true",property="failOnError")
@Parameter(defaultValue = "true", property = "failOnError")
private boolean failOnError = true;
private void executeLanguageTask() throws MojoExecutionException {
if (taskPropertyValues==null) {
if (taskPropertyValues == null) {
taskPropertyValues = new ArrayList<String>(10);
}
if (verbose) {
getLog().info("Verbose: "+verbose);
getLog().info("Fail on error: "+failOnError);
getLog().info("Verbose: " + verbose);
getLog().info("Fail on error: " + failOnError);
}
long startTime = System.currentTimeMillis();
if (verbose) {
getLog().info("Starting "+getTaskId()+" for "+getLanguageName()); //+":"+languageVersion
getLog().info("Starting " + getTaskId() + " for " + getLanguageName()); // +":"+languageVersion
}
List<X4OTaskProperty> taskProperties = new ArrayList<X4OTaskProperty>(20);
for (String taskPropertyLine:taskPropertyValues) {
for (String taskPropertyLine : taskPropertyValues) {
taskProperties.add(X4OTaskProperty.parseLine(taskPropertyLine));
}
try {
X4OTaskRunner.runTask(getLanguageName(),getLanguageVersion(), getTaskId(), taskProperties);
X4OTaskRunner.runTask(getLanguageName(), getLanguageVersion(), getTaskId(), taskProperties);
} catch (X4OLanguageTaskException e) {
throw new MojoExecutionException("Error while running task: "+getTaskId()+" error: "+e.getMessage(),e);
throw new MojoExecutionException("Error while running task: " + getTaskId() + " error: " + e.getMessage(), e);
}
long stopTime = System.currentTimeMillis();
String taskName = getLanguageName();
if (getLanguageVersion() != null) {
taskName += ":"+getLanguageVersion();
taskName += ":" + getLanguageVersion();
}
getLog().info("Done " + getTaskId() + " for " + taskName + " in " + (stopTime-startTime) + " ms.");
getLog().info("Done " + getTaskId() + " for " + taskName + " in " + (stopTime - startTime) + " ms.");
}
public void execute() throws MojoExecutionException {
@ -167,12 +167,14 @@ public class X4OLanguageTaskMojo extends AbstractMojo {
public void setLanguageVersion(String languageVersion) {
this.languageVersion = languageVersion;
}
/**
* @return the taskId
*/
public String getTaskId() {
return taskId;
}
/**
* @param taskId the taskId to set
*/

View file

@ -45,11 +45,11 @@ public class X4OLanguageTaskMojoTest extends AbstractMojoTestCase {
super.tearDown(); // required
}
private void executeGoal(String goal,String testFile) throws Exception {
private void executeGoal(String goal, String testFile) throws Exception {
File pom = getTestFile(testFile);
assertNotNull(pom);
assertTrue(pom.exists());
X4OLanguageTaskMojo mojo = (X4OLanguageTaskMojo) lookupMojo(goal,pom);
X4OLanguageTaskMojo mojo = (X4OLanguageTaskMojo) lookupMojo(goal, pom);
assertNotNull(mojo);
mojo.execute();
}
@ -58,63 +58,43 @@ public class X4OLanguageTaskMojoTest extends AbstractMojoTestCase {
File pom = getTestFile("src/test/resources/junit/test-plugin-defaults.pom");
assertNotNull(pom);
assertTrue(pom.exists());
Mojo mojo = lookupMojo("help",pom);
Mojo mojo = lookupMojo("help", pom);
assertNotNull(mojo);
mojo.execute();
}
public void testConfAllWriteDoc() throws Exception {
executeGoal(X4OLanguageTaskMojo.GOAL,"src/test/resources/junit/test-plugin-conf-all.pom");
executeGoal(X4OLanguageTaskMojo.GOAL, "src/test/resources/junit/test-plugin-conf-all.pom");
File outputDir = new File("target/jtest/test-plugin-conf-all/doc-eld-1.0");
if (!outputDir.exists()) {
return; // TODO: fix fails in maven test run ?
}
assertTrue(outputDir.exists());
int files = outputDir.listFiles().length;
assertEquals("Should created more then two files", true, files>2);
assertEquals("Should created more then two files", true, files > 2);
}
/*
public void testConfLangWriteDoc() throws Exception {
executeGoal(X4OLanguageTaskMojo.GOAL,"src/test/resources/junit/test-plugin-conf-lang.pom");
File outputDir = new File("target/jtest/test-plugin-conf-lang/cel");
int files = outputDir.listFiles().length;
assertEquals("Should created more then one files", true, files>1);
}
public void testConfDefaultsWriteDoc() throws Exception {
executeGoal(X4OLanguageTaskMojo.GOAL,"src/test/resources/junit/test-plugin-defaults.pom");
File outputDir = new File("target/x4o/doc-cel-1.0");
int files = outputDir.listFiles().length;
assertEquals("Should created more then two files", true, files>2);
outputDir = new File("target/x4o/doc-eld-1.0");
files = outputDir.listFiles().length;
assertEquals("Should created more then two files", true, files>2);
}
public void testConfAllWriteSchema() throws Exception {
executeGoal(X4OLanguageTaskMojo.GOAL,"src/test/resources/junit/test-plugin-conf-all.pom");
File outputDir = new File("target/jtest/test-plugin-conf-all/xsd-eld-1.0");
assertTrue(outputDir.exists());
int files = outputDir.listFiles().length;
assertEquals("Should created more then two files", true, files>2);
}
public void testConfLangWriteSchema() throws Exception {
executeGoal(X4OLanguageTaskMojo.GOAL,"src/test/resources/junit/test-plugin-conf-lang.pom");
File outputDir = new File("target/jtest/test-plugin-conf-lang/xsd-cel-1.0");
int files = outputDir.listFiles().length;
assertEquals("Should created more then one file", true, files>1);
}
public void testConfDefaultsWriteSchema() throws Exception {
executeGoal(X4OLanguageTaskMojo.GOAL,"src/test/resources/junit/test-plugin-defaults.pom");
File outputDir = new File("target/x4o/xsd-cel-1.0");
int files = outputDir.listFiles().length;
assertEquals("Should created more then one file", true, files>1);
outputDir = new File("target/x4o/xsd-eld-1.0");
files = outputDir.listFiles().length;
assertEquals("Should created more then two files", true, files>2);
}
* public void testConfLangWriteDoc() throws Exception { executeGoal(X4OLanguageTaskMojo.GOAL,"src/test/resources/junit/test-plugin-conf-lang.pom"); File
* outputDir = new File("target/jtest/test-plugin-conf-lang/cel"); int files = outputDir.listFiles().length;
* assertEquals("Should created more then one files", true, files>1); }
*
* public void testConfDefaultsWriteDoc() throws Exception { executeGoal(X4OLanguageTaskMojo.GOAL,"src/test/resources/junit/test-plugin-defaults.pom"); File
* outputDir = new File("target/x4o/doc-cel-1.0"); int files = outputDir.listFiles().length; assertEquals("Should created more then two files", true,
* files>2); outputDir = new File("target/x4o/doc-eld-1.0"); files = outputDir.listFiles().length; assertEquals("Should created more then two files", true,
* files>2); }
*
* public void testConfAllWriteSchema() throws Exception { executeGoal(X4OLanguageTaskMojo.GOAL,"src/test/resources/junit/test-plugin-conf-all.pom"); File
* outputDir = new File("target/jtest/test-plugin-conf-all/xsd-eld-1.0"); assertTrue(outputDir.exists()); int files = outputDir.listFiles().length;
* assertEquals("Should created more then two files", true, files>2); }
*
* public void testConfLangWriteSchema() throws Exception { executeGoal(X4OLanguageTaskMojo.GOAL,"src/test/resources/junit/test-plugin-conf-lang.pom"); File
* outputDir = new File("target/jtest/test-plugin-conf-lang/xsd-cel-1.0"); int files = outputDir.listFiles().length;
* assertEquals("Should created more then one file", true, files>1); }
*
* public void testConfDefaultsWriteSchema() throws Exception { executeGoal(X4OLanguageTaskMojo.GOAL,"src/test/resources/junit/test-plugin-defaults.pom");
* File outputDir = new File("target/x4o/xsd-cel-1.0"); int files = outputDir.listFiles().length; assertEquals("Should created more then one file", true,
* files>1); outputDir = new File("target/x4o/xsd-eld-1.0"); files = outputDir.listFiles().length; assertEquals("Should created more then two files", true,
* files>2); }
*/
}