List of usage examples for org.jdom2 Namespace getNamespace
public static Namespace getNamespace(final String uri)
Namespace
for the supplied URI, and make it usable as a default namespace, as no prefix is supplied. From source file:com.rometools.modules.itunes.io.ITunesParserOldNamespace.java
License:Open Source License
/** Creates a new instance of ITunesParserOldNamespace */ public ITunesParserOldNamespace() { super(); super.ns = Namespace.getNamespace(URI); }
From source file:com.rometools.modules.mediarss.io.RSS20YahooParser.java
License:Open Source License
/** * Returns the namespace used by RSS elements in document of the RSS 1.0 * <P>/* w ww . j a va2 s.c o m*/ * * @return returns "http://purl.org/rss/1.0/". */ @Override protected Namespace getRSSNamespace() { return Namespace.getNamespace(RSS_URI); }
From source file:com.rometools.modules.sle.io.ItemParser.java
License:Apache License
/** * Parses the XML node (JDOM element) extracting module information. * <p>/*from w w w . ja va2s.c om*/ * * @param element the XML node (JDOM element) to extract module information from. * @return a module instance, <b>null</b> if the element did not have module information. */ @Override public Module parse(final Element element, final Locale locale) { final SleEntryImpl sle = new SleEntryImpl(); ArrayList<EntryValue> values = new ArrayList<EntryValue>(); final List<Element> groups = element.getChildren("group", ModuleParser.TEMP); for (final Element group : groups) { final StringValue value = new StringValue(); value.setElement(group.getAttributeValue("element")); value.setLabel(group.getAttributeValue("label")); value.setValue(group.getAttributeValue("value")); if (group.getAttributeValue("ns") != null) { value.setNamespace(Namespace.getNamespace(group.getAttributeValue("ns"))); } else { value.setNamespace(element.getDocument().getRootElement().getNamespace()); } values.add(value); element.removeContent(group); } sle.setGroupValues(values.toArray(new EntryValue[values.size()])); values = values.size() == 0 ? values : new ArrayList<EntryValue>(); final List<Element> sorts = new ArrayList<Element>(element.getChildren("sort", ModuleParser.TEMP)); // LOG.debug("]]] sorts on element"+sorts.size()); for (final Element sort : sorts) { final String dataType = sort.getAttributeValue("data-type"); // LOG.debug("Doing datatype "+dataType +" :: "+sorts.size()); if (dataType == null || dataType.equals(Sort.TEXT_TYPE)) { final StringValue value = new StringValue(); value.setElement(sort.getAttributeValue("element")); value.setLabel(sort.getAttributeValue("label")); value.setValue(sort.getAttributeValue("value")); if (sort.getAttributeValue("ns") != null) { value.setNamespace(Namespace.getNamespace(sort.getAttributeValue("ns"))); } else { value.setNamespace(element.getDocument().getRootElement().getNamespace()); } values.add(value); element.removeContent(sort); } else if (dataType.equals(Sort.DATE_TYPE)) { final DateValue value = new DateValue(); value.setElement(sort.getAttributeValue("element")); value.setLabel(sort.getAttributeValue("label")); if (sort.getAttributeValue("ns") != null) { value.setNamespace(Namespace.getNamespace(sort.getAttributeValue("ns"))); } else { value.setNamespace(element.getDocument().getRootElement().getNamespace()); } Date dateValue = null; try { dateValue = DateParser.parseRFC822(sort.getAttributeValue("value"), locale); if (dateValue == null) { dateValue = DateParser.parseW3CDateTime(sort.getAttributeValue("value"), locale); } } catch (final Exception e) { ; // ignore parse exceptions } value.setValue(dateValue); values.add(value); element.removeContent(sort); } else if (dataType.equals(Sort.NUMBER_TYPE)) { final NumberValue value = new NumberValue(); value.setElement(sort.getAttributeValue("element")); value.setLabel(sort.getAttributeValue("label")); if (sort.getAttributeValue("ns") != null) { value.setNamespace(Namespace.getNamespace(sort.getAttributeValue("ns"))); } else { value.setNamespace(element.getDocument().getRootElement().getNamespace()); } try { value.setValue(new BigDecimal(sort.getAttributeValue("value"))); } catch (final NumberFormatException nfe) { ; // ignore values.add(value); element.removeContent(sort); } } else { throw new RuntimeException("Unknown datatype"); } } // LOG.debug("Values created "+values.size()+" from sorts" +sorts.size()); sle.setSortValues(values.toArray(new EntryValue[values.size()])); return sle; }
From source file:com.rometools.modules.sle.io.ModuleParser.java
License:Apache License
/** * Parses the XML node (JDOM element) extracting module information. * <p>/* w w w . jav a2s . c om*/ * * @param element the XML node (JDOM element) to extract module information from. * @return a module instance, <b>null</b> if the element did not have module information. */ @Override public Module parse(final Element element, final Locale locale) { if (element.getChild("treatAs", NS) == null) { return null; } final SimpleListExtension sle = new SimpleListExtensionImpl(); sle.setTreatAs(element.getChildText("treatAs", NS)); final Element listInfo = element.getChild("listinfo", NS); ArrayList<Object> values = new ArrayList<Object>(); for (final Element ge : listInfo.getChildren("group", NS)) { final Namespace ns = ge.getAttribute("ns") == null ? element.getNamespace() : Namespace.getNamespace(ge.getAttributeValue("ns")); final String elementName = ge.getAttributeValue("element"); final String label = ge.getAttributeValue("label"); values.add(new Group(ns, elementName, label)); } sle.setGroupFields(values.toArray(new Group[values.size()])); values = values.size() == 0 ? values : new ArrayList<Object>(); for (final Element se : listInfo.getChildren("sort", NS)) { LOG.debug("Parse cf:sort {}{}", se.getAttributeValue("element"), se.getAttributeValue("data-type")); final Namespace ns = se.getAttributeValue("ns") == null ? element.getNamespace() : Namespace.getNamespace(se.getAttributeValue("ns")); final String elementName = se.getAttributeValue("element"); final String label = se.getAttributeValue("label"); final String dataType = se.getAttributeValue("data-type"); final boolean defaultOrder = se.getAttributeValue("default") == null ? false : new Boolean(se.getAttributeValue("default")).booleanValue(); values.add(new Sort(ns, elementName, dataType, label, defaultOrder)); } sle.setSortFields(values.toArray(new Sort[values.size()])); insertValues(sle, element.getChildren()); return sle; }
From source file:com.rometools.propono.atom.common.rome.AppModuleParser.java
License:Apache License
/** Get namespace of module */ public Namespace getContentNamespace() { return Namespace.getNamespace(AppModule.URI); }
From source file:com.rometools.rome.io.impl.ModuleParsers.java
License:Open Source License
public List<Module> parseModules(final Element root, final Locale locale) { final List<ModuleParser> parsers = getPlugins(); List<Module> modules = null; for (final ModuleParser parser : parsers) { final String namespaceUri = parser.getNamespaceUri(); final Namespace namespace = Namespace.getNamespace(namespaceUri); if (hasElementsFrom(root, namespace)) { final Module module = parser.parse(root, locale); if (module != null) { modules = Lists.createWhenNull(modules); modules.add(module);/* w w w . jav a 2 s . co m*/ } } } return modules; }
From source file:com.rometools.rome.io.impl.RSS091UserlandParser.java
License:Open Source License
@Override protected Namespace getRSSNamespace() { return Namespace.getNamespace(""); }
From source file:com.rometools.rome.io.impl.RSS20wNSParser.java
License:Open Source License
@Override protected Namespace getRSSNamespace() { return Namespace.getNamespace(RSS20_URI); }
From source file:com.rometools.rome.io.impl.SyModuleParser.java
License:Open Source License
private Namespace getDCNamespace() { return Namespace.getNamespace(SyModule.URI); }
From source file:com.sun.syndication.io.impl.ModuleParsers.java
License:Open Source License
public List parseModules(Element root) { List parsers = getPlugins();/*from w w w .j a v a 2 s. c o m*/ List modules = null; for (int i = 0; i < parsers.size(); i++) { ModuleParser parser = (ModuleParser) parsers.get(i); String namespaceUri = parser.getNamespaceUri(); Namespace namespace = Namespace.getNamespace(namespaceUri); if (hasElementsFrom(root, namespace)) { Module module = parser.parse(root); if (module != null) { if (modules == null) { modules = new ArrayList(); } modules.add(module); } } } return modules; }