List of usage examples for org.jdom2 Element getName
public String getName()
From source file:com.ohnosequences.xml.model.uniprot.IsoformXML.java
License:Open Source License
public IsoformXML(Element elem) throws XMLElementException { super(elem);// w ww . j a v a2s. co m if (!elem.getName().equals(TAG_NAME)) { throw new XMLElementException(XMLElementException.WRONG_TAG_NAME, new XMLElement(elem)); } }
From source file:com.ohnosequences.xml.model.uniprot.KeywordXML.java
License:Open Source License
public KeywordXML(Element elem) throws XMLElementException { super(elem);/*w w w .ja va2 s. c om*/ if (!elem.getName().equals(TAG_NAME)) { throw new XMLElementException(XMLElementException.WRONG_TAG_NAME, new XMLElement(elem)); } }
From source file:com.ohnosequences.xml.model.uniprot.ProteinXML.java
License:Open Source License
public ProteinXML(Element elem) throws XMLElementException { super(elem);/*from ww w . j av a 2s. c o m*/ if (!elem.getName().equals(TAG_NAME)) { throw new XMLElementException(XMLElementException.WRONG_TAG_NAME, new XMLElement(elem)); } }
From source file:com.ohnosequences.xml.model.uniprot.SubcellularLocationXML.java
License:Open Source License
public SubcellularLocationXML(Element elem) throws XMLElementException { super(elem);/* w w w. j av a2s .c o m*/ if (!elem.getName().equals(TAG_NAME)) { throw new XMLElementException(XMLElementException.WRONG_TAG_NAME, new XMLElement(elem)); } }
From source file:com.ohnosequences.xml.model.util.Argument.java
License:Open Source License
public Argument(Element elem) throws XMLElementException { super(elem);// w ww . j ava 2 s . c o m if (!elem.getName().equals(TAG_NAME)) { throw new XMLElementException(XMLElementException.WRONG_TAG_NAME, new XMLElement(elem)); } }
From source file:com.ohnosequences.xml.model.util.Arguments.java
License:Open Source License
public Arguments(Element elem) throws XMLElementException { super(elem);//from w w w. j a v a 2 s .c o m if (!elem.getName().equals(TAG_NAME)) { throw new XMLElementException(XMLElementException.WRONG_TAG_NAME, new XMLElement(elem)); } }
From source file:com.ohnosequences.xml.model.util.Error.java
License:Open Source License
public Error(Element elem) throws XMLElementException { super(elem);//from w w w . j a v a 2s . c o m if (!elem.getName().equals(TAG_NAME)) { throw new XMLElementException(XMLElementException.WRONG_TAG_NAME, new XMLElement(elem)); } }
From source file:com.ohnosequences.xml.model.util.Execution.java
License:Open Source License
public Execution(Element elem) throws XMLElementException { super(elem);/* www .j av a 2s .c om*/ if (!elem.getName().equals(TAG_NAME)) { throw new XMLElementException(XMLElementException.WRONG_TAG_NAME, new XMLElement(elem)); } }
From source file:com.ohnosequences.xml.model.util.FlexXMLWrapperClassCreator.java
License:Open Source License
public static void main(String[] args) { if (args.length != 1) { System.out.println("El programa espera un parametro: \n" + "1. Nombre del archivo xml con la descripcion de la clase \n"); } else {//from ww w. j a v a 2 s .c o m File inFile = new File(args[0]); try { BufferedReader reader = new BufferedReader(new FileReader(inFile)); String line = null; StringBuilder stBuilder = new StringBuilder(); while ((line = reader.readLine()) != null) { stBuilder.append(line); } reader.close(); XMLElement classes = new XMLElement(stBuilder.toString()); List<Element> list = classes.getRoot().getChildren(XMLWrapperClass.TAG_NAME); for (Element elem : list) { XMLWrapperClass wrapper = new XMLWrapperClass(elem); //primero creo los directorios del package String[] packageSplit = wrapper.getPackage().split("\\."); String currentFolder = "./"; for (int i = 0; i < packageSplit.length; i++) { String string = packageSplit[i]; currentFolder += string; System.out.println("currentFolder = " + currentFolder); File tempFile = new File(currentFolder); if (!tempFile.exists()) { tempFile.mkdir(); System.out.println("no existe: tempFile = " + tempFile); } else { System.out.println("existe: tempFile = " + tempFile); } currentFolder += "/"; } BufferedWriter outBuff = new BufferedWriter( new FileWriter(new File(currentFolder + wrapper.getClassName() + ".as"))); outBuff.write("package " + wrapper.getPackage() + "\n{\n"); outBuff.write(NECESSARY_IMPORTS); outBuff.write("\n\npublic class " + wrapper.getClassName() + " extends XMLObject{\n\n"); outBuff.write("public static const TAG_NAME:String = \"" + wrapper.getTagName() + "\";\n\n"); HashMap<String, String> varsDeclarationNames = new HashMap<String, String>(); HashMap<String, String> varsTypes = new HashMap<String, String>(); List<Element> vars = wrapper.getVars().getChildren(); for (Element element : vars) { outBuff.write(VARS_PREFIX + " "); String varName = element.getText(); String varDeclarationName = ""; for (int i = 0; i < varName.length(); i++) { char c = varName.charAt(i); if (Character.isUpperCase(c)) { varDeclarationName += "_" + c; } else { varDeclarationName += ("" + c).toUpperCase(); } } varDeclarationName = varDeclarationName + "_TAG_NAME"; varsDeclarationNames.put(varName, varDeclarationName); varsTypes.put(varName, element.getName()); //En este ciclo cambio la mayuscula del nombre de la variable por '_' String tempTagName = ""; for (int i = 0; i < varName.length(); i++) { char c = varName.charAt(i); if (Character.isUpperCase(c)) { tempTagName += "_" + ("" + c).toLowerCase(); } else { tempTagName += "" + c; } } outBuff.write(varDeclarationName + ":String = \"" + tempTagName + "\";\n"); } //Ahora la parte de los constructores outBuff.write( "\n" + CONSTRUCTORS_STR.replaceAll(CLASS_NAME_CONSTRUCTOR_VAR, wrapper.getClassName())); Set<String> varsKeySet = varsDeclarationNames.keySet(); //A rellenar los getters! outBuff.write("\n" + GETTERS_STR); for (String key : varsKeySet) { String varType = varsTypes.get(key); String getStr = key; outBuff.write("\npublic function get " + getStr + "():" + varType + "{\treturn "); if (varType.equals("int")) { outBuff.write("parseInt(getTagText(" + varsDeclarationNames.get(key) + "));}"); } else if (varType.equals("Number")) { outBuff.write("new Number(getTagText(" + varsDeclarationNames.get(key) + "));}"); } else if (varType.equals("String")) { outBuff.write("getTagText(" + varsDeclarationNames.get(key) + ");}"); } else if (varType.equals("Boolean")) { outBuff.write("BooleanParser.parseBoolean(getTagText(" + varsDeclarationNames.get(key) + "));}"); } else { outBuff.write("getTagText(" + varsDeclarationNames.get(key) + ");}"); } } //A rellenar los setters! outBuff.write("\n" + SETTERS_STR); for (String key : varsKeySet) { String varType = varsTypes.get(key); String setStr = " set " + key; outBuff.write("\n[Bindable]\npublic function " + setStr + "(value:" + varType + "):void{\t setTagText(" + varsDeclarationNames.get(key) + ", "); if (varType.equals("String")) { outBuff.write("value"); } else { outBuff.write("String(value)"); } outBuff.write(");}"); } //Llave que cierra la clase outBuff.write("\n}\n"); //Llave que cierra el package outBuff.write("\n}\n"); outBuff.close(); } } catch (Exception e) { e.printStackTrace(); } } }
From source file:com.ohnosequences.xml.model.util.ScheduledExecutions.java
License:Open Source License
public ScheduledExecutions(Element elem) throws XMLElementException { super(elem);//from w w w . j av a 2 s .c o m if (!elem.getName().equals(TAG_NAME)) { throw new XMLElementException(XMLElementException.WRONG_TAG_NAME, new XMLElement(elem)); } }