/** * Sets a property. * * @param p The property to be set. * * @see #setProperty(int, long, Object) * @see #getProperty * @see Variant */ public void setProperty(final Property p) { Property old = properties.get(p.getID()); if (old == null || !old.equals(p)) { properties.put(p.getID(), p); sectionBytes.reset(); } }
private String decodeValueFromID() { try { switch((int)getID()) { case PropertyIDMap.PID_CODEPAGE: return CodePageUtil.codepageToEncoding(((Number)value).intValue()); case PropertyIDMap.PID_LOCALE: return LocaleUtil.getLocaleFromLCID(((Number)value).intValue()); } } catch (Exception e) { LOG.log(POILogger.WARN, "Can't decode id "+getID()); } return null; }
private String getVariantName() { if (getID() == 0) { return "dictionary"; } return Variant.getVariantName(getType()); }
/** * Removes all properties from the section including 0 (dictionary) and 1 (codepage). */ public void clear() { for (Property p : getProperties()) { removeProperty(p.getID()); } }
private static String getPropertiesText(PropertySet ps) { if (ps == null) { // Not defined, oh well return ""; } StringBuilder text = new StringBuilder(); PropertyIDMap idMap = ps.getPropertySetIDMap(); Property[] props = ps.getProperties(); for (Property prop : props) { String type = Long.toString(prop.getID()); Object typeObj = (idMap == null) ? null : idMap.get(prop.getID()); if (typeObj != null) { type = typeObj.toString(); } String val = getPropertyValueText(prop.getValue()); text.append(type).append(" = ").append(val).append("\n"); } return text.toString(); }
/** * Constructs a {@code Section} by doing a deep copy of an * existing {@code Section}. All nested {@code Property} * instances, will be their mutable counterparts in the new * {@code MutableSection}. * * @param s The section set to copy */ public Section(final Section s) { this._offset = -1; setFormatID(s.getFormatID()); for (Property p : s.properties.values()) { properties.put(p.getID(), new Property(p)); } setDictionary(s.getDictionary()); }
final long pId = p.getID(); if (id != pId || (id != 0 && !typesAreEqual(type, p.getType()))) { return false;
/** * Gets the custom properties. * * @return The custom properties. */ public CustomProperties getCustomProperties() { CustomProperties cps = null; if (getSectionCount() >= 2) { cps = new CustomProperties(); final Section section = getSections().get(1); final Map<Long,String> dictionary = section.getDictionary(); final Property[] properties = section.getProperties(); int propertyCount = 0; for (Property p : properties) { final long id = p.getID(); if (id == PropertyIDMap.PID_CODEPAGE) { cps.setCodepage((Integer)p.getValue()); } else if (id > PropertyIDMap.PID_CODEPAGE) { propertyCount++; final CustomProperty cp = new CustomProperty(p, dictionary.get(id)); cps.put(cp.getName(), cp); } } if (cps.size() != propertyCount) { cps.setPure(false); } } return cps; }
/** * <p>Removes a property.</p> * * @param id The ID of the property to be removed */ public void removeProperty(final long id) { for (final Iterator<Property> i = preprops.iterator(); i.hasNext();) if (i.next().getID() == id) { i.remove(); break; } dirty = true; }
/** * <p>Removes a property.</p> * * @param id The ID of the property to be removed */ public void removeProperty(final long id) { for (final Iterator<Property> i = preprops.iterator(); i.hasNext();) if (i.next().getID() == id) { i.remove(); break; } dirty = true; }
private String decodeValueFromID() { try { switch((int)getID()) { case PropertyIDMap.PID_CODEPAGE: return CodePageUtil.codepageToEncoding(((Number)value).intValue()); case PropertyIDMap.PID_LOCALE: return LocaleUtil.getLocaleFromLCID(((Number)value).intValue()); } } catch (Exception e) { LOG.log(POILogger.WARN, "Can't decode id "+getID()); } return null; }
private String getVariantName() { if (getID() == 0) { return "dictionary"; } return Variant.getVariantName(getType()); }
/** * Removes all properties from the section including 0 (dictionary) and 1 (codepage). */ public void clear() { for (Property p : getProperties()) { removeProperty(p.getID()); } }
/** * <p>Removes all properties from the section including 0 (dictionary) and * 1 (codepage).</p> */ public void clear() { final Property[] properties = getProperties(); for (int i = 0; i < properties.length; i++) { final Property p = properties[i]; removeProperty(p.getID()); } }
/** * <p>Removes all properties from the section including 0 (dictionary) and * 1 (codepage).</p> */ public void clear() { final Property[] properties = getProperties(); for (int i = 0; i < properties.length; i++) { final Property p = properties[i]; removeProperty(p.getID()); } }
/** * <p>Creates a <code>MutableProperty</code> as a copy of an existing * <code>Property</code>.</p> * * @param p The property to copy. */ public MutableProperty(final Property p) { setID(p.getID()); setType(p.getType()); setValue(p.getValue()); }
/** * <p>Creates a <code>MutableProperty</code> as a copy of an existing * <code>Property</code>.</p> * * @param p The property to copy. */ public MutableProperty(final Property p) { setID(p.getID()); setType(p.getType()); setValue(p.getValue()); }