/** * Get the JAXB Unmarshaller * @param pkgName The package name for the jaxb context * @return unmarshaller * @throws JAXBException */ public static Unmarshaller getUnmarshaller(String pkgName) throws JAXBException { if (pkgName == null) throw new IllegalArgumentException(ErrorCodes.NULL_ARGUMENT + "pkgName"); JAXBContext jc = getJAXBContext(pkgName); return jc.createUnmarshaller(); }
/** * Get the JAXB Unmarshaller * * @param pkgName The package name for the jaxb context * @param schemaLocation location of the schema to validate against * @return unmarshaller * @throws JAXBException * @throws SAXException */ public static Unmarshaller getValidatingUnmarshaller(String pkgName, String schemaLocation) throws JAXBException, SAXException { Unmarshaller unmarshaller = getUnmarshaller(pkgName); Schema schema = getJAXPSchemaInstance(schemaLocation); unmarshaller.setSchema(schema); return unmarshaller; }
/** * Get the JAXB Marshaller * * @param pkgName The package name for the jaxb context * @param schemaLocation location of the schema to validate against * @return Marshaller * @throws JAXBException * @throws SAXException */ public static Marshaller getValidatingMarshaller(String pkgName, String schemaLocation) throws JAXBException, SAXException { Marshaller marshaller = getMarshaller(pkgName); // Validate against schema Schema schema = getJAXPSchemaInstance(schemaLocation); marshaller.setSchema(schema); return marshaller; }
/** * Get the JAXB Unmarshaller for a selected set * of package names * @param pkgNames * @return * @throws JAXBException */ public static Unmarshaller getUnmarshaller(String... pkgNames) throws JAXBException { if (pkgNames == null) throw new IllegalArgumentException(ErrorCodes.NULL_ARGUMENT + "pkgName"); int len = pkgNames.length; if (len == 0) return getUnmarshaller(pkgNames[0]); JAXBContext jc = getJAXBContext(pkgNames); return jc.createUnmarshaller(); }
public static Unmarshaller getValidatingUnmarshaller(String[] pkgNames, String[] schemaLocations) throws JAXBException, SAXException, IOException { StringBuilder builder = new StringBuilder(); int len = pkgNames.length; if (len == 0) throw new IllegalArgumentException(ErrorCodes.NULL_VALUE + "Packages are empty"); for (String pkg : pkgNames) { builder.append(pkg); builder.append(":"); } Unmarshaller unmarshaller = getUnmarshaller(builder.toString()); SchemaFactory schemaFactory = getSchemaFactory(); //Get the sources Source[] schemaSources = new Source[schemaLocations.length]; int i = 0; for (String schemaLocation : schemaLocations) { URL schemaURL = SecurityActions.loadResource(JAXBUtil.class, schemaLocation); if (schemaURL == null) throw new IllegalStateException(ErrorCodes.NULL_VALUE + "Schema URL :" + schemaLocation); schemaSources[i++] = new StreamSource(schemaURL.openStream()); } Schema schema = schemaFactory.newSchema(schemaSources); unmarshaller.setSchema(schema); return unmarshaller; }
private static Schema getJAXPSchemaInstance(String schemaLocation) throws SAXException { URL schemaURL = SecurityActions.loadResource(JAXBUtil.class, schemaLocation); if (schemaURL == null) throw new IllegalStateException(ErrorCodes.NULL_VALUE + "Schema URL :" + schemaLocation); SchemaFactory scFact = getSchemaFactory(); Schema schema = scFact.newSchema(schemaURL); return schema; }
Marshaller m = JAXBUtil.getMarshaller(RequestType.class.getPackage().getName()); m.marshal(of.createRequest(xacmlRequest), sw); } catch (JAXBException e) {
/** * Get the JAXB Unmarshaller for a selected set * of package names * @param pkgNames * @return * @throws JAXBException */ public static Unmarshaller getUnmarshaller(String... pkgNames) throws JAXBException { if (pkgNames == null) throw new IllegalArgumentException(ErrorCodes.NULL_ARGUMENT + "pkgName"); int len = pkgNames.length; if (len == 0) return getUnmarshaller(pkgNames[0]); JAXBContext jc = getJAXBContext(pkgNames); return jc.createUnmarshaller(); }
public static Unmarshaller getValidatingUnmarshaller(String[] pkgNames, String[] schemaLocations) throws JAXBException, SAXException, IOException { StringBuilder builder = new StringBuilder(); int len = pkgNames.length; if (len == 0) throw new IllegalArgumentException(ErrorCodes.NULL_VALUE + "Packages are empty"); for (String pkg : pkgNames) { builder.append(pkg); builder.append(":"); } Unmarshaller unmarshaller = getUnmarshaller(builder.toString()); SchemaFactory schemaFactory = getSchemaFactory(); //Get the sources Source[] schemaSources = new Source[schemaLocations.length]; int i = 0; for (String schemaLocation : schemaLocations) { URL schemaURL = SecurityActions.loadResource(JAXBUtil.class, schemaLocation); if (schemaURL == null) throw new IllegalStateException(ErrorCodes.NULL_VALUE + "Schema URL :" + schemaLocation); schemaSources[i++] = new StreamSource(schemaURL.openStream()); } Schema schema = schemaFactory.newSchema(schemaSources); unmarshaller.setSchema(schema); return unmarshaller; }
private static Schema getJAXPSchemaInstance(String schemaLocation) throws SAXException { URL schemaURL = SecurityActions.loadResource(JAXBUtil.class, schemaLocation); if (schemaURL == null) throw new IllegalStateException(ErrorCodes.NULL_VALUE + "Schema URL :" + schemaLocation); SchemaFactory scFact = getSchemaFactory(); Schema schema = scFact.newSchema(schemaURL); return schema; }
Marshaller m = JAXBUtil.getMarshaller(RequestType.class.getPackage().getName()); m.marshal(of.createRequest(xacmlRequest), sw); } catch (JAXBException e) {
/** * Get the JAXB Unmarshaller * @param pkgName The package name for the jaxb context * @return unmarshaller * @throws JAXBException */ public static Unmarshaller getUnmarshaller(String pkgName) throws JAXBException { if (pkgName == null) throw new IllegalArgumentException(ErrorCodes.NULL_ARGUMENT + "pkgName"); JAXBContext jc = getJAXBContext(pkgName); return jc.createUnmarshaller(); }
/** * Get the JAXB Unmarshaller for a selected set of package names * * @param pkgNames * @return * @throws JAXBException */ public static Unmarshaller getUnmarshaller(String... pkgNames) throws JAXBException { if (pkgNames == null) throw logger.nullArgumentError("pkgName"); int len = pkgNames.length; if (len == 0) return getUnmarshaller(pkgNames[0]); JAXBContext jc = getJAXBContext(pkgNames); return jc.createUnmarshaller(); }
/** * Get the JAXB Unmarshaller * @param pkgName The package name for the jaxb context * @param schemaLocation location of the schema to validate against * @return unmarshaller * @throws JAXBException * @throws SAXException */ public static Unmarshaller getValidatingUnmarshaller(String pkgName, String schemaLocation) throws JAXBException, SAXException { Unmarshaller unmarshaller = getUnmarshaller(pkgName); Schema schema = getJAXPSchemaInstance(schemaLocation); unmarshaller.setSchema(schema); return unmarshaller; }
/** * Get the JAXB Marshaller * @param pkgName The package name for the jaxb context * @param schemaLocation location of the schema to validate against * @return Marshaller * @throws JAXBException * @throws SAXException */ public static Marshaller getValidatingMarshaller(String pkgName, String schemaLocation) throws JAXBException, SAXException { Marshaller marshaller = getMarshaller(pkgName); //Validate against schema Schema schema = getJAXPSchemaInstance(schemaLocation); marshaller.setSchema(schema); return marshaller; }
public static Unmarshaller getValidatingUnmarshaller(String[] pkgNames, String[] schemaLocations) throws JAXBException, SAXException, IOException { StringBuilder builder = new StringBuilder(); int len = pkgNames.length; if (len == 0) throw logger.nullValueError("Packages are empty"); for (String pkg : pkgNames) { builder.append(pkg); builder.append(":"); } Unmarshaller unmarshaller = getUnmarshaller(builder.toString()); SchemaFactory schemaFactory = getSchemaFactory(); // Get the sources Source[] schemaSources = new Source[schemaLocations.length]; int i = 0; for (String schemaLocation : schemaLocations) { URL schemaURL = SecurityActions.loadResource(JAXBUtil.class, schemaLocation); if (schemaURL == null) throw logger.nullValueError("Schema URL :" + schemaLocation); schemaSources[i++] = new StreamSource(schemaURL.openStream()); } Schema schema = schemaFactory.newSchema(schemaSources); unmarshaller.setSchema(schema); return unmarshaller; }
private static Schema getJAXPSchemaInstance(String schemaLocation) throws SAXException { URL schemaURL = SecurityActions.loadResource(JAXBUtil.class, schemaLocation); if (schemaURL == null) throw logger.nullValueError("Schema URL :" + schemaLocation); SchemaFactory scFact = getSchemaFactory(); Schema schema = scFact.newSchema(schemaURL); return schema; }
Marshaller m = JAXBUtil.getMarshaller(RequestType.class.getPackage().getName()); m.marshal(of.createRequest(xacmlRequest), sw); } catch (JAXBException e) {
/** * Get the JAXB Marshaller * @param pkgName The package name for the jaxb context * @return Marshaller * @throws JAXBException */ public static Marshaller getMarshaller(String pkgName) throws JAXBException { if (pkgName == null) throw new IllegalArgumentException(ErrorCodes.NULL_ARGUMENT + "pkgName"); JAXBContext jc = getJAXBContext(pkgName); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.FALSE); //Breaks signatures return marshaller; }
/** * Get the JAXB Unmarshaller for a selected set of package names * * @param pkgNames * * @return * * @throws JAXBException */ public static Unmarshaller getUnmarshaller(String... pkgNames) throws JAXBException { if (pkgNames == null) throw logger.nullArgumentError("pkgName"); int len = pkgNames.length; if (len == 0) return getUnmarshaller(pkgNames[0]); JAXBContext jc = getJAXBContext(pkgNames); return jc.createUnmarshaller(); }