Last active
December 13, 2015 22:39
-
-
Save amlcurran/4986106 to your computer and use it in GitHub Desktop.
XmlFileParser example project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xml> | |
<list-item> | |
<label>Functional Groups</label> | |
<type>-2</type> | |
<extra>fcn</extra> | |
</list-item> | |
<list-item> | |
<label>Kinetics</label> | |
<type>-1</type> | |
<extra>chem_kinetics</extra> | |
</list-item> | |
<list-item> | |
<label>Thermodynamics</label> | |
<type>-1</type> | |
<extra>chem_tdynamics</extra> | |
</list-item> | |
<list-item> | |
<label>Electrochemistry & SCM</label> | |
<type>-1</type> | |
<extra>chem_electro</extra> | |
</list-item> | |
<list-item> | |
<label>Quantum Mechanics</label> | |
<type>-1</type> | |
<extra>chem_quantum</extra> | |
</list-item> | |
<list-item> | |
<label>Statistical Mechanics</label> | |
<type>-1</type> | |
<extra>chem_statmech</extra> | |
</list-item> | |
<list-item> | |
<label>Spectroscopy</label> | |
<type>-1</type> | |
<extra>chem_spectro</extra> | |
</list-item> | |
<list-item> | |
<label>Named Reactions</label> | |
<type>-2</type> | |
<extra>rxn</extra> | |
</list-item> | |
<list-item> | |
<label>Crystal Structures</label> | |
<type>-2</type> | |
<extra>cry</extra> | |
</list-item> | |
<list-item> | |
<label>Amino Acids</label> | |
<type>-2</type> | |
<extra>amn</extra> | |
</list-item> | |
</xml> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.espian.formulae.data; | |
/** | |
* Created with IntelliJ IDEA. | |
* User: alexcurran | |
* Date: 18/02/2013 | |
*/ | |
public class ListItem { | |
public String label; | |
public int type; | |
public String extra; | |
public ListItem() { } | |
public ListItem(String label, int type, String extra) { | |
this.label = label; | |
this.type = type; | |
this.extra = extra; | |
} | |
@Override | |
public String toString() { | |
return label; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.espian.formulae.data; | |
import com.espian.formulae.lib.XmlFileParser; | |
/** | |
* Created with IntelliJ IDEA. | |
* User: alexcurran | |
* Date: 19/02/2013 | |
*/ | |
public class XmlListItemParser extends XmlFileParser<ListItem> { | |
public XmlListItemParser() { | |
super(); | |
} | |
@Override | |
public ListItem createBlankClass() { | |
return new ListItem(); | |
} | |
@Override | |
public Object parseValue(String tag, String text) { | |
if (tag.equals(XmlListParser.TAG_TYPE)) | |
return Integer.valueOf(text); | |
else return super.parseValue(tag, text); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment