protected static CTEncryption parseDescriptor(String descriptor) { // try { // return EncryptionDocument.Factory.parse(descriptor); // } catch (XmlException e) { // throw new EncryptedDocumentException("Unable to parse encryption descriptor", e); // } log.error(descriptor); CTEncryption encryption = null; try { encryption = (CTEncryption)XmlUtils.unmarshalString(descriptor, Context.jcEncryption, CTEncryption.class); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } return encryption; }
private void reloadTgConfig(boolean configRenewed) { File tgFile = getTgFile(); if (!tgFile.exists() || tgFile.lastModified() != last_load_time_tg) { //for backward compatibility if (!tgFile.exists() && configRenewed) { telegrafInputConfigMap = telegrafInputConfigMapDeprecated; } else if (tgFile.canRead()) { try { telegrafOriginalConfig = (TgConfig) unmarshaller.unmarshal(tgFile); last_load_time_tg = tgFile.lastModified(); } catch (JAXBException e) { e.printStackTrace(); } applyTelegrafInputConfigNew(); } } }
ObjectFactory objFactory = new ObjectFactory(); MyRootElement root = objFactory.createMyRootElement(); ... // Set root properties ... if (!writeDocument(objFactory.createMyRootElement(root), output)) { System.err.println("Failed to marshal XML document"); } ... private boolean writeDocument(JAXBElement document, OutputStream output) { Class<?> clazz = document.getValue().getClass(); try { JAXBContext context = JAXBContext.newInstance(clazz.getPackage().getName()); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); m.marshal(document, output); return true; } catch (JAXBException e) { e.printStackTrace(System.err); return false; } }
} catch (JAXBException e1) { e1.printStackTrace();
} catch (JAXBException e1) { e1.printStackTrace();
public static String JAXBElementDebug(javax.xml.bind.JAXBElement o) { String prefix = null; if (o.getName().getNamespaceURI()!=null) { try { prefix = NamespacePrefixMapperUtils.getPreferredPrefix(o.getName().getNamespaceURI(), null, false); } catch (JAXBException e) { e.printStackTrace(); } } if (prefix!=null) { return prefix + ':' + o.getName().getLocalPart() + " is a javax.xml.bind.JAXBElement; it has declared type " + o.getDeclaredType().getName(); } else { return o.getName() + " is a javax.xml.bind.JAXBElement; it has declared type " + o.getDeclaredType().getName(); } }
public Style getDefaultCharacterStyle() { if (defaultCharacterStyle==null) { defaultCharacterStyle = getDefaultStyle("character"); } // OpenOffice conversion to docx // doesn't necessarily contain a default character style // so manufacture one if (defaultCharacterStyle==null) { try { defaultCharacterStyle = (Style)XmlUtils.unmarshalString(DEFAULT_CHARACTER_STYLE_DEFAULT); this.getJaxbElement().getStyle().add(defaultCharacterStyle); } catch (JAXBException e) { e.printStackTrace(); } } return defaultCharacterStyle; }
public static void updateComplexFieldDefinition(AbstractWmlConversionContext context, NodeIterator fldCharNodeIt) { org.docx4j.wml.FldChar field = null; Node node = fldCharNodeIt.nextNode(); try { field = (org.docx4j.wml.FldChar)XmlUtils.unmarshal( node, Context.jc, org.docx4j.wml.FldChar.class); } catch (JAXBException e1) { e1.printStackTrace(); } STFldCharType fieldCharType = field.getFldCharType(); if (fieldCharType==null) { if (log.isDebugEnabled()) { log.debug("Ignoring unrecognised: " + XmlUtils.w3CDomNodeToString(node)); } } else { context.updateComplexFieldDefinition(fieldCharType); } }
} catch (JAXBException e) { e.printStackTrace();
converter.pic = (org.pptx4j.pml.Pic)XmlUtils.unmarshal(n, org.pptx4j.jaxb.Context.jcPML, org.pptx4j.pml.Pic.class); } catch (JAXBException e1) { e1.printStackTrace();
} catch (JAXBException e) { e.printStackTrace();
public void save(File file) { try { JAXBContext jaxbContext = JAXBContext.newInstance(JarSettings.class); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.marshal(this, file); } catch (JAXBException e) { e.printStackTrace(); } }
/** * XML转对象 * @param xmlStr xml字串 * @param t 对象类型 * @return 对象 */ @SuppressWarnings("unchecked") public static <T> T xmlToBean(String xmlStr, Class<T> t) { try { JAXBContext context = JAXBContext.newInstance(t); Unmarshaller unmarshaller = context.createUnmarshaller(); return (T) unmarshaller.unmarshal(new StringReader(xmlStr)); } catch (JAXBException e) { e.printStackTrace(); return null; } }
public static JarSettings readFromFile(File file) { if (file.exists()) { try { JAXBContext jaxbContext = JAXBContext.newInstance(JarSettings.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); JarSettings unmarshal = (JarSettings) unmarshaller.unmarshal(file); unmarshal.setLastFile(file); return unmarshal; } catch (JAXBException e) { e.printStackTrace(); } } else { return new JarSettings(); } return null; }
public static void main(String[] args) { PluginDescriptor descriptor = new PluginDescriptor(); // Dependency dependency = new Dependency(); // dependency.setPath("test"); JavaPlugin pluginImplementation = new JavaPlugin(); descriptor.getPlugins().add(pluginImplementation); // descriptor.getDependencies().add(dependency); try { JAXBContext jaxbContext = JAXBContext.newInstance(PluginDescriptor.class); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.marshal(descriptor, new FileOutputStream(new File("testdescriptor.xml"))); } catch (JAXBException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } } }
public synchronized List<Scenario> getScenarios() throws Exception { if (scenarios != null) { return scenarios; } scenarios = Collections.synchronizedList(new ArrayList<Scenario>()); for (Path path : getPaths(getFilePattern())) { try { List<Scenario> scenarioList = XMLConfigParser.readDataModel(path).getScenarios(); for (Scenario scenario : scenarioList) { scenarios.add(scenario); } } catch (JAXBException e) { e.printStackTrace(); } } return scenarios; }
} catch (JAXBException e) { e.printStackTrace();
private static void writeXmlAndEnd(HttpServerResponse rep, EchoResponse echo) { try (BufferOutputStream bufferOutputStream = new BufferOutputStream(500, rep)) { Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); jaxbMarshaller.marshal(echo, bufferOutputStream); } catch (JAXBException e) { e.printStackTrace(); throw new RuntimeException(e); } }
public void save(File file){ try { write(this,file.getAbsolutePath()); } catch (JAXBException e) { e.printStackTrace(); } }
WSDiscoveryProvider() { try { context = JAXBContextCache.getCachedContextAndSchemas(ObjectFactory.class).getContext(); } catch (JAXBException e) { e.printStackTrace(); } }