Java 类org.jdom.Attribute 实例源码

项目:parabuild-ci    文件:Atom03Generator.java   
protected Element generateGeneratorElement(Generator generator) {
    Element generatorElement = new Element("generator", getFeedNamespace());

    if (generator.getUrl() != null) {
        Attribute urlAttribute = new Attribute("url", generator.getUrl());
        generatorElement.setAttribute(urlAttribute);
    }

    if (generator.getVersion() != null) {
        Attribute versionAttribute = new Attribute("version", generator.getVersion());
        generatorElement.setAttribute(versionAttribute);
    }

    if (generator.getValue() != null) {
        generatorElement.addContent(generator.getValue());
    }

    return generatorElement;

}
项目:educational-plugin    文件:StudySerializationUtils.java   
public static Element getChildWithName(Element parent, String name, boolean optional) throws StudyUnrecognizedFormatException {
  for (Element child : parent.getChildren()) {
    Attribute attribute = child.getAttribute(NAME);
    if (attribute == null) {
      continue;
    }
    if (name.equals(attribute.getValue())) {
      return child;
    }
  }
  if (optional) {
    return null;
  }
  throw new StudyUnrecognizedFormatException();
}
项目:parabuild-ci    文件:Atom03Generator.java   
protected Element createRootElement(Feed feed) {
    Element root = new Element("feed",getFeedNamespace());
    root.addNamespaceDeclaration(getFeedNamespace());
    Attribute version = new Attribute("version", getVersion());
    root.setAttribute(version);
    generateModuleNamespaceDefs(root);
    return root;
}
项目:parabuild-ci    文件:Atom03Generator.java   
protected Element generateLinkElement(Link link) {
    Element linkElement = new Element("link", getFeedNamespace());

    if (link.getRel() != null) {
        Attribute relAttribute = new Attribute("rel", link.getRel().toString());
        linkElement.setAttribute(relAttribute);
    }

    if (link.getType() != null) {
        Attribute typeAttribute = new Attribute("type", link.getType());
        linkElement.setAttribute(typeAttribute);
    }

    if (link.getHref() != null) {
        Attribute hrefAttribute = new Attribute("href", link.getHref());
        linkElement.setAttribute(hrefAttribute);
    }
    return linkElement;
}
项目:parabuild-ci    文件:Atom10Parser.java   
/** Use xml:base attributes at feed and entry level to resolve relative links */
private String resolveURI(URL baseURI, Parent parent, String url) {
    url = (url.equals(".") || url.equals("./")) ? "" : url;
    if (isRelativeURI(url) && parent != null && parent instanceof Element) {
        Attribute baseAtt = ((Element)parent).getAttribute("base", Namespace.XML_NAMESPACE);
        String xmlBase = (baseAtt == null) ? "" : baseAtt.getValue();
        if (!isRelativeURI(xmlBase) && !xmlBase.endsWith("/")) {
            xmlBase = xmlBase.substring(0, xmlBase.lastIndexOf("/")+1);
        }
        return resolveURI(baseURI, parent.getParent(), xmlBase + url);
    } else if (isRelativeURI(url) && parent == null) {
        return baseURI + url;
    } else if (baseURI != null && url.startsWith("/")) {
        String hostURI = baseURI.getProtocol() + "://" + baseURI.getHost();
        if (baseURI.getPort() != baseURI.getDefaultPort()) {
            hostURI = hostURI + ":" + baseURI.getPort();
        }
        return hostURI + url;
    }
    return url;
}
项目:parabuild-ci    文件:DCModuleGenerator.java   
/**
 * Utility method to generate an element for a subject.
 * <p>
 * @param subject the subject to generate an element for.
 * @return the element for the subject.
 */
protected final Element generateSubjectElement(DCSubject subject) {
    Element subjectElement = new Element("subject", getDCNamespace());

    if (subject.getTaxonomyUri() != null) {
        Element descriptionElement = new Element("Description", getRDFNamespace());
        Element topicElement = new Element("topic", getTaxonomyNamespace());
        Attribute resourceAttribute = new Attribute("resource", subject.getTaxonomyUri(), getRDFNamespace());
        topicElement.setAttribute(resourceAttribute);
        descriptionElement.addContent(topicElement);

        if (subject.getValue() != null) {
            Element valueElement = new Element("value", getRDFNamespace());
            valueElement.addContent(subject.getValue());
            descriptionElement.addContent(valueElement);
        }
        subjectElement.addContent(descriptionElement);
    } else {
        subjectElement.addContent(subject.getValue());
    }
    return subjectElement;
}
项目:parabuild-ci    文件:RSS091UserlandParser.java   
public boolean isMyType(Document document) {
    boolean ok = false;
    Element rssRoot = document.getRootElement();
    ok = rssRoot.getName().equals("rss");
    if (ok) {
        ok = false;
        Attribute version = rssRoot.getAttribute("version");
        if (version!=null) {
            ok = version.getValue().equals(getRSSVersion());
        }
    }
    return ok;
}
项目:parabuild-ci    文件:Atom10Generator.java   
protected Element generateCategoryElement(Category cat) {
    Element catElement = new Element("category", getFeedNamespace());

    if (cat.getTerm() != null) {
        Attribute termAttribute = new Attribute("term", cat.getTerm());
        catElement.setAttribute(termAttribute);
    }

    if (cat.getLabel() != null) {
        Attribute labelAttribute = new Attribute("label", cat.getLabel());
        catElement.setAttribute(labelAttribute);
    }

    if (cat.getScheme() != null) {
        Attribute schemeAttribute = new Attribute("scheme", cat.getScheme());
        catElement.setAttribute(schemeAttribute);
    }
    return catElement;
}
项目:parabuild-ci    文件:Atom10Generator.java   
protected Element generateLinkElement(Link link) {
    Element linkElement = new Element("link", getFeedNamespace());

    if (link.getRel() != null) {
        Attribute relAttribute = new Attribute("rel", link.getRel().toString());
        linkElement.setAttribute(relAttribute);
    }

    if (link.getType() != null) {
        Attribute typeAttribute = new Attribute("type", link.getType());
        linkElement.setAttribute(typeAttribute);
    }

    if (link.getHref() != null) {
        Attribute hrefAttribute = new Attribute("href", link.getHref());
        linkElement.setAttribute(hrefAttribute);
    }

    if (link.getHreflang() != null) {
        Attribute hreflangAttribute = new Attribute("hreflang", link.getHreflang());
        linkElement.setAttribute(hreflangAttribute);
    }
    return linkElement;
}
项目:parabuild-ci    文件:Atom10Generator.java   
protected Element generateTagLineElement(Content tagline) {
    Element taglineElement = new Element("subtitle", getFeedNamespace());

    if (tagline.getType() != null) {
        Attribute typeAttribute = new Attribute("type", tagline.getType());
        taglineElement.setAttribute(typeAttribute);
    }

    if (tagline.getValue() != null) {
        taglineElement.addContent(tagline.getValue());
    }
    return taglineElement;
}
项目:parabuild-ci    文件:Atom10Generator.java   
protected Element generateGeneratorElement(Generator generator) {
    Element generatorElement = new Element("generator", getFeedNamespace());

    if (generator.getUrl() != null) {
        Attribute urlAttribute = new Attribute("uri", generator.getUrl());
        generatorElement.setAttribute(urlAttribute);
    }

    if (generator.getVersion() != null) {
        Attribute versionAttribute = new Attribute("version", generator.getVersion());
        generatorElement.setAttribute(versionAttribute);
    }

    if (generator.getValue() != null) {
        generatorElement.addContent(generator.getValue());
    }

    return generatorElement;

}
项目:parabuild-ci    文件:RSS094Generator.java   
protected void populateItem(Item item, Element eItem, int index) {
    super.populateItem(item,eItem, index);

    Description description = item.getDescription();
    if (description!=null && description.getType()!=null) {
        Element eDescription = eItem.getChild("description",getFeedNamespace());
        eDescription.setAttribute(new Attribute("type",description.getType()));
    }
    eItem.removeChild("expirationDate",getFeedNamespace());
}
项目:parabuild-ci    文件:RSS092Generator.java   
protected Element generateCloud(Cloud cloud) {
    Element eCloud = new Element("cloud",getFeedNamespace());

    if (cloud.getDomain() != null) {
        eCloud.setAttribute(new Attribute("domain", cloud.getDomain()));
    }

    if (cloud.getPort() != 0) {
        eCloud.setAttribute(new Attribute("port", String.valueOf(cloud.getPort())));
    }

    if (cloud.getPath() != null) {
        eCloud.setAttribute(new Attribute("path", cloud.getPath()));
    }

    if (cloud.getRegisterProcedure() != null) {
        eCloud.setAttribute(new Attribute("registerProcedure", cloud.getRegisterProcedure()));
    }

    if (cloud.getProtocol() != null) {
        eCloud.setAttribute(new Attribute("protocol", cloud.getProtocol()));
    }
    return eCloud;
}
项目:parabuild-ci    文件:RSS092Generator.java   
protected Element generateSourceElement(Source source) {
    Element sourceElement = new Element("source",getFeedNamespace());
    if (source.getUrl() != null) {
        sourceElement.setAttribute(new Attribute("url", source.getUrl()));
    }
    sourceElement.addContent(source.getValue());
    return sourceElement;
}
项目:parabuild-ci    文件:DCModuleParser.java   
/**
 * Utility method to parse a taxonomy from an element.
 * <p>
 * @param desc the taxonomy description element.
 * @return the string contained in the resource of the element.
 */
protected final String getTaxonomy(Element desc) {
    String d = null;
    Element taxo = desc.getChild("topic", getTaxonomyNamespace());
    if (taxo!=null) {
        Attribute a = taxo.getAttribute("resource", getRDFNamespace());
        if (a!=null) {
            d = a.getValue();
        }
    }
    return d;
}
项目:MultiHighlight    文件:NamedTextAttr.java   
public NamedTextAttr(@NotNull Element element) {
    super(element);
    final Attribute attribute = element.getAttribute(ATTR_NAME);
    if (attribute != null) {
        name = attribute.getValue();
    }
    if (name == null) {
        name = "";
    }
}
项目:LAS    文件:LASConfig.java   
/**
 * Get all of the attributes from the parent data set element.
 * @param varXPath the variable whose parent data set will be used
 * @return the attributes
 * @throws JDOMException
 */
public HashMap <String, String> getDatasetAttributes(String varXPath) throws JDOMException {
    HashMap<String, String> attrs = new HashMap<String, String>();
    if (!varXPath.contains("@ID")) {
        String[] parts = varXPath.split("/");
        // Throw away index 0 since the string has a leading "/".
        varXPath = "/"+parts[1]+"/"+parts[2]+"/dataset[@ID='"+parts[3]+"']/"+parts[4]+"/variable[@ID='"+parts[5]+"']";
    }

    Element variable = getElementByXPath(varXPath);
    Element dataset = variable.getParentElement().getParentElement();
    List attributes = dataset.getAttributes();
    for (Iterator iter = attributes.iterator(); iter.hasNext();) {
        Attribute attr = (Attribute) iter.next();
        String name = attr.getName();
        String value = attr.getValue();
        if ( name != null && value != null && !name.equals("") && !value.equals("") ) {
           attrs.put(name, value );
        }
    }
    return attrs;
}
项目:pathvisio    文件:GpmlFormat200X.java   
protected void mapBiopax(PathwayElement o, Element e) throws ConverterException
{
    //this method clones all content,
    //getContent will leave them attached to the parent, which we don't want
    //We can safely remove them, since the JDOM element isn't used anymore after this method
    Element root = new Element("RDF", GpmlFormat.RDF);
    root.addNamespaceDeclaration(GpmlFormat.RDFS);
    root.addNamespaceDeclaration(GpmlFormat.RDF);
    root.addNamespaceDeclaration(GpmlFormat.OWL);
    root.addNamespaceDeclaration(GpmlFormat.BIOPAX);
    root.setAttribute(new Attribute("base", getGpmlNamespace().getURI() + "#", Namespace.XML_NAMESPACE));
    //Element owl = new Element("Ontology", OWL);
    //owl.setAttribute(new Attribute("about", "", RDF));
    //Element imp = new Element("imports", OWL);
    //imp.setAttribute(new Attribute("resource", BIOPAX.getURI(), RDF));
    //owl.addContent(imp);
    //root.addContent(owl);

    root.addContent(e.cloneContent());
    Document bp = new Document(root);

    updateBiopaxNamespace(root);
    ((BiopaxElement)o).setBiopax(bp);
}
项目:pathvisio    文件:GpmlFormat2010a.java   
protected void mapBiopax(PathwayElement o, Element e) throws ConverterException
{
    //this method clones all content,
    //getContent will leave them attached to the parent, which we don't want
    //We can safely remove them, since the JDOM element isn't used anymore after this method
    Element root = new Element("RDF", GpmlFormat.RDF);
    root.addNamespaceDeclaration(GpmlFormat.RDFS);
    root.addNamespaceDeclaration(GpmlFormat.RDF);
    root.addNamespaceDeclaration(GpmlFormat.OWL);
    root.addNamespaceDeclaration(GpmlFormat.BIOPAX);
    root.setAttribute(new Attribute("base", getGpmlNamespace().getURI() + "#", Namespace.XML_NAMESPACE));
    //Element owl = new Element("Ontology", OWL);
    //owl.setAttribute(new Attribute("about", "", RDF));
    //Element imp = new Element("imports", OWL);
    //imp.setAttribute(new Attribute("resource", BIOPAX.getURI(), RDF));
    //owl.addContent(imp);
    //root.addContent(owl);

    root.addContent(e.cloneContent());
    Document bp = new Document(root);

    ((BiopaxElement)o).setBiopax(bp);
}
项目:intellij-ce-playground    文件:DebuggerUtilsEx.java   
private static boolean attributeListsEqual(List<Attribute> l1, List<Attribute> l2) {
  if(l1 == null) return l2 == null;
  if(l2 == null) return false;

  if(l1.size() != l2.size()) return false;

  Iterator<Attribute> i1 = l1.iterator();

  for (Attribute aL2 : l2) {
    Attribute attr1 = i1.next();

    if (!Comparing.equal(attr1.getName(), aL2.getName()) || !Comparing.equal(attr1.getValue(), aL2.getValue())) {
      return false;
    }
  }
  return true;
}
项目:intellij-ce-playground    文件:LwXmlReader.java   
public static ColorDescriptor getColorDescriptor(final Element element) throws Exception {
  Attribute attr = element.getAttribute(UIFormXmlConstants.ATTRIBUTE_COLOR);
  if (attr != null) {
    return new ColorDescriptor(new Color(attr.getIntValue()));
  }
  String swingColor = element.getAttributeValue(UIFormXmlConstants.ATTRIBUTE_SWING_COLOR);
  if (swingColor != null) {
    return ColorDescriptor.fromSwingColor(swingColor);
  }
  String systemColor = element.getAttributeValue(UIFormXmlConstants.ATTRIBUTE_SYSTEM_COLOR);
  if (systemColor != null) {
    return ColorDescriptor.fromSystemColor(systemColor);
  }
  String awtColor = element.getAttributeValue(UIFormXmlConstants.ATTRIBUTE_AWT_COLOR);
  if (awtColor != null) {
    return ColorDescriptor.fromAWTColor(awtColor);
  }
  return new ColorDescriptor(null);
}
项目:intellij-ce-playground    文件:StateSplitterEx.java   
protected static void mergeStateInto(@NotNull Element target, @NotNull Element subState, @NotNull String subStateName) {
  if (subState.getName().equals(subStateName)) {
    target.addContent(subState);
  }
  else {
    for (Iterator<Element> iterator = subState.getChildren().iterator(); iterator.hasNext(); ) {
      Element configuration = iterator.next();
      iterator.remove();
      target.addContent(configuration);
    }
    for (Iterator<Attribute> iterator = subState.getAttributes().iterator(); iterator.hasNext(); ) {
      Attribute attribute = iterator.next();
      iterator.remove();
      target.setAttribute(attribute);
    }
  }
}
项目:intellij-ce-playground    文件:ModuleJdkOrderEntryImpl.java   
ModuleJdkOrderEntryImpl(@NotNull Element element, @NotNull RootModelImpl rootModel, @NotNull ProjectRootManagerImpl projectRootManager) throws InvalidDataException {
  super(rootModel, projectRootManager);
  if (!element.getName().equals(OrderEntryFactory.ORDER_ENTRY_ELEMENT_NAME)) {
    throw new InvalidDataException();
  }
  final Attribute jdkNameAttribute = element.getAttribute(JDK_NAME_ATTR);
  if (jdkNameAttribute == null) {
    throw new InvalidDataException();
  }

  final String jdkName = jdkNameAttribute.getValue();
  final String jdkType = element.getAttributeValue(JDK_TYPE_ATTR);
  final Sdk jdkByName = findJdk(jdkName, jdkType);
  if (jdkByName == null) {
    init(null, jdkName, jdkType);
  }
  else {
    init(jdkByName, null, null);
  }
}
项目:intellij-ce-playground    文件:PathMacrosCollectorTest.java   
public void testWithFilter() throws Exception {
  Element root = new Element("root");
  final Element testTag = new Element("test");
  testTag.setAttribute("path", "$MACRO$");
  testTag.setAttribute("ignore", "$PATH$");
  root.addContent(testTag);

  final Set<String> macros = PathMacrosCollector.getMacroNames(root, null, new PathMacrosImpl());
  assertEquals(2, macros.size());
  assertTrue(macros.contains("MACRO"));
  assertTrue(macros.contains("PATH"));

  final Set<String> filtered = PathMacrosCollector.getMacroNames(root, new PathMacroFilter() {
                                                                   @Override
                                                                   public boolean skipPathMacros(Attribute attribute) {
                                                                     return "ignore".equals(attribute.getName());
                                                                   }
                                                                 }, new PathMacrosImpl());

  assertEquals(1, filtered.size());
  assertTrue(macros.contains("MACRO"));
}
项目:intellij-ce-playground    文件:UnknownRunConfiguration.java   
@Override
public void writeExternal(final Element element) throws WriteExternalException {
  if (myStoredElement != null) {
    final List attributeList = myStoredElement.getAttributes();
    for (Object anAttributeList : attributeList) {
      final Attribute a = (Attribute) anAttributeList;
      element.setAttribute(a.getName(), a.getValue());
    }

    final List list = myStoredElement.getChildren();
    for (Object child : list) {
      final Element c = (Element) child;
      element.addContent((Element) c.clone());
    }
  }
}
项目:intellij-ce-playground    文件:PersistentFileSetManager.java   
@Override
public void loadState(Element state) {
  final VirtualFileManager vfManager = VirtualFileManager.getInstance();
  for (Object child : state.getChildren(FILE_ELEMENT)) {
    if (child instanceof Element) {
      final Element fileElement = (Element)child;
      final Attribute filePathAttr = fileElement.getAttribute(PATH_ATTR);
      if (filePathAttr != null) {
        final String filePath = filePathAttr.getValue();
        VirtualFile vf = vfManager.findFileByUrl(filePath);
        if (vf != null) {
          myFiles.add(vf);
        }
      }
    }
  }
}
项目:intellij-ce-playground    文件:RunConfigurationPathMacroFilter.java   
@Override
public boolean skipPathMacros(Attribute attribute) {
  final Element parent = attribute.getParent();
  final String attrName = attribute.getName();
  String tagName = parent.getName();
  if (tagName.equals(EnvironmentVariablesComponent.ENV) &&
      (attrName.equals(EnvironmentVariablesComponent.NAME) || attrName.equals(EnvironmentVariablesComponent.VALUE))) {
    return true;
  }

  if (tagName.equals("configuration") && attrName.equals("name")) {
    return true;
  }

  return false;
}
项目:intellij-ce-playground    文件:XmlWriter.java   
public void writeElement(final Element element){
  startElement(element.getName());
  try {
    for (final Object o1 : element.getAttributes()) {
      final Attribute attribute = (Attribute)o1;
      addAttribute(attribute.getName(), attribute.getValue());
    }
    for (final Object o : element.getChildren()) {
      final Element child = (Element)o;
      writeElement(child);
    }
  }
  finally {
    endElement();
  }
}
项目:eurocarbdb    文件:CalcParameterXml.java   
/** 
 * Exports a parameter object to an XML string
 * 
 * @param t_objSetting
 * @return XML-string
 * @throws IOException
 */
public String exportParameter(CalculationParameter t_objSetting) throws IOException
{
    // Erzeugung eines XML-Dokuments
    Document t_objDocument = new Document();
    // Erzeugung des Root-XML-Elements 
    Element t_objRoot = new Element("glycopeakfinder_calculation");
    Namespace xsiNS = Namespace.getNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance");        
    t_objRoot.addNamespaceDeclaration(xsiNS);
    t_objRoot.setAttribute(new Attribute("noNamespaceSchemaLocation",this.m_strFile, xsiNS));
    // write Settings to element
    this.exportParameter(t_objRoot, t_objSetting);
    // Und jetzt haengen wir noch das Root-Element an das Dokument
    t_objDocument.setRootElement(t_objRoot);
    // Damit das XML-Dokument schoen formattiert wird holen wir uns ein Format
    Format t_objFormat = Format.getPrettyFormat();
    t_objFormat.setEncoding("iso-8859-1");
    // Erzeugung eines XMLOutputters dem wir gleich unser Format mitgeben
    XMLOutputter t_objExportXML = new XMLOutputter(t_objFormat);
    // Schreiben der XML-Datei in einen String
    StringWriter t_objWriter = new StringWriter();
    t_objExportXML.output(t_objDocument, t_objWriter );
    return t_objWriter.toString();
}
项目:RealmSpeak    文件:GameSetup.java   
public void setXML(Element element) {
        reset();
        Attribute nameAtt = element.getAttribute("name");
        if (nameAtt!=null) {
            setName((String)nameAtt.getValue());
        }

        // Read all commands
        Collection commands = element.getChildren();
        gameCommands.clear();
        for (Iterator i=commands.iterator();i.hasNext();) {
            Element command = (Element)i.next();
            GameCommand newCommand = GameCommand.createFromXML(this,command);
//          GameCommand newCommand = new GameCommand(this);
//          newCommand.setXML(command);
            gameCommands.add(newCommand);
        }

        setModified(true);
    }
项目:che    文件:JdomUtil.java   
private static int getHash(int hash, Element element) {
  hash = sumHash(hash, element.getName());

  for (Object object : element.getAttributes()) {
    Attribute attribute = (Attribute) object;
    hash = sumHash(hash, attribute.getName());
    hash = sumHash(hash, attribute.getValue());
  }

  for (Object o : element.getContent()) {
    if (o instanceof Element) {
      hash = getHash(hash, (Element) o);
    } else if (o instanceof Text) {
      String text = ((Text) o).getText();
      if (!isNullOrWhitespace(text)) {
        hash = sumHash(hash, text);
      }
    }
  }

  return hash;
}
项目:BART    文件:DAOEGTaskConfiguration.java   
private OutlierErrorConfiguration extractOutlierErrorConfiguration(Element outlierErrorsTag) {
    OutlierErrorConfiguration outlierErrorConfiguration = new OutlierErrorConfiguration();
    Element tablesElement = getMandatoryElement(outlierErrorsTag, "tables");
    List<Element> tables = getMandatoryElements(tablesElement, "table");
    for (Element table : tables) {
        Attribute tableName = getMandatoryAttribute(table, "name");
        Element attributesElement = getMandatoryElement(table, "attributes");
        List<Element> attributeElements = getMandatoryElements(attributesElement, "attribute");
        for (Element attribute : attributeElements) {
            Attribute percentageAttribute = getMandatoryAttribute(attribute, "percentage");
            Attribute detectableAttribute = getMandatoryAttribute(attribute, "detectable");
            String attributeName = attribute.getTextTrim();
            double percentage = Double.parseDouble(percentageAttribute.getValue().trim());
            boolean detectable = Boolean.parseBoolean(detectableAttribute.getValue().trim());
            outlierErrorConfiguration.addAttributes(tableName.getValue().trim(), attributeName, percentage, detectable);
        }
    }
    return outlierErrorConfiguration;
}
项目:totalboumboum    文件:PortraitsLoader.java   
/**
 * Process the element of the XML file describing the in-game portrait files.
 * 
 * @param root
 *      XML element.
 * @param folderPath
 *      Current path.
 * @param colormap
 *      Map of colors.
 * @param result
 *      Portrait object, to complete.
 * 
 * @throws IOException
 *      Problem while loading a file.
 * @throws ParserConfigurationException
 *      Problem while loading a file.
 * @throws SAXException
 *      Problem while loading a file.
 */
@SuppressWarnings("unchecked")
private static void loadIngameElement(Element root, String folderPath, ColorMap colormap, Portraits result) throws IOException, ParserConfigurationException, SAXException
{   // folder
    String folder = folderPath;
    Attribute attribute = root.getAttribute(XmlNames.FOLDER);
    if(attribute!=null)
    {   String f = attribute.getValue().trim();
        folder = folder + File.separator + f;           
    }
    // portraits
    List<Element> elements = root.getChildren(XmlNames.PORTRAIT);
    Iterator<Element> i = elements.iterator();
    while(i.hasNext())
    {   Element temp = i.next();
        String name = temp.getAttribute(XmlNames.NAME).getValue().trim().toUpperCase(Locale.ENGLISH);
        String file = temp.getAttribute(XmlNames.FILE).getValue().trim();
        String imagePath = folder + File.separator + file;
        BufferedImage image = ImageTools.loadImage(imagePath,colormap);
        image = ImageTools.getCompatibleImage(image);
        result.addIngamePortrait(name, image);
    }
}
项目:totalboumboum    文件:PortraitsLoader.java   
/**
 * Process the main element of the XML file describing off-game the portrait files.
 * 
 * @param root
 *      XML element.
 * @param folderPath
 *      Current path.
 * @param colormap
 *      Map of colors.
 * @param result
 *      Portrait object, to complete.
 * 
 * @throws IOException
 *      Problem while loading a file.
 * @throws ParserConfigurationException
 *      Problem while loading a file.
 * @throws SAXException
 *      Problem while loading a file.
 */
@SuppressWarnings("unchecked")
private static void loadOffgameElement(Element root, String folderPath, ColorMap colormap, Portraits result) throws IOException, ParserConfigurationException, SAXException
{   // folder
    String folder = folderPath;
    Attribute attribute = root.getAttribute(XmlNames.FOLDER);
    if(attribute!=null)
    {   String f = attribute.getValue().trim();
        folder = folder + File.separator + f;           
    }
    // portraits
    List<Element> elements = root.getChildren(XmlNames.PORTRAIT);
    Iterator<Element> i = elements.iterator();
    while(i.hasNext())
    {   Element temp = i.next();
        String name = temp.getAttribute(XmlNames.NAME).getValue().trim().toUpperCase(Locale.ENGLISH);
        String file = temp.getAttribute(XmlNames.FILE).getValue().trim();
        String imagePath = folder + File.separator + file;
        BufferedImage image = ImageTools.loadImage(imagePath,colormap);
        image = ImageTools.getCompatibleImage(image);
        result.addOffgamePortrait(name,image);
    }
}
项目:totalboumboum    文件:HollowAnimesLoader.java   
@SuppressWarnings("unchecked")
private static void loadImagesElement(Element root, HollowGesturePack pack) throws IOException
   {    // folder
    String localFilePath = "";
    Attribute attribute = root.getAttribute(XmlNames.FOLDER);
    if(attribute!=null)
        localFilePath = attribute.getValue()+File.separator;

    // images
    List<Element> imgs = root.getChildren(XmlNames.IMAGE);
    Iterator<Element> i = imgs.iterator();
    while(i.hasNext())
    {   Element tp = i.next();
        loadImageElement(tp,localFilePath,pack);
    }
   }
项目:totalboumboum    文件:HollowAnimesLoader.java   
private static void loadImageElement(Element root, String individualFolder, HollowGesturePack pack) throws IOException
  { // folder
    String localFilePath = individualFolder;
Attribute attribute = root.getAttribute(XmlNames.FOLDER);
if(attribute!=null)
    localFilePath = localFilePath+attribute.getValue()+File.separator;

// file
    String localPath = localFilePath + root.getAttribute(XmlNames.FILE).getValue().trim();

    // name
    String name = root.getAttribute(XmlNames.NAME).getValue().trim();

    // result
    pack.addCommonImageFileName(name,localPath);
  }
项目:totalboumboum    文件:HollowAnimesLoader.java   
@SuppressWarnings("unchecked")
private static void loadShadowsElement(Element root, HollowGesturePack pack) throws IOException
   {    // folder
    String localFilePath = "";
    Attribute attribute = root.getAttribute(XmlNames.FOLDER);
    if(attribute!=null)
        localFilePath = attribute.getValue()+File.separator;

    // shadows
    List<Element> shdws = root.getChildren(XmlNames.SHADOW);
    Iterator<Element> i = shdws.iterator();
    while(i.hasNext())
    {   Element tp = i.next();
        loadShadowElement(tp,localFilePath,pack);
    }
   }
项目:totalboumboum    文件:HollowAnimesLoader.java   
@SuppressWarnings("unchecked")
private static void loadGesturesElement(Element root, HollowGesturePack pack) throws IOException
   {    // folder
    String localFilePath = "";
    Attribute attribute = root.getAttribute(XmlNames.FOLDER);
    if(attribute!=null)
        localFilePath = localFilePath+attribute.getValue()+File.separator;

    // gestures
    List<Element> gesturesList = root.getChildren();
    Iterator<Element> i = gesturesList.iterator();
    while(i.hasNext())
    {   Element tp = i.next();
        loadGestureElement(tp,pack,localFilePath);
    }
   }
项目:totalboumboum    文件:FiresetMapLoader.java   
private static void loadFireElement(String folder, Element root, HollowFireset result, HashMap<String,HollowFireFactory> abstractFires, Type type) throws ParserConfigurationException, SAXException, IOException, ClassNotFoundException
  { // name
String name = root.getAttribute(XmlNames.NAME).getValue().trim();

// folder
    String individualFolder = folder;
Attribute attribute = root.getAttribute(XmlNames.FOLDER);
individualFolder = individualFolder+File.separator+attribute.getValue().trim();

// fire factory
boolean isAbstract = type==Type.ABSTRACT;
HollowFireFactory fireFactory = HollowFireFactoryLoader.loadFireFactory(individualFolder,abstractFires,isAbstract);
if(isAbstract)
    abstractFires.put(name,fireFactory);
else
    result.addFireFactory(name,fireFactory);
  }
项目:totalboumboum    文件:ItemsetPreviewLoader.java   
private static void loadItemElement(Element root, String folder, ItemsetPreview result, HashMap<String,SpritePreview> abstractItems, Type type) throws ParserConfigurationException, SAXException, IOException, ClassNotFoundException
  { // name
String name = root.getAttribute(XmlNames.NAME).getValue().trim();

// folder
    String individualFolder = folder;
Attribute attribute = root.getAttribute(XmlNames.FOLDER);
if(attribute!=null)
    individualFolder = individualFolder+File.separator+attribute.getValue().trim();

// preview
SpritePreview itemPreview = SpritePreviewLoader.loadSpritePreview(individualFolder,abstractItems);
if(type==Type.CONCRETE)
    result.putItemPreview(name,itemPreview);
else
    abstractItems.put(name,itemPreview);
  }