本文整理汇总了Java中org.exolab.castor.xml.Unmarshaller.unmarshal方法的典型用法代码示例。如果您正苦于以下问题:Java Unmarshaller.unmarshal方法的具体用法?Java Unmarshaller.unmarshal怎么用?Java Unmarshaller.unmarshal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.exolab.castor.xml.Unmarshaller
的用法示例。
在下文中一共展示了Unmarshaller.unmarshal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStatisticDescriptors
import org.exolab.castor.xml.Unmarshaller; //导入方法依赖的package包/类
@Override
public List<StatisticDescriptor> getStatisticDescriptors(String filePath)
throws ParserException {
try {
Mapping mapping = new Mapping();
mapping.loadMapping(FileUtils.findFileAsResource("StatisticDescriptorMapping.xml"));
XMLContext context = new XMLContext();
context.addMapping(mapping);
InputSource source = new InputSource(FileUtils.findFileAsStream(filePath));
Unmarshaller unmarshaller = context.createUnmarshaller();
unmarshaller.setClass(StatisticList.class);
StatisticList list = (StatisticList)unmarshaller.unmarshal(source);
validate(list.getDescriptors());
return list.getDescriptors();
} catch (Exception e) {
ParserException parserException = new ParserException("Exception parsing statistic descriptor files", e);
Logger.getLogger(this.getClass()).error(parserException.getMessage(), parserException);
throw parserException;
}
}
示例2: readFromFile
import org.exolab.castor.xml.Unmarshaller; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static List<Synonym> readFromFile(String filename) throws Exception {
Mapping mapping = getMapping();
Unmarshaller unmarshaller = new Unmarshaller(ArrayList.class);
unmarshaller.setMapping(mapping);
File file = new File(filename);
if (file.exists() && !file.isFile()) {
throw new IOException("File " + file.getAbsolutePath() + " exists but is not a file.");
}
if (!file.exists() || file.length() == 0) {
return Collections.emptyList();
}
Reader reader = new FileReader(file);
return (List<Synonym>) unmarshaller.unmarshal(reader);
}
示例3: unserializeTxnRes
import org.exolab.castor.xml.Unmarshaller; //导入方法依赖的package包/类
@Override
public TxnRes unserializeTxnRes(String xml) throws IOException {
try {
Unmarshaller unmarshaller = new Unmarshaller(_mapping);
return (TxnRes) unmarshaller.unmarshal(new InputSource(new ByteArrayInputStream(xml.getBytes())));
} catch (Exception e) {
throw new IOException("Exception occured during XML unmarshalling.", e);
}
}
示例4: readFromFile
import org.exolab.castor.xml.Unmarshaller; //导入方法依赖的package包/类
public static Configuration readFromFile(String filename) throws Exception {
Mapping mapping = getMapping();
Unmarshaller unmarshaller = new Unmarshaller(mapping);
File file = new File(filename);
Reader reader = new FileReader(file);
Configuration configuration = (Configuration)unmarshaller.unmarshal(reader);
LOG.info("Configuration read from " + file.getAbsoluteFile());
return configuration;
}
示例5: unmarshal
import org.exolab.castor.xml.Unmarshaller; //导入方法依赖的package包/类
public static Varbind unmarshal(final Reader reader) throws MarshalException, ValidationException {
return (Varbind) Unmarshaller.unmarshal(Varbind.class, reader);
}
示例6: unmarshal
import org.exolab.castor.xml.Unmarshaller; //导入方法依赖的package包/类
public static Script unmarshal(final Reader reader) throws MarshalException, ValidationException {
return (Script) Unmarshaller.unmarshal(Script.class, reader);
}
示例7: unmarshal
import org.exolab.castor.xml.Unmarshaller; //导入方法依赖的package包/类
public static Security unmarshal(final Reader reader) throws MarshalException, ValidationException {
return (Security) Unmarshaller.unmarshal(Security.class, reader);
}
示例8: unmarshal
import org.exolab.castor.xml.Unmarshaller; //导入方法依赖的package包/类
public static Maskelement unmarshal(final Reader reader) throws MarshalException, ValidationException {
return (Maskelement) Unmarshaller.unmarshal(Maskelement.class, reader);
}
示例9: unmarshal
import org.exolab.castor.xml.Unmarshaller; //导入方法依赖的package包/类
public static Mask unmarshal(final Reader reader) throws MarshalException, ValidationException {
return (Mask) Unmarshaller.unmarshal(Mask.class, reader);
}
示例10: unmarshal
import org.exolab.castor.xml.Unmarshaller; //导入方法依赖的package包/类
public static Autoaction unmarshal(final Reader reader) throws MarshalException, ValidationException {
return (Autoaction) Unmarshaller.unmarshal(Autoaction.class, reader);
}
示例11: unmarshal
import org.exolab.castor.xml.Unmarshaller; //导入方法依赖的package包/类
public static Operaction unmarshal(final Reader reader) throws MarshalException, ValidationException {
return (Operaction) Unmarshaller.unmarshal(Operaction.class, reader);
}
示例12: unmarshal
import org.exolab.castor.xml.Unmarshaller; //导入方法依赖的package包/类
/**
* Method unmarshal.
*
* @param reader
* @throws org.exolab.castor.xml.MarshalException if object is
* null or if any SAXException is thrown during marshaling
* @throws org.exolab.castor.xml.ValidationException if this
* object is an invalid instance according to the schema
* @return the unmarshaled
* org.opennms.netmgt.config.collectd.jmx.Mbeans
*/
@Deprecated
public static Mbeans unmarshal(
final java.io.Reader reader)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
return (Mbeans) Unmarshaller.unmarshal(Mbeans.class, reader);
}
示例13: unmarshal
import org.exolab.castor.xml.Unmarshaller; //导入方法依赖的package包/类
/**
* Method unmarshal.
*
* @param reader
* @throws org.exolab.castor.xml.MarshalException if object is
* null or if any SAXException is thrown during marshaling
* @throws org.exolab.castor.xml.ValidationException if this
* object is an invalid instance according to the schema
* @return the unmarshaled
* org.opennms.netmgt.config.collectd.jmx.Attrib
*/
@Deprecated
public static Attrib unmarshal(
final java.io.Reader reader)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
return (Attrib) Unmarshaller.unmarshal(Attrib.class, reader);
}
示例14: unmarshal
import org.exolab.castor.xml.Unmarshaller; //导入方法依赖的package包/类
/**
* Method unmarshal.
*
* @param reader
* @throws org.exolab.castor.xml.MarshalException if object is
* null or if any SAXException is thrown during marshaling
* @throws org.exolab.castor.xml.ValidationException if this
* object is an invalid instance according to the schema
* @return the unmarshaled
* org.opennms.netmgt.config.collectd.jmx.CompAttrib
*/
@Deprecated
public static CompAttrib unmarshal(
final java.io.Reader reader)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
return (CompAttrib) Unmarshaller.unmarshal(CompAttrib.class, reader);
}
示例15: unmarshal
import org.exolab.castor.xml.Unmarshaller; //导入方法依赖的package包/类
/**
* Method unmarshal.
*
* @param reader
* @throws org.exolab.castor.xml.MarshalException if object is
* null or if any SAXException is thrown during marshaling
* @throws org.exolab.castor.xml.ValidationException if this
* object is an invalid instance according to the schema
* @return the unmarshaled
* org.opennms.netmgt.config.collectd.jmx.JmxDatacollectionConfig
*/
@Deprecated
public static JmxDatacollectionConfig unmarshal(
final java.io.Reader reader)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
return (JmxDatacollectionConfig) Unmarshaller.unmarshal(JmxDatacollectionConfig.class, reader);
}