/** * Converts XML namespace URI and local name to fully qualified class name. * * @param namespaceUri namespace URI * @param localName local name * @param ignoreLowLine should low lines be ignored in the class name * @return fully qualified class name */ public static String xmlNameToClassName(String namespaceUri, String localName, boolean ignoreLowLine) { return namespaceUri == null || namespaceUri.length() == 0 ? xmlNameToClassName(localName, ignoreLowLine) : xmlNamespaceToJavaPackage(namespaceUri) + '.' + xmlNameToClassName(localName, ignoreLowLine); }
public static XSModel loadSchema(InputStream is, String encoding, SchemaBindingResolver schemaResolver) { if(log.isTraceEnabled()) { log.trace("loading xsd from InputStream"); } LSInputAdaptor input = new LSInputAdaptor(is, encoding); XSImplementation impl = getXSImplementation(); XSLoader schemaLoader = impl.createXSLoader(null); setDOMErrorHandler(schemaLoader); if(schemaResolver != null) { setResourceResolver(schemaLoader, schemaResolver); } return schemaLoader.load(input); }
public static XSModel loadSchema(String data, String encoding) { if(log.isTraceEnabled()) { log.trace("loading xsd from string"); } LSInputAdaptor input = new LSInputAdaptor(data, encoding); XSImplementation impl = getXSImplementation(); XSLoader schemaLoader = impl.createXSLoader(null); setDOMErrorHandler(schemaLoader); return schemaLoader.load(input); }
public static void set(Object o, QName elementName, Object value, boolean ignoreLowLine) { if(o instanceof Collection) { ((Collection)o).add(value); } else { String fieldName = Util.xmlNameToFieldName(elementName.getLocalPart(), ignoreLowLine); FieldInfo fieldInfo = FieldInfo.getFieldInfo(o.getClass(), fieldName, true); fieldInfo.setValue(o, value); } }
public void marshal(String xsdURL, ObjectModelProvider provider, Object root, Writer writer) throws IOException, SAXException { XSModel model = Util.loadSchema(xsdURL, schemaResolver); marshallInternal(provider, root, model, writer); }
/** * Extracts the package name from the typeNS * @param typeNS * @return */ public String getPackageName(String typeNS) { String pkgname = Util.xmlNamespaceToJavaPackage(typeNS); return pkgname; }
/** * Converts XML name to Java getter method name according to * Binding XML Names to Java Identifiers * C.2. The Name to Identifier Mapping Algorithm * jaxb-2_0-edr-spec-10_jun_2004.pdf * * @param name XML name * @param ignoreLowLine whether low lines should not be parts of Java identifiers * @return Java getter method name */ public static String xmlNameToGetMethodName(String name, boolean ignoreLowLine) { return "get" + xmlNameToClassName(name, ignoreLowLine); }
String fieldName = Util.xmlNameToFieldName(localName, true); fieldInfo = FieldInfo.getFieldInfo(o.getClass(), fieldName, true); String fieldName = Util.xmlNameToFieldName(localName, true); FieldInfo fieldInfo = FieldInfo.getFieldInfo(oCls, fieldName, true); if(Collection.class.isAssignableFrom(fieldInfo.getType())) else if(!Util.isAttributeType(fieldInfo.getType()))
String schemaLocation = attrs == null ? null : Util.getSchemaLocation(attrs, qName.getNamespaceURI()); SchemaBinding schema = resolver.resolve(qName.getNamespaceURI(), null, schemaLocation); if(schema != null)
parent.getClass(); String fieldName = Util.xmlNameToFieldName(localName, true); FieldInfo fieldInfo = FieldInfo.getFieldInfo(parentCls, fieldName, false); if(trace)
public void marshal(Reader xsdReader, ObjectModelProvider provider, Object root, Writer writer) throws IOException, SAXException, ParserConfigurationException { XSModel model = Util.loadSchema(xsdReader, null, schemaResolver); marshallInternal(provider, root, model, writer); }
/** * Converts XML name to Java setter method name according to * Binding XML Names to Java Identifiers * C.2. The Name to Identifier Mapping Algorithm * jaxb-2_0-edr-spec-10_jun_2004.pdf * * @param name XML name * @param ignoreLowLine whether low lines should not be parts of Java identifiers * @return Java setter method name */ public static String xmlNameToSetMethodName(String name, boolean ignoreLowLine) { return "set" + xmlNameToClassName(name, ignoreLowLine); }
String schemaLocation = atts == null ? null : Util.getSchemaLocation(atts, namespaceURI); schemaBinding = schemaResolver.resolve(namespaceURI, null, schemaLocation); if(schemaBinding != null)
public static XSModel loadSchema(Reader reader, String encoding, SchemaBindingResolver schemaResolver) { if(log.isTraceEnabled()) { log.trace("loading xsd from Reader"); } LSInputAdaptor input = new LSInputAdaptor(reader, encoding); XSImplementation impl = getXSImplementation(); XSLoader schemaLoader = impl.createXSLoader(null); setDOMErrorHandler(schemaLoader); if(schemaResolver != null) { setResourceResolver(schemaLoader, schemaResolver); } return schemaLoader.load(input); }
fieldName = Util.xmlNameToFieldName(localName, ignoreLowLine);
/** * Create a SchemaBinding from and xsd url/uri. * * @param xsdUrl * @param resolver the resolver will be used to resolve imported schemas in the schema being loaded * and also will be set on the returned instance of SchemaBinding * @return SchemaBinding mapping */ public static SchemaBinding bind(String xsdUrl, SchemaBindingResolver resolver) { XSModel model = Util.loadSchema(xsdUrl, resolver); return bind(model, resolver); }
Util.xmlNameToClassName(namespaceURI, type.getName(), true) : Util.xmlNameToClassName(namespaceURI, localName, true);
public static XSModel loadSchema(String xsdURL, SchemaBindingResolver schemaResolver) { boolean trace = log.isTraceEnabled(); long start = System.currentTimeMillis(); if(trace) log.trace("loading xsd: " + xsdURL); if(xsImpl == null) { xsImpl = getXSImplementation(); } XSLoader schemaLoader = xsImpl.createXSLoader(null); if(schemaResolver != null) { setResourceResolver(schemaLoader, schemaResolver); } setDOMErrorHandler(schemaLoader); XSModel model = schemaLoader.loadURI(xsdURL); if(model == null) { throw new IllegalArgumentException("Invalid URI for schema: " + xsdURL); } if (trace) log.trace("Loaded xsd: " + xsdURL + " in " + (System.currentTimeMillis() - start) + "ms"); return model; }
fieldName = Util.xmlNameToFieldName(element.getQName().getLocalPart(), ignoreLowLine);