📄 property.java
字号:
char[] char_array = name.toCharArray(); int limit = Math.min(char_array.length, _max_name_length); _name = new String(char_array, 0, limit); short offset = 0; int j = 0; for (; j < limit; j++) { new ShortField(offset, ( short ) char_array[ j ], _raw_data); offset += LittleEndianConsts.SHORT_SIZE; } for (; j < _max_name_length + 1; j++) { new ShortField(offset, ( short ) 0, _raw_data); offset += LittleEndianConsts.SHORT_SIZE; } // double the count, and include the null at the end _name_size .set(( short ) ((limit + 1) * LittleEndianConsts.SHORT_SIZE), _raw_data); } /** * Sets the storage class ID for this property stream. This is the Class ID * of the COM object which can read and write this property stream * @param clsidStorage Storage Class ID */ public void setStorageClsid( ClassID clsidStorage) { _storage_clsid = clsidStorage; if( clsidStorage == null) { Arrays.fill( _raw_data, _storage_clsid_offset, _storage_clsid_offset + ClassID.LENGTH, (byte) 0); } else { clsidStorage.write( _raw_data, _storage_clsid_offset); } } /** * Set the property type. Makes no attempt to validate the value. * * @param propertyType the property type (root, file, directory) */ protected void setPropertyType(final byte propertyType) { _property_type.set(propertyType, _raw_data); } /** * Set the node color. * * @param nodeColor the node color (red or black) */ protected void setNodeColor(final byte nodeColor) { _node_color.set(nodeColor, _raw_data); } /** * Set the child property. * * @param child the child property's index in the Property Table */ protected void setChildProperty(final int child) { _child_property.set(child, _raw_data); } /** * Get the child property (its index in the Property Table) * * @return child property index */ protected int getChildIndex() { return _child_property.get(); } /** * Set the size of the document associated with this Property * * @param size the size of the document, in bytes */ protected void setSize(final int size) { _size.set(size, _raw_data); } /** * Set the index for this Property * * @param index this Property's index within its containing * Property Table */ protected void setIndex(final int index) { _index = index; } /** * get the index for this Property * * @return the index of this Property within its Property Table */ protected int getIndex() { return _index; } /** * Perform whatever activities need to be performed prior to * writing */ abstract protected void preWrite(); /** * get the next sibling * * @return index of next sibling */ int getNextChildIndex() { return _next_property.get(); } /** * get the previous sibling * * @return index of previous sibling */ int getPreviousChildIndex() { return _previous_property.get(); } /** * determine whether the specified index is valid * * @param index value to be checked * * @return true if the index is valid */ static boolean isValidIndex(int index) { return index != _NO_INDEX; } /* ********** START implementation of Child ********** */ /** * Get the next Child, if any * * @return the next Child; may return null */ public Child getNextChild() { return _next_child; } /** * Get the previous Child, if any * * @return the previous Child; may return null */ public Child getPreviousChild() { return _previous_child; } /** * Set the next Child * * @param child the new 'next' child; may be null, which has the * effect of saying there is no 'next' child */ public void setNextChild(final Child child) { _next_child = child; _next_property.set((child == null) ? _NO_INDEX : (( Property ) child) .getIndex(), _raw_data); } /** * Set the previous Child * * @param child the new 'previous' child; may be null, which has * the effect of saying there is no 'previous' child */ public void setPreviousChild(final Child child) { _previous_child = child; _previous_property.set((child == null) ? _NO_INDEX : (( Property ) child) .getIndex(), _raw_data); } /* ********** END implementation of Child ********** */ /* ********** START begin implementation of POIFSViewable ********** */ /** * Get an array of objects, some of which may implement * POIFSViewable * * @return an array of Object; may not be null, but may be empty */ public Object [] getViewableArray() { Object[] results = new Object[ 5 ]; results[ 0 ] = "Name = \"" + getName() + "\""; results[ 1 ] = "Property Type = " + _property_type.get(); results[ 2 ] = "Node Color = " + _node_color.get(); long time = _days_1.get(); time <<= 32; time += (( long ) _seconds_1.get()) & 0x0000FFFFL; results[ 3 ] = "Time 1 = " + time; time = _days_2.get(); time <<= 32; time += (( long ) _seconds_2.get()) & 0x0000FFFFL; results[ 4 ] = "Time 2 = " + time; return results; } /** * Get an Iterator of objects, some of which may implement * POIFSViewable * * @return an Iterator; may not be null, but may have an empty * back end store */ public Iterator getViewableIterator() { return Collections.EMPTY_LIST.iterator(); } /** * Give viewers a hint as to whether to call getViewableArray or * getViewableIterator * * @return true if a viewer should call getViewableArray, false if * a viewer should call getViewableIterator */ public boolean preferArray() { return true; } /** * Provides a short description of the object, to be used when a * POIFSViewable object has not provided its contents. * * @return short description */ public String getShortDescription() { StringBuffer buffer = new StringBuffer(); buffer.append("Property: \"").append(getName()).append("\""); return buffer.toString(); } /* ********** END begin implementation of POIFSViewable ********** */} // end public abstract class Property
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -