gpt4 book ai didi

org.nuxeo.common.xmap.XMap.load()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 15:48:40 27 4
gpt4 key购买 nike

本文整理了Java中org.nuxeo.common.xmap.XMap.load()方法的一些代码示例,展示了XMap.load()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMap.load()方法的具体详情如下:
包路径:org.nuxeo.common.xmap.XMap
类名称:XMap
方法名:load

XMap.load介绍

[英]Processes the XML content from the given input stream using a default context.
[中]使用默认上下文处理给定输入流中的XML内容。

代码示例

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api

/**
 * Gets existing descriptor or creates a default one.
 */
protected BinaryManagerRootDescriptor getDescriptor(File configFile) throws IOException {
  BinaryManagerRootDescriptor desc;
  if (configFile.exists()) {
    XMap xmap = new XMap();
    xmap.register(BinaryManagerRootDescriptor.class);
    desc = (BinaryManagerRootDescriptor) xmap.load(new FileInputStream(configFile));
  } else {
    desc = new BinaryManagerRootDescriptor();
    // TODO fetch from repo descriptor
    desc.digest = getDefaultDigestAlgorithm();
    desc.depth = DEFAULT_DEPTH;
    desc.write(configFile); // may throw IOException
  }
  return desc;
}

代码示例来源:origin: org.nuxeo.common/nuxeo-common

/**
 * Processes the XML file at the given URL and using the given contexts.
 *
 * @param ctx the context to use
 * @param url the XML file url
 * @return the first registered top level object that is found in the file.
 */
public Object load(Context ctx, URL url) throws IOException {
  return load(ctx, url.openStream());
}

代码示例来源:origin: org.nuxeo.common/nuxeo-common

/**
 * Processes the XML file at the given URL using a default context.
 *
 * @param url the XML file url
 * @return the first registered top level object that is found in the file, or null if no objects are found.
 */
public Object load(URL url) throws IOException {
  return load(new Context(), url.openStream());
}

代码示例来源:origin: org.nuxeo.runtime/nuxeo-connect-standalone

@Override
public PackageDefinition loadPackage(InputStream in) throws PackageException {
  try {
    return (PackageDefinition) xmap.load(in);
  } catch (IOException e) {
    throw new PackageException("Failed to parse XML package definition", e);
  }
}

代码示例来源:origin: org.nuxeo.common/nuxeo-common

/**
 * Processes the XML content from the given input stream using a default context.
 *
 * @param in the XML input source
 * @return the first registered top level object that is found in the file.
 */
public Object load(InputStream in) throws IOException {
  return load(new Context(), in);
}

代码示例来源:origin: org.nuxeo.common/nuxeo-common

/**
 * Processes the given DOM element and return the first mappable object found in the element.
 * <p>
 * A default context is used.
 *
 * @param root the element to process
 * @return the first object found in this element or null if none
 */
public Object load(Element root) {
  return load(new Context(), root);
}

代码示例来源:origin: org.nuxeo.common/nuxeo-common

/**
 * Processes the XML content from the given input stream using the given context.
 *
 * @param ctx the context to use
 * @param in the input stream
 * @return the first registered top level object that is found in the file.
 */
public Object load(Context ctx, InputStream in) throws IOException {
  try {
    DocumentBuilderFactory factory = getFactory();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(in);
    return load(ctx, document.getDocumentElement());
  } catch (ParserConfigurationException | SAXException e) {
    throw new IOException(e);
  } finally {
    if (in != null) {
      try {
        in.close();
      } catch (IOException e) {
        // do nothing
      }
    }
  }
}

代码示例来源:origin: org.nuxeo.common/nuxeo-common

/**
 * Processes the given DOM element and return the first mappable object found in the element.
 * <p>
 * The given context is used.
 *
 * @param ctx the context to use
 * @param root the element to process
 * @return the first object found in this element or null if none
 */
public Object load(Context ctx, Element root) {
  // check if the current element is bound to an annotated object
  String name = root.getNodeName();
  XAnnotatedObject xob = roots.get(name);
  if (xob != null) {
    return xob.newInstance(ctx, root);
  } else {
    Node p = root.getFirstChild();
    while (p != null) {
      if (p.getNodeType() == Node.ELEMENT_NODE) {
        // Recurse in the first child Element
        return load((Element) p);
      }
      p = p.getNextSibling();
    }
    // We didn't find any Element
    return null;
  }
}

代码示例来源:origin: org.nuxeo.ecm.webengine/nuxeo-webengine-core

public static ModuleConfiguration readConfiguration(final WebEngine engine, File file) throws IOException {
  XMap xmap = new XMap();
  xmap.register(ModuleConfiguration.class);
  InputStream in = new BufferedInputStream(new FileInputStream(file));
  ModuleConfiguration mc = (ModuleConfiguration) xmap.load(createXMapContext(engine), in);
  return mc;
}

代码示例来源:origin: org.nuxeo.runtime/nuxeo-connect-standalone

public Form[] getForms(String path) throws PackageException {
  File file = data.getEntry(path);
  if (file.isFile()) {
    try (FileInputStream in = new FileInputStream(file)) {
      FormsDefinition forms = (FormsDefinition) StandaloneUpdateService.getXmap().load(in);
      return forms.getForms();
    } catch (IOException e) {
      throw new PackageException("Failed to load forms file: " + file);
    }
  }
  return null;
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-persistence

public static HibernateConfiguration load(URL location) {
  XMap map = new XMap();
  map.register(HibernateConfiguration.class);
  try {
    return (HibernateConfiguration) map.load(location);
  } catch (IOException e) {
    throw new PersistenceError("Cannot load hibernate configuration from " + location, e);
  }
}

代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-forms-layout-core

@XContent("selectOptions")
public void setSelectOptions(DocumentFragment selectOptionsDOM) {
  XMap xmap = new XMap();
  xmap.register(WidgetSelectOptionDescriptor.class);
  xmap.register(WidgetSelectOptionsDescriptor.class);
  Node p = selectOptionsDOM.getFirstChild();
  List<WidgetSelectOption> options = new ArrayList<WidgetSelectOption>();
  while (p != null) {
    if (p.getNodeType() == Node.ELEMENT_NODE) {
      Object desc = xmap.load((Element) p);
      if (desc instanceof WidgetSelectOptionDescriptor) {
        options.add(((WidgetSelectOptionDescriptor) desc).getWidgetSelectOption());
      } else if (desc instanceof WidgetSelectOptionsDescriptor) {
        options.add(((WidgetSelectOptionsDescriptor) desc).getWidgetSelectOption());
      } else {
        log.error("Unknown resolution of select option");
      }
    }
    p = p.getNextSibling();
  }
  selectOptions = options.toArray(new WidgetSelectOption[0]);
}

代码示例来源:origin: org.nuxeo.runtime/nuxeo-connect-standalone

/**
 * @since 5.8
 */
public LocalPackageImpl(ClassLoader parent, File file, PackageState state, PackageUpdateService pus)
    throws PackageException {
  this.state = state;
  service = pus;
  XMap xmap = StandaloneUpdateService.getXmap();
  if (xmap == null) { // for tests
    xmap = StandaloneUpdateService.createXmap();
  }
  try {
    data = new LocalPackageData(parent, file);
    InputStream in = new FileInputStream(data.getManifest());
    def = (PackageDefinitionImpl) xmap.load(in);
  } catch (FileNotFoundException e) {
    throw new PackageException("Invalid package - no package.xml file found in package " + file.getName());
  } catch (IOException e) {
    throw new PackageException("Failed to load package.xml descriptor for package " + file.getName(), e);
  }
  id = def.getId();
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com