public Kind getKind() { return ((PrimitiveType)delegate).getKind(); }
public void visitPrimitiveType(PrimitiveType primitiveType) { if (isInArray && (primitiveType.getKind() == PrimitiveType.Kind.BYTE)) { //special case for byte[] this.xmlType = KnownXmlType.BASE64_BINARY; } else { this.xmlType = new XmlPrimitiveType(primitiveType); } }
public void visitPrimitiveType(PrimitiveType primitiveType) { if (isInArray && (primitiveType.getKind() == PrimitiveType.Kind.BYTE)) { //special case for byte[] this.xmlType = KnownXmlType.BASE64_BINARY; } else { this.xmlType = new XmlPrimitiveType(primitiveType); } }
@Override public void visitPrimitiveType(PrimitiveType primitiveType) { isPrimitive[0] = true; switch (primitiveType.getKind()) { case BOOLEAN: fqn[0] = Boolean.class.getName();
private boolean isIs() { return (getSimpleName().startsWith("is") && (getReturnType() instanceof PrimitiveType) && (((PrimitiveType) getReturnType()).getKind() == PrimitiveType.Kind.BOOLEAN)); }
switch (((PrimitiveType) typeMirror).getKind()) { case BOOLEAN: return Boolean.class.getName();
/** * The min occurs of this element. * * @return The min occurs of this element. */ public int getMinOccurs() { if (isRequired()) { return 1; } TypeMirror accessorType = getAccessorType(); boolean primitive = (accessorType instanceof PrimitiveType); if ((!primitive) && (accessorType instanceof ArrayType)) { //we have to check if the component type if its an array type, too. TypeMirror componentType = ((ArrayType) accessorType).getComponentType(); primitive = (componentType instanceof PrimitiveType) && (((PrimitiveType)componentType).getKind() != PrimitiveType.Kind.BYTE); } return primitive ? 1 : 0; }
/** * The min occurs of this element. * * @return The min occurs of this element. */ public int getMinOccurs() { if (isRequired()) { return 1; } TypeMirror accessorType = getAccessorType(); boolean primitive = (accessorType instanceof PrimitiveType); if ((!primitive) && (accessorType instanceof ArrayType)) { //we have to check if the component type if its an array type, too. TypeMirror componentType = ((ArrayType) accessorType).getComponentType(); primitive = (componentType instanceof PrimitiveType) && (((PrimitiveType)componentType).getKind() != PrimitiveType.Kind.BYTE); } return primitive ? 1 : 0; }
@Override public String convert(TypeMirror typeMirror) throws TemplateModelException { if (typeMirror instanceof ArrayType) { TypeMirror componentType = ((ArrayType) typeMirror).getComponentType(); if (!(componentType instanceof PrimitiveType) || (((PrimitiveType) componentType).getKind() != PrimitiveType.Kind.BYTE)) { return super.convert(componentType); } } else if (typeMirror instanceof DeclaredType) { DecoratedTypeMirror decoratedTypeMirror = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(typeMirror); if (decoratedTypeMirror.isCollection()) { DeclaredType declaredType = (DeclaredType) typeMirror; Iterator<TypeMirror> actualTypeArguments = declaredType.getActualTypeArguments().iterator(); if (actualTypeArguments.hasNext()) { return super.convert(actualTypeArguments.next()); } else { return Object.class.getName(); } } } return super.convert(typeMirror); }
@Override public String convert(TypeMirror typeMirror) throws TemplateModelException { if (typeMirror instanceof ArrayType) { TypeMirror componentType = ((ArrayType) typeMirror).getComponentType(); if (!(componentType instanceof PrimitiveType) || (((PrimitiveType) componentType).getKind() != PrimitiveType.Kind.BYTE)) { return super.convert(componentType); } } else if (typeMirror instanceof DeclaredType) { DecoratedTypeMirror decoratedTypeMirror = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(typeMirror); if (decoratedTypeMirror.isCollection()) { DeclaredType declaredType = (DeclaredType) typeMirror; Iterator<TypeMirror> actualTypeArguments = declaredType.getActualTypeArguments().iterator(); if (actualTypeArguments.hasNext()) { return super.convert(actualTypeArguments.next()); } else { return Object.class.getName(); } } } return super.convert(typeMirror); }
protected String getValue() throws TemplateException { if (type == null) { throw new MissingParameterException("type"); } if (!(type instanceof PrimitiveType)) { throw new TemplateException("'type' must be a primitive type."); } switch (((PrimitiveType) type).getKind()) { case BOOLEAN: return "Boolean"; case BYTE: return "Byte"; case CHAR: return "Character"; case DOUBLE: return "Double"; case FLOAT: return "Float"; case INT: return "Integer"; case LONG: return "Long"; case SHORT: return "Short"; default: throw new TemplateException("No wrapper for primitive type " + type); } }
DecoratedTypeMirror decorated = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(accessor.getAccessorType()); if (decorated.isPrimitive()) { return ((PrimitiveType) decorated).getKind() == PrimitiveType.Kind.LONG;
@Override public String convert(TypeMirror typeMirror) throws TemplateModelException { DecoratedTypeMirror decorated = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(typeMirror); if (decorated.isPrimitive()) { PrimitiveType.Kind kind = ((PrimitiveType) decorated).getKind(); switch (kind) { case BOOLEAN: return "bool"; //boolean as 'bool' case CHAR: return "ushort"; default: return kind.toString().toLowerCase(); } } else if (decorated.isCollection()) { //collections will be converted to arrays. return getCollectionTypeConversion((DeclaredType) typeMirror); } return super.convert(typeMirror); }
DecoratedTypeMirror decorated = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(typeMirror); if (decorated.isPrimitive()) { PrimitiveType.Kind kind = ((PrimitiveType) decorated).getKind(); switch (kind) { case BOOLEAN: if ((componentType instanceof PrimitiveType) && (((PrimitiveType) componentType).getKind() == PrimitiveType.Kind.BYTE)) { return "String";
DecoratedTypeMirror decorated = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(typeMirror); if (decorated.isPrimitive()) { PrimitiveType.Kind kind = ((PrimitiveType) decorated).getKind(); switch (kind) { case BOOLEAN: if ((componentType instanceof PrimitiveType) && (((PrimitiveType) componentType).getKind() == PrimitiveType.Kind.BYTE)) { return "String";
/** * The max occurs of the web result. * * @return The max occurs. */ public String getMaxOccurs() { DecoratedTypeMirror typeMirror = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(this.delegate); boolean unbounded = typeMirror.isCollection() || typeMirror.isArray(); if (typeMirror.isArray()) { TypeMirror componentType = ((ArrayType) typeMirror).getComponentType(); //special case for byte[] if ((componentType instanceof PrimitiveType) && (((PrimitiveType) componentType).getKind() == PrimitiveType.Kind.BYTE)) { unbounded = false; } } return unbounded ? "unbounded" : "1"; }
/** * The max occurs of this parameter as a child element. * * @return The max occurs of this parameter as a child element. */ public String getMaxOccurs() { DecoratedTypeMirror paramType = (DecoratedTypeMirror) getType(); boolean unbounded = paramType.isCollection() || paramType.isArray(); if (paramType.isArray()) { TypeMirror componentType = ((ArrayType) paramType).getComponentType(); //special case for byte[] if ((componentType instanceof PrimitiveType) && (((PrimitiveType) componentType).getKind() == PrimitiveType.Kind.BYTE)) { unbounded = false; } } return unbounded ? "unbounded" : "1"; }
private FaultBeanChildElement(PropertyDeclaration property, WebFault webFault) { DecoratedTypeMirror propertyType = (DecoratedTypeMirror) property.getPropertyType(); this.adaperType = AdapterUtil.findAdapterType(property.getGetter()); int minOccurs = propertyType.isPrimitive() ? 1 : 0; boolean unbounded = propertyType.isCollection() || propertyType.isArray(); if (propertyType.isArray()) { TypeMirror componentType = ((ArrayType) propertyType).getComponentType(); //special case for byte[] if ((componentType instanceof PrimitiveType) && (((PrimitiveType) componentType).getKind() == PrimitiveType.Kind.BYTE)) { unbounded = false; } } String maxOccurs = unbounded ? "unbounded" : "1"; this.property = property; this.minOccurs = minOccurs; this.maxOccurs = maxOccurs; this.webFault = webFault; }
/** * Whether the accessor type is a collection type. * * @return Whether the accessor type is a collection type. */ public boolean isCollectionType() { if (isXmlList()) { return false; } DecoratedTypeMirror accessorType; if (isAdapted()) { accessorType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(getAdapterType().getAdaptingType()); } else { accessorType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(getAccessorType()); } if (accessorType.isArray()) { TypeMirror componentType = ((ArrayType) accessorType).getComponentType(); //special case for byte[] return !(componentType instanceof PrimitiveType) || !(((PrimitiveType) componentType).getKind() == PrimitiveType.Kind.BYTE); } return accessorType.isCollection(); }
/** * Whether the accessor type is a collection type. * * @return Whether the accessor type is a collection type. */ public boolean isCollectionType() { if (isXmlList()) { return false; } DecoratedTypeMirror accessorType; if (isAdapted()) { accessorType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(getAdapterType().getAdaptingType(getAccessorType())); } else { accessorType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(getAccessorType()); } if (accessorType.isArray()) { TypeMirror componentType = ((ArrayType) accessorType).getComponentType(); //special case for byte[] return !(componentType instanceof PrimitiveType) || !(((PrimitiveType) componentType).getKind() == PrimitiveType.Kind.BYTE); } return accessorType.isCollection(); }