Java Code Examples for com.sun.xml.xsom.XmlString

The following examples show how to use com.sun.xml.xsom.XmlString. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public Long getValue(XSFacet facet) {
	final XmlString value = facet.getValue();

	if (value == null) {
		return null;
	} else {
		final String v = value.value;

		if (v == null) {
			return null;
		} else {
			final BigInteger integerValue = DatatypeConverter.parseInteger(v);
			if (integerValue.compareTo(BigInteger
					.valueOf(Long.MAX_VALUE)) > 0) {
				return Long.MAX_VALUE;
			} else {
				return integerValue.longValue();
			}
		}
	}
}
 
Example 2
public AttributeDeclImpl( SchemaDocumentImpl owner,
    String _targetNamespace, String _name,
    AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl _fa, boolean _anonymous,
    XmlString _defValue, XmlString _fixedValue,
    Ref.SimpleType _type ) {
    
    super(owner,_annon,_loc,_fa,_targetNamespace,_name,_anonymous);
    
    if(_name==null) // assertion failed.
        throw new IllegalArgumentException();
    
    this.defaultValue = _defValue;
    this.fixedValue = _fixedValue;
    this.type = _type;
}
 
Example 3
public AttributeUseImpl( SchemaDocumentImpl owner, AnnotationImpl ann, Locator loc, ForeignAttributesImpl fa, Ref.Attribute _decl,
    XmlString def, XmlString fixed, boolean req ) {
    
    super(owner,ann,loc,fa);
    
    this.att = _decl;
    this.defaultValue = def;
    this.fixedValue = fixed;
    this.required = req;
}
 
Example 4
Source Project: jolie   Source File: FacetImpl.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
public FacetImpl( SchemaDocumentImpl owner, AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl _fa,
    String _name, XmlString _value, boolean _fixed ) {
    
    super(owner,_annon,_loc,_fa);
    
    this.name = _name;
    this.value = _value;
    this.fixed = _fixed;
}
 
Example 5
Source Project: jolie   Source File: ElementDecl.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
public ElementDecl( PatcherManager reader, SchemaDocumentImpl owner,
    AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl fa,
    String _tns, String _name, boolean _anonymous,
    
    XmlString _defv, XmlString _fixedv,
    boolean _nillable, boolean _abstract,
    Ref.Type _type, Ref.Element _substHead,
    int _substDisallowed, int _substExcluded,
    List<IdentityConstraintImpl> idConstraints ) {
    
    super(owner,_annon,_loc,fa,_tns,_name,_anonymous);
    
    this.defaultValue = _defv;
    this.fixedValue = _fixedv;
    this.nillable = _nillable;
    this._abstract = _abstract;
    this.type = _type;
    this.substHead = _substHead;
    this.substDisallowed = _substDisallowed;
    this.substExcluded = _substExcluded;
    this.idConstraints = Collections.unmodifiableList((List<? extends XSIdentityConstraint>)idConstraints);

    for (IdentityConstraintImpl idc : idConstraints)
        idc.setParent(this);

    if(type==null)
        throw new IllegalArgumentException();
}
 
Example 6
protected String getDefaultValue(CAttributePropertyInfo propertyInfo) {

		final XSAttributeUse attributeUse = getAttributeUse(propertyInfo);
		if (attributeUse != null) {
			final XmlString defaultValue = attributeUse.getDefaultValue();
			if (defaultValue != null) {
				return defaultValue.value;
			}
		}
		return null;
	}
 
Example 7
protected NamespaceContext getDefaultValueNamespaceContext(
		CAttributePropertyInfo propertyInfo) {
	final XSAttributeUse attributeUse = getAttributeUse(propertyInfo);
	if (attributeUse != null) {
		final XmlString defaultValue = attributeUse.getDefaultValue();
		if (defaultValue != null) {
			return new NamespaceContextAdapter(defaultValue);
		}
	}
	return null;

}
 
Example 8
Source Project: hyperjaxb3   Source File: DefaultTypeUse.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
public JExpression createConstant(Outline outline, XmlString lexical) {
	if (isCollection())
		return null;

	if (adapter == null)
		return coreType.createConstant(outline, lexical);

	// [RESULT] new Adapter().unmarshal(CONSTANT);
	JExpression cons = coreType.createConstant(outline, lexical);
	@SuppressWarnings("unchecked")
	Class<? extends XmlAdapter<?, ?>> atype = (Class<? extends XmlAdapter<?, ?>>) adapter
			.getAdapterIfKnown();

	// try to run the adapter now rather than later.
	if (cons instanceof JStringLiteral && atype != null) {
		JStringLiteral scons = (JStringLiteral) cons;
		@SuppressWarnings("unchecked")
		XmlAdapter<Object, String> a = (XmlAdapter<Object, String>) ClassFactory
				.create(atype);
		try {
			Object value = a.unmarshal(scons.str);
			if (value instanceof String) {
				return JExpr.lit((String) value);
			}
		} catch (Exception e) {
			// assume that we can't eagerly bind this
		}
	}

	return JExpr._new(adapter.getAdapterClass(outline)).invoke("unmarshal")
			.arg(cons);
}
 
Example 9
@Override
public JSAssignmentExpression createValue(MappingCompiler<T, C> mappingCompiler, XmlString item) {
	final MTypeInfo<T, C> baseTypeInfo = enumLeafInfo.getBaseTypeInfo();
	final TypeInfoCompiler<T, C> baseTypeInfoCompiler = mappingCompiler.getTypeInfoCompiler(enumLeafInfo,
			baseTypeInfo);
	return baseTypeInfoCompiler.createValue(mappingCompiler, item);
}
 
Example 10
private void appendEnumerationValues(final TypeInfoCompiler<T, C> typeInfoCompiler) {
	if (info instanceof MOriginated) {
		MOriginated<?> originated = (MOriginated<?>) info;
		Object origin = originated.getOrigin();
		if (origin instanceof SchemaComponentAware) {
			final XSComponent component = ((SchemaComponentAware) origin).getSchemaComponent();
			if (component != null) {

				final CollectEnumerationValuesVisitor collectEnumerationValuesVisitor = new CollectEnumerationValuesVisitor();
				component.visit(collectEnumerationValuesVisitor);
				final List<XmlString> enumerationValues = collectEnumerationValuesVisitor.getValues();
				if (enumerationValues != null && !enumerationValues.isEmpty()) {
					final JSArrayLiteral values = mappingCompiler.getCodeModel().array();
					boolean valueSupported = true;
					for (XmlString enumerationValue : enumerationValues) {
						final JSAssignmentExpression value = typeInfoCompiler.createValue(this.mappingCompiler,
								enumerationValue);
						if (value == null) {
							valueSupported = false;
							break;
						} else {
							values.append(value);
						}
					}
					if (valueSupported) {
						options.append(mappingCompiler.getNaming().values(), values);
					}
				}
			}
		}
	}
}
 
Example 11
@Override
public JsonValue createValue(JsonSchemaMappingCompiler<T, C> mappingCompiler, XmlString item) {
	final MTypeInfo<T, C> baseTypeInfo = enumLeafInfo.getBaseTypeInfo();
	final TypeInfoProducer<T, C> baseTypeInfoProducer = mappingCompiler.getTypeInfoProducer(enumLeafInfo,
			baseTypeInfo);
	return baseTypeInfoProducer.createValue(mappingCompiler, item);
}
 
Example 12
@Override
public JsonSchemaBuilder visitBuiltinLeafInfo(MBuiltinLeafInfo<T, C> typeInfo) {
	final TypeInfoProducer<T, C> typeInfoCompiler = mappingCompiler.getTypeInfoProducer(info, typeInfo);
	final JsonSchemaBuilder typeInfoSchemaRef = typeInfoCompiler.createTypeInfoSchemaRef(mappingCompiler);

	if (info instanceof MOriginated) {
		MOriginated<?> originated = (MOriginated<?>) info;
		Object origin = originated.getOrigin();
		if (origin instanceof SchemaComponentAware) {
			final XSComponent component = ((SchemaComponentAware) origin).getSchemaComponent();
			if (component != null) {

				final CollectEnumerationValuesVisitor collectEnumerationValuesVisitor = new CollectEnumerationValuesVisitor();
				component.visit(collectEnumerationValuesVisitor);
				final List<XmlString> enumerationValues = collectEnumerationValuesVisitor.getValues();
				if (enumerationValues != null && !enumerationValues.isEmpty()) {
					final JsonSchemaBuilder values = new JsonSchemaBuilder();
					boolean valueSupported = true;
					for (XmlString enumerationValue : enumerationValues) {
						final JsonValue value = typeInfoCompiler.createValue(this.mappingCompiler,
								enumerationValue);
						if (value == null) {
							valueSupported = false;
							break;
						} else {
							values.addEnum(value);
						}
					}
					if (valueSupported) {
						final JsonSchemaBuilder typeInfoSchemaRefWithEnums = new JsonSchemaBuilder();
						typeInfoSchemaRefWithEnums.addAllOf(typeInfoSchemaRef);
						typeInfoSchemaRefWithEnums.addAllOf(values);
						return typeInfoSchemaRefWithEnums;
					}
				}
			}
		}
	}
	return typeInfoSchemaRef;
}
 
Example 13
@Override
public void restrictionSimpleType(XSRestrictionSimpleType type) {
	final List<XSFacet> facets = type.getFacets(XSFacet.FACET_ENUMERATION);
	if (facets != null) {
		for (XSFacet facet : facets) {
			final XmlString value = facet.getValue();
			if (value != null) {
				this.values.add(value);
			}
		}
	}
}
 
Example 14
Source Project: jolie   Source File: NGCCRuntimeEx.java    License: GNU Lesser General Public License v2.1 4 votes vote down vote up
public XmlString createXmlString(String value) {
    if(value==null)     return null;
    else    return new XmlString(value,createValidationContext());
}
 
Example 15
Source Project: jolie   Source File: XPathImpl.java    License: GNU Lesser General Public License v2.1 4 votes vote down vote up
public XPathImpl(SchemaDocumentImpl _owner, AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl fa, XmlString xpath) {
    super(_owner, _annon, _loc, fa);
    this.xpath = xpath;
}
 
Example 16
Source Project: jolie   Source File: XPathImpl.java    License: GNU Lesser General Public License v2.1 4 votes vote down vote up
public XmlString getXPath() {
    return xpath;
}
 
Example 17
public XmlString getDefaultValue() {
    if( defaultValue!=null )    return defaultValue;
    else                        return getDecl().getDefaultValue();
}
 
Example 18
public XmlString getFixedValue() {
    if( fixedValue!=null )      return fixedValue;
    else                        return getDecl().getFixedValue();
}
 
Example 19
public JExpression createConstant(Outline arg0, XmlString arg1) {
	return null;
}
 
Example 20
@Override
public JSAssignmentExpression createValue(MappingCompiler<T, C> mappingCompiler, XmlString item) {
	return createValue(mappingCompiler, item.value);
}
 
Example 21
@Override
public JSAssignmentExpression createValue(MappingCompiler<T, C> mappingCompiler, XmlString item) {
	return createValue(mappingCompiler, item.value);
}
 
Example 22
@Override
public JsonValue createValue(JsonSchemaMappingCompiler<T, C> mappingCompiler, XmlString item) {
	return createValue(mappingCompiler, item.value);
}
 
Example 23
@Override
public JsonValue createValue(JsonSchemaMappingCompiler<T, C> mappingCompiler, XmlString item) {
	return createValue(mappingCompiler, item.value);
}
 
Example 24
public List<XmlString> getValues() {
	return values;
}
 
Example 25
Source Project: dynaform   Source File: XmlFormBuilder.java    License: Artistic License 2.0 4 votes vote down vote up
private FormElement declSimple(XSSimpleType simpleType,
    String name,
    XmlString defaultValue,
    XmlString fixedValue) {
  
  if (log.isDebugEnabled()) {
    log.debug("Simple Type: " + simpleType);
    log.debug("Primitive: " + simpleType.isPrimitive());
  }
  
  Data data = null;
  Control control = null;
  boolean required = false;
  
  if (simpleType.isRestriction()) {
    XSRestrictionSimpleType restriction = simpleType.asRestriction();
    
    if (isEnumeration(restriction)) {
      control = new Controls.SelectOneImpl();
      if (log.isDebugEnabled())
        log.debug("Control: " + control);
    }
    
    required = hasMinLength(restriction);
    
    data = createData(simpleType);
    if (data == null) {
      log.warn("Unsupported Primitive Type: " + simpleType);
      return null;
    }
  }
  
  else if (simpleType.isList()) {
    XSListSimpleType list = simpleType.asList();
    XSSimpleType itemType = list.getItemType();
    
    if (log.isDebugEnabled()) {
      log.debug("List: " + list);
      log.debug("Item type: " + itemType);
    }
    
    data = new StringData();
  }
  
  else if (simpleType.isUnion()) {
    log.warn("Unsupported Simple Type: " + simpleType);
    return null;
  }
  
  else
    throw new AssertionError("Unknown Simple Type: " + simpleType);
  
  if (control == null)
    control = new Controls.InputImpl();
  
  String value = null;
  boolean readOnly = false;
  
  if (defaultValue != null) {
    if (log.isDebugEnabled())
      log.debug("Default Value: " + defaultValue);
    
    value = defaultValue.toString();
  }
  
  if (fixedValue != null) {
    if (log.isDebugEnabled())
      log.debug("Fixed Value: " + fixedValue);
    
    value = fixedValue.toString();
    readOnly = true;
  }
  
  FormElement element = new FormElementImpl(name, control, data);
  
  if (value != null) {
    try {
      element.setXmlValue(value);
    } catch (Exception e) {
      log.warn("Failed to inject XML value: " + value, e);
    }
  }
  
  if (simpleType.isRestriction())
    processRestrictions(simpleType.asRestriction(), element.getRestrictions());
  
  element.setReadOnly(readOnly);
  element.setRequired(required);
  
  return element;
}
 
Example 26
public XmlString getDefaultValue() { return defaultValue; } 
Example 27
public XmlString getFixedValue() { return fixedValue; } 
Example 28
Source Project: jolie   Source File: FacetImpl.java    License: GNU Lesser General Public License v2.1 votes vote down vote up
public XmlString getValue() { return value; } 
Example 29
Source Project: jolie   Source File: ElementDecl.java    License: GNU Lesser General Public License v2.1 votes vote down vote up
public XmlString getDefaultValue() { return defaultValue; } 
Example 30
Source Project: jolie   Source File: ElementDecl.java    License: GNU Lesser General Public License v2.1 votes vote down vote up
public XmlString getFixedValue() { return fixedValue; }