/** * Get the root binding definition. This is only allowed after the call to * {@link #writeBindings(String, String, List, ProblemHandler)}. * * @return root binding element */ public BindingElement getRootBinding() { return m_rootHolder.getBinding(); }
/** * Set the name and namespace URI for a concrete <mapping> binding component. This is the same logic as used in * the {@link StructureClassHolder} equivalent. * * @param qname qualified name to be set (<code>null</code> if none) * @param mapping concrete mapping definition * @param holder binding containing the mapping */ private void setName(QName qname, MappingElementBase mapping, BindingHolder holder) { if (qname != null) { String name = qname.getName(); mapping.setName(name); String uri = qname.getUri(); holder.addNamespaceUsage(uri); if (!Utility.safeEquals(uri, holder.getElementDefaultNamespace())) { mapping.setUri(uri); } } }
File file = new File(dir, root.getFileName()); ValidationContext vctx = new ValidationContext(loc); FileInputStream is = new FileInputStream(file); BindingElement binding = BindingElement.validateBinding(root.getFileName(), file.toURI().toURL(), is, vctx); if (binding == null || vctx.getErrorCount() > 0 || vctx.getFatalCount() > 0) { return null; BindingHolder hold = getBinding(uri); if (hold != root) { URL url = new URL(base, hold.getFileName()); if (binding.addIncludePath(url.toExternalForm(), false)) { throw new IllegalStateException("Binding not found when read from file");
if (hold.getMappingCount() == 0) { unbounduris.add(uri); File path = m_generationParameters.getGeneratePath(); BindingHolder rhold = m_bindingGenerator.finish(name); if (rhold.getBinding().topChildren().size() > 0) {
hold.addTypeNameReference(uri, uri); struct.setMapAsQName(qname); hold.addNamespaceUsage(hold.getNamespace()); struct.setCreateType(custom.getCreateType()); struct.setFactoryName(custom.getFactoryMethod()); hold.addNamespaceUsage(hold.getNamespace()); fillStructure(custom, null, null, struct, hold); coll.addChild(struct);
String uri = bind.getNamespace(); qname = new QName(uri, CustomBase.convertName(name, CustomBase.CAMEL_CASE_NAMES)); mapping.setTypeQName(qname); bind.addTypeNameReference(uri, uri); typemap.put(ptype, qname); bind.addMapping(mapping);
public boolean visit(MappingElement mapping) { org.jibx.runtime.QName qname = mapping.getTypeQName(); if (qname != null) { types.put(qname, mapping); } String name = mapping.getName(); if (name != null) { NamespaceElement ns = mapping.getNamespace(); if (ns == null) { qname = new org.jibx.runtime.QName(holder.getElementDefaultNamespace(), name); } else { qname = new org.jibx.runtime.QName(mapping.getNamespace().getUri(), name); } elems.put(qname, mapping); } return false; } };
BindingHolder hold = m_directory.getBinding(uri); if (mainmapping.isAbstract()) { hold.addTypeNameReference(uri, uri); } else { uri = tname.getUri(); hold.addTypeNameReference(uri, uri); struct.setMapAsQName(tname); hold.addMapping(mainmapping); if (mapabs != null && mapcon != null) { QName tname = detail.getTypeQName(); uri = tname.getUri(); hold.addTypeNameReference(uri, uri); struct.setMapAsQName(tname); mapcon.addChild(struct); hold.addMapping(mapcon);
if ((cust.isWrapCollections() || memb.isElementForced()) && name != null) { coll.setName(name); hold.addNamespaceUsage(hold.getNamespace()); hold.addNamespaceUsage(hold.getNamespace());
/** * Set serializer/deserializer options for a <value> component of the binding. If the item defining the item is a * reference, this uses the definition type name as the format and makes sure the definition namespace is defined * within the binding being generated. If the item defining the item is a builtin type, this sets the format and/or * serializer/deserializer methods based on the type definition. * * @param item * @param value * @param holder */ private void setValueHandlingOptions(Item item, ValueElement value, BindingHolder holder) { if (item instanceof ReferenceItem) { ReferenceItem refitem = (ReferenceItem)item; DefinitionItem defitem = refitem.getDefinition(); QName qname = defitem.getQName(); if (qname != null) { value.setFormatQName(qname); String uri = qname.getUri(); if (uri != null) { holder.addTypeNameReference(uri, defitem.getSchemaComponent().getSchema()); } } } else if (item instanceof ValueItem) { ValueItem valitem = (ValueItem)item; JavaType jtype = valitem.getType(); value.setFormatName(jtype.getFormat()); value.setSerializerName(jtype.getSerializerMethod()); value.setDeserializerName(jtype.getDeserializerMethod()); } }
format.setTypeName(child.getBindingName()); ((EnumerationClassHolder)child).setBinding(format); bindhold.addFormat(format);
holder.addMapping(mapping); ((StructureClassHolder)clas).setBinding(mapping); DefinitionItem elementdef = (DefinitionItem)typeinst.get(definition); holder.addMapping(elmapping);
QName qname = detail.getTypeQName(); String uri = qname.getUri(); hold.addTypeNameReference(uri, uri); struct.setMapAsQName(qname); if (memb != null) { struct.setName(memb.getXmlName()); hold.addNamespaceUsage(hold.getNamespace()); hold.addNamespaceUsage(hold.getNamespace());
String uri = qname.getUri(); if (uri != null) { holder.addTypeNameReference(uri, def.getSchemaComponent().getSchema());
public void onBindViewHolder(BindingHolder holder, int position) { final T item = mItems.get(position); holder.getBinding().setVariable(BR.item, item); holder.getBinding().executePendingBindings(); }
/** * Set the name and namespace URI for a <structure> or <collection> binding component. * * @param qname qualified name to be set (<code>null</code> if none) * @param holder binding containing the structure or collection definition * @param struct binding component */ private static void setName(QName qname, BindingHolder holder, StructureElementBase struct) { if (qname != null) { if (struct.getName() != null) { throw new IllegalStateException("Internal error - trying to overwrite name '" + struct.getName() + "' with '" + qname.getName() + '\''); } String name = qname.getName(); String uri = qname.getUri(); if (name.charAt(0) == '{') { int split = name.indexOf('}'); uri = name.substring(1, split); name = name.substring(split+1); } struct.setName(name); holder.addNamespaceUsage(uri); if (!Utility.safeEquals(uri, holder.getElementDefaultNamespace())) { struct.setUri(uri); } } }
holder.addTypeNameReference(uri, def.getSchemaComponent().getSchema()); String uri = qname.getUri(); if (uri != null) { holder.addTypeNameReference(uri, def.getSchemaComponent().getSchema());
public static void getDefinitions(final BindingHolder holder, final Map<org.jibx.runtime.QName, MappingElement> types, final Map<org.jibx.runtime.QName, MappingElement> elems) { TreeContext ctx = new TreeContext(new DummyClassLocator()); ModelVisitor visitor = new ModelVisitor() { public boolean visit(MappingElement mapping) { org.jibx.runtime.QName qname = mapping.getTypeQName(); if (qname != null) { types.put(qname, mapping); } String name = mapping.getName(); if (name != null) { NamespaceElement ns = mapping.getNamespace(); if (ns == null) { qname = new org.jibx.runtime.QName(holder.getElementDefaultNamespace(), name); } else { qname = new org.jibx.runtime.QName(mapping.getNamespace().getUri(), name); } elems.put(qname, mapping); } return false; } }; ctx.tourTree(holder.getBinding(), visitor); } public String getType(QName qn, boolean element) {
/** * Set the name and namespace URI for a <value> binding component. The value style must be set before making this * call, since element and attribute elements are handled differently. * * @param qname qualified name to be set (<code>null</code> if none) * @param holder binding containing the value definition * @param value binding component */ private static void setName(QName qname, BindingHolder holder, ValueElement value) { if (qname != null) { if (value.getName() != null) { throw new IllegalStateException("Internal error - trying to overwrite name '" + value.getName() + "' with '" + qname.getName() + '\''); } value.setName(qname.getName()); String uri = qname.getUri(); int style = value.getStyle(); if (style == NestingAttributes.ATTRIBUTE_STYLE) { if (uri != null) { holder.addNamespaceUsage(uri); } value.setUri(uri); } else if (style == NestingAttributes.ELEMENT_STYLE) { holder.addNamespaceUsage(uri); if (!Utility.safeEquals(uri, holder.getElementDefaultNamespace())) { value.setUri(uri); } } } }