javax.xml.bind.JAXB.unmarshal()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(235)

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

JAXB.unmarshal介绍

[英]Reads in a Java object tree from the given XML input.
[中]从给定的XML输入读取Java对象树。

代码示例

代码示例来源:origin: stackoverflow.com

javax.xml.bind.JAXB.unmarshal(stringFormOfOutput, Long.class)

代码示例来源:origin: stackoverflow.com

Exception in thread "main" java.lang.ExceptionInInitializerError
  at java.lang.Class.forName0(Native Method)
  at java.lang.Class.forName(Class.java:190)
  at com.intellij.rt.execution.application.AppMain.main(AppMain.java:87)
Caused by: javax.xml.bind.DataBindingException: javax.xml.bind.UnmarshalException
 - with linked exception:
[java.io.FileNotFoundException: C:\dev\src\misc\[29, 23, 19, 17, 13, 11, 7, 5, 3, 2] (The system cannot find the file specified)]
  at javax.xml.bind.JAXB.unmarshal(JAXB.java:208)
...

代码示例来源:origin: stackoverflow.com

void b(int b\u0029{
  Lon\u0067 c,d,f[]\u003d{}\u003b
  for(f\u003dj\u0061v\u0061.util.Arr\u0061ys.copy\u004ff(f,b\u0029,Arr\u0061ys.fill(f,0L\u0029\u003bb-->0\u003b\u0029
    for(d\u003d0L,c\u003d2L\u003bf[b]<1\u003bf[b]\u003dd<1?c:f[b],d\u003d0L,c\u002b\u002b\u0029
      for(lon\u0067 h:f\u0029
        d\u003dh>0&&c\u002fh*h\u003d\u003dc?1:d\u003b
  j\u0061v\u0061x.x\u006dl.bind.JAXB.un\u006d\u0061rsh\u0061l(""\u002bArr\u0061ys.\u0061sList(f\u0029, Lon\u0067.cl\u0061ss\u0029\u003b
}

代码示例来源:origin: stackoverflow.com

void b(int b){
  Long c,d,f[]={};
  for(f=java.util.Arrays.copyOf(f,b),Arrays.fill(f,0L);b-->0;)
    for(d=0L,c=2L;f[b]<1;f[b]=d<1?c:f[b],d=0L,c++)
      for(long h:f)
        d=h>0&&c/h*h==c?1:d;
  javax.xml.bind.JAXB.unmarshal(""+Arrays.asList(f),Long.class);
}

代码示例来源:origin: igniterealtime/Openfire

handleHTTPError(response);
final Groups groups = JAXB.unmarshal(response.getEntity().getContent(), Groups.class);
if (groups != null && groups.group != null) {
  for (final Group group : groups.group) {

代码示例来源:origin: igniterealtime/Openfire

handleHTTPError(response);
final Users users = JAXB.unmarshal(response.getEntity().getContent(), Users.class);
if (users != null && users.user != null) {
  for (final User user : users.user) {

代码示例来源:origin: igniterealtime/Openfire

handleHTTPError(response);
final Users users = JAXB.unmarshal(response.getEntity().getContent(), Users.class);

代码示例来源:origin: igniterealtime/Openfire

handleHTTPError(response);
final Groups groups = JAXB.unmarshal(response.getEntity().getContent(), Groups.class);

代码示例来源:origin: igniterealtime/Openfire

/**
 * Get the description of a group from crowd
 * @param groupName
 * @return a Group object
 * @throws RemoteException
 */
public Group getGroup(String groupName) throws RemoteException {
  LOG.debug("Get group:" + groupName + " from crowd");
  final HttpUriRequest getRequest = RequestBuilder.get(crowdServer.resolve("group?groupname=" + urlEncode(groupName)))
    .setConfig(requestConfig)
    .addHeader(HEADER_ACCEPT_APPLICATION_XML)
    .addHeader(HEADER_ACCEPT_CHARSET_UTF8)
    .build();
  Group group = null;
  try (final CloseableHttpResponse response = client.execute(getRequest, clientContext)) {
    if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
      handleHTTPError(response);
    }
    group = JAXB.unmarshal(response.getEntity().getContent(), Group.class);
    
  } catch (IOException ioe) {
    handleError(ioe);
  }
  return group;
}

代码示例来源:origin: org.apache.openejb/javaee-api

public static <T> T unmarshal(String str, Class<T> type) {
  if (str == null) {
    throw new IllegalStateException("No string destination is given");
  }
  try {
    return unmarshal(new URI(str), type);
  } catch (URISyntaxException e) {
    return unmarshal(new File(str), type);
  }
}

代码示例来源:origin: org.apache.openejb/javaee-api

public static <T> T unmarshal(File file, Class<T> type) {
  if (file == null) {
    throw new IllegalStateException("No file is given");
  }
  return unmarshal(new StreamSource(file), type);
}

代码示例来源:origin: org.apache.openejb/javaee-api

public static <T> T unmarshal(InputStream is, Class<T> type) {
  if (is == null) {
    throw new IllegalStateException("No input stream is given");
  }
  return unmarshal(new StreamSource(is), type);
}

代码示例来源:origin: org.apache.openejb/javaee-api

public static <T> T unmarshal(URL url, Class<T> type) {
  if (url == null) {
    throw new IllegalStateException("No url is given");
  }
  return unmarshal(new StreamSource(url.toExternalForm()), type);
}

代码示例来源:origin: OpenNMS/opennms

@Override
public List<? extends PackageDefinition> getPackages() {
  try (InputStream inputStream = getClass().getResourceAsStream("/package.xml")) {
    final org.opennms.netmgt.telemetry.config.model.PackageConfig pkg = JAXB.unmarshal(inputStream, org.opennms.netmgt.telemetry.config.model.PackageConfig.class);
    return Lists.newArrayList(pkg);
  } catch (IOException e) {
    throw new RuntimeException("Error while reading package.xml", e);
  }
}

代码示例来源:origin: org.apache.openejb/javaee-api

public static <T> T unmarshal(URI uri, Class<T> type) {
  if (uri == null) {
    throw new IllegalStateException("No uri is given");
  }
  try {
    return unmarshal(uri.toURL(), type);
  } catch (MalformedURLException e) {
    throw new DataBindingException(e);
  }
}

代码示例来源:origin: org.apache.servicemix.specs/org.apache.servicemix.specs.jaxb-api-2.1

public static <T> T unmarshal(URI uri, Class<T> type) {
  if (uri == null) {
    throw new IllegalStateException("No uri is given");
  }
  try {
    return unmarshal(uri.toURL(), type);
  } catch (MalformedURLException e) {
    throw new DataBindingException(e);
  }
}

代码示例来源:origin: OpenNMS/opennms

@Override
  public List<CredentialsScope> getCredentials() {
    if (Files.exists(configPath)) {
      final ElasticCredentials credentialsWrapper = JAXB.unmarshal(configPath.toFile(), ElasticCredentials.class);
      return credentialsWrapper.getCredentialsScopes();
    }
    return new ArrayList<>();
  }
}

代码示例来源:origin: vojtechhabarta/typescript-generator

private static List<Root> loadJavadocXmlFiles(List<File> javadocXmlFiles) {
  final List<Root> dRoots = new ArrayList<>();
  if (javadocXmlFiles != null) {
    for (File file : javadocXmlFiles) {
      TypeScriptGenerator.getLogger().info("Loading Javadoc XML file: " + file);
      final Root dRoot = JAXB.unmarshal(file, Root.class);
      dRoots.add(dRoot);
    }
  }
  return dRoots;
}

代码示例来源:origin: octo-online/reactive-audit

@Test(expected = FileReactiveAuditException.class)
public void unmarshal_InputStream()
{
  TestTools.strict.commit();
  JAXB.unmarshal(IOTestTools.getTempFileInputStream(), null);
}

代码示例来源:origin: octo-online/reactive-audit

@Test(expected = FileReactiveAuditException.class)
public void unmarshal_Reader()
{
  TestTools.strict.commit();
  JAXB.unmarshal(IOTestTools.getTempFileReader(), null);
}

相关文章