Java Code Examples for org.jdom2.Namespace#getURI()

The following examples show how to use org.jdom2.Namespace#getURI() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CatalogBuilder.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected ThreddsMetadata.MetadataOther readMetadata(Map<String, Object> flds, DatasetBuilder dataset,
    Element mdataElement) {
  // there are 6 cases to deal with: threddsNamespace vs not & inline vs Xlink & (if thredds) inherited or not
  Namespace namespace;
  List inlineElements = mdataElement.getChildren();
  if (!inlineElements.isEmpty()) {
    // look at the namespace of the children, if they exist
    namespace = ((Element) inlineElements.get(0)).getNamespace();
  } else {
    namespace = mdataElement.getNamespace(); // will be thredds
  }

  String mtype = mdataElement.getAttributeValue("metadataType");
  String href = mdataElement.getAttributeValue("href", Catalog.xlinkNS);
  String title = mdataElement.getAttributeValue("title", Catalog.xlinkNS);
  String inheritedS = mdataElement.getAttributeValue("inherited");
  boolean inherited = "true".equalsIgnoreCase(inheritedS);

  boolean isThreddsNamespace = ((mtype == null) || mtype.equalsIgnoreCase("THREDDS"))
      && namespace.getURI().equals(Catalog.CATALOG_NAMESPACE_10);

  // the case where its not ThreddsMetadata
  if (!isThreddsNamespace) {
    if (!inlineElements.isEmpty()) {
      // just hold onto the jdom elements as the "content"
      return new ThreddsMetadata.MetadataOther(mtype, namespace.getURI(), namespace.getPrefix(), inherited,
          mdataElement);

    } else {
      // otherwise it must be an Xlink
      return new ThreddsMetadata.MetadataOther(href, title, mtype, namespace.getURI(), namespace.getPrefix(),
          inherited);
    }
  }

  // the case where its ThreddsMetadata
  Map<String, Object> useFlds;
  if (inherited) {
    // the case where its inherited ThreddsMetadata: gonna put stuff in the tmi.
    ThreddsMetadata tmi = (ThreddsMetadata) dataset.get(Dataset.ThreddsMetadataInheritable);
    if (tmi == null) {
      tmi = new ThreddsMetadata();
      dataset.put(Dataset.ThreddsMetadataInheritable, tmi);
    }
    useFlds = tmi.getFlds();

  } else {
    // the case where its non-inherited ThreddsMetadata: gonna put stuff directly into the dataset
    useFlds = flds;
  }
  readThreddsMetadataGroup(useFlds, dataset, mdataElement);

  // also need to capture any XLinks. see
  // http://www.unidata.ucar.edu/software/thredds/v4.6/tds/catalog/InvCatalogSpec.html#metadataElement
  // in this case we just suck it in as if it was inline
  if (href != null) {
    try {
      URI xlinkUri = Catalog.resolveUri(baseURI, href);
      Element remoteMdata = readMetadataFromUrl(xlinkUri);
      return readMetadata(useFlds, dataset, remoteMdata);
    } catch (Exception ioe) {
      errlog.format("Cant read in referenced metadata %s err=%s%n", href, ioe.getMessage());
      logger.debug("Can't read in referenced metadata {} err={}}", href, ioe.getMessage());
    }

  }
  return null; // ThreddsMetadata.MetadataOther was directly added
}
 
Example 2
Source File: ProxyNamespaceIO.java    From n2o-framework with Apache License 2.0 4 votes vote down vote up
@Override
public Element persist(T entity, Namespace namespace) {
    Element element = new Element(getElementName(), entity.getNamespaceUri() != null ? entity.getNamespaceUri() : namespace.getURI());
    io.io(element, entity, processor);
    return element;
}
 
Example 3
Source File: ProxyTypedElementIO.java    From n2o-framework with Apache License 2.0 4 votes vote down vote up
@Override
public Element persist(T entity, Namespace namespace) {
    Element element = new Element(getElementName(), namespace.getURI());
    io.io(element, entity, processor);
    return element;
}
 
Example 4
Source File: N2oNamespace.java    From n2o-framework with Apache License 2.0 4 votes vote down vote up
public N2oNamespace(Namespace namespace) {
    this.prefix = namespace.getPrefix();
    this.uri = namespace.getURI();
}