} else { Class componentType = fieldType.getComponentType(); componentType = componentType.isPrimitive() ? Primitives.box(componentType) : componentType; if (itemType == null) { itemType = componentType; } else { itemType = itemType.isPrimitive() ? Primitives.box(itemType) : itemType; if (!componentType.isAssignableFrom(itemType)) { throw new InitializationException("Field \""
public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) { final int length = Array.getLength(source); for (int i = 0; i < length; ++i) { final Object item = Array.get(source, i); final Class itemType = item == null ? Mapper.Null.class : arrayType.getComponentType().isPrimitive() ? Primitives.unbox(item.getClass()) : item.getClass(); ExtendedHierarchicalStreamWriterHelper.startNode(writer, itemName, itemType); if (!itemType.equals(arrayType.getComponentType())) { final String attributeName = mapper.aliasForSystemAttribute("class"); if (attributeName != null) { writer.addAttribute(attributeName, mapper.serializedClass(itemType)); } } if (item != null) { context.convertAnother(item); } writer.endNode(); } }
public boolean allows(Class type) { return type != null && type != void.class && type != Void.class && type.isPrimitive() || Primitives.isBoxed(type); }
public Class realClass(String elementName) { String mappedName = (String) nameToType.get(elementName); if (mappedName != null) { Class type = Primitives.primitiveType(mappedName); if (type != null) { return type; } elementName = mappedName; } return super.realClass(elementName); }
private String arrayType(int dimensions, Class componentType) { StringBuffer className = new StringBuffer(); for (int i = 0; i < dimensions; i++) { className.append('['); } if (componentType.isPrimitive()) { className.append(Primitives.representingChar(componentType)); return className.toString(); } else { className.append('L').append(componentType.getName()).append(';'); return className.toString(); } }
public Class realClass(String elementName) { Class resultingClass = Primitives.primitiveType(elementName); if( resultingClass != null ){ return resultingClass; } try { boolean initialize = true; final ClassLoader classLoader; if (elementName.startsWith(XSTREAM_PACKAGE_ROOT)) { classLoader = DefaultMapper.class.getClassLoader(); } else { classLoader = classLoaderReference.getReference(); initialize = elementName.charAt(0) == '['; } return Class.forName(elementName, initialize, classLoader); } catch (ClassNotFoundException e) { throw new CannotResolveClassException(elementName); } }
private String arrayType(final int dimensions, final Class<?> componentType) { final StringBuilder className = new StringBuilder(); for (int i = 0; i < dimensions; i++) { className.append('['); } if (componentType.isPrimitive()) { className.append(Primitives.representingChar(componentType)); return className.toString(); } else { className.append('L').append(componentType.getName()).append(';'); return className.toString(); } }
/** * * @param clazz class * @return true if need quotes */ private boolean needsQuotes(Class<?> clazz) { clazz = clazz != null && clazz.isPrimitive() ? clazz : Primitives.unbox(clazz); return clazz == null || clazz == Character.TYPE; }
public Class realClass(String elementName) { int dimensions = 0; // strip off "-array" suffix while (elementName.endsWith("-array")) { elementName = elementName.substring(0, elementName.length() - 6); // cut off -array ++dimensions; } if (dimensions > 0) { Class componentType = Primitives.primitiveType(elementName); if (componentType == null) { componentType = super.realClass(elementName); } while (componentType.isArray()) { componentType = componentType.getComponentType(); ++dimensions; } return super.realClass(arrayType(dimensions, componentType)); } else { return super.realClass(elementName); } }
private String boxedTypeName(Class type) { return Primitives.isBoxed(type) ? type.getName() : null; } }
private String arrayType(int dimensions, Class componentType) { StringBuffer className = new StringBuffer(); for (int i = 0; i < dimensions; i++) { className.append('['); } if (componentType.isPrimitive()) { className.append(Primitives.representingChar(componentType)); return className.toString(); } else { className.append('L').append(componentType.getName()).append(';'); return className.toString(); } }
Object value = converter.fromString(reader.getAttribute(attrAlias)); if (type.isPrimitive()) { type = Primitives.box(type);
/** * * @param clazz class * @return true if need quotes */ private boolean needsQuotes(Class<?> clazz) { clazz = clazz != null && clazz.isPrimitive() ? clazz : Primitives.unbox(clazz); return clazz == null || clazz == Character.TYPE; }
public Class realClass(String elementName) { String mappedName = (String) nameToType.get(elementName); if (mappedName != null) { Class type = Primitives.primitiveType(mappedName); if (type != null) { return type; } elementName = mappedName; } return super.realClass(elementName); }
@Override public boolean allows(Class<?> type) { return type != null && type != void.class && type != Void.class && type.isPrimitive() || Primitives.isBoxed(type); }
private String arrayType(int dimensions, Class componentType) { StringBuffer className = new StringBuffer(); for (int i = 0; i < dimensions; i++) { className.append('['); } if (componentType.isPrimitive()) { className.append(Primitives.representingChar(componentType)); return className.toString(); } else { className.append('L').append(componentType.getName()).append(';'); return className.toString(); } }
.getAttribute(attrName)); if (type.isPrimitive()) { type = Primitives.box(type);
private boolean needsQuotes(Class clazz) { clazz = clazz != null && clazz.isPrimitive() ? clazz : Primitives.unbox(clazz); return clazz == null || clazz == Character.TYPE; }
@Override public Class<?> realClass(String elementName) { final String mappedName = nameToType.get(elementName); if (mappedName != null) { final Class<?> type = Primitives.primitiveType(mappedName); if (type != null) { return type; } elementName = mappedName; } return super.realClass(elementName); }