nodepropbundle.java
来自「jsr170接口的java实现。是个apache的开源项目。」· Java 代码 · 共 698 行 · 第 1/2 页
JAVA
698 行
} } /** * Checks if this bundle has a property * @param name the name of the property * @return <code>true</code> if the property exists; * <code>false</code> otherwise. */ public boolean hasProperty(QName name) { return properties.containsKey(name) || name.equals(QName.JCR_PRIMARYTYPE) || (isReferenceable && name.equals(QName.JCR_UUID)) || (mixinTypeNames.size()>0 && name.equals(QName.JCR_MIXINTYPES)); } /** * Returns a set of the property names. * @return a set of the property names. */ public Set getPropertyNames() { return properties.keySet(); } /** * Returns a collection of property entries. * @return a collection of property entries. */ public Collection getPropertyEntries() { return properties.values(); } /** * Returns the property entry with the given name. * @param name the name of the property entry * @return the desired property entry or <code>null</code> */ public PropertyEntry getPropertyEntry(QName name) { return (PropertyEntry) properties.get(name); } /** * Removes all property entries */ public void removeAllProperties() { Iterator iter = properties.keySet().iterator(); while (iter.hasNext()) { QName name = (QName) iter.next(); removeProperty(name); iter = properties.keySet().iterator(); } } /** * Removes the proprty with the given name from this bundle. * @param name the name of the property */ public void removeProperty(QName name) { PropertyEntry pe = (PropertyEntry) properties.remove(name); if (pe != null) { pe.destroy(); } } /** * Returns the approx. size of this bundle. * @return the approx. size of this bundle. */ public long getSize() { // add some internal memory // + shallow size: 64 // + properties // + shallow size: 40 // + N * property entry: 218 + values + blobids // + childnodes // + shallow size: 24 // + N * 24 + 160 + 44 + name.length // + mixintypes names // + shallow size: 16 // + N * QNames // + nodetype name: // + shallow size: 24 // + string: 20 + length // + parentId: 160 // + id: 160 return 500 + size + 300 * (childNodeEntries.size() + properties.size() + 3); } /** * Sets the data size of this bundle * @param size the data size */ public void setSize(long size) { this.size = size; } //-----------------------------------------------------< ChildNodeEntry >--- /** * Helper class for a child node entry */ public static class ChildNodeEntry { /** * the name of the entry */ private final QName name; /** * the id of the entry */ private final NodeId id; /** * Creates a new entry with the given name and id * @param name the name * @param id the id */ public ChildNodeEntry(QName name, NodeId id) { this.name = name; this.id = id; } /** * Returns the name. * @return the name. */ public QName getName() { return name; } /** * Returns the id. * @return the id. */ public NodeId getId() { return id; } } //------------------------------------------------------< PropertyEntry >--- /** * Helper class for a property enrty */ public static class PropertyEntry { /** * The property id */ private final PropertyId id; /** * the internal value */ private InternalValue[] values; /** * the property type */ private int type; /** * the multivalued flag */ private boolean multiValued; /** * the propedef id */ private PropDefId propDefId; /** * the blob ids */ private String[] blobIds = null; /** * the mod count */ private short modCount = 0; /** * Creates a new property entry with the given id. * @param id the id */ public PropertyEntry(PropertyId id) { this.id = id; } /** * Creates a new property entry and initialized it with values from * the given property state. * @param state the source property state. */ public PropertyEntry(PropertyState state) { this((PropertyId) state.getId()); values = state.getValues(); type = state.getType(); multiValued = state.isMultiValued(); propDefId = state.getDefinitionId(); modCount = state.getModCount(); if (type == PropertyType.BINARY) { blobIds = new String[values.length]; } } /** * Returns the property id. * @return the property id. */ public PropertyId getId() { return id; } /** * Returns the property name * @return the property name */ public QName getName() { return id.getName(); } /** * Retruns the internal values * @return the internal values */ public InternalValue[] getValues() { return values; } /** * Sets the internal values. * @param values the internal values. */ public void setValues(InternalValue[] values) { this.values = values; } /** * Returns the type. * @return the type. */ public int getType() { return type; } /** * Sets the type * @param type the type */ public void setType(int type) { this.type = type; } /** * Returns the multivalued flag. * @return the multivalued flag. */ public boolean isMultiValued() { return multiValued; } /** * Sets the multivalued flag. * @param multiValued the multivalued flag */ public void setMultiValued(boolean multiValued) { this.multiValued = multiValued; } /** * Returns the propdef id. * @return the propdef id. */ public PropDefId getPropDefId() { return propDefId; } /** * Sets the propdef id * @param propDefId the propdef id */ public void setPropDefId(PropDefId propDefId) { this.propDefId = propDefId; } /** * Returns the n<sup>th</sup> blob id. * @param n the index of the blob id * @return the blob id */ public String getBlobId(int n) { return blobIds[n]; } /** * Sets the blob ids * @param blobIds the blobids */ public void setBlobIds(String[] blobIds) { this.blobIds = blobIds; } /** * Sets the n<sup>th</sup> blobid * @param blobId the blob id * @param n the index of the blob id */ public void setBlobId(String blobId, int n) { blobIds[n] = blobId; } /** * Returns the mod count. * @return the mod count. */ public short getModCount() { return modCount; } /** * Sets the mod count * @param modCount the mod count */ public void setModCount(short modCount) { this.modCount = modCount; } /** * Destroys this property state and deletes temporary blob file values. */ private void destroy() { if (type == PropertyType.BINARY) { // destroy binary property values for (int i=0; i<values.length; i++) { if (values[i].internalValue() instanceof BLOBFileValue) { ((BLOBFileValue) values[i].internalValue()).delete(true); } } } } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?