@Override public void putAll(Map<? extends String, ?> m) { for (Map.Entry<? extends String, ?> me : m.entrySet()) { put(me.getKey(), me.getValue()); } }
return put(new CustomProperty(p, key));
/** * Puts a {@link CustomProperty} that has not yet a valid ID into this * map. The method will allocate a suitable ID for the custom property: * * <ul> * <li>If there is already a property with the same name, take the ID * of that property. * * <li>Otherwise find the highest ID and use its value plus one. * </ul> * * @param customProperty The {@link CustomProperty} to add. * @return If there was already a property with the same name, the old property * @throws ClassCastException */ private Object put(final CustomProperty customProperty) throws ClassCastException { final String name = customProperty.getName(); /* Check whether a property with this name is in the map already. */ final Long oldId = (name == null) ? null : dictionary.getKey(name); if (oldId != null) { customProperty.setID(oldId); } else { long lastKey = (dictionary.isEmpty()) ? 0 : dictionary.lastKey(); long nextKey = Math.max(lastKey,PropertyIDMap.PID_MAX)+1; customProperty.setID(nextKey); } return this.put(name, customProperty); }
/** * 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; }
@Override public void putAll(Map<? extends String, ?> m) { for (Map.Entry<? extends String, ?> me : m.entrySet()) { put(me.getKey(), me.getValue()); } }
/** * <p>Sets the codepage.</p> * * @param codepage the codepage */ public void setCodepage(final int codepage) { final MutableProperty p = new MutableProperty(); p.setID(PropertyIDMap.PID_CODEPAGE); p.setType(Variant.VT_I2); p.setValue(Integer.valueOf(codepage)); put(new CustomProperty(p)); }
/** * <p>Sets the codepage.</p> * * @param codepage the codepage */ public void setCodepage(final int codepage) { final MutableProperty p = new MutableProperty(); p.setID(PropertyIDMap.PID_CODEPAGE); p.setType(Variant.VT_I2); p.setValue(Integer.valueOf(codepage)); put(new CustomProperty(p)); }
/** * <p>Adds a named date property.</p> * * @param name The property's name. * @param value The property's value. * @return the property that was stored under the specified name before, or * <code>null</code> if there was no such property before. */ public Object put(final String name, final Date value) { final MutableProperty p = new MutableProperty(); p.setID(-1); p.setType(Variant.VT_FILETIME); p.setValue(value); final CustomProperty cp = new CustomProperty(p, name); return put(cp); }
/** * <p>Adds a named double property.</p> * * @param name The property's name. * @param value The property's value. * @return the property that was stored under the specified name before, or * <code>null</code> if there was no such property before. */ public Object put(final String name, final Double value) { final MutableProperty p = new MutableProperty(); p.setID(-1); p.setType(Variant.VT_R8); p.setValue(value); final CustomProperty cp = new CustomProperty(p, name); return put(cp); }
/** * <p>Adds a named long property.</p> * * @param name The property's name. * @param value The property's value. * @return the property that was stored under the specified name before, or * <code>null</code> if there was no such property before. */ public Object put(final String name, final Long value) { final MutableProperty p = new MutableProperty(); p.setID(-1); p.setType(Variant.VT_I8); p.setValue(value); final CustomProperty cp = new CustomProperty(p, name); return put(cp); }
/** * <p>Adds a named string property.</p> * * @param name The property's name. * @param value The property's value. * @return the property that was stored under the specified name before, or * <code>null</code> if there was no such property before. */ public Object put(final String name, final String value) { final MutableProperty p = new MutableProperty(); p.setID(-1); p.setType(Variant.VT_LPWSTR); p.setValue(value); final CustomProperty cp = new CustomProperty(p, name); return put(cp); }
/** * <p>Adds a named string property.</p> * * @param name The property's name. * @param value The property's value. * @return the property that was stored under the specified name before, or * <code>null</code> if there was no such property before. */ public Object put(final String name, final String value) { final MutableProperty p = new MutableProperty(); p.setID(-1); p.setType(Variant.VT_LPWSTR); p.setValue(value); final CustomProperty cp = new CustomProperty(p, name); return put(cp); }
/** * <p>Adds a named double property.</p> * * @param name The property's name. * @param value The property's value. * @return the property that was stored under the specified name before, or * <code>null</code> if there was no such property before. */ public Object put(final String name, final Double value) { final MutableProperty p = new MutableProperty(); p.setID(-1); p.setType(Variant.VT_R8); p.setValue(value); final CustomProperty cp = new CustomProperty(p, name); return put(cp); }
/** * <p>Adds a named integer property.</p> * * @param name The property's name. * @param value The property's value. * @return the property that was stored under the specified name before, or * <code>null</code> if there was no such property before. */ public Object put(final String name, final Integer value) { final MutableProperty p = new MutableProperty(); p.setID(-1); p.setType(Variant.VT_I4); p.setValue(value); final CustomProperty cp = new CustomProperty(p, name); return put(cp); }
/** * <p>Adds a named integer property.</p> * * @param name The property's name. * @param value The property's value. * @return the property that was stored under the specified name before, or * <code>null</code> if there was no such property before. */ public Object put(final String name, final Integer value) { final MutableProperty p = new MutableProperty(); p.setID(-1); p.setType(Variant.VT_I4); p.setValue(value); final CustomProperty cp = new CustomProperty(p, name); return put(cp); }
/** * <p>Adds a named date property.</p> * * @param name The property's name. * @param value The property's value. * @return the property that was stored under the specified name before, or * <code>null</code> if there was no such property before. */ public Object put(final String name, final Date value) { final MutableProperty p = new MutableProperty(); p.setID(-1); p.setType(Variant.VT_FILETIME); p.setValue(value); final CustomProperty cp = new CustomProperty(p, name); return put(cp); }
/** * <p>Adds a named boolean property.</p> * * @param name The property's name. * @param value The property's value. * @return the property that was stored under the specified name before, or * <code>null</code> if there was no such property before. */ public Object put(final String name, final Boolean value) { final MutableProperty p = new MutableProperty(); p.setID(-1); p.setType(Variant.VT_BOOL); p.setValue(value); final CustomProperty cp = new CustomProperty(p, name); return put(cp); }
/** * <p>Adds a named long property.</p> * * @param name The property's name. * @param value The property's value. * @return the property that was stored under the specified name before, or * <code>null</code> if there was no such property before. */ public Object put(final String name, final Long value) { final MutableProperty p = new MutableProperty(); p.setID(-1); p.setType(Variant.VT_I8); p.setValue(value); final CustomProperty cp = new CustomProperty(p, name); return put(cp); }
/** * <p>Adds a named boolean property.</p> * * @param name The property's name. * @param value The property's value. * @return the property that was stored under the specified name before, or * <code>null</code> if there was no such property before. */ public Object put(final String name, final Boolean value) { final MutableProperty p = new MutableProperty(); p.setID(-1); p.setType(Variant.VT_BOOL); p.setValue(value); final CustomProperty cp = new CustomProperty(p, name); return put(cp); }
/** * Puts a {@link CustomProperty} that has not yet a valid ID into this * map. The method will allocate a suitable ID for the custom property: * * <ul> * <li>If there is already a property with the same name, take the ID * of that property. * * <li>Otherwise find the highest ID and use its value plus one. * </ul> * * @param customProperty The {@link CustomProperty} to add. * @return If there was already a property with the same name, the old property * @throws ClassCastException */ private Object put(final CustomProperty customProperty) throws ClassCastException { final String name = customProperty.getName(); /* Check whether a property with this name is in the map already. */ final Long oldId = (name == null) ? null : dictionary.getKey(name); if (oldId != null) { customProperty.setID(oldId); } else { long lastKey = (dictionary.isEmpty()) ? 0 : dictionary.lastKey(); long nextKey = Math.max(lastKey,PropertyIDMap.PID_MAX)+1; customProperty.setID(nextKey); } return this.put(name, customProperty); }