Methods Summary |
---|
public java.lang.Object | get(java.lang.String name)Gets a named value from the custom properties.
final Long id = (Long) dictionaryNameToID.get(name);
final CustomProperty cp = (CustomProperty) super.get(id);
return cp != null ? cp.getValue() : null;
|
public int | getCodepage()Gets the codepage.
int codepage = -1;
for (final Iterator i = this.values().iterator(); codepage == -1 && i.hasNext();)
{
final CustomProperty cp = (CustomProperty) i.next();
if (cp.getID() == PropertyIDMap.PID_CODEPAGE)
codepage = ((Integer) cp.getValue()).intValue();
}
return codepage;
|
java.util.Map | getDictionary()Gets the dictionary which contains IDs and names of the named custom
properties.
return dictionaryIDToName;
|
public boolean | isPure()Tells whether this {@link CustomProperties} instance is pure or one or
more properties of the underlying low-level property set has been
dropped.
return isPure;
|
public java.lang.Object | put(java.lang.Object name, java.lang.Object customProperty)Puts a {@link CustomProperty} into this map. It is assumed that the
{@link CustomProperty} already has a valid ID. Otherwise use
{@link #put(CustomProperty)}.
final CustomProperty cp = (CustomProperty) customProperty;
if (name == null)
{
/* Ignoring a property without a name. */
isPure = false;
return null;
}
if (!(name instanceof String))
throw new ClassCastException("The name of a custom property must " +
"be a java.lang.String, but it is a " +
name.getClass().getName());
if (!(name.equals(cp.getName())))
throw new IllegalArgumentException("Parameter \"name\" (" + name +
") and custom property's name (" + cp.getName() +
") do not match.");
/* Register name and ID in the dictionary. Mapping in both directions is possible. If there is already a */
final Long idKey = new Long(cp.getID());
final Object oldID = dictionaryNameToID.get(name);
dictionaryIDToName.remove(oldID);
dictionaryNameToID.put(name, idKey);
dictionaryIDToName.put(idKey, name);
/* Put the custom property into this map. */
final Object oldCp = super.remove(oldID);
super.put(idKey, cp);
return oldCp;
|
public java.lang.Object | put(java.lang.String name, java.util.Date value)Adds a named date property.
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);
|
private java.lang.Object | put(org.apache.poi.hpsf.CustomProperty customProperty)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:
If there is already a property with the same name, take the ID
of that property.
Otherwise find the highest ID and use its value plus one.
final String name = customProperty.getName();
/* Check whether a property with this name is in the map already. */
final Long oldId = (Long) dictionaryNameToID.get(name);
if (oldId != null)
customProperty.setID(oldId.longValue());
else
{
long max = 1;
for (final Iterator i = dictionaryIDToName.keySet().iterator(); i.hasNext();)
{
final long id = ((Long) i.next()).longValue();
if (id > max)
max = id;
}
customProperty.setID(max + 1);
}
return this.put(name, customProperty);
|
public java.lang.Object | put(java.lang.String name, java.lang.String value)Adds a named string property.
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);
|
public java.lang.Object | put(java.lang.String name, java.lang.Long value)Adds a named long property.
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);
|
public java.lang.Object | put(java.lang.String name, java.lang.Double value)Adds a named double property.
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);
|
public java.lang.Object | put(java.lang.String name, java.lang.Integer value)Adds a named integer property.
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);
|
public java.lang.Object | put(java.lang.String name, java.lang.Boolean value)Adds a named boolean property.
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);
|
public java.lang.Object | remove(java.lang.String name)Removes a custom property.
final Long id = (Long) dictionaryNameToID.get(name);
if (id == null)
return null;
dictionaryIDToName.remove(id);
dictionaryNameToID.remove(name);
return super.remove(id);
|
public void | setCodepage(int codepage)Sets the codepage.
final MutableProperty p = new MutableProperty();
p.setID(PropertyIDMap.PID_CODEPAGE);
p.setType(Variant.VT_I2);
p.setValue(new Integer(codepage));
put(new CustomProperty(p));
|
public void | setPure(boolean isPure)Sets the purity of the custom property set.
this.isPure = isPure;
|