You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2009/10/09 00:29:43 UTC
svn commit: r823348 [2/4] - in /poi/trunk/src:
contrib/src/org/apache/poi/hssf/contrib/view/
contrib/src/org/apache/poi/ss/usermodel/contrib/
examples/src/org/apache/poi/hpsf/examples/ java/org/apache/poi/ddf/
java/org/apache/poi/hpsf/ java/org/apache/...
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/function/FunctionDataBuilder.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/function/FunctionDataBuilder.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/function/FunctionDataBuilder.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/function/FunctionDataBuilder.java Thu Oct 8 22:29:41 2009
@@ -25,7 +25,7 @@
/**
* Temporarily collects <tt>FunctionMetadata</tt> instances for creation of a
* <tt>FunctionMetadataRegistry</tt>.
- *
+ *
* @author Josh Micich
*/
final class FunctionDataBuilder {
@@ -46,10 +46,10 @@
byte returnClassCode, byte[] parameterClassCodes, boolean hasFootnote) {
FunctionMetadata fm = new FunctionMetadata(functionIndex, functionName, minParams, maxParams,
returnClassCode, parameterClassCodes);
-
- Integer indexKey = new Integer(functionIndex);
-
-
+
+ Integer indexKey = Integer.valueOf(functionIndex);
+
+
if(functionIndex > _maxFunctionIndex) {
_maxFunctionIndex = functionIndex;
}
@@ -60,7 +60,7 @@
if(!hasFootnote || !_mutatingFunctionIndexes.contains(indexKey)) {
throw new RuntimeException("Multiple entries for function name '" + functionName + "'");
}
- _functionDataByIndex.remove(new Integer(prevFM.getIndex()));
+ _functionDataByIndex.remove(Integer.valueOf(prevFM.getIndex()));
}
prevFM = (FunctionMetadata) _functionDataByIndex.get(indexKey);
if(prevFM != null) {
@@ -85,7 +85,7 @@
FunctionMetadata fd = jumbledArray[i];
fdIndexArray[fd.getIndex()] = fd;
}
-
+
return new FunctionMetadataRegistry(fdIndexArray, _functionDataByName);
}
-}
\ No newline at end of file
+}
Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/FontDetails.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/FontDetails.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/FontDetails.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/FontDetails.java Thu Oct 8 22:29:41 2009
@@ -57,7 +57,7 @@
public void addChar( char c, int width )
{
- charWidths.put(new Character(c), new Integer(width));
+ charWidths.put(new Character(c), Integer.valueOf(width));
}
/**
@@ -78,7 +78,7 @@
{
for ( int i = 0; i < characters.length; i++ )
{
- charWidths.put( new Character(characters[i]), new Integer(widths[i]));
+ charWidths.put( new Character(characters[i]), Integer.valueOf(widths[i]));
}
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFPictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFPictureData.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFPictureData.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFPictureData.java Thu Oct 8 22:29:41 2009
@@ -79,6 +79,7 @@
/**
* @see #getFormat
+ * @return 'wmf', 'jpeg' etc depending on the format. never <code>null</code>
*/
public String suggestFileExtension()
{
Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java Thu Oct 8 22:29:41 2009
@@ -149,7 +149,7 @@
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "Time at start of cell creating in HSSF sheet = ",
- new Long(timestart));
+ Long.valueOf(timestart));
HSSFRow lastrow = null;
// Add every cell to its row
@@ -180,12 +180,12 @@
hrow.createCellFromRecord( cval );
if (log.check( POILogger.DEBUG ))
log.log( DEBUG, "record took ",
- new Long( System.currentTimeMillis() - cellstart ) );
+ Long.valueOf( System.currentTimeMillis() - cellstart ) );
}
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "total sheet cell creation took ",
- new Long(System.currentTimeMillis() - timestart));
+ Long.valueOf(System.currentTimeMillis() - timestart));
}
/**
@@ -231,7 +231,7 @@
}
if (_rows.size() > 0) {
- Integer key = new Integer(row.getRowNum());
+ Integer key = Integer.valueOf(row.getRowNum());
HSSFRow removedRow = _rows.remove(key);
if (removedRow != row) {
//should not happen if the input argument is valid
@@ -296,7 +296,7 @@
private void addRow(HSSFRow row, boolean addLow)
{
- _rows.put(new Integer(row.getRowNum()), row);
+ _rows.put(Integer.valueOf(row.getRowNum()), row);
if (addLow)
{
_sheet.addRow(row.getRowRecord());
@@ -319,7 +319,7 @@
* @return HSSFRow representing the row number or null if its not defined on the sheet
*/
public HSSFRow getRow(int rowIndex) {
- return _rows.get(new Integer(rowIndex));
+ return _rows.get(Integer.valueOf(rowIndex));
}
/**
Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java Thu Oct 8 22:29:41 2009
@@ -1081,7 +1081,7 @@
// So we don't confuse users, give them back
// the same object every time, but create
// them lazily
- Short sIdx = new Short(idx);
+ Short sIdx = Short.valueOf(idx);
if(fonts.containsKey(sIdx)) {
return (HSSFFont)fonts.get(sIdx);
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/util/HSSFColor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/util/HSSFColor.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/util/HSSFColor.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/util/HSSFColor.java Thu Oct 8 22:29:41 2009
@@ -63,7 +63,7 @@
for (int i = 0; i < colors.length; i++) {
HSSFColor color = colors[i];
- Integer index1 = new Integer(color.getIndex());
+ Integer index1 = Integer.valueOf(color.getIndex());
if (result.containsKey(index1)) {
HSSFColor prevColor = (HSSFColor)result.get(index1);
throw new RuntimeException("Dup color index (" + index1
@@ -111,7 +111,7 @@
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
- return new Integer(s.intValue());
+ return Integer.valueOf(s.intValue());
}
private static HSSFColor[] getAllColors() {
Modified: poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java Thu Oct 8 22:29:41 2009
@@ -192,7 +192,7 @@
if (sheetIndex < 0) {
throw new RuntimeException("Specified sheet from a different book");
}
- result = new Integer(sheetIndex);
+ result = Integer.valueOf(sheetIndex);
_sheetIndexesBySheet.put(sheet, result);
}
return result.intValue();
@@ -214,7 +214,7 @@
if (sheetIndex < 0) {
return -1;
}
- result = new Integer(sheetIndex);
+ result = Integer.valueOf(sheetIndex);
_sheetIndexesByName.put(sheetName, result);
}
return result.intValue();
Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/BuiltinFormats.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/BuiltinFormats.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/BuiltinFormats.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/BuiltinFormats.java Thu Oct 8 22:29:41 2009
@@ -67,9 +67,9 @@
* <p/>
*
* @author Yegor Kozlov
- *
- * Modified 6/17/09 by Stanislav Shor - positive formats don't need starting '('
- *
+ *
+ * Modified 6/17/09 by Stanislav Shor - positive formats don't need starting '('
+ *
*/
public final class BuiltinFormats {
/**
@@ -142,7 +142,7 @@
public static Map<Integer, String> getBuiltinFormats() {
Map<Integer, String> result = new LinkedHashMap<Integer, String>();
for (int i=0; i<_formats.length; i++) {
- result.put(new Integer(i), _formats[i]);
+ result.put(Integer.valueOf(i), _formats[i]);
}
return result;
}
Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java Thu Oct 8 22:29:41 2009
@@ -147,7 +147,7 @@
if (format != null) {
return format;
}
- if (formatStr.equals("General") || formatStr.equals("@")) {
+ if ("General".equals(formatStr) || "@".equals(formatStr)) {
if (DataFormatter.isWholeNumber(cellValue)) {
return generalWholeNumFormat;
}
@@ -257,7 +257,7 @@
if(mIsMonth) {
sb.append('M');
ms.add(
- new Integer(sb.length() -1)
+ Integer.valueOf(sb.length() -1)
);
} else {
sb.append('m');
Modified: poi/trunk/src/java/org/apache/poi/ss/util/SheetReferences.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/SheetReferences.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/SheetReferences.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/SheetReferences.java Thu Oct 8 22:29:41 2009
@@ -34,13 +34,12 @@
{
map = new HashMap(5);
}
-
+
public void addSheetReference(String sheetName, int number) {
- map.put(new Integer(number), sheetName);
- }
+ map.put(Integer.valueOf(number), sheetName);
+ }
public String getSheetName(int number) {
- return (String)map.get(new Integer(number));
+ return (String)map.get(Integer.valueOf(number));
}
-
}
Modified: poi/trunk/src/java/org/apache/poi/util/BitFieldFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/BitFieldFactory.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/BitFieldFactory.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/BitFieldFactory.java Thu Oct 8 22:29:41 2009
@@ -15,7 +15,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.util;
@@ -27,18 +26,15 @@
* @author Jason Height (jheight at apache dot org)
*/
-public class BitFieldFactory
-{
+public class BitFieldFactory {
private static Map instances = new HashMap();
-
- public static BitField getInstance(final int mask) {
- BitField f = (BitField)instances.get(new Integer(mask));
+
+ public static BitField getInstance(int mask) {
+ BitField f = (BitField)instances.get(Integer.valueOf(mask));
if (f == null) {
f = new BitField(mask);
- instances.put(new Integer(mask), f);
+ instances.put(Integer.valueOf(mask), f);
}
return f;
}
-
-} // end public class BitFieldFactory
-
+}
Modified: poi/trunk/src/java/org/apache/poi/util/HexRead.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/HexRead.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/HexRead.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/HexRead.java Thu Oct 8 22:29:41 2009
@@ -62,7 +62,7 @@
* @see #readData(String)
*/
public static byte[] readData(InputStream stream, String section ) throws IOException {
-
+
try
{
StringBuffer sectionText = new StringBuffer();
@@ -128,7 +128,7 @@
characterCount++;
if ( characterCount == 2 )
{
- bytes.add( new Byte( b ) );
+ bytes.add( Byte.valueOf( b ) );
characterCount = 0;
b = (byte) 0;
}
@@ -151,7 +151,7 @@
characterCount++;
if ( characterCount == 2 )
{
- bytes.add( new Byte( b ) );
+ bytes.add( Byte.valueOf( b ) );
characterCount = 0;
b = (byte) 0;
}
Modified: poi/trunk/src/java/org/apache/poi/util/IntMapper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/IntMapper.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/IntMapper.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/IntMapper.java Thu Oct 8 22:29:41 2009
@@ -69,7 +69,7 @@
{
int index = elements.size();
elements.add(value);
- valueKeyMap.put(value, new Integer(index));
+ valueKeyMap.put(value, Integer.valueOf(index));
return true;
}
Modified: poi/trunk/src/java/org/apache/poi/util/POILogger.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/POILogger.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/POILogger.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/POILogger.java Thu Oct 8 22:29:41 2009
@@ -601,7 +601,7 @@
for (int j = 0; j < array.length; j++)
{
- results.add(new Byte(array[ j ]));
+ results.add(Byte.valueOf(array[ j ]));
}
}
if (object instanceof char [])
@@ -619,7 +619,7 @@
for (int j = 0; j < array.length; j++)
{
- results.add(new Short(array[ j ]));
+ results.add(Short.valueOf(array[ j ]));
}
}
else if (object instanceof int [])
@@ -628,7 +628,7 @@
for (int j = 0; j < array.length; j++)
{
- results.add(new Integer(array[ j ]));
+ results.add(Integer.valueOf(array[ j ]));
}
}
else if (object instanceof long [])
@@ -637,7 +637,7 @@
for (int j = 0; j < array.length; j++)
{
- results.add(new Long(array[ j ]));
+ results.add(Long.valueOf(array[ j ]));
}
}
else if (object instanceof float [])
Modified: poi/trunk/src/java/org/apache/poi/util/StringUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/StringUtil.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/StringUtil.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/StringUtil.java Thu Oct 8 22:29:41 2009
@@ -24,7 +24,7 @@
import org.apache.poi.hssf.record.RecordInputStream;
/**
* Title: String Utility Description: Collection of string handling utilities<p/>
- *
+ *
* Note - none of the methods in this class deals with {@link org.apache.poi.hssf.record.ContinueRecord}s. For such
* functionality, consider using {@link RecordInputStream
} *
@@ -52,7 +52,7 @@
* byte array. it is assumed that string[ offset ] and string[ offset +
* 1 ] contain the first 16-bit unicode character
* @param len the length of the final string
- * @return the converted string
+ * @return the converted string, never <code>null</code>.
* @exception ArrayIndexOutOfBoundsException if offset is out of bounds for
* the byte array (i.e., is negative or is greater than or equal to
* string.length)
@@ -87,7 +87,7 @@
* { 0x16, 0x00 } -0x16
*
* @param string the byte array to be converted
- * @return the converted string
+ * @return the converted string, never <code>null</code>
*/
public static String getFromUnicodeLE(byte[] string) {
if(string.length == 0) { return ""; }
@@ -132,7 +132,7 @@
* For this encoding, the is16BitFlag is always present even if nChars==0.
*/
public static String readUnicodeString(LittleEndianInput in) {
-
+
int nChars = in.readUShort();
byte flag = in.readByte();
if ((flag & 0x01) == 0) {
@@ -148,17 +148,17 @@
* </ol>
* For this encoding, the is16BitFlag is always present even if nChars==0.
* <br/>
- * This method should be used when the nChars field is <em>not</em> stored
- * as a ushort immediately before the is16BitFlag. Otherwise, {@link
- * #readUnicodeString(LittleEndianInput)} can be used.
+ * This method should be used when the nChars field is <em>not</em> stored
+ * as a ushort immediately before the is16BitFlag. Otherwise, {@link
+ * #readUnicodeString(LittleEndianInput)} can be used.
*/
public static String readUnicodeString(LittleEndianInput in, int nChars) {
byte is16Bit = in.readByte();
if ((is16Bit & 0x01) == 0) {
return readCompressedUnicode(in, nChars);
}
- return readUnicodeLE(in, nChars);
- }
+ return readUnicodeLE(in, nChars);
+ }
/**
* OutputStream <tt>out</tt> will get:
* <ol>
@@ -169,7 +169,7 @@
* For this encoding, the is16BitFlag is always present even if nChars==0.
*/
public static void writeUnicodeString(LittleEndianOutput out, String value) {
-
+
int nChars = value.length();
out.writeShort(nChars);
boolean is16Bit = hasMultibyte(value);
@@ -188,11 +188,11 @@
* </ol>
* For this encoding, the is16BitFlag is always present even if nChars==0.
* <br/>
- * This method should be used when the nChars field is <em>not</em> stored
- * as a ushort immediately before the is16BitFlag. Otherwise, {@link
- * #writeUnicodeString(LittleEndianOutput, String)} can be used.
+ * This method should be used when the nChars field is <em>not</em> stored
+ * as a ushort immediately before the is16BitFlag. Otherwise, {@link
+ * #writeUnicodeString(LittleEndianOutput, String)} can be used.
*/
- public static void writeUnicodeStringFlagAndData(LittleEndianOutput out, String value) {
+ public static void writeUnicodeStringFlagAndData(LittleEndianOutput out, String value) {
boolean is16Bit = hasMultibyte(value);
out.writeByte(is16Bit ? 0x01 : 0x00);
if (is16Bit) {
@@ -201,7 +201,7 @@
putCompressedUnicode(value, out);
}
}
-
+
/**
* @return the number of bytes that would be written by {@link #writeUnicodeString(LittleEndianOutput, String)}
*/
@@ -267,7 +267,7 @@
}
out.write(bytes);
}
-
+
public static String readUnicodeLE(LittleEndianInput in, int nChars) {
char[] buf = new char[nChars];
for (int i = 0; i < buf.length; i++) {
@@ -360,7 +360,7 @@
/**
* check the parameter has multibyte character
- *
+ *
* @param value string to check
* @return boolean result true:string has at least one multibyte character
*/
@@ -378,7 +378,7 @@
/**
* Checks to see if a given String needs to be represented as Unicode
- *
+ *
* @param value
* @return true if string needs Unicode to be represented.
*/
Modified: poi/trunk/src/ooxml/java/org/apache/poi/POIXMLProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/POIXMLProperties.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/POIXMLProperties.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/POIXMLProperties.java Thu Oct 8 22:29:41 2009
@@ -37,7 +37,7 @@
import org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperty;
/**
- * Wrapper around the two different kinds of OOXML properties
+ * Wrapper around the two different kinds of OOXML properties
* a document can have
*/
public class POIXMLProperties {
@@ -46,123 +46,123 @@
private ExtendedProperties ext;
private CustomProperties cust;
- private PackagePart extPart;
- private PackagePart custPart;
+ private PackagePart extPart;
+ private PackagePart custPart;
- private static final org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument NEW_EXT_INSTANCE;
- private static final org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument NEW_CUST_INSTANCE;
- static {
- NEW_EXT_INSTANCE = org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument.Factory.newInstance();
- NEW_EXT_INSTANCE.addNewProperties();
+ private static final org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument NEW_EXT_INSTANCE;
+ private static final org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument NEW_CUST_INSTANCE;
+ static {
+ NEW_EXT_INSTANCE = org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument.Factory.newInstance();
+ NEW_EXT_INSTANCE.addNewProperties();
- NEW_CUST_INSTANCE = org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument.Factory.newInstance();
- NEW_CUST_INSTANCE.addNewProperties();
- }
+ NEW_CUST_INSTANCE = org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument.Factory.newInstance();
+ NEW_CUST_INSTANCE.addNewProperties();
+ }
- public POIXMLProperties(OPCPackage docPackage) throws IOException, OpenXML4JException, XmlException {
+ public POIXMLProperties(OPCPackage docPackage) throws IOException, OpenXML4JException, XmlException {
this.pkg = docPackage;
-
+
// Core properties
- core = new CoreProperties((PackagePropertiesPart)pkg.getPackageProperties() );
-
+ core = new CoreProperties((PackagePropertiesPart)pkg.getPackageProperties() );
+
// Extended properties
PackageRelationshipCollection extRel =
pkg.getRelationshipsByType(POIXMLDocument.EXTENDED_PROPERTIES_REL_TYPE);
if(extRel.size() == 1) {
- extPart = pkg.getPart( extRel.getRelationship(0));
- org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument props = org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument.Factory.parse(
- extPart.getInputStream()
+ extPart = pkg.getPart( extRel.getRelationship(0));
+ org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument props = org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument.Factory.parse(
+ extPart.getInputStream()
);
ext = new ExtendedProperties(props);
} else {
- extPart = null;
- ext = new ExtendedProperties((org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument)NEW_EXT_INSTANCE.copy());
- }
-
+ extPart = null;
+ ext = new ExtendedProperties((org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument)NEW_EXT_INSTANCE.copy());
+ }
+
// Custom properties
PackageRelationshipCollection custRel =
pkg.getRelationshipsByType(POIXMLDocument.CUSTOM_PROPERTIES_REL_TYPE);
if(custRel.size() == 1) {
- custPart = pkg.getPart( custRel.getRelationship(0));
- org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument props = org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument.Factory.parse(
+ custPart = pkg.getPart( custRel.getRelationship(0));
+ org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument props = org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument.Factory.parse(
custPart.getInputStream()
);
cust = new CustomProperties(props);
} else {
- custPart = null;
- cust = new CustomProperties((org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument)NEW_CUST_INSTANCE.copy());
+ custPart = null;
+ cust = new CustomProperties((org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument)NEW_CUST_INSTANCE.copy());
}
}
-
+
/**
* Returns the core document properties
*/
public CoreProperties getCoreProperties() {
return core;
}
-
+
/**
* Returns the extended document properties
*/
public ExtendedProperties getExtendedProperties() {
return ext;
}
-
+
/**
* Returns the custom document properties
*/
public CustomProperties getCustomProperties() {
return cust;
}
-
+
/**
* Commit changes to the underlying OPC package
*/
public void commit() throws IOException{
- if(extPart == null && !NEW_EXT_INSTANCE.toString().equals(ext.props.toString())){
- try {
- PackagePartName prtname = PackagingURIHelper.createPartName("/docProps/app.xml");
- pkg.addRelationship(prtname, TargetMode.INTERNAL, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties");
- extPart = pkg.createPart(prtname, "application/vnd.openxmlformats-officedocument.extended-properties+xml");
- } catch (InvalidFormatException e){
- throw new POIXMLException(e);
- }
- }
- if(custPart == null && !NEW_CUST_INSTANCE.toString().equals(cust.props.toString())){
- try {
- PackagePartName prtname = PackagingURIHelper.createPartName("/docProps/custom.xml");
- pkg.addRelationship(prtname, TargetMode.INTERNAL, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties");
- custPart = pkg.createPart(prtname, "application/vnd.openxmlformats-officedocument.custom-properties+xml");
- } catch (InvalidFormatException e){
- throw new POIXMLException(e);
- }
- }
- if(extPart != null){
- XmlOptions xmlOptions = new XmlOptions(POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
-
- Map<String, String> map = new HashMap<String, String>();
- map.put("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes", "vt");
- xmlOptions.setSaveSuggestedPrefixes(map);
-
- OutputStream out = extPart.getOutputStream();
- ext.props.save(out, xmlOptions);
- out.close();
- }
- if(custPart != null){
- XmlOptions xmlOptions = new XmlOptions(POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
-
- Map<String, String> map = new HashMap<String, String>();
- map.put("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes", "vt");
- xmlOptions.setSaveSuggestedPrefixes(map);
-
- OutputStream out = custPart.getOutputStream();
- cust.props.save(out, xmlOptions);
- out.close();
- }
+ if(extPart == null && !NEW_EXT_INSTANCE.toString().equals(ext.props.toString())){
+ try {
+ PackagePartName prtname = PackagingURIHelper.createPartName("/docProps/app.xml");
+ pkg.addRelationship(prtname, TargetMode.INTERNAL, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties");
+ extPart = pkg.createPart(prtname, "application/vnd.openxmlformats-officedocument.extended-properties+xml");
+ } catch (InvalidFormatException e){
+ throw new POIXMLException(e);
+ }
+ }
+ if(custPart == null && !NEW_CUST_INSTANCE.toString().equals(cust.props.toString())){
+ try {
+ PackagePartName prtname = PackagingURIHelper.createPartName("/docProps/custom.xml");
+ pkg.addRelationship(prtname, TargetMode.INTERNAL, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties");
+ custPart = pkg.createPart(prtname, "application/vnd.openxmlformats-officedocument.custom-properties+xml");
+ } catch (InvalidFormatException e){
+ throw new POIXMLException(e);
+ }
+ }
+ if(extPart != null){
+ XmlOptions xmlOptions = new XmlOptions(POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes", "vt");
+ xmlOptions.setSaveSuggestedPrefixes(map);
+
+ OutputStream out = extPart.getOutputStream();
+ ext.props.save(out, xmlOptions);
+ out.close();
+ }
+ if(custPart != null){
+ XmlOptions xmlOptions = new XmlOptions(POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
+
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes", "vt");
+ xmlOptions.setSaveSuggestedPrefixes(map);
+
+ OutputStream out = custPart.getOutputStream();
+ cust.props.save(out, xmlOptions);
+ out.close();
+ }
}
-
+
/**
* The core document properties
*/
@@ -171,7 +171,7 @@
private CoreProperties(PackagePropertiesPart part) {
this.part = part;
}
-
+
public String getCategory() {
return part.getCategoryProperty().getValue();
}
@@ -252,17 +252,17 @@
}
public void setRevision(String revision) {
try {
- new Long(revision);
+ Long.valueOf(revision);
part.setRevisionProperty(revision);
}
catch (NumberFormatException e) {}
}
-
+
public PackagePropertiesPart getUnderlyingProperties() {
return part;
}
}
-
+
/**
* Extended document properties
*/
@@ -271,115 +271,115 @@
private ExtendedProperties(org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument props) {
this.props = props;
}
-
+
public org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.CTProperties getUnderlyingProperties() {
return props.getProperties();
}
}
-
+
/**
* Custom document properties
*/
public class CustomProperties {
- /**
- * Each custom property element contains an fmtid attribute
- * with the same GUID value ({D5CDD505-2E9C-101B-9397-08002B2CF9AE}).
- */
- public static final String FORMAT_ID = "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}";
+ /**
+ * Each custom property element contains an fmtid attribute
+ * with the same GUID value ({D5CDD505-2E9C-101B-9397-08002B2CF9AE}).
+ */
+ public static final String FORMAT_ID = "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}";
- private org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument props;
+ private org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument props;
private CustomProperties(org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument props) {
this.props = props;
}
-
+
public org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperties getUnderlyingProperties() {
return props.getProperties();
}
- /**
- * Add a new property
- *
- * @param name the property name
- * @throws IllegalArgumentException if a property with this name already exists
- */
- private CTProperty add(String name) {
- if(contains(name)) {
- throw new IllegalArgumentException("A property with this name " +
- "already exists in the custom properties");
- }
-
- CTProperty p = props.getProperties().addNewProperty();
- int pid = nextPid();
- p.setPid(pid);
- p.setFmtid(FORMAT_ID);
- p.setName(name);
- return p;
- }
-
- /**
- * Add a new string property
- *
- * @throws IllegalArgumentException if a property with this name already exists
- */
- public void addProperty(String name, String value){
- CTProperty p = add(name);
- p.setLpwstr(value);
- }
-
- /**
- * Add a new double property
- *
- * @throws IllegalArgumentException if a property with this name already exists
- */
- public void addProperty(String name, double value){
- CTProperty p = add(name);
- p.setR8(value);
- }
-
- /**
- * Add a new integer property
- *
- * @throws IllegalArgumentException if a property with this name already exists
- */
- public void addProperty(String name, int value){
- CTProperty p = add(name);
- p.setI4(value);
- }
-
- /**
- * Add a new boolean property
- *
- * @throws IllegalArgumentException if a property with this name already exists
- */
- public void addProperty(String name, boolean value){
- CTProperty p = add(name);
- p.setBool(value);
- }
-
- /**
- * Generate next id that uniquely relates a custom property
- *
- * @return next property id starting with 2
- */
- protected int nextPid(){
- int propid = 1;
- for(CTProperty p : props.getProperties().getPropertyArray()){
- if(p.getPid() > propid) propid = p.getPid();
- }
- return propid + 1;
- }
-
- /**
- * Check if a property with this name already exists in the collection of custom properties
- *
- * @param name the name to check
- * @return whether a property with the given name exists in the custom properties
- */
- public boolean contains(String name){
- for(CTProperty p : props.getProperties().getPropertyArray()){
- if(p.getName().equals(name)) return true;
- }
- return false;
- }
- }
+ /**
+ * Add a new property
+ *
+ * @param name the property name
+ * @throws IllegalArgumentException if a property with this name already exists
+ */
+ private CTProperty add(String name) {
+ if(contains(name)) {
+ throw new IllegalArgumentException("A property with this name " +
+ "already exists in the custom properties");
+ }
+
+ CTProperty p = props.getProperties().addNewProperty();
+ int pid = nextPid();
+ p.setPid(pid);
+ p.setFmtid(FORMAT_ID);
+ p.setName(name);
+ return p;
+ }
+
+ /**
+ * Add a new string property
+ *
+ * @throws IllegalArgumentException if a property with this name already exists
+ */
+ public void addProperty(String name, String value){
+ CTProperty p = add(name);
+ p.setLpwstr(value);
+ }
+
+ /**
+ * Add a new double property
+ *
+ * @throws IllegalArgumentException if a property with this name already exists
+ */
+ public void addProperty(String name, double value){
+ CTProperty p = add(name);
+ p.setR8(value);
+ }
+
+ /**
+ * Add a new integer property
+ *
+ * @throws IllegalArgumentException if a property with this name already exists
+ */
+ public void addProperty(String name, int value){
+ CTProperty p = add(name);
+ p.setI4(value);
+ }
+
+ /**
+ * Add a new boolean property
+ *
+ * @throws IllegalArgumentException if a property with this name already exists
+ */
+ public void addProperty(String name, boolean value){
+ CTProperty p = add(name);
+ p.setBool(value);
+ }
+
+ /**
+ * Generate next id that uniquely relates a custom property
+ *
+ * @return next property id starting with 2
+ */
+ protected int nextPid(){
+ int propid = 1;
+ for(CTProperty p : props.getProperties().getPropertyArray()){
+ if(p.getPid() > propid) propid = p.getPid();
+ }
+ return propid + 1;
+ }
+
+ /**
+ * Check if a property with this name already exists in the collection of custom properties
+ *
+ * @param name the name to check
+ * @return whether a property with the given name exists in the custom properties
+ */
+ public boolean contains(String name){
+ for(CTProperty p : props.getProperties().getPropertyArray()){
+ if(p.getName().equals(name)) return true;
+ }
+ return false;
+ }
+ }
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java Thu Oct 8 22:29:41 2009
@@ -58,15 +58,15 @@
import org.xml.sax.SAXException;
/**
- *
+ *
* Maps an XLSX to an XML according to one of the mapping defined.
- *
- *
+ *
+ *
* The output XML Schema must respect this limitations:
- *
+ *
* <ul>
* <li> all mandatory elements and attributes must be mapped (enable validation to check this)</li>
- *
+ *
* <li> no <any> in complex type/element declaration </li>
* <li> no <anyAttribute> attributes declaration </li>
* <li> no recursive structures: recursive structures can't be nested more than one level </li>
@@ -74,31 +74,26 @@
* <li> no mixed content: an element can't contain simple text and child element(s) together </li>
* <li> no <substitutionGroup> in complex type/element declaration </li>
* </ul>
- *
- * @author Roberto Manicardi
- *
- *
*
+ * @author Roberto Manicardi
*/
-
-
public class XSSFExportToXml implements Comparator<String>{
-
+
private XSSFMap map;
-
+
/**
* Creates a new exporter and sets the mapping to be used when generating the XML output document
- *
+ *
* @param map the mapping rule to be used
*/
- public XSSFExportToXml(XSSFMap map){
+ public XSSFExportToXml(XSSFMap map) {
this.map = map;
}
-
+
/**
- *
- * Exports the data in an XML stream
- *
+ *
+ * Exports the data in an XML stream
+ *
* @param os OutputStream in which will contain the output XML
* @param validate if true, validates the XML againts the XML Schema
* @throws SAXException
@@ -106,252 +101,242 @@
public void exportToXML(OutputStream os, boolean validate) throws SAXException{
exportToXML(os,"UTF-8", validate);
}
-
+
private Document getEmptyDocument() throws ParserConfigurationException{
-
-
+
DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
- DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
- Document doc = docBuilder.newDocument();
+ DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
+ Document doc = docBuilder.newDocument();
-
-
- return doc;
+ return doc;
}
-
+
/**
* Exports the data in an XML stream
- *
+ *
* @param os OutputStream in which will contain the output XML
- * @param encoding the output charset encoding
+ * @param encoding the output charset encoding
* @param validate if true, validates the XML againts the XML Schema
* @throws SAXException
* @throws InvalidFormatException
*/
-
public void exportToXML(OutputStream os, String encoding, boolean validate) throws SAXException{
List<XSSFSingleXmlCell> singleXMLCells = map.getRelatedSingleXMLCell();
List<Table> tables = map.getRelatedTables();
-
+
String rootElement = map.getCtMap().getRootElement();
-
+
try{
-
+
Document doc = getEmptyDocument();
-
- Element root = null;
-
- if(isNamespaceDeclared()){
- root=doc.createElementNS(getNamespace(),rootElement);
- }else{
- root=doc.createElement(rootElement);
- }
- doc.appendChild(root);
-
-
- List<String> xpaths = new Vector<String>();
- Map<String,XSSFSingleXmlCell> singleXmlCellsMappings = new HashMap<String,XSSFSingleXmlCell>();
- Map<String,Table> tableMappings = new HashMap<String,Table>();
-
- for(XSSFSingleXmlCell simpleXmlCell : singleXMLCells){
- xpaths.add(simpleXmlCell.getXpath());
- singleXmlCellsMappings.put(simpleXmlCell.getXpath(), simpleXmlCell);
- }
- for(Table table : tables){
- String commonXPath = table.getCommonXpath();
- xpaths.add(commonXPath);
- tableMappings.put(commonXPath, table);
- }
-
-
- Collections.sort(xpaths,this);
-
- for(String xpath : xpaths){
-
- XSSFSingleXmlCell simpleXmlCell = singleXmlCellsMappings.get(xpath);
- Table table = tableMappings.get(xpath);
-
- if(!xpath.matches(".*\\[.*")){
-
- // Exports elements and attributes mapped with simpleXmlCell
- if(simpleXmlCell!=null){
- XSSFCell cell = simpleXmlCell.getReferencedCell();
- if(cell!=null){
- Node currentNode = getNodeByXPath(xpath,doc.getFirstChild(),doc,false);
- STXmlDataType.Enum dataType = simpleXmlCell.getXmlDataType();
- mapCellOnNode(cell,currentNode,dataType);
- }
- }
-
- // Exports elements and attributes mapped with tables
- if(table!=null){
-
- List<XSSFXmlColumnPr> tableColumns = table.getXmlColumnPrs();
-
- XSSFSheet sheet = table.getXSSFSheet();
-
- int startRow = table.getStartCellReference().getRow();
- // In mappings created with Microsoft Excel the first row contains the table header and must be skipped
- startRow +=1;
-
- int endRow = table.getEndCellReference().getRow();
-
- for(int i = startRow; i<= endRow; i++){
- XSSFRow row = sheet.getRow(i);
-
- Node tableRootNode = getNodeByXPath(table.getCommonXpath(),doc.getFirstChild(),doc,true);
-
- short startColumnIndex = table.getStartCellReference().getCol();
- for(int j = startColumnIndex; j<= table.getEndCellReference().getCol();j++){
- XSSFCell cell = row.getCell(j);
- if(cell!=null){
- XSSFXmlColumnPr pointer = tableColumns.get(j-startColumnIndex);
- String localXPath = pointer.getLocalXPath();
- Node currentNode = getNodeByXPath(localXPath,tableRootNode,doc,false);
- STXmlDataType.Enum dataType = pointer.getXmlDataType();
-
-
- mapCellOnNode(cell,currentNode,dataType);
- }
-
- }
-
- }
-
-
-
- }
- }else{
- // TODO: implement filtering management in xpath
- }
- }
-
- boolean isValid = true;
- if(validate){
- isValid =isValid(doc);
- }
-
-
-
- if(isValid){
-
+
+ Element root = null;
+
+ if (isNamespaceDeclared()) {
+ root=doc.createElementNS(getNamespace(),rootElement);
+ } else {
+ root=doc.createElement(rootElement);
+ }
+ doc.appendChild(root);
+
+
+ List<String> xpaths = new Vector<String>();
+ Map<String,XSSFSingleXmlCell> singleXmlCellsMappings = new HashMap<String,XSSFSingleXmlCell>();
+ Map<String,Table> tableMappings = new HashMap<String,Table>();
+
+ for(XSSFSingleXmlCell simpleXmlCell : singleXMLCells) {
+ xpaths.add(simpleXmlCell.getXpath());
+ singleXmlCellsMappings.put(simpleXmlCell.getXpath(), simpleXmlCell);
+ }
+ for(Table table : tables) {
+ String commonXPath = table.getCommonXpath();
+ xpaths.add(commonXPath);
+ tableMappings.put(commonXPath, table);
+ }
+
+
+ Collections.sort(xpaths,this);
+
+ for(String xpath : xpaths) {
+
+ XSSFSingleXmlCell simpleXmlCell = singleXmlCellsMappings.get(xpath);
+ Table table = tableMappings.get(xpath);
+
+ if (!xpath.matches(".*\\[.*")) {
+
+ // Exports elements and attributes mapped with simpleXmlCell
+ if (simpleXmlCell!=null) {
+ XSSFCell cell = simpleXmlCell.getReferencedCell();
+ if (cell!=null) {
+ Node currentNode = getNodeByXPath(xpath,doc.getFirstChild(),doc,false);
+ STXmlDataType.Enum dataType = simpleXmlCell.getXmlDataType();
+ mapCellOnNode(cell,currentNode,dataType);
+ }
+ }
+
+ // Exports elements and attributes mapped with tables
+ if (table!=null) {
+
+ List<XSSFXmlColumnPr> tableColumns = table.getXmlColumnPrs();
+
+ XSSFSheet sheet = table.getXSSFSheet();
+
+ int startRow = table.getStartCellReference().getRow();
+ // In mappings created with Microsoft Excel the first row contains the table header and must be skipped
+ startRow +=1;
+
+ int endRow = table.getEndCellReference().getRow();
+
+ for(int i = startRow; i<= endRow; i++) {
+ XSSFRow row = sheet.getRow(i);
+
+ Node tableRootNode = getNodeByXPath(table.getCommonXpath(),doc.getFirstChild(),doc,true);
+
+ short startColumnIndex = table.getStartCellReference().getCol();
+ for(int j = startColumnIndex; j<= table.getEndCellReference().getCol();j++) {
+ XSSFCell cell = row.getCell(j);
+ if (cell!=null) {
+ XSSFXmlColumnPr pointer = tableColumns.get(j-startColumnIndex);
+ String localXPath = pointer.getLocalXPath();
+ Node currentNode = getNodeByXPath(localXPath,tableRootNode,doc,false);
+ STXmlDataType.Enum dataType = pointer.getXmlDataType();
+
+
+ mapCellOnNode(cell,currentNode,dataType);
+ }
+
+ }
+
+ }
+
+
+
+ }
+ } else {
+ // TODO: implement filtering management in xpath
+ }
+ }
+
+ boolean isValid = true;
+ if (validate) {
+ isValid =isValid(doc);
+ }
+
+
+
+ if (isValid) {
+
/////////////////
- //Output the XML
-
- //set up a transformer
- TransformerFactory transfac = TransformerFactory.newInstance();
- Transformer trans = transfac.newTransformer();
- trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
- trans.setOutputProperty(OutputKeys.INDENT, "yes");
- trans.setOutputProperty(OutputKeys.ENCODING, encoding);
-
- //create string from xml tree
-
- StreamResult result = new StreamResult(os);
- DOMSource source = new DOMSource(doc);
- trans.transform(source, result);
-
- }
- }catch(ParserConfigurationException e){
+ //Output the XML
+
+ //set up a transformer
+ TransformerFactory transfac = TransformerFactory.newInstance();
+ Transformer trans = transfac.newTransformer();
+ trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ trans.setOutputProperty(OutputKeys.INDENT, "yes");
+ trans.setOutputProperty(OutputKeys.ENCODING, encoding);
+
+ //create string from xml tree
+
+ StreamResult result = new StreamResult(os);
+ DOMSource source = new DOMSource(doc);
+ trans.transform(source, result);
+
+ }
+ }catch(ParserConfigurationException e) {
e.printStackTrace();
- }catch(TransformerException e){
+ }catch(TransformerException e) {
e.printStackTrace();
}
-
+
}
-
+
/**
* Validate the generated XML against the XML Schema associated with the XSSFMap
- *
+ *
* @param xml the XML to validate
* @return
*/
-
private boolean isValid(Document xml) throws SAXException{
boolean isValid = false;
try{
- String language = XMLConstants.W3C_XML_SCHEMA_NS_URI;
- SchemaFactory factory = SchemaFactory.newInstance(language);
+ String language = XMLConstants.W3C_XML_SCHEMA_NS_URI;
+ SchemaFactory factory = SchemaFactory.newInstance(language);
- Source source = new DOMSource(map.getSchema());
- Schema schema = factory.newSchema(source);
- Validator validator = schema.newValidator();
- validator.validate(new DOMSource(xml));
- //if no exceptions where raised, the document is valid
- isValid=true;
-
-
- }catch(IOException e){
+ Source source = new DOMSource(map.getSchema());
+ Schema schema = factory.newSchema(source);
+ Validator validator = schema.newValidator();
+ validator.validate(new DOMSource(xml));
+ //if no exceptions where raised, the document is valid
+ isValid=true;
+
+
+ } catch(IOException e) {
e.printStackTrace();
}
- return isValid;
+ return isValid;
}
-
-
- private void mapCellOnNode(XSSFCell cell, Node node, STXmlDataType.Enum outputDataType){
-
-
+
+
+ private void mapCellOnNode(XSSFCell cell, Node node, STXmlDataType.Enum outputDataType) {
+
String value ="";
- switch (cell.getCellType()){
-
+ switch (cell.getCellType()) {
+
case XSSFCell.CELL_TYPE_STRING: value = cell.getStringCellValue(); break;
case XSSFCell.CELL_TYPE_BOOLEAN: value += cell.getBooleanCellValue(); break;
case XSSFCell.CELL_TYPE_ERROR: value = cell.getErrorCellString(); break;
case XSSFCell.CELL_TYPE_FORMULA: value = cell.getStringCellValue(); break;
case XSSFCell.CELL_TYPE_NUMERIC: value += cell.getRawValue(); break;
default: ;
-
+
}
- if(node instanceof Element){
+ if (node instanceof Element) {
Element currentElement = (Element) node;
currentElement.setTextContent(value);
- }else{
+ } else {
node.setNodeValue(value);
- }
-
-
+ }
}
-
- private String removeNamespace(String elementName){
+
+ private String removeNamespace(String elementName) {
return elementName.matches(".*:.*")?elementName.split(":")[1]:elementName;
}
-
-
-
- private Node getNodeByXPath(String xpath,Node rootNode,Document doc,boolean createMultipleInstances){
+
+
+
+ private Node getNodeByXPath(String xpath,Node rootNode,Document doc,boolean createMultipleInstances) {
String[] xpathTokens = xpath.split("/");
-
-
+
+
Node currentNode =rootNode;
// The first token is empty, the second is the root node
- for(int i =2; i<xpathTokens.length;i++){
-
+ for(int i =2; i<xpathTokens.length;i++) {
+
String axisName = removeNamespace(xpathTokens[i]);
-
- if(!axisName.startsWith("@")){
-
- NodeList list =currentNode.getChildNodes();
-
- Node selectedNode = null;
- if(!(createMultipleInstances && i==xpathTokens.length-1) ){
- // select the last child node only if we need to map to a single cell
- selectedNode = selectNode(axisName, list);
+
+ if (!axisName.startsWith("@")) {
+
+ NodeList list =currentNode.getChildNodes();
+
+ Node selectedNode = null;
+ if (!(createMultipleInstances && i==xpathTokens.length-1) ) {
+ // select the last child node only if we need to map to a single cell
+ selectedNode = selectNode(axisName, list);
+ }
+ if (selectedNode==null) {
+ selectedNode = createElement(doc, currentNode, axisName);
}
- if(selectedNode==null){
- selectedNode = createElement(doc, currentNode, axisName);
- }
- currentNode = selectedNode;
- }else{
-
-
+ currentNode = selectedNode;
+ } else {
+
+
Node attribute = createAttribute(doc, currentNode, axisName);
-
- currentNode = attribute;
-
+
+ currentNode = attribute;
}
-
}
return currentNode;
}
@@ -360,7 +345,7 @@
String attributeName = axisName.substring(1);
NamedNodeMap attributesMap = currentNode.getAttributes();
Node attribute = attributesMap.getNamedItem(attributeName);
- if(attribute==null){
+ if (attribute==null) {
attribute = doc.createAttribute(attributeName);
attributesMap.setNamedItem(attribute);
}
@@ -369,9 +354,9 @@
private Node createElement(Document doc, Node currentNode, String axisName) {
Node selectedNode;
- if(isNamespaceDeclared()){
+ if (isNamespaceDeclared()) {
selectedNode =doc.createElementNS(getNamespace(),axisName);
- }else{
+ } else {
selectedNode =doc.createElement(axisName);
}
currentNode.appendChild(selectedNode);
@@ -380,123 +365,113 @@
private Node selectNode(String axisName, NodeList list) {
Node selectedNode = null;
- for(int j=0;j<list.getLength();j++){
+ for(int j=0;j<list.getLength();j++) {
Node node = list.item(j);
- if(node.getNodeName().equals(axisName)){
+ if (node.getNodeName().equals(axisName)) {
selectedNode=node;
break;
}
}
return selectedNode;
}
-
-
- private boolean isNamespaceDeclared(){
+
+
+ private boolean isNamespaceDeclared() {
String schemaNamespace = getNamespace();
return schemaNamespace!=null && !schemaNamespace.equals("");
}
-
- private String getNamespace(){
+
+ private String getNamespace() {
return map.getCTSchema().getNamespace();
}
-
+
/**
* Compares two xpaths to define an ordering according to the XML Schema
- *
+ *
*/
public int compare(String leftXpath, String rightXpath) {
-
- int result = 0;
+
+ int result = 0;
Node xmlSchema = map.getSchema();
-
-
-
-
+
+
String[] leftTokens = leftXpath.split("/");
String[] rightTokens = rightXpath.split("/");
-
+
int minLenght = leftTokens.length< rightTokens.length? leftTokens.length : rightTokens.length;
-
+
Node localComplexTypeRootNode = xmlSchema;
-
-
- for(int i =1;i <minLenght; i++){
-
+
+
+ for(int i =1;i <minLenght; i++) {
+
String leftElementName =leftTokens[i];
String rightElementName = rightTokens[i];
-
- if(leftElementName.equals(rightElementName)){
-
-
+
+ if (leftElementName.equals(rightElementName)) {
+
+
Node complexType = getComplexTypeForElement(leftElementName, xmlSchema,localComplexTypeRootNode);
- localComplexTypeRootNode = complexType;
- }else{
+ localComplexTypeRootNode = complexType;
+ } else {
int leftIndex = indexOfElementInComplexType(leftElementName,localComplexTypeRootNode);
int rightIndex = indexOfElementInComplexType(rightElementName,localComplexTypeRootNode);
- if(leftIndex!=-1 && rightIndex!=-1){
- if( leftIndex < rightIndex){
+ if (leftIndex!=-1 && rightIndex!=-1) {
+ if ( leftIndex < rightIndex) {
result = -1;
- }if( leftIndex > rightIndex){
- result = 1;
+ }if ( leftIndex > rightIndex) {
+ result = 1;
}
- }else{
+ } else {
// NOTE: the xpath doesn't match correctly in the schema
}
-
-
}
-
}
-
-
-
-
+
return result;
}
-
- private int indexOfElementInComplexType(String elementName,Node complexType){
-
+
+ private int indexOfElementInComplexType(String elementName,Node complexType) {
+
NodeList list = complexType.getChildNodes();
int indexOf = -1;
-
- for(int i=0; i< list.getLength();i++){
+
+ for(int i=0; i< list.getLength();i++) {
Node node = list.item(i);
- if(node instanceof Element){
- if(node.getLocalName().equals("element")){
+ if (node instanceof Element) {
+ if (node.getLocalName().equals("element")) {
Node nameAttribute = node.getAttributes().getNamedItem("name");
- if(nameAttribute.getNodeValue().equals(removeNamespace(elementName))){
+ if (nameAttribute.getNodeValue().equals(removeNamespace(elementName))) {
indexOf = i;
break;
}
-
+
}
}
}
-
return indexOf;
-
}
-
- private Node getComplexTypeForElement(String elementName,Node xmlSchema,Node localComplexTypeRootNode){
+
+ private Node getComplexTypeForElement(String elementName,Node xmlSchema,Node localComplexTypeRootNode) {
Node complexTypeNode = null;
-
+
String elementNameWithoutNamespace = removeNamespace(elementName);
-
+
NodeList list = localComplexTypeRootNode.getChildNodes();
String complexTypeName = "";
-
-
- for(int i=0; i< list.getLength();i++){
+
+
+ for(int i=0; i< list.getLength();i++) {
Node node = list.item(i);
- if( node instanceof Element){
- if(node.getLocalName().equals("element")){
+ if ( node instanceof Element) {
+ if (node.getLocalName().equals("element")) {
Node nameAttribute = node.getAttributes().getNamedItem("name");
- if(nameAttribute.getNodeValue().equals(elementNameWithoutNamespace)){
+ if (nameAttribute.getNodeValue().equals(elementNameWithoutNamespace)) {
Node complexTypeAttribute = node.getAttributes().getNamedItem("type");
- if(complexTypeAttribute!=null){
+ if (complexTypeAttribute!=null) {
complexTypeName = complexTypeAttribute.getNodeValue();
break;
}
@@ -505,40 +480,35 @@
}
}
// Note: we expect that all the complex types are defined at root level
- if(!complexTypeName.equals("")){
+ if (!"".equals(complexTypeName)) {
NodeList complexTypeList = xmlSchema.getChildNodes();
- for(int i=0; i< complexTypeList.getLength();i++){
+ for(int i=0; i< complexTypeList.getLength();i++) {
Node node = list.item(i);
- if( node instanceof Element){
- if(node.getLocalName().equals("complexType")){
+ if ( node instanceof Element) {
+ if (node.getLocalName().equals("complexType")) {
Node nameAttribute = node.getAttributes().getNamedItem("name");
- if(nameAttribute.getNodeValue().equals(complexTypeName)){
-
+ if (nameAttribute.getNodeValue().equals(complexTypeName)) {
+
NodeList complexTypeChildList =node.getChildNodes();
- for(int j=0; j<complexTypeChildList.getLength();j++){
+ for(int j=0; j<complexTypeChildList.getLength();j++) {
Node sequence = complexTypeChildList.item(j);
-
- if( sequence instanceof Element){
- if(sequence.getLocalName().equals("sequence")){
+
+ if ( sequence instanceof Element) {
+ if (sequence.getLocalName().equals("sequence")) {
complexTypeNode = sequence;
break;
}
}
}
- if(complexTypeNode!=null){
+ if (complexTypeNode!=null) {
break;
}
-
+
}
}
}
}
}
-
return complexTypeNode;
-
-
}
-
-
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/Borders.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/Borders.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/Borders.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/Borders.java Thu Oct 8 22:29:41 2009
@@ -612,12 +612,12 @@
private static Map<Integer, Borders> imap = new HashMap<Integer, Borders>();
static {
for (Borders p : values()) {
- imap.put(new Integer(p.getValue()), p);
+ imap.put(Integer.valueOf(p.getValue()), p);
}
}
public static Borders valueOf(int type) {
- Borders pBorder = imap.get(new Integer(type));
+ Borders pBorder = imap.get(Integer.valueOf(type));
if (pBorder == null) {
throw new IllegalArgumentException("Unknown paragraph border: " + type);
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/TOC.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/TOC.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/TOC.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/TOC.java Thu Oct 8 22:29:41 2009
@@ -23,13 +23,13 @@
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTheme;
public class TOC {
-
+
CTSdtBlock block;
-
+
public TOC() {
this(CTSdtBlock.Factory.newInstance());
}
-
+
public TOC(CTSdtBlock block) {
this.block = block;
CTSdtPr sdtPr = block.addNewSdtPr();
@@ -55,11 +55,11 @@
p.addNewPPr().addNewPStyle().setVal("TOCHeading");
p.addNewR().addNewT().set("Table of Contents");
}
-
+
public CTSdtBlock getBlock() {
return this.block;
}
-
+
public void addRow(int level, String title, int page, String bookmarkRef) {
CTSdtContentBlock contentBlock = this.block.getSdtContent();
CTP p = contentBlock.addNewP();
@@ -96,11 +96,9 @@
// page number run
run = p.addNewR();
run.addNewRPr().addNewNoProof();
- run.addNewT().set(new Integer(page).toString());
+ run.addNewT().set(Integer.valueOf(page).toString());
run = p.addNewR();
run.addNewRPr().addNewNoProof();
run.addNewFldChar().setFldCharType(STFldCharType.END);
-
}
-
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java Thu Oct 8 22:29:41 2009
@@ -66,7 +66,7 @@
//build a tree of POIXMLDocumentParts, this document being the root
load(XWPFFactory.getInstance());
}
-
+
public XWPFDocument(InputStream is) throws IOException {
super(PackageHelper.open(is));
@@ -97,7 +97,7 @@
initFootnotes();
// filling paragraph list
- for (CTP p : body.getPArray()) {
+ for (CTP p : body.getPArray()) {
paragraphs.add(new XWPFParagraph(p, this));
}
@@ -128,7 +128,7 @@
private void initHyperlinks(){
// Get the hyperlinks
// TODO: make me optional/separated in private function
- try {
+ try {
Iterator <PackageRelationship> relIter =
getPackagePart().getRelationshipsByType(XWPFRelation.HYPERLINK.getRelation()).iterator();
while(relIter.hasNext()) {
@@ -164,7 +164,7 @@
*/
protected static OPCPackage newPackage() {
try {
- OPCPackage pkg = OPCPackage.create(PackageHelper.createTempFile());
+ OPCPackage pkg = OPCPackage.create(PackageHelper.createTempFile());
// Main part
PackagePartName corePartName = PackagingURIHelper.createPartName(XWPFRelation.DOCUMENT.getDefaultFileName());
// Create main part relationship
@@ -355,13 +355,13 @@
/**
* Create an empty table with one row and one column as default.
- *
+ *
* @return a new table
*/
public XWPFTable createTable(){
return new XWPFTable(this, ctDocument.getBody().addNewTbl());
}
-
+
/**
* Create an empty table with a number of rows and cols specified
* @param rows
@@ -369,26 +369,25 @@
* @return table
*/
public XWPFTable createTable(int rows, int cols) {
- return new XWPFTable(this, ctDocument.getBody().addNewTbl(), rows, cols);
+ return new XWPFTable(this, ctDocument.getBody().addNewTbl(), rows, cols);
}
-
+
public void createTOC() {
- CTSdtBlock block = this.getDocument().getBody().addNewSdt();
- TOC toc = new TOC(block);
- int i = 1;
- for (Iterator<XWPFParagraph> iterator = getParagraphsIterator() ; iterator.hasNext() ; ) {
- XWPFParagraph par = iterator.next();
- String parStyle = par.getStyle();
- if (parStyle != null && parStyle.substring(0, 7).equals("Heading")) {
- try {
- int level = new Integer(parStyle.substring("Heading".length()));
- toc.addRow(level, par.getText(), 1, "112723803");
- }
- catch (NumberFormatException e) {
- e.printStackTrace();
- }
- }
- }
+ CTSdtBlock block = this.getDocument().getBody().addNewSdt();
+ TOC toc = new TOC(block);
+ int i = 1;
+ for (Iterator<XWPFParagraph> iterator = getParagraphsIterator() ; iterator.hasNext() ; ) {
+ XWPFParagraph par = iterator.next();
+ String parStyle = par.getStyle();
+ if (parStyle != null && parStyle.substring(0, 7).equals("Heading")) {
+ try {
+ int level = Integer.valueOf(parStyle.substring("Heading".length()));
+ toc.addRow(level, par.getText(), 1, "112723803");
+ }
+ catch (NumberFormatException e) {
+ e.printStackTrace();
+ }
+ }
+ }
}
}
-
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hdf/extractor/WordDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hdf/extractor/WordDocument.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hdf/extractor/WordDocument.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hdf/extractor/WordDocument.java Thu Oct 8 22:29:41 2009
@@ -394,7 +394,7 @@
byte[] chpx = new byte[size];
System.arraycopy(fkp, ++chpxOffset, chpx, 0, size);
- //_papTable.put(new Integer(fcStart), papx);
+ //_papTable.put(Integer.valueOf(fcStart), papx);
_characterTable.add(new ChpxNode(fcStart, fcEnd, chpx));
}
@@ -734,12 +734,12 @@
lineWidth += 10 * tempString.length();//metrics.stringWidth(tempString);
if(lineWidth > pageWidth)
{
- lineHeights.add(new Integer(maxHeight));
+ lineHeights.add(Integer.valueOf(maxHeight));
maxHeight = 0;
lineWidth = 0;
}
}
- lineHeights.add(new Integer(maxHeight));
+ lineHeights.add(Integer.valueOf(maxHeight));
}
int sum = 0;
size = lineHeights.size();
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hdf/extractor/data/ListTables.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hdf/extractor/data/ListTables.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hdf/extractor/data/ListTables.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hdf/extractor/data/ListTables.java Thu Oct 8 22:29:41 2009
@@ -51,14 +51,14 @@
LFOLVL lfolvl = override._levels[x];
if(lfolvl._fFormatting)
{
- LST lst = (LST)_lists.get(new Integer(override._lsid));
+ LST lst = (LST)_lists.get(Integer.valueOf(override._lsid));
LVL lvl = lfolvl._override;
lvl._istd = Utils.convertBytesToShort(lst._rgistd, level * 2);
return lvl;
}
else if(lfolvl._fStartAt)
{
- LST lst = (LST)_lists.get(new Integer(override._lsid));
+ LST lst = (LST)_lists.get(Integer.valueOf(override._lsid));
LVL lvl = lst._levels[level];
LVL newLvl = (LVL)lvl.clone();
newLvl._istd = Utils.convertBytesToShort(lst._rgistd, level * 2);
@@ -68,7 +68,7 @@
}
}
- LST lst = (LST)_lists.get(new Integer(override._lsid));
+ LST lst = (LST)_lists.get(Integer.valueOf(override._lsid));
LVL lvl = lst._levels[level];
lvl._istd = Utils.convertBytesToShort(lst._rgistd, level * 2);
return lvl;
@@ -89,7 +89,7 @@
byte code = plcflst[2 + 26 + (x * 28)];
lst._fSimpleList = StyleSheet.getFlag(code & 0x01);
//lstArray[x] = lst;
- _lists.put(new Integer(lst._lsid), lst);
+ _lists.put(Integer.valueOf(lst._lsid), lst);
if(lst._fSimpleList)
{
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hdf/extractor/util/BTreeSet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hdf/extractor/util/BTreeSet.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hdf/extractor/util/BTreeSet.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hdf/extractor/util/BTreeSet.java Thu Oct 8 22:29:41 2009
@@ -161,7 +161,7 @@
while (temp._entries[0].child != null) {
temp = temp._entries[0].child;
- parentIndex.push(new Integer(0));
+ parentIndex.push(Integer.valueOf(0));
}
return temp;
@@ -193,11 +193,11 @@
// else - You're not a leaf so simply find and return the successor of lastReturned
currentNode = currentNode._entries[index].child;
- parentIndex.push(new Integer(index));
+ parentIndex.push(Integer.valueOf(index));
while (currentNode._entries[0].child != null) {
currentNode = currentNode._entries[0].child;
- parentIndex.push(new Integer(0));
+ parentIndex.push(Integer.valueOf(0));
}
index = 1;
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hdf/model/HDFObjectFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hdf/model/HDFObjectFactory.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hdf/model/HDFObjectFactory.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hdf/model/HDFObjectFactory.java Thu Oct 8 22:29:41 2009
@@ -345,7 +345,7 @@
byte[] chpx = new byte[size];
System.arraycopy(fkp, ++chpxOffset, chpx, 0, size);
- //_papTable.put(new Integer(fcStart), papx);
+ //_papTable.put(Integer.valueOf(fcStart), papx);
_characterRuns.add(new ChpxNode(fcStart, fcEnd, chpx));
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/ListTables.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/ListTables.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/ListTables.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/ListTables.java Thu Oct 8 22:29:41 2009
@@ -51,14 +51,14 @@
LFOLVL lfolvl = override._levels[x];
if(lfolvl._fFormatting)
{
- LST lst = (LST)_lists.get(new Integer(override._lsid));
+ LST lst = (LST)_lists.get(Integer.valueOf(override._lsid));
LVL lvl = lfolvl._override;
lvl._istd = Utils.convertBytesToShort(lst._rgistd, level * 2);
return lvl;
}
else if(lfolvl._fStartAt)
{
- LST lst = (LST)_lists.get(new Integer(override._lsid));
+ LST lst = (LST)_lists.get(Integer.valueOf(override._lsid));
LVL lvl = lst._levels[level];
LVL newLvl = (LVL)lvl.clone();
newLvl._istd = Utils.convertBytesToShort(lst._rgistd, level * 2);
@@ -68,7 +68,7 @@
}
}
- LST lst = (LST)_lists.get(new Integer(override._lsid));
+ LST lst = (LST)_lists.get(Integer.valueOf(override._lsid));
LVL lvl = lst._levels[level];
lvl._istd = Utils.convertBytesToShort(lst._rgistd, level * 2);
return lvl;
@@ -89,7 +89,7 @@
byte code = plcflst[2 + 26 + (x * 28)];
lst._fSimpleList = StyleSheet.getFlag(code & 0x01);
//lstArray[x] = lst;
- _lists.put(new Integer(lst._lsid), lst);
+ _lists.put(Integer.valueOf(lst._lsid), lst);
if(lst._fSimpleList)
{
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hdf/model/util/BTreeSet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hdf/model/util/BTreeSet.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hdf/model/util/BTreeSet.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hdf/model/util/BTreeSet.java Thu Oct 8 22:29:41 2009
@@ -235,7 +235,7 @@
while (temp.entries[0].child != null)
{
temp = temp.entries[0].child;
- parentIndex.push(new Integer(0));
+ parentIndex.push(Integer.valueOf(0));
}
return temp;
@@ -272,12 +272,12 @@
// else - You're not a leaf so simply find and return the successor of lastReturned
currentNode = currentNode.entries[index].child;
- parentIndex.push(new Integer(index));
+ parentIndex.push(Integer.valueOf(index));
while (currentNode.entries[0].child != null)
{
currentNode = currentNode.entries[0].child;
- parentIndex.push(new Integer(0));
+ parentIndex.push(Integer.valueOf(0));
}
index = 1;
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/Chunk.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/Chunk.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/Chunk.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/Chunk.java Thu Oct 8 22:29:41 2009
@@ -166,10 +166,10 @@
// Types 0->7 = a flat at bit 0->7
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
int val = contents[offset] & (1<<type);
- command.value = new Boolean( (val > 0) );
+ command.value = Boolean.valueOf(val > 0);
break;
case 8:
- command.value = new Byte( contents[offset] );
+ command.value = Byte.valueOf(contents[offset]);
break;
case 9:
command.value = new Double(
@@ -195,12 +195,12 @@
command.value = StringUtil.getFromUnicodeLE(contents, startsAt, strLen);
break;
case 25:
- command.value = new Short(
+ command.value = Short.valueOf(
LittleEndian.getShort(contents, offset)
);
break;
case 26:
- command.value = new Integer(
+ command.value = Integer.valueOf(
LittleEndian.getInt(contents, offset)
);
break;
@@ -273,7 +273,7 @@
}
private void setOffset(int offset) {
this.offset = offset;
- value = new Integer(offset);
+ value = Integer.valueOf(offset);
}
}
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkFactory.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkFactory.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkFactory.java Thu Oct 8 22:29:41 2009
@@ -98,7 +98,7 @@
defsL.toArray(new CommandDefinition[defsL.size()]);
// Add to the hashtable
- chunkCommandDefinitions.put(new Integer(chunkType), defs);
+ chunkCommandDefinitions.put(Integer.valueOf(chunkType), defs);
}
inp.close();
cpd.close();
@@ -171,7 +171,7 @@
// Feed in the stuff from chunks_parse_cmds.tbl
CommandDefinition[] defs = (CommandDefinition[])
- chunkCommandDefinitions.get(new Integer(header.getType()));
+ chunkCommandDefinitions.get(Integer.valueOf(header.getType()));
if(defs == null) defs = new CommandDefinition[0];
chunk.commandDefinitions = defs;
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/EncryptedSlideShow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/EncryptedSlideShow.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/EncryptedSlideShow.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/EncryptedSlideShow.java Thu Oct 8 22:29:41 2009
@@ -117,7 +117,7 @@
int offset = (
(Integer)pph.getSlideLocationsLookup().get(
- new Integer(maxSlideId)
+ Integer.valueOf(maxSlideId)
) ).intValue();
Record r3 = Record.buildRecordAtOffset(
hss.getUnderlyingBytes(),
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java Thu Oct 8 22:29:41 2009
@@ -231,11 +231,11 @@
HashMap offset2id = new HashMap();
while (usrOffset != 0){
UserEditAtom usr = (UserEditAtom) Record.buildRecordAtOffset(docstream, usrOffset);
- lst.add(new Integer(usrOffset));
+ lst.add(Integer.valueOf(usrOffset));
int psrOffset = usr.getPersistPointersOffset();
PersistPtrHolder ptr = (PersistPtrHolder)Record.buildRecordAtOffset(docstream, psrOffset);
- lst.add(new Integer(psrOffset));
+ lst.add(Integer.valueOf(psrOffset));
Hashtable entries = ptr.getSlideLocationsLookup();
for (Iterator it = entries.keySet().iterator(); it.hasNext(); ) {
Integer id = (Integer)it.next();
@@ -401,7 +401,7 @@
int oldPos = pdr.getLastOnDiskOffset();
int newPos = baos.size();
pdr.setLastOnDiskOffset(newPos);
- oldToNewPositions.put(new Integer(oldPos),new Integer(newPos));
+ oldToNewPositions.put(Integer.valueOf(oldPos),Integer.valueOf(newPos));
//System.out.println(oldPos + " -> " + newPos);
}
@@ -438,7 +438,7 @@
// Update and write out the Current User atom
int oldLastUserEditAtomPos = (int)currentUser.getCurrentEditOffset();
- Integer newLastUserEditAtomPos = (Integer)oldToNewPositions.get(new Integer(oldLastUserEditAtomPos));
+ Integer newLastUserEditAtomPos = (Integer)oldToNewPositions.get(Integer.valueOf(oldLastUserEditAtomPos));
if(newLastUserEditAtomPos == null) {
throw new HSLFException("Couldn't find the new location of the UserEditAtom that used to be at " + oldLastUserEditAtomPos);
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java Thu Oct 8 22:29:41 2009
@@ -124,7 +124,7 @@
int[] sheetIDs = pph.getKnownSlideIDs();
Hashtable sheetOffsets = pph.getSlideLocationsLookup();
for(int j=0; j<sheetIDs.length; j++) {
- Integer id = new Integer(sheetIDs[j]);
+ Integer id = Integer.valueOf(sheetIDs[j]);
Integer offset = (Integer)sheetOffsets.get(id);
System.out.println(" Knows about sheet " + id);
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/UserEditAndPersistListing.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/UserEditAndPersistListing.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/UserEditAndPersistListing.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/UserEditAndPersistListing.java Thu Oct 8 22:29:41 2009
@@ -63,7 +63,7 @@
int[] sheetIDs = pph.getKnownSlideIDs();
Hashtable sheetOffsets = pph.getSlideLocationsLookup();
for(int j=0; j<sheetIDs.length; j++) {
- Integer id = new Integer(sheetIDs[j]);
+ Integer id = Integer.valueOf(sheetIDs[j]);
Integer offset = (Integer)sheetOffsets.get(id);
System.out.println(" Knows about sheet " + id);
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java Thu Oct 8 22:29:41 2009
@@ -237,7 +237,7 @@
if (notes == null) {
continue;
}
- Integer id = new Integer(notes._getSheetNumber());
+ Integer id = Integer.valueOf(notes._getSheetNumber());
if (seenNotes.contains(id)) {
continue;
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeTypes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeTypes.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeTypes.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeTypes.java Thu Oct 8 22:29:41 2009
@@ -34,7 +34,7 @@
* @return the name of the shape
*/
public static String typeName(int type) {
- String name = (String)types.get(new Integer(type));
+ String name = (String)types.get(Integer.valueOf(type));
return name;
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/CString.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/CString.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/CString.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/CString.java Thu Oct 8 22:29:41 2009
@@ -38,7 +38,7 @@
/** The bytes that make up the text */
private byte[] _text;
- /** Grabs the text. */
+ /** Grabs the text. Never <code>null</code> */
public String getText() {
return StringUtil.getFromUnicodeLE(_text);
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java Thu Oct 8 22:29:41 2009
@@ -98,10 +98,10 @@
System.arraycopy(_ptrData,0,newPtrData,0,_ptrData.length);
// Add to the slide location lookup hash
- _slideLocations.put(new Integer(slideID), new Integer(posOnDisk));
+ _slideLocations.put(Integer.valueOf(slideID), Integer.valueOf(posOnDisk));
// Add to the ptrData offset lookup hash
- _slideOffsetDataLocation.put(new Integer(slideID),
- new Integer(_ptrData.length + 4));
+ _slideOffsetDataLocation.put(Integer.valueOf(slideID),
+ Integer.valueOf(_ptrData.length + 4));
// Build the info block
// First 20 bits = offset number = slide ID
@@ -163,8 +163,8 @@
for(int i=0; i<offset_count; i++) {
int sheet_no = offset_no + i;
long sheet_offset = LittleEndian.getUInt(_ptrData,pos);
- _slideLocations.put(new Integer(sheet_no), new Integer((int)sheet_offset));
- _slideOffsetDataLocation.put(new Integer(sheet_no), new Integer(pos));
+ _slideLocations.put(Integer.valueOf(sheet_no), Integer.valueOf((int)sheet_offset));
+ _slideOffsetDataLocation.put(Integer.valueOf(sheet_no), Integer.valueOf(pos));
// Wind on by 4 bytes per sheet found
pos += 4;
@@ -188,7 +188,7 @@
// Find where they used to live, and where they now live
// Then, update the right bit of _ptrData with their new location
for(int i=0; i<slideIDs.length; i++) {
- Integer id = new Integer(slideIDs[i]);
+ Integer id = Integer.valueOf(slideIDs[i]);
Integer oldPos = (Integer)_slideLocations.get(id);
Integer newPos = (Integer)oldToNewReferencesLookup.get(oldPos);
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java Thu Oct 8 22:29:41 2009
@@ -179,7 +179,7 @@
// Grab the right constructor
java.lang.reflect.Constructor con = c.getDeclaredConstructor(new Class[] { byte[].class, Integer.TYPE, Integer.TYPE });
// Instantiate
- toReturn = (Record)(con.newInstance(new Object[] { b, new Integer(start), new Integer(len) }));
+ toReturn = (Record)(con.newInstance(new Object[] { b, Integer.valueOf(start), Integer.valueOf(len) }));
} catch(InstantiationException ie) {
throw new RuntimeException("Couldn't instantiate the class for type with id " + type + " on class " + c + " : " + ie, ie);
} catch(java.lang.reflect.InvocationTargetException ite) {
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordContainer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordContainer.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordContainer.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordContainer.java Thu Oct 8 22:29:41 2009
@@ -36,7 +36,7 @@
public abstract class RecordContainer extends Record
{
protected Record[] _children;
- private Boolean changingChildRecordsLock = new Boolean(true);
+ private Boolean changingChildRecordsLock = Boolean.TRUE;
/**
* Return any children
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org