本文整理汇总了Java中javax.xml.bind.JAXBElement.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java JAXBElement.getValue方法的具体用法?Java JAXBElement.getValue怎么用?Java JAXBElement.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.bind.JAXBElement
的用法示例。
在下文中一共展示了JAXBElement.getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: puraText
import javax.xml.bind.JAXBElement; //导入方法依赖的package包/类
protected void puraText(POCDMT000040Section section, List<String> nayttomuoto) {
StrucDocText text = section.getText();
if ( text != null && text.getContent() != null && !text.getContent().isEmpty() ) {
List<Serializable> content = text.getContent();
for (int i = 0; i < content.size(); i++) {
if ( !(content.get(i) instanceof JAXBElement) ) {
continue;
}
JAXBElement<?> elem = (JAXBElement<?>) content.get(i);
if ( elem.getValue() instanceof StrucDocParagraph ) {
StrucDocParagraph paragraph = (StrucDocParagraph) elem.getValue();
puraDocParagraph(paragraph, nayttomuoto);
}
}
}
}
示例2: loadAuthorizersConfiguration
import javax.xml.bind.JAXBElement; //导入方法依赖的package包/类
private Authorizers loadAuthorizersConfiguration() throws Exception {
final File authorizersConfigurationFile = properties.getAuthorizersConfigurationFile();
// load the authorizers from the specified file
if (authorizersConfigurationFile.exists()) {
try {
// find the schema
final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
final Schema schema = schemaFactory.newSchema(Authorizers.class.getResource(AUTHORIZERS_XSD));
// attempt to unmarshal
final Unmarshaller unmarshaller = JAXB_CONTEXT.createUnmarshaller();
unmarshaller.setSchema(schema);
final JAXBElement<Authorizers> element = unmarshaller.unmarshal(XmlUtils.createSafeReader(new StreamSource(authorizersConfigurationFile)), Authorizers.class);
return element.getValue();
} catch (SAXException | JAXBException e) {
throw new Exception("Unable to load the authorizer configuration file at: " + authorizersConfigurationFile.getAbsolutePath(), e);
}
} else {
throw new Exception("Unable to find the authorizer configuration file at " + authorizersConfigurationFile.getAbsolutePath());
}
}
示例3: loadLoginIdentityProvidersConfiguration
import javax.xml.bind.JAXBElement; //导入方法依赖的package包/类
private IdentityProviders loadLoginIdentityProvidersConfiguration() throws Exception {
final File loginIdentityProvidersConfigurationFile = properties.getIdentityProviderConfigurationFile();
// load the users from the specified file
if (loginIdentityProvidersConfigurationFile.exists()) {
try {
// find the schema
final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
final Schema schema = schemaFactory.newSchema(IdentityProviders.class.getResource(LOGIN_IDENTITY_PROVIDERS_XSD));
// attempt to unmarshal
XMLStreamReader xsr = XmlUtils.createSafeReader(new StreamSource(loginIdentityProvidersConfigurationFile));
final Unmarshaller unmarshaller = JAXB_CONTEXT.createUnmarshaller();
unmarshaller.setSchema(schema);
final JAXBElement<IdentityProviders> element = unmarshaller.unmarshal(xsr, IdentityProviders.class);
return element.getValue();
} catch (SAXException | JAXBException e) {
throw new Exception("Unable to load the login identity provider configuration file at: " + loginIdentityProvidersConfigurationFile.getAbsolutePath());
}
} else {
throw new Exception("Unable to find the login identity provider configuration file at " + loginIdentityProvidersConfigurationFile.getAbsolutePath());
}
}
示例4: initialiseInventory
import javax.xml.bind.JAXBElement; //导入方法依赖的package包/类
private void initialiseInventory(EntityPlayerMP player, Inventory inventory)
{
// Clear inventory:
player.inventory.func_174925_a(null, -1, -1, null);
player.inventoryContainer.detectAndSendChanges();
if (!player.capabilities.isCreativeMode)
player.updateHeldItem();
// Now add specified items:
for (JAXBElement<? extends InventoryObjectType> el : inventory.getInventoryObject())
{
InventoryObjectType obj = el.getValue();
DrawItem di = new DrawItem();
di.setColour(obj.getColour());
di.setVariant(obj.getVariant());
di.setType(obj.getType());
ItemStack item = MinecraftTypeHelper.getItemStackFromDrawItem(di);
if( item != null )
{
item.stackSize = obj.getQuantity();
player.inventory.setInventorySlotContents(obj.getSlot(), item);
}
}
}
示例5: unmarshallAuthorizations
import javax.xml.bind.JAXBElement; //导入方法依赖的package包/类
private Authorizations unmarshallAuthorizations() throws JAXBException {
final Unmarshaller unmarshaller = JAXB_AUTHORIZATIONS_CONTEXT.createUnmarshaller();
unmarshaller.setSchema(authorizationsSchema);
final JAXBElement<Authorizations> element = unmarshaller.unmarshal(new StreamSource(authorizationsFile), Authorizations.class);
return element.getValue();
}
示例6: puraDocParagraph
import javax.xml.bind.JAXBElement; //导入方法依赖的package包/类
protected void puraDocParagraph(StrucDocParagraph paragraph, List<String> nayttomuoto) {
List<Serializable> content = paragraph.getContent();
for (int i = 0; i < content.size(); i++) {
if ( content.get(i) instanceof JAXBElement ) {
JAXBElement<?> elem = (JAXBElement<?>) content.get(i);
if ( elem.getValue() instanceof StrucDocContent ) {
StrucDocContent doc = (StrucDocContent) elem.getValue();
puraDocContent(doc, nayttomuoto);
}
}
}
}
示例7: loadMetroConfig
import javax.xml.bind.JAXBElement; //导入方法依赖的package包/类
private static MetroConfig loadMetroConfig(@NotNull URL resourceUrl) {
try (InputStream is = getConfigInputStream(resourceUrl)) {
JAXBContext jaxbContext = createJAXBContext();
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
XMLInputFactory factory = XmlUtil.newXMLInputFactory(true);
JAXBElement<MetroConfig> configElement = unmarshaller.unmarshal(factory.createXMLStreamReader(is), MetroConfig.class);
return configElement.getValue();
} catch (Exception e) {
String message = TubelineassemblyMessages.MASM_0010_ERROR_READING_CFG_FILE_FROM_LOCATION(
resourceUrl != null ? resourceUrl.toString() : null);
InternalError error = new InternalError(message);
LOGGER.logException(error, e, Level.SEVERE);
throw error;
}
}
示例8: getId
import javax.xml.bind.JAXBElement; //导入方法依赖的package包/类
public String getId(JAXBElement e, XMLSerializer target) {
// TODO: is this OK? Should we be returning the ID value of the type property?
/*
There's one case where we JAXBElement needs to be designated as ID,
and that is when there's a global element whose type is ID.
*/
Object o = e.getValue();
if(o instanceof String)
return (String)o;
else
return null;
}
示例9: parse_file
import javax.xml.bind.JAXBElement; //导入方法依赖的package包/类
/**
* Get parsed TraML object
*
* @param tramlFileName - file name
* @param logger - logger
* @throws Exception - exception during parsing
*/
public void parse_file(String tramlFileName, Logger logger) throws Exception {
JAXBContext ctx = JAXBContext.newInstance("ExternalPackages.org.hupo.psi.ms.traml");
Unmarshaller um = ctx.createUnmarshaller();
JAXBElement<TraMLType> jaxb_traml = (JAXBElement<TraMLType>) um.unmarshal(new File(tramlFileName));
this.traML = jaxb_traml.getValue();
}
示例10: P11Conf
import javax.xml.bind.JAXBElement; //导入方法依赖的package包/类
public P11Conf(InputStream confStream, PasswordResolver passwordResolver)
throws InvalidConfException, IOException {
ParamUtil.requireNonNull("confStream", confStream);
try {
JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
SchemaFactory schemaFact = SchemaFactory.newInstance(
javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = schemaFact.newSchema(getClass().getResource( "/xsd/pkcs11-conf.xsd"));
unmarshaller.setSchema(schema);
@SuppressWarnings("unchecked")
JAXBElement<PKCS11ConfType> rootElement = (JAXBElement<PKCS11ConfType>)
unmarshaller.unmarshal(confStream);
PKCS11ConfType pkcs11Conf = rootElement.getValue();
ModulesType modulesType = pkcs11Conf.getModules();
Map<String, P11ModuleConf> confs = new HashMap<>();
for (ModuleType moduleType : modulesType.getModule()) {
P11ModuleConf conf = new P11ModuleConf(moduleType, passwordResolver);
confs.put(conf.name(), conf);
}
if (!confs.containsKey(P11CryptServiceFactory.DEFAULT_P11MODULE_NAME)) {
throw new InvalidConfException("module '"
+ P11CryptServiceFactory.DEFAULT_P11MODULE_NAME + "' is not defined");
}
this.moduleConfs = Collections.unmodifiableMap(confs);
this.moduleNames = Collections.unmodifiableSet(new HashSet<>(confs.keySet()));
} catch (JAXBException | SAXException ex) {
final String exceptionMsg = (ex instanceof JAXBException)
? getMessage((JAXBException) ex) : ex.getMessage();
LogUtil.error(LOG, ex, exceptionMsg);
throw new InvalidConfException("invalid PKCS#11 configuration");
} finally {
confStream.close();
}
}
示例11: isParametersMatch
import javax.xml.bind.JAXBElement; //导入方法依赖的package包/类
private boolean isParametersMatch(OpParameter opParam, JAXBElement<? extends ConfigurationProperty> pNode, StringBuilder reason, int i) {
ConfigurationProperty prop = pNode.getValue();
String name = prop.getName();
if (!opParam.getName().equals(name)) {
reason.append("parameter " + i + " name not match, expected: " + name + " but actual: " + opParam.getName() + "; ");
return false;
}
return matchParameterType(opParam.getType(), prop, reason, i);
}
示例12: Draw
import javax.xml.bind.JAXBElement; //导入方法依赖的package包/类
/**
* Draws the specified drawing into the Minecraft world supplied.
* @param drawingNode The sequence of drawing primitives to draw.
* @param world The world in which to draw them.
* @throws Exception Unrecognised block types or primitives cause an exception to be thrown.
*/
public void Draw( DrawingDecorator drawingNode, World world ) throws Exception
{
beginDrawing(world);
for(JAXBElement<?> jaxbobj : drawingNode.getDrawObjectType())
{
Object obj = jaxbobj.getValue();
// isn't there an easier way of doing this?
if( obj instanceof DrawBlock )
DrawPrimitive( (DrawBlock)obj, world );
else if( obj instanceof DrawItem )
DrawPrimitive( (DrawItem)obj, world );
else if( obj instanceof DrawCuboid )
DrawPrimitive( (DrawCuboid)obj, world );
else if (obj instanceof DrawSphere )
DrawPrimitive( (DrawSphere)obj, world );
else if (obj instanceof DrawLine )
DrawPrimitive( (DrawLine)obj, world );
else if (obj instanceof DrawEntity)
DrawPrimitive( (DrawEntity)obj, world );
else
throw new Exception("Unsupported drawing primitive: "+obj.getClass().getName() );
}
endDrawing(world);
}
示例13: unmarshallTenants
import javax.xml.bind.JAXBElement; //导入方法依赖的package包/类
private Tenants unmarshallTenants() throws JAXBException {
final Unmarshaller unmarshaller = JAXB_TENANTS_CONTEXT.createUnmarshaller();
unmarshaller.setSchema(tenantsSchema);
final JAXBElement<Tenants> element = unmarshaller.unmarshal(new StreamSource(tenantsFile), Tenants.class);
return element.getValue();
}
示例14: generateDigest
import javax.xml.bind.JAXBElement; //导入方法依赖的package包/类
/**
* Generates a digest for a complete message or field (which ever is handed over as first parameter).
* During digest (SHA-256) generation, the parameter is converted to a JAXBElement and then EXI encoded
* using the respective EXI schema-informed grammar. If the digest for the signature is to be generated,
* the second parameter is to be set to true, for all other messages or fields the second parameter
* needs to be set to false.
*
* @param jaxbMessageOrField The message or field for which a digest is to be generated, given as a JAXB element
* @param digestForSignedInfoElement True if a digest for the SignedInfoElement of the header's signature is to be generated, false otherwise
* @return The SHA-256 digest for message or field
*/
@SuppressWarnings("rawtypes")
public static byte[] generateDigest(String id, JAXBElement jaxbMessageOrField) {
byte[] encoded;
// The schema-informed fragment grammar option needs to be used for EXI encodings in the header's signature
getExiCodec().setFragment(true);
/*
* When creating the signature value for the SignedInfoElement, we need to use the XMLdsig schema,
* whereas for creating the reference elements of the signature, we need to use the V2G_CI_MsgDef schema.
*/
if (jaxbMessageOrField.getValue() instanceof SignedInfoType) {
encoded = getExiCodec().encodeEXI(jaxbMessageOrField, GlobalValues.SCHEMA_PATH_XMLDSIG.toString());
} else encoded = getExiCodec().encodeEXI(jaxbMessageOrField, GlobalValues.SCHEMA_PATH_MSG_DEF.toString());
// Do not use the schema-informed fragment grammar option for other EXI encodings (message bodies)
getExiCodec().setFragment(false);
if (encoded == null) {
getLogger().error("Digest could not be generated because of EXI encoding problem");
return null;
}
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(encoded);
byte[] digest = md.digest();
if (showSignatureVerificationLog) {
/*
* Show Base64 encoding of digests only for reference elements, not for the SignedInfo element.
* The hashed SignedInfo element is input for ECDSA before the final signature value gets Base64 encoded.
*/
if ( !(jaxbMessageOrField.getValue() instanceof SignedInfoType) ) {
getLogger().debug("\n"
+ "\tDigest generated for XML reference element " + jaxbMessageOrField.getName().getLocalPart() + " with ID '" + id + "': " + ByteUtils.toHexString(digest) + "\n"
+ "\tBase64 encoding of digest: " + Base64.getEncoder().encodeToString(digest));
}
}
return digest;
} catch (NoSuchAlgorithmException e) {
getLogger().error("NoSuchAlgorithmException occurred while trying to create digest", e);
return null;
}
}
示例15: build
import javax.xml.bind.JAXBElement; //导入方法依赖的package包/类
/**
* Build a class hierarchy from the input previously given with one of <code>set</code>-methods.
* <p>Example usage:</p>
* <pre>
* RsBuilder rsBuilder = new RsBuilder(new ResourceSyncContext());
* Optional<RsRoot> maybeRoot = rsBuilder.setInputStream(inStream).build();
* </pre>
* <p>We can test what concrete class was unmarshalled by obtaining the QName:</p>
* <pre>
* Optional<QName> maybeQName = rsBuilder.getQName();
* </pre>
* <p>Or directly test one of two possibilities:</p>
* <pre>
* Optional<Sitemapindex> maybeSitemapindex = rsBuilder.getSitemapindex();
* Optional<Urlset> maybeUrlset = rsBuilder.getUrlset();
* </pre>
*
*
* @return Optional of RsRoot
* @throws JAXBException for invalid input
*/
@SuppressWarnings ("unchecked")
public Optional<RsRoot> build() throws JAXBException {
latestQName = null;
urlset = null;
sitemapindex = null;
JAXBElement<RsRoot> je = null;
RsRoot rsRoot = null;
Unmarshaller unmarshaller = rsContext.createUnmarshaller();
if (file != null) {
je = (JAXBElement<RsRoot>) unmarshaller.unmarshal(file);
file = null;
} else if (inputSource != null) {
je = (JAXBElement<RsRoot>) unmarshaller.unmarshal(inputSource);
inputSource = null;
} else if (inputStream != null) {
je = (JAXBElement<RsRoot>) unmarshaller.unmarshal(inputStream);
inputStream = null;
} else if (node != null) {
je = (JAXBElement<RsRoot>) unmarshaller.unmarshal(node);
node = null;
} else if (reader != null) {
je = (JAXBElement<RsRoot>) unmarshaller.unmarshal(reader);
reader = null;
} else if (source != null) {
je = (JAXBElement<RsRoot>) unmarshaller.unmarshal(source);
source = null;
} else if (url != null) {
je = (JAXBElement<RsRoot>) unmarshaller.unmarshal(url);
url = null;
} else if (xmlEventReader != null) {
je = (JAXBElement<RsRoot>) unmarshaller.unmarshal(xmlEventReader);
xmlEventReader = null;
} else if (xmlStreamReader != null) {
je = (JAXBElement<RsRoot>) unmarshaller.unmarshal(xmlStreamReader);
xmlStreamReader = null;
}
if (je != null) {
latestQName = je.getName();
rsRoot = je.getValue();
if (latestQName.equals(Urlset.QNAME)) {
urlset = (Urlset) rsRoot;
} else if (latestQName.equals(Sitemapindex.QNAME)) {
sitemapindex = (Sitemapindex) rsRoot;
}
}
return Optional.ofNullable(rsRoot);
}