/** * Gets a named value from the custom properties - only works for keys of type String * * @param key the name of the value to get * @return the value or {@code null} if a value with the specified * name is not found in the custom properties. */ @Override public Object get(final Object key) { final Long id = dictionary.getKey(key); final CustomProperty cp = props.get(id); return cp != null ? cp.getValue() : null; }
/** * Puts a {@link CustomProperty} into this map. It is assumed that the * {@link CustomProperty} already has a valid ID. Otherwise use * {@link #put(CustomProperty)}. * * @param name the property name * @param cp the property * * @return the previous property stored under this name */ public CustomProperty put(final String name, final CustomProperty cp) { if (name == null) { /* Ignoring a property without a name. */ isPure = false; return null; } if (!name.equals(cp.getName())) { throw new IllegalArgumentException("Parameter \"name\" (" + name + ") and custom property's name (" + cp.getName() + ") do not match."); } checkCodePage(name); /* Register name and ID in the dictionary. Mapping in both directions is possible. If there is already a */ props.remove(dictionary.getKey(name)); dictionary.put(cp.getID(), name); /* Put the custom property into this map. */ return props.put(cp.getID(), 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); }
Long cpOffset = offset2Id.getKey((long)PropertyIDMap.PID_CODEPAGE);
/** * Gets a named value from the custom properties - only works for keys of type String * * @param key the name of the value to get * @return the value or {@code null} if a value with the specified * name is not found in the custom properties. */ @Override public Object get(final Object key) { final Long id = dictionary.getKey(key); final CustomProperty cp = props.get(id); return cp != null ? cp.getValue() : null; }
/** * Puts a {@link CustomProperty} into this map. It is assumed that the * {@link CustomProperty} already has a valid ID. Otherwise use * {@link #put(CustomProperty)}. * * @param name the property name * @param cp the property * * @return the previous property stored under this name */ public CustomProperty put(final String name, final CustomProperty cp) { if (name == null) { /* Ignoring a property without a name. */ isPure = false; return null; } if (!name.equals(cp.getName())) { throw new IllegalArgumentException("Parameter \"name\" (" + name + ") and custom property's name (" + cp.getName() + ") do not match."); } checkCodePage(name); /* Register name and ID in the dictionary. Mapping in both directions is possible. If there is already a */ props.remove(dictionary.getKey(name)); dictionary.put(cp.getID(), name); /* Put the custom property into this map. */ return props.put(cp.getID(), 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); }
Long cpOffset = offset2Id.getKey((long)PropertyIDMap.PID_CODEPAGE);