Java Code Examples for org.jdom.Element

The following are top voted examples for showing how to use org.jdom.Element. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: parabuild-ci   File: Atom10Parser.java   Source Code and License 8 votes vote down vote up
private Content parseContent(Element e) {
    String value = null;
    String src = e.getAttributeValue("src");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
    String type = e.getAttributeValue("type");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
    type = (type!=null) ? type : Content.TEXT;
    if (type.equals(Content.TEXT)) {
        // do nothing XML Parser took care of this
        value = e.getText();
    }
    else if (type.equals(Content.HTML)) {
        value = e.getText();
    }
    else if (type.equals(Content.XHTML)) {
        XMLOutputter outputter = new XMLOutputter();
        List eContent = e.getContent();
        Iterator i = eContent.iterator();
        while (i.hasNext()) {
            org.jdom.Content c = (org.jdom.Content) i.next();
            if (c instanceof Element) {
                Element eC = (Element) c;
                if (eC.getNamespace().equals(getAtomNamespace())) {
                    ((Element)c).setNamespace(Namespace.NO_NAMESPACE);
                }
            }
        }
        value = outputter.outputString(eContent);
    }
           
    Content content = new Content();
    content.setSrc(src);
    content.setType(type);
    content.setValue(value);
    return content;
}
 
Example 2
Project: parabuild-ci   File: RSS090Parser.java   Source Code and License 8 votes vote down vote up
/**
 * Parses an item element of an RSS document looking for item information.
 * <p/>
 * It reads title and link out of the 'item' element.
 * <p/>
 *
 * @param rssRoot the root element of the RSS document in case it's needed for context.
 * @param eItem the item element to parse.
 * @return the parsed RSSItem bean.
 */
protected Item parseItem(Element rssRoot,Element eItem) {
    Item item = new Item();
    Element e = eItem.getChild("title",getRSSNamespace());
    if (e!=null) {
        item.setTitle(e.getText());
    }
    e = eItem.getChild("link",getRSSNamespace());
    if (e!=null) {
        item.setLink(e.getText());
    }
    
    item.setModules(parseItemModules(eItem));

    return item;
}
 
Example 3
Project: parabuild-ci   File: Atom10Parser.java   Source Code and License 7 votes vote down vote up
private Person parsePerson(URL baseURI, Element ePerson) {
    Person person = new Person();
    Element e = ePerson.getChild("name",getAtomNamespace());
    if (e!=null) {
        person.setName(e.getText());
    }
    e = ePerson.getChild("uri",getAtomNamespace());
    if (e!=null) {
        person.setUri(resolveURI(baseURI, ePerson, e.getText()));
    }
    e = ePerson.getChild("email",getAtomNamespace());
    if (e!=null) {
        person.setEmail(e.getText());
    }
    return person;
}
 
Example 4
Project: parabuild-ci   File: Atom03Parser.java   Source Code and License 7 votes vote down vote up
private List parseLinks(List eLinks,boolean alternate) {
    List links = new ArrayList();
    for (int i=0;i<eLinks.size();i++) {
        Element eLink = (Element) eLinks.get(i);
        //Namespace ns = getAtomNamespace();
        String rel = eLink.getAttributeValue("rel");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
        if (alternate) {
            if ("alternate".equals(rel)) {
                links.add(parseLink(eLink));
            }
        }
        else {
            if (!("alternate".equals(rel))) {
                links.add(parseLink(eLink));
            }
        }
    }
    return (links.size()>0) ? links : null;
}
 
Example 5
Project: airsonic   File: LyricsService.java   Source Code and License 7 votes vote down vote up
private LyricsInfo parseSearchResult(String xml) throws Exception {
    SAXBuilder builder = new SAXBuilder();
    Document document = builder.build(new StringReader(xml));

    Element root = document.getRootElement();
    Namespace ns = root.getNamespace();

    String lyric = StringUtils.trimToNull(root.getChildText("Lyric", ns));
    String song =  root.getChildText("LyricSong", ns);
    String artist =  root.getChildText("LyricArtist", ns);

    return new LyricsInfo(lyric, artist, song);
}
 
Example 6
Project: airsonic   File: PodcastService.java   Source Code and License 7 votes vote down vote up
private String getITunesAttribute(Element element, String childName, String attributeName) {
    for (Namespace ns : ITUNES_NAMESPACES) {
        Element elem = element.getChild(childName, ns);
        if (elem != null) {
            return StringUtils.trimToNull(elem.getAttributeValue(attributeName));
        }
    }
    return null;
}
 
Example 7
Project: gate-core   File: Plugin.java   Source Code and License 7 votes vote down vote up
@Override
public Document getCreoleXML() throws Exception, JDOMException {
  Document doc = new Document();
  Element element;
  doc.addContent(element = new Element("CREOLE-DIRECTORY"));
  element.addContent(element = new Element("CREOLE"));
  element.addContent(element = new Element("RESOURCE"));
  Element classElement  = new Element("CLASS");
  classElement.setText(resourceClass.getName());
  element.addContent(classElement);
  
  return doc;
}
 
Example 8
Project: gate-core   File: CreoleAnnotationHandler.java   Source Code and License 7 votes vote down vote up
/**
 * Process the given RESOURCE element, adding extra elements to it based on
 * the annotations on the resource class.
 * 
 * @param element
 *          the RESOURCE element to process.
 */
private void processAnnotationsForResource(Element element)
    throws GateException {
  String className = element.getChildTextTrim("CLASS");
  if(className == null) { throw new GateException(
      "\"CLASS\" element not found for resource in " + plugin); }
  Class<?> resourceClass = null;
  try {
    resourceClass = Gate.getClassLoader().loadClass(className);
  } catch(ClassNotFoundException e) {
    log.debug("Couldn't load class " + className + " for resource in "
        + plugin, e);
    throw new GateException("Couldn't load class " + className
        + " for resource in " + plugin);
  }

  processCreoleResourceAnnotations(element, resourceClass);
}
 
Example 9
Project: gate-core   File: CreoleAnnotationHandler.java   Source Code and License 7 votes vote down vote up
/**
 * Given a single-argument method whose parameter is a {@link Collection}, use
 * the method's generic type information to determine the collection element
 * type and store it as the ITEM_CLASS_NAME attribute of the given Element.
 * 
 * @param method
 *          the setter method
 * @param paramElt
 *          the PARAMETER element
 */
private void determineCollectionElementType(AnnotatedElement method,
    Type paramType, Element paramElt) {
  if(paramElt.getAttributeValue("ITEM_CLASS_NAME") == null) {
    Class<?> elementType;
    CreoleParameter paramAnnot = method.getAnnotation(CreoleParameter.class);
    if(paramAnnot != null
        && paramAnnot.collectionElementType() != CreoleParameter.NoElementType.class) {
      elementType = paramAnnot.collectionElementType();
    } else {
      elementType = findCollectionElementType(paramType);
    }
    if(elementType != null) {
      paramElt.setAttribute("ITEM_CLASS_NAME", elementType.getName());
    }
  }
}
 
Example 10
Project: teamcity-msteams-notifier   File: MsTeamsNotificationMainSettings.java   Source Code and License 7 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void readFrom(Element rootElement)
/* Is passed an Element by TC, and is expected to persist it to the settings object.
 * Old settings should be overwritten.
 */
{
    if(msteamsNotificationMainConfig.getConfigFileExists()){
        // The MainConfigProcessor approach has been deprecated.
        // Instead we will use our own config file so we have better control over when it is persisted
        return;
    }
	Loggers.SERVER.info("MsTeamsNotificationMainSettings: re-reading main settings using old-style MainConfigProcessor. From now on we will use the msteams/msteams-config.xml file instead of main-config.xml");
	Loggers.SERVER.debug(NAME + ":readFrom :: " + rootElement.toString());
	MsTeamsNotificationMainConfig tempConfig = new MsTeamsNotificationMainConfig(serverPaths);
	Element msteamsNotificationsElement = rootElement.getChild("msteamsnotifications");
    tempConfig.readConfigurationFromXmlElement(msteamsNotificationsElement);
    this.msteamsNotificationMainConfig = tempConfig;
    tempConfig.save();
}
 
Example 11
Project: incubator-netbeans   File: NetbeansBuildActionJDOMWriter.java   Source Code and License 6 votes vote down vote up
/**
 * Method updateNetbeansActionMapping.
 * 
 * @param value
 * @param element
 * @param counter
 * @param xmlTag
 */
protected void updateNetbeansActionMapping(NetbeansActionMapping value, String xmlTag, Counter counter, Element element)
{
    Element root = element;
    Counter innerCount = new Counter(counter.getDepth() + 1);
    findAndReplaceSimpleElement(innerCount, root,  "actionName", value.getActionName(), null);
    findAndReplaceSimpleElement(innerCount, root,  "displayName", value.getDisplayName(), null);
    findAndReplaceSimpleElement(innerCount, root,  "basedir", value.getBasedir(), null);
    findAndReplaceSimpleElement(innerCount, root,  "reactor", value.getReactor(), null);
    findAndReplaceSimpleElement(innerCount, root,  "preAction", value.getPreAction(), null);
    findAndReplaceSimpleElement(innerCount, root,  "recursive", value.isRecursive() == true ? null : String.valueOf( value.isRecursive() ), "true");
    findAndReplaceSimpleLists(innerCount, root, value.getPackagings(), "packagings", "packaging");
    findAndReplaceSimpleLists(innerCount, root, value.getGoals(), "goals", "goal");
    findAndReplaceProperties(innerCount, root,  "properties", value.getProperties());
    findAndReplaceSimpleLists(innerCount, root, value.getActivatedProfiles(), "activatedProfiles", "activatedProfile");
}
 
Example 12
Project: educational-plugin   File: StudySerializationUtils.java   Source Code and License 6 votes vote down vote up
public static Element convertToThirdVersion(Element state, Project project) throws StudyUnrecognizedFormatException {
  Element taskManagerElement = state.getChild(MAIN_ELEMENT);
  XMLOutputter outputter = new XMLOutputter();

  Map<String, String> placeholderTextToStatus = fillStatusMap(taskManagerElement, STUDY_STATUS_MAP, outputter);
  Map<String, String> taskFileToStatusMap = fillStatusMap(taskManagerElement, TASK_STATUS_MAP, outputter);

  Element courseElement = getChildWithName(taskManagerElement, COURSE).getChild(COURSE_TITLED);
  for (Element lesson : getChildList(courseElement, LESSONS)) {
    int lessonIndex = getAsInt(lesson, INDEX);
    for (Element task : getChildList(lesson, TASK_LIST)) {
      String taskStatus = null;
      int taskIndex = getAsInt(task, INDEX);
      Map<String, Element> taskFiles = getChildMap(task, TASK_FILES);
      for (Map.Entry<String, Element> entry : taskFiles.entrySet()) {
        Element taskFileElement = entry.getValue();
        String taskFileText = outputter.outputString(taskFileElement);
        String taskFileStatus = taskFileToStatusMap.get(taskFileText);
        if (taskFileStatus != null && (taskStatus == null || taskFileStatus.equals(StudyStatus.Failed.toString()))) {
          taskStatus = taskFileStatus;
        }
        Document document = StudyUtils.getDocument(project.getBasePath(), lessonIndex, taskIndex, entry.getKey());
        if (document == null) {
          continue;
        }
        for (Element placeholder : getChildList(taskFileElement, ANSWER_PLACEHOLDERS)) {
          taskStatus = addStatus(outputter, placeholderTextToStatus, taskStatus, placeholder);
          addOffset(document, placeholder);
          addInitialState(document, placeholder);
        }
      }
      if (taskStatus != null) {
        addChildWithName(task, STATUS, taskStatus);
      }
    }
  }
  return state;
}
 
Example 13
Project: incubator-netbeans   File: ModuleConvertor.java   Source Code and License 6 votes vote down vote up
private void processModule(Element module, String path, Properties props) {
    if (!"module".equals(module.getName())) {
        return;
    }
    String moduleName = module.getAttributeValue("name");
    @SuppressWarnings("unchecked")
    List<Element> propElements = module.getChildren("property");
    Map<String, String> moduleProps = new HashMap<String, String>();
    for (Element prp : propElements) {
        String name = prp.getAttributeValue("name");
        String value = prp.getAttributeValue("value");
        assert name != null && value != null;
        moduleProps.put(name, value);
    }
    String modulePath = path + "/" + moduleName;
    checkRules(modulePath, moduleProps, props);
    //now check child modules..
    @SuppressWarnings("unchecked")
    List<Element> childs = module.getChildren("module");
    for (Element child : childs) {
        processModule(child, modulePath, props);
    }
}
 
Example 14
Project: quicknotes   File: NoteListRenderer.java   Source Code and License 6 votes vote down vote up
/**
 * @param list
 * @param value
 * @param index
 * @param isSelected
 * @param cellHasFocus
 * @return
 */
public Component getListCellRendererComponent( final JList list,
                                               final Object value,
                                               final int index,
                                               final boolean isSelected,
                                               boolean cellHasFocus ) {
    return new JPanel() {
        public void paintComponent( Graphics g ) {
            super.paintComponent( g );
            Element e = ( Element ) value;
            String title = e.getAttributeValue( "title" );
            String text = e.getText().trim();

            g.setColor( isSelected ? COLOR_SELECTED : index % 2 == 0 ? COLOR_EVEN : COLOR_ODD );
            g.fillRect( 0, 0, getWidth(), getHeight() );

            g.setColor( isSelected ? Color.WHITE : list.getForeground() );
            g.setFont( new Font( Font.SANS_SERIF, Font.BOLD, 12 ) );
            g.drawString( ( index + 1 ) + ". " + title, 5, 16 );
            g.setFont( new Font( Font.SANS_SERIF, Font.PLAIN, 12 ) );

            if ( text.indexOf( "\n" ) != -1 ) {
                text = text.substring( 0, text.indexOf( "\n" ) );
            }
            g.drawString( text, 20, 32 );
        }

        public Dimension getPreferredSize() {
            return new Dimension( 200, 40 );
        }
    };
}
 
Example 15
Project: parabuild-ci   File: Atom10Parser.java   Source Code and License 6 votes vote down vote up
private Link parseLink(Feed feed , Entry entry, URL baseURI, Element eLink) {
    Link link = new Link();
    String att = eLink.getAttributeValue("rel");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
    if (att!=null) {
        link.setRel(att);
    }
    att = eLink.getAttributeValue("type");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
    if (att!=null) {
        link.setType(att);
    }
    att = eLink.getAttributeValue("href");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
    if (att!=null) {
        if (isRelativeURI(att)) { //
            link.setHref(resolveURI(baseURI, eLink, ""));
        } else {
            link.setHref(att);
        }
    }
    att = eLink.getAttributeValue("hreflang");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
    if (att!=null) {
        link.setHreflang(att);
    }
    att = eLink.getAttributeValue("length");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
    if (att!=null) {
        link.setLength(Long.parseLong(att));
    }
    return link;
}
 
Example 16
Project: parabuild-ci   File: Atom10Generator.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 17
Project: apache-maven-shade-plugin   File: MavenJDOMWriter.java   Source Code and License 6 votes vote down vote up
/**
 * Method updatePlugin
 *
 * @param value
 * @param element
 * @param counter
 * @param xmlTag
 */
protected void updatePlugin( Plugin value, String xmlTag, Counter counter, Element element )
{
    Element root = element;
    Counter innerCount = new Counter( counter.getDepth() + 1 );
    findAndReplaceSimpleElement( innerCount, root, "groupId", value.getGroupId(), "org.apache.maven.plugins" );
    findAndReplaceSimpleElement( innerCount, root, "artifactId", value.getArtifactId(), null );
    findAndReplaceSimpleElement( innerCount, root, "version", value.getVersion(), null );
    findAndReplaceSimpleElement( innerCount, root, "extensions",
                                 !value.isExtensions() ? null : String.valueOf( value.isExtensions() ), "false" );
    iteratePluginExecution( innerCount, root, value.getExecutions(), "executions", "execution" );
    iterateDependency( innerCount, root, value.getDependencies(), "dependencies", "dependency" );
    findAndReplaceXpp3DOM( innerCount, root, "goals", (Xpp3Dom) value.getGoals() );
    findAndReplaceSimpleElement( innerCount, root, "inherited", value.getInherited(), null );
    findAndReplaceXpp3DOM( innerCount, root, "configuration", (Xpp3Dom) value.getConfiguration() );
}
 
Example 18
Project: processing-idea   File: ProcessingRunConfiguration.java   Source Code and License 6 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
    super.readExternal(element);

    String name = ProcessingRunSettings.class.getSimpleName();
    Element settingsElement = element.getChild(name);

    if (settingsElement == null) return;

    ProcessingRunSettings deserializedConfig = XmlSerializer.deserialize(settingsElement, ProcessingRunSettings.class);

    runSettings.setModule(deserializedConfig.getModule());
    runSettings.setSketchClass(deserializedConfig.getSketchClass());
    runSettings.setFullscreen(deserializedConfig.isFullscreen());
    runSettings.setHideStopButton(deserializedConfig.isHideStopButton());
    runSettings.setJvmArguments(deserializedConfig.getJvmArguments());
    runSettings.setSketchArguments(deserializedConfig.getSketchArguments());
    runSettings.setWindowBackgroundColor(deserializedConfig.getWindowBackgroundColor());
    runSettings.setStopButtonColor(deserializedConfig.getStopButtonColor());
    runSettings.setSketchOutputPath(deserializedConfig.getSketchOutputPath());
    runSettings.setLocation(deserializedConfig.getLocation());

    readModule(element);
}
 
Example 19
Project: apache-maven-shade-plugin   File: MavenJDOMWriter.java   Source Code and License 6 votes vote down vote up
/**
 * Method updateBuild
 *
 * @param value
 * @param element
 * @param counter
 * @param xmlTag
 */
//CHECKSTYLE_OFF: LineLength
protected void updateBuild( Build value, String xmlTag, Counter counter, Element element )
{
    boolean shouldExist = value != null;
    Element root = updateElement( counter, element, xmlTag, shouldExist );
    if ( shouldExist )
    {
        Counter innerCount = new Counter( counter.getDepth() + 1 );
        findAndReplaceSimpleElement( innerCount, root, "sourceDirectory", value.getSourceDirectory(), null );
        findAndReplaceSimpleElement( innerCount, root, "scriptSourceDirectory", value.getScriptSourceDirectory(),
                                     null );
        findAndReplaceSimpleElement( innerCount, root, "testSourceDirectory", value.getTestSourceDirectory(), null );
        findAndReplaceSimpleElement( innerCount, root, "outputDirectory", value.getOutputDirectory(), null );
        findAndReplaceSimpleElement( innerCount, root, "testOutputDirectory", value.getTestOutputDirectory(), null );
        iterateExtension( innerCount, root, value.getExtensions(), "extensions", "extension" );
        findAndReplaceSimpleElement( innerCount, root, "defaultGoal", value.getDefaultGoal(), null );
        iterateResource( innerCount, root, value.getResources(), "resources", "resource" );
        iterateResource( innerCount, root, value.getTestResources(), "testResources", "testResource" );
        findAndReplaceSimpleElement( innerCount, root, "directory", value.getDirectory(), null );
        findAndReplaceSimpleElement( innerCount, root, "finalName", value.getFinalName(), null );
        findAndReplaceSimpleLists( innerCount, root, value.getFilters(), "filters", "filter" );
        updatePluginManagement( value.getPluginManagement(), "pluginManagement", innerCount, root );
        iteratePlugin( innerCount, root, value.getPlugins(), "plugins", "plugin" );
    }
}
 
Example 20
Project: AppleScript-IDEA   File: AppleScriptSystemDictionaryRegistryService.java   Source Code and License 6 votes vote down vote up
private static void hashSimpleElementForObject(@NotNull Element suiteObjectElement, @NotNull String applicationName,
                                               Map<String, HashSet<String>> objectNameToApplicationNameListMap) {
  final String objectName = suiteObjectElement.getAttributeValue("name");
  final String code = suiteObjectElement.getAttributeValue("code");
  if (objectName == null || code == null) return;

  updateObjectNameSetForApplication(objectName, applicationName, objectNameToApplicationNameListMap);
}
 
Example 21
Project: idea-php-typo3-plugin   File: TYPO3CMSSettings.java   Source Code and License 6 votes vote down vote up
@Nullable
@Override
public Element getState() {
    final Element element = new Element(KEY.ROOT.toString());
    element.setAttribute(KEY.VERSION.toString(), version);

    return element;
}
 
Example 22
Project: MultiHighlight   File: NamedTextAttr.java   Source Code and License 6 votes vote down vote up
public NamedTextAttr(@NotNull Element element) {
    super(element);
    final Attribute attribute = element.getAttribute(ATTR_NAME);
    if (attribute != null) {
        name = attribute.getValue();
    }
    if (name == null) {
        name = "";
    }
}
 
Example 23
Project: parabuild-ci   File: SyModuleGenerator.java   Source Code and License 6 votes vote down vote up
public void generate(Module module, Element element) {

        SyModule syModule = (SyModule)module;

        Element updatePeriodElement = new Element("updatePeriod", SY_NS);
        updatePeriodElement.addContent(syModule.getUpdatePeriod().toString());
        element.addContent(updatePeriodElement);

        Element updateFrequencyElement = new Element("updateFrequency", SY_NS);
        updateFrequencyElement.addContent(String.valueOf(syModule.getUpdateFrequency()));
        element.addContent(updateFrequencyElement);

        Element updateBaseElement = new Element("updateBase", SY_NS);
        updateBaseElement.addContent(DateParser.formatW3CDateTime(syModule.getUpdateBase()));
        element.addContent(updateBaseElement);
    }
 
Example 24
Project: airsonic   File: PodcastService.java   Source Code and License 6 votes vote down vote up
private String getChannelImageUrl(Element channelElement) {
    String result = getITunesAttribute(channelElement, "image", "href");
    if (result == null) {
        Element imageElement = channelElement.getChild("image");
        if (imageElement != null) {
            result = imageElement.getChildTextTrim("url");
        }
    }
    return result;
}
 
Example 25
Project: gate-core   File: CreoleAnnotationHandler.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void findResourceElements(Map<String, Element> map, Element elt) {
  if(elt.getName().equals("RESOURCE")) {
    String className = elt.getChildTextTrim("CLASS");
    if(className != null) {
      map.put(className, elt);
    }
  } else {
    for(Element child : (List<Element>)elt.getChildren()) {
      findResourceElements(map, child);
    }
  }
}
 
Example 26
Project: apache-maven-shade-plugin   File: MavenJDOMWriter.java   Source Code and License 6 votes vote down vote up
/**
 * Method updateModelBase
 *
 * @param value
 * @param element
 * @param counter
 * @param xmlTag
 */
//CHECKSTYLE_OFF: LineLength
protected void updateModelBase( ModelBase value, String xmlTag, Counter counter, Element element )
{
    boolean shouldExist = value != null;
    Element root = updateElement( counter, element, xmlTag, shouldExist );
    if ( shouldExist )
    {
        Counter innerCount = new Counter( counter.getDepth() + 1 );
        findAndReplaceSimpleLists( innerCount, root, value.getModules(), "modules", "module" );
        iterateRepository( innerCount, root, value.getRepositories(), "repositories", "repository" );
        iterateRepository( innerCount, root, value.getPluginRepositories(), "pluginRepositories",
                           "pluginRepository" );
        iterateDependency( innerCount, root, value.getDependencies(), "dependencies", "dependency" );
        findAndReplaceXpp3DOM( innerCount, root, "reports", (Xpp3Dom) value.getReports() );
        updateReporting( value.getReporting(), "reporting", innerCount, root );
        updateDependencyManagement( value.getDependencyManagement(), "dependencyManagement", innerCount, root );
        updateDistributionManagement( value.getDistributionManagement(), "distributionManagement", innerCount, root );
        findAndReplaceProperties( innerCount, root, "properties", value.getProperties() );
    }
}
 
Example 27
Project: gate-core   File: CreoleAnnotationHandler.java   Source Code and License 6 votes vote down vote up
/**
 * Recursive method to process the {@link CreoleResource} elements that can be
 * inherited from superclasses and interfaces (everything except the PRIVATE
 * and MAIN_VIEWER flags, the NAME and the AUTOINSTANCEs). Once data has been
 * extracted from the current class the method calls itself recursively for
 * the superclass and any implemented interfaces. For any given attribute, the
 * first value specified wins (i.e. the one on the most specific class).
 * 
 * @param clazz
 *          the class to process
 * @param element
 *          the RESOURCE element to which data should be added.
 */
private void processInheritableResourceData(Class<?> clazz, Element element) {
  CreoleResource cr = clazz.getAnnotation(CreoleResource.class);
  if(cr != null) {
    addElement(element, cr.comment(), "COMMENT");
    addElement(element, cr.helpURL(), "HELPURL");
    addElement(element, cr.interfaceName(), "INTERFACE");
    addElement(element, cr.icon(), "ICON");
    if(cr.guiType() != GuiType.NONE && element.getChild("GUI") == null) {
      Element guiElement =
          new Element("GUI").setAttribute("TYPE", cr.guiType().toString());
      element.addContent(guiElement);
      addElement(guiElement, cr.resourceDisplayed(), "RESOURCE_DISPLAYED");
    }
    addElement(element, cr.annotationTypeDisplayed(),
        "ANNOTATION_TYPE_DISPLAYED");
  }

  Class<?> superclass = clazz.getSuperclass();
  if(superclass != null) {
    processInheritableResourceData(superclass, element);
  }

  for(Class<?> intf : clazz.getInterfaces()) {
    processInheritableResourceData(intf, element);
  }
}
 
Example 28
Project: MultiHighlight   File: MultiHighlightConfig.java   Source Code and License 6 votes vote down vote up
private void readColors(Element element) {
    if (namedTextAttrs == null) {
        namedTextAttrs = new ArrayList<>();
    }

    final Element colorListTag = element.getChild(COLOR_LIST_TAG);
    if (colorListTag != null) {
        for (Element colorTag : colorListTag.getChildren(COLOR_TAG)) {
            namedTextAttrs.add(new NamedTextAttr(colorTag));
        }
    }
}
 
Example 29
Project: parabuild-ci   File: RSS092Generator.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 30
Project: educational-plugin   File: StudySerializationUtils.java   Source Code and License 6 votes vote down vote up
public static String addStatus(XMLOutputter outputter,
                               Map<String, String> placeholderTextToStatus,
                               String taskStatus,
                               Element placeholder) {
  String placeholderText = outputter.outputString(placeholder);
  String status = placeholderTextToStatus.get(placeholderText);
  if (status != null) {
    addChildWithName(placeholder, STATUS, status);
    if (taskStatus == null || status.equals(StudyStatus.Failed.toString())) {
      taskStatus = status;
    }
  }
  return taskStatus;
}
 
Example 31
Project: gate-core   File: TestResourceReference.java   Source Code and License 6 votes vote down vote up
@Override
public Document getCreoleXML() throws Exception, JDOMException {
  Document doc = new Document();
  Element element = null;
  doc.addContent(element = new Element("CREOLE-DIRECTORY"));

  element.addContent(element = new Element("CREOLE"));
  element.addContent(element = new Element("RESOURCE"));
  Element classElement = new Element("CLASS");
  classElement.setText(TestResource.class.getName());
  element.addContent(classElement);
  return doc;
}
 
Example 32
Project: parabuild-ci   File: SampleModuleGenerator.java   Source Code and License 6 votes vote down vote up
public void generate(Module module, Element element) {

        SampleModule fm = (SampleModule)module;

        if (fm.getBar() != null) {
            element.addContent(generateSimpleElement("bar", fm.getBar()));
        }

        List foos = fm.getFoos();
        for (int i = 0; i < foos.size(); i++) {
            element.addContent(generateSimpleElement("foo",foos.get(i).toString()));
        }
        if (fm.getDate() != null) {
            element.addContent(
                generateSimpleElement("date", DateParser.formatW3CDateTime(fm.getDate())));
        }
    }
 
Example 33
Project: json2java4idea   File: PersistentJson2JavaSettingsTest.java   Source Code and License 6 votes vote down vote up
@Test
public void noStateLoadedShouldUseDefaultValue() throws Exception {
    // exercise
    underTest.noStateLoaded();

    // verify
    final Element actual = underTest.getState();
    assertThat(actual)
            .isNotNull()
            .hasName("component")
            .hasAttribute("style", "NONE")
            .hasAttribute("classNamePrefix", "")
            .hasAttribute("classNameSuffix", "")
            .hasAttribute("annotationGenerated", "true")
            .hasAttribute("annotationSuppressWarnings", "true");
}
 
Example 34
Project: processing-idea   File: ProcessingRunConfiguration.java   Source Code and License 5 votes vote down vote up
@Override
public void writeExternal(Element parentNode) throws WriteExternalException {
    super.writeExternal(parentNode);

    parentNode.addContent(XmlSerializer.serialize(runSettings));

    writeModule(parentNode);
}
 
Example 35
Project: educational-plugin   File: CCProjectService.java   Source Code and License 5 votes vote down vote up
@Override
public Element getState() {
  if (myCourse == null) {
    return null;
  }
  return XmlSerializer.serialize(this);
}
 
Example 36
Project: parabuild-ci   File: Atom03Parser.java   Source Code and License 5 votes vote down vote up
private List parseEntries(List eEntries) {
    List entries = new ArrayList();
    for (int i=0;i<eEntries.size();i++) {
        entries.add(parseEntry((Element)eEntries.get(i)));
    }
    return (entries.size()>0) ? entries : null;
}
 
Example 37
Project: apache-maven-shade-plugin   File: MavenJDOMWriter.java   Source Code and License 5 votes vote down vote up
/**
 * Method updateActivationProperty
 *
 * @param value
 * @param element
 * @param counter
 * @param xmlTag
 */
protected void updateActivationProperty( ActivationProperty value, String xmlTag, Counter counter, Element element )
{
    boolean shouldExist = value != null;
    Element root = updateElement( counter, element, xmlTag, shouldExist );
    if ( shouldExist )
    {
        Counter innerCount = new Counter( counter.getDepth() + 1 );
        findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null );
        findAndReplaceSimpleElement( innerCount, root, "value", value.getValue(), null );
    }
}
 
Example 38
Project: incubator-netbeans   File: MavenSettingsGrammar.java   Source Code and License 5 votes vote down vote up
@Override
    protected List<GrammarResult> getDynamicCompletion(String path, HintContext hintCtx, Element lowestParent) {
        if ("/settings/proxies".equals(path)) { //NOI18N
            // doesn't work!!!'
//            if ("proxy".startsWith(hintCtx.getCurrentPrefix())) {
//                ArrayList lst = new ArrayList();
//                lst.add(new MyElement("host"));
//                lst.add(new MyElement("port"));
//                GrammarResult rootRes = new ComplexElement("proxy2", "Insert Proxy", new NodeListImpl(lst));
//                return Collections.singletonList(rootRes);
//            }
        }
        return Collections.<GrammarResult>emptyList();
    }
 
Example 39
Project: apache-maven-shade-plugin   File: MavenJDOMWriter.java   Source Code and License 5 votes vote down vote up
/**
 * Method findAndReplaceXpp3DOM
 *
 * @param counter
 * @param dom
 * @param name
 * @param parent
 */
protected Element findAndReplaceXpp3DOM( Counter counter, Element parent, String name, Xpp3Dom dom )
{
    boolean shouldExist = dom != null && ( dom.getChildCount() > 0 || dom.getValue() != null );
    Element element = updateElement( counter, parent, name, shouldExist );
    if ( shouldExist )
    {
        replaceXpp3DOM( element, dom, new Counter( counter.getDepth() + 1 ) );
    }
    return element;
}
 
Example 40
Project: parabuild-ci   File: Atom10Parser.java   Source Code and License 5 votes vote down vote up
private List parsePersons(URL baseURI, List ePersons) {
    List persons = new ArrayList();
    for (int i=0;i<ePersons.size();i++) {
        persons.add(parsePerson(baseURI, (Element)ePersons.get(i)));
    }
    return (persons.size()>0) ? persons : null;
}