/** * Gets the type of the attribute this histogram describes. * * @return attribute type */ public GoogleBaseAttributeType getAttributeType() { return attributeId.getType(); }
/** * Gets the type of the attribute this histogram describes. * * @return attribute type */ public GoogleBaseAttributeType getAttributeType() { return attributeId.getType(); }
/** Gets the type of the attribute, or null. */ public GoogleBaseAttributeType getType() { return attributeId.getType(); }
/** Gets the type of the attribute, or null. */ public GoogleBaseAttributeType getType() { return attributeId.getType(); }
private boolean hasNameAndType(GoogleBaseAttribute attr, String name, GoogleBaseAttributeType type) { GoogleBaseAttributeType subtype = attr.getAttributeId().getType(); return name.equals(attr.getAttributeId().getName()) && (type == null || subtype != null && type.isSupertypeOf(subtype)); }
private boolean hasNameAndType(GoogleBaseAttribute attr, String name, GoogleBaseAttributeType type) { GoogleBaseAttributeType subtype = attr.getAttributeId().getType(); return name.equals(attr.getAttributeId().getName()) && (type == null || subtype != null && type.isSupertypeOf(subtype)); }
/** * Returns the XML attributes that should be set to the * element corresponding to the given * {@link com.google.api.gbase.client.GoogleBaseAttribute}. * * This method is meant to be implemented in subclasses that need * so set attributes. By default, it defines no attributes and * simply returns null. * * @param attribute * @return a collection of XML attributes or null */ private Collection<XmlWriter.Attribute> getXmlAttributes( GoogleBaseAttribute attribute) { GoogleBaseAttributeType type = attribute.getAttributeId().getType(); if (type == null) { return null; } List<XmlWriter.Attribute> attributes = new ArrayList<XmlWriter.Attribute>(); attributes.add(new XmlWriter.Attribute("type", type.toString())); if (attribute.isPrivate()) { attributes.add(new XmlWriter.Attribute("access", "private")); } return attributes; }
/** * Returns the XML attributes that should be set to the * element corresponding to the given * {@link com.google.api.gbase.client.GoogleBaseAttribute}. * * This method is meant to be implemented in subclasses that need * so set attributes. By default, it defines no attributes and * simply returns null. * * @param attribute * @return a collection of XML attributes or null */ private Collection<XmlWriter.Attribute> getXmlAttributes( GoogleBaseAttribute attribute) { GoogleBaseAttributeType type = attribute.getAttributeId().getType(); if (type == null) { return null; } List<XmlWriter.Attribute> attributes = new ArrayList<XmlWriter.Attribute>(); attributes.add(new XmlWriter.Attribute("type", type.toString())); if (attribute.isPrivate()) { attributes.add(new XmlWriter.Attribute("access", "private")); } return attributes; }
/** Generate the XML representation for this tag. */ public void generate(XmlWriter w, ExtensionProfile extProfile) throws IOException { if (attributes.isEmpty()) { // Nothing to write return; } w.startElement(GoogleBaseNamespaces.GM, "attributes", null, null); w.startRepeatingElement(); for (GmAttribute attribute : attributes) { List<XmlWriter.Attribute> attributes = new ArrayList<XmlWriter.Attribute>(); GoogleBaseAttributeId id = attribute.getAttributeId(); attributes.add(new XmlWriter.Attribute("name", id.getName())); if (id.getType() != null) { attributes.add(new XmlWriter.Attribute("type", id.getType().getName())); } if (attribute.getImportance() != null) { attributes.add(new XmlWriter.Attribute("importance", attribute.getImportance().getXmlValue())); } w.simpleElement(GoogleBaseNamespaces.GM, "attribute", attributes, null); } w.endRepeatingElement(); w.endElement(); }
/** Generate the XML representation for this tag. */ public void generate(XmlWriter w, ExtensionProfile extProfile) throws IOException { if (attributes.isEmpty()) { // Nothing to write return; } w.startElement(GoogleBaseNamespaces.GM, "attributes", null, null); w.startRepeatingElement(); for (GmAttribute attribute : attributes) { List<XmlWriter.Attribute> attributes = new ArrayList<XmlWriter.Attribute>(); GoogleBaseAttributeId id = attribute.getAttributeId(); attributes.add(new XmlWriter.Attribute("name", id.getName())); if (id.getType() != null) { attributes.add(new XmlWriter.Attribute("type", id.getType().getName())); } if (attribute.getImportance() != null) { attributes.add(new XmlWriter.Attribute("importance", attribute.getImportance().getXmlValue())); } w.simpleElement(GoogleBaseNamespaces.GM, "attribute", attributes, null); } w.endRepeatingElement(); w.endElement(); }
/** * Extracts a {@link Number} from a {@link GoogleBaseAttribute}. * * @param attr an attribute of type NUMBER, FLOAT or INT, may be null * @return a Number, which might be an Integer or a Float depending * on the type of the attribute, or null if {@code attr} was null */ public static Number extractNumber(GoogleBaseAttribute attr) { if (attr == null) { return null; } /* If the attribute has been declared as being an int, * treat it as such, otherwise create a Float. */ if (GoogleBaseAttributeType.FLOAT.equals(attr.getAttributeId().getType())) { return toFloat(attr.getValueAsString()); } else { return toInteger(attr.getValueAsString()); } }
/** * Extracts a <code>NumberUnit<Number></code> from a * {@link GoogleBaseAttribute}. * * @param attr an attribute of type NUMBER_UNIT, FLOAT_UNIT or INT_UNIT, * may be null * @return a NumberUnit object whose number might be an Integer * or a Float, depending on the type of the attribute, or null * if {@code attr} was null */ public static NumberUnit<? extends Number> extractNumberUnit( GoogleBaseAttribute attr) { if (attr == null) { return null; } if (GoogleBaseAttributeType.INT_UNIT.equals(attr.getAttributeId().getType())) { return toIntUnit(attr.getValueAsString()); } return toFloatUnit(attr.getValueAsString()); } }
/** * Extracts a <code>NumberUnit<Number></code> from a * {@link GoogleBaseAttribute}. * * @param attr an attribute of type NUMBER_UNIT, FLOAT_UNIT or INT_UNIT, * may be null * @return a NumberUnit object whose number might be an Integer * or a Float, depending on the type of the attribute, or null * if {@code attr} was null */ public static NumberUnit<? extends Number> extractNumberUnit( GoogleBaseAttribute attr) { if (attr == null) { return null; } if (GoogleBaseAttributeType.INT_UNIT.equals(attr.getAttributeId().getType())) { return toIntUnit(attr.getValueAsString()); } return toFloatUnit(attr.getValueAsString()); } }
/** * Extracts a {@link Number} from a {@link GoogleBaseAttribute}. * * @param attr an attribute of type NUMBER, FLOAT or INT, may be null * @return a Number, which might be an Integer or a Float depending * on the type of the attribute, or null if {@code attr} was null */ public static Number extractNumber(GoogleBaseAttribute attr) { if (attr == null) { return null; } /* If the attribute has been declared as being an int, * treat it as such, otherwise create a Float. */ if (GoogleBaseAttributeType.FLOAT.equals(attr.getAttributeId().getType())) { return toFloat(attr.getValueAsString()); } else { return toInteger(attr.getValueAsString()); } }