Added Apache License text to files where it was missing. Also fixed some compiler warnings in those files.

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@745976 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2009-02-19 19:50:20 +00:00
parent d527d61af4
commit 3e6f2bbf80
13 changed files with 363 additions and 232 deletions

View File

@ -43,7 +43,7 @@ public class EscherContainerRecord extends EscherRecord
public static final short SP_CONTAINER = (short)0xF004; public static final short SP_CONTAINER = (short)0xF004;
public static final short SOLVER_CONTAINER = (short)0xF005; public static final short SOLVER_CONTAINER = (short)0xF005;
private List childRecords = new ArrayList(); private final List<EscherRecord> _childRecords = new ArrayList<EscherRecord>();
public int fillFields( byte[] data, int offset, EscherRecordFactory recordFactory ) public int fillFields( byte[] data, int offset, EscherRecordFactory recordFactory )
{ {
@ -120,9 +120,8 @@ public class EscherContainerRecord extends EscherRecord
* Returns a list of all the child (escher) records * Returns a list of all the child (escher) records
* of the container. * of the container.
*/ */
public List getChildRecords() public List<EscherRecord> getChildRecords() {
{ return _childRecords;
return childRecords;
} }
/** /**
@ -142,15 +141,13 @@ public class EscherContainerRecord extends EscherRecord
return containers; return containers;
} }
public void setChildRecords( List childRecords ) public void setChildRecords(List<EscherRecord> childRecords) {
{ _childRecords.clear();
this.childRecords = childRecords; _childRecords.addAll(childRecords);
} }
public String getRecordName() public String getRecordName() {
{ switch (getRecordId()) {
switch ((short)getRecordId())
{
case DGG_CONTAINER: case DGG_CONTAINER:
return "DggContainer"; return "DggContainer";
case BSTORE_CONTAINER: case BSTORE_CONTAINER:
@ -171,16 +168,15 @@ public class EscherContainerRecord extends EscherRecord
public void display( PrintWriter w, int indent ) public void display( PrintWriter w, int indent )
{ {
super.display( w, indent ); super.display( w, indent );
for ( Iterator iterator = childRecords.iterator(); iterator.hasNext(); ) for (Iterator iterator = _childRecords.iterator(); iterator.hasNext();)
{ {
EscherRecord escherRecord = (EscherRecord) iterator.next(); EscherRecord escherRecord = (EscherRecord) iterator.next();
escherRecord.display( w, indent + 1 ); escherRecord.display( w, indent + 1 );
} }
} }
public void addChildRecord( EscherRecord record ) public void addChildRecord(EscherRecord record) {
{ _childRecords.add( record );
this.childRecords.add( record );
} }
public String toString() public String toString()
@ -226,7 +222,7 @@ public class EscherContainerRecord extends EscherRecord
public EscherSpRecord getChildById( short recordId ) public EscherSpRecord getChildById( short recordId )
{ {
for ( Iterator iterator = childRecords.iterator(); iterator.hasNext(); ) for ( Iterator iterator = _childRecords.iterator(); iterator.hasNext(); )
{ {
EscherRecord escherRecord = (EscherRecord) iterator.next(); EscherRecord escherRecord = (EscherRecord) iterator.next();
if (escherRecord.getRecordId() == recordId) if (escherRecord.getRecordId() == recordId)
@ -241,7 +237,7 @@ public class EscherContainerRecord extends EscherRecord
* @param out - list to store found records * @param out - list to store found records
*/ */
public void getRecordsById(short recordId, List out){ public void getRecordsById(short recordId, List out){
for(Iterator it = childRecords.iterator(); it.hasNext();) { for(Iterator it = _childRecords.iterator(); it.hasNext();) {
Object er = it.next(); Object er = it.next();
EscherRecord r = (EscherRecord)er; EscherRecord r = (EscherRecord)er;
if(r instanceof EscherContainerRecord) { if(r instanceof EscherContainerRecord) {

View File

@ -30,16 +30,15 @@ import java.util.List;
* *
* @author Glen Stampoultzis * @author Glen Stampoultzis
*/ */
abstract public class EscherRecord public abstract class EscherRecord {
{ private short _options;
private short options; private short _recordId;
private short recordId;
/** /**
* Create a new instance * Create a new instance
*/ */
public EscherRecord() public EscherRecord() {
{ // fields uninitialised
} }
/** /**
@ -73,11 +72,10 @@ abstract public class EscherRecord
* @return the number of bytes remaining in this record. This * @return the number of bytes remaining in this record. This
* may include the children if this is a container. * may include the children if this is a container.
*/ */
protected int readHeader( byte[] data, int offset ) protected int readHeader( byte[] data, int offset ) {
{
EscherRecordHeader header = EscherRecordHeader.readHeader(data, offset); EscherRecordHeader header = EscherRecordHeader.readHeader(data, offset);
options = header.getOptions(); _options = header.getOptions();
recordId = header.getRecordId(); _recordId = header.getRecordId();
return header.getRemainingBytes(); return header.getRemainingBytes();
} }
@ -86,26 +84,23 @@ abstract public class EscherRecord
* field. * field.
* @return true is this is a container field. * @return true is this is a container field.
*/ */
public boolean isContainerRecord() public boolean isContainerRecord() {
{ return (_options & (short)0x000f) == (short)0x000f;
return (options & (short)0x000f) == (short)0x000f;
} }
/** /**
* @return The options field for this record. All records have one. * @return The options field for this record. All records have one.
*/ */
public short getOptions() public short getOptions() {
{ return _options;
return options;
} }
/** /**
* Set the options this this record. Container records should have the * Set the options this this record. Container records should have the
* last nibble set to 0xF. * last nibble set to 0xF.
*/ */
public void setOptions( short options ) public void setOptions( short options ) {
{ _options = options;
this.options = options;
} }
/** /**
@ -164,17 +159,15 @@ abstract public class EscherRecord
* *
* @return The 16 bit record id. * @return The 16 bit record id.
*/ */
public short getRecordId() public short getRecordId() {
{ return _recordId;
return recordId;
} }
/** /**
* Sets the record id for this record. * Sets the record id for this record.
*/ */
public void setRecordId( short recordId ) public void setRecordId( short recordId ) {
{ _recordId = recordId;
this.recordId = recordId;
} }
/** /**
@ -184,7 +177,7 @@ abstract public class EscherRecord
* *
* @see EscherContainerRecord * @see EscherContainerRecord
*/ */
public List getChildRecords() { return Collections.EMPTY_LIST; } public List<EscherRecord> getChildRecords() { return Collections.emptyList(); }
/** /**
* Sets the child records for this record. By default this will throw * Sets the child records for this record. By default this will throw
@ -192,7 +185,9 @@ abstract public class EscherRecord
* *
* @param childRecords Not used in base implementation. * @param childRecords Not used in base implementation.
*/ */
public void setChildRecords( List childRecords ) { throw new IllegalArgumentException("This record does not support child records."); } public void setChildRecords(List<EscherRecord> childRecords) {
throw new UnsupportedOperationException("This record does not support child records.");
}
/** /**
* Escher records may need to be clonable in the future. * Escher records may need to be clonable in the future.
@ -205,9 +200,8 @@ abstract public class EscherRecord
/** /**
* Returns the indexed child record. * Returns the indexed child record.
*/ */
public EscherRecord getChild( int index ) public EscherRecord getChild( int index ) {
{ return getChildRecords().get(index);
return (EscherRecord) getChildRecords().get(index);
} }
/** /**
@ -233,9 +227,8 @@ abstract public class EscherRecord
* *
* @return The instance part of the record * @return The instance part of the record
*/ */
public short getInstance() public short getInstance() {
{ return (short) ( _options >> 4 );
return (short) ( options >> 4 );
} }
/** /**
@ -247,8 +240,8 @@ abstract public class EscherRecord
private short recordId; private short recordId;
private int remainingBytes; private int remainingBytes;
private EscherRecordHeader() private EscherRecordHeader() {
{ // fields uninitialised
} }
public static EscherRecordHeader readHeader( byte[] data, int offset ) public static EscherRecordHeader readHeader( byte[] data, int offset )
@ -284,8 +277,5 @@ abstract public class EscherRecord
", remainingBytes=" + remainingBytes + ", remainingBytes=" + remainingBytes +
"}"; "}";
} }
} }
} }

View File

@ -1,5 +1,27 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hssf.record.formula.eval; package org.apache.poi.hssf.record.formula.eval;
/**
* Common base class for implementors of {@link RefEval}
*
* @author Josh Micich
*/
public abstract class RefEvalBase implements RefEval { public abstract class RefEvalBase implements RefEval {
private final int _rowIndex; private final int _rowIndex;

View File

@ -1,3 +1,20 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.xssf.usermodel; package org.apache.poi.xssf.usermodel;
import java.io.IOException; import java.io.IOException;
@ -9,43 +26,47 @@ import org.apache.poi.xssf.model.XSSFWritableModel;
import org.apache.poi.POIXMLException; import org.apache.poi.POIXMLException;
import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackagePart;
public class XSSFActiveXData implements PictureData, XSSFWritableModel { /**
*
* @author Nick Burch
*/
public final class XSSFActiveXData implements PictureData, XSSFWritableModel {
private PackagePart packagePart; private final PackagePart _packagePart;
private String originalId; private final String _originalId;
public XSSFActiveXData(PackagePart packagePart, String originalId) { public XSSFActiveXData(PackagePart packagePart, String originalId) {
this(packagePart); _packagePart = packagePart;
this.originalId = originalId; _originalId = originalId;
} }
public XSSFActiveXData(PackagePart packagePart) { public XSSFActiveXData(PackagePart packagePart) {
this.packagePart = packagePart; this(packagePart, null);
} }
public String getOriginalId() { public String getOriginalId() {
return originalId; return _originalId;
} }
public PackagePart getPart() { public PackagePart getPart() {
return packagePart; return _packagePart;
} }
public void writeTo(OutputStream out) throws IOException { public void writeTo(OutputStream out) throws IOException {
IOUtils.copy(packagePart.getInputStream(), out); IOUtils.copy(_packagePart.getInputStream(), out);
} }
public byte[] getData() { public byte[] getData() {
// TODO - is this right? // TODO - is this right?
// Are there headers etc? // Are there headers etc?
try { try {
return IOUtils.toByteArray(packagePart.getInputStream()); return IOUtils.toByteArray(_packagePart.getInputStream());
} catch(IOException e) { } catch(IOException e) {
throw new POIXMLException(e); throw new POIXMLException(e);
} }
} }
public String suggestFileExtension() { public String suggestFileExtension() {
return packagePart.getPartName().getExtension(); return _packagePart.getPartName().getExtension();
} }
} }

View File

@ -1,3 +1,20 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.xssf.usermodel; package org.apache.poi.xssf.usermodel;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -105,7 +122,7 @@ public final class TestXSSFFont extends TestCase{
assertEquals(11,xssfFont.getFontHeight()); assertEquals(11,xssfFont.getFontHeight());
xssfFont.setFontHeight((short)20); xssfFont.setFontHeight((short)20);
assertEquals(new Double(20).doubleValue(),ctFont.getSzArray(0).getVal()); assertEquals(20.0, ctFont.getSzArray(0).getVal(), 0.0);
} }
public void testFontHeightInPoint() { public void testFontHeightInPoint() {
@ -118,7 +135,7 @@ public final class TestXSSFFont extends TestCase{
assertEquals(14,xssfFont.getFontHeightInPoints()); assertEquals(14,xssfFont.getFontHeightInPoints());
xssfFont.setFontHeightInPoints((short)20); xssfFont.setFontHeightInPoints((short)20);
assertEquals(new Double(20).doubleValue(),ctFont.getSzArray(0).getVal()); assertEquals(20.0, ctFont.getSzArray(0).getVal(), 0.0);
} }
public void testUnderline() { public void testUnderline() {
@ -353,8 +370,8 @@ public final class TestXSSFFont extends TestCase{
XSSFSheet s = wb.createSheet(); XSSFSheet s = wb.createSheet();
s.createRow(0); s.createRow(0);
s.createRow(1); s.createRow(1);
XSSFCell c1 = s.getRow(0).createCell(0); s.getRow(0).createCell(0);
XSSFCell c2 = s.getRow(1).createCell(0); s.getRow(1).createCell(0);
assertEquals(1, wb.getNumberOfFonts()); assertEquals(1, wb.getNumberOfFonts());
@ -364,10 +381,7 @@ public final class TestXSSFFont extends TestCase{
// Check that asking for the same font // Check that asking for the same font
// multiple times gives you the same thing. // multiple times gives you the same thing.
// Otherwise, our tests wouldn't work! // Otherwise, our tests wouldn't work!
assertEquals( assertEquals(wb.getFontAt((short)0), wb.getFontAt((short)0));
wb.getFontAt((short)0),
wb.getFontAt((short)0)
);
// Look for a new font we have // Look for a new font we have
// yet to add // yet to add
@ -396,15 +410,8 @@ public final class TestXSSFFont extends TestCase{
assertEquals(2, wb.getNumberOfFonts()); assertEquals(2, wb.getNumberOfFonts());
assertEquals(nf, wb.getFontAt((short)1)); assertEquals(nf, wb.getFontAt((short)1));
assertEquals( assertEquals(wb.getFontAt((short)1), wb.getFontAt((short)1));
wb.getFontAt((short)1), assertTrue(wb.getFontAt((short)0) != wb.getFontAt((short)1));
wb.getFontAt((short)1)
);
assertTrue(
wb.getFontAt((short)0)
!=
wb.getFontAt((short)1)
);
// Find it now // Find it now
assertNotNull( assertNotNull(

View File

@ -1,3 +1,20 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hslf.model; package org.apache.poi.hslf.model;
import org.apache.poi.ddf.*; import org.apache.poi.ddf.*;
@ -15,7 +32,7 @@ import java.util.Iterator;
* TODO: finish * TODO: finish
* @author Yegor Kozlov * @author Yegor Kozlov
*/ */
public class ActiveXShape extends Picture { public final class ActiveXShape extends Picture {
public static final int DEFAULT_ACTIVEX_THUMBNAIL = -1; public static final int DEFAULT_ACTIVEX_THUMBNAIL = -1;
/** /**
@ -83,8 +100,8 @@ public class ActiveXShape extends Picture {
*/ */
public void setActiveXIndex(int idx){ public void setActiveXIndex(int idx){
EscherContainerRecord spContainer = getSpContainer(); EscherContainerRecord spContainer = getSpContainer();
for (Iterator it = spContainer.getChildRecords().iterator(); it.hasNext();) { for (Iterator<EscherRecord> it = spContainer.getChildRecords().iterator(); it.hasNext();) {
EscherRecord obj = (EscherRecord) it.next(); EscherRecord obj = it.next();
if (obj.getRecordId() == EscherClientDataRecord.RECORD_ID) { if (obj.getRecordId() == EscherClientDataRecord.RECORD_ID) {
EscherClientDataRecord clientRecord = (EscherClientDataRecord)obj; EscherClientDataRecord clientRecord = (EscherClientDataRecord)obj;
byte[] recdata = clientRecord.getRemainingData(); byte[] recdata = clientRecord.getRemainingData();

View File

@ -1,54 +1,75 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hslf.model; package org.apache.poi.hslf.model;
import org.apache.poi.hslf.record.Comment2000; import org.apache.poi.hslf.record.Comment2000;
public class Comment { /**
private Comment2000 comment2000; *
* @author Nick Burch
*/
public final class Comment {
private Comment2000 _comment2000;
public Comment(Comment2000 comment2000) { public Comment(Comment2000 comment2000) {
this.comment2000 = comment2000; _comment2000 = comment2000;
} }
protected Comment2000 getComment2000() { protected Comment2000 getComment2000() {
return comment2000; return _comment2000;
} }
/** /**
* Get the Author of this comment * Get the Author of this comment
*/ */
public String getAuthor() { public String getAuthor() {
return comment2000.getAuthor(); return _comment2000.getAuthor();
} }
/** /**
* Set the Author of this comment * Set the Author of this comment
*/ */
public void setAuthor(String author) { public void setAuthor(String author) {
comment2000.setAuthor(author); _comment2000.setAuthor(author);
} }
/** /**
* Get the Author's Initials of this comment * Get the Author's Initials of this comment
*/ */
public String getAuthorInitials() { public String getAuthorInitials() {
return comment2000.getAuthorInitials(); return _comment2000.getAuthorInitials();
} }
/** /**
* Set the Author's Initials of this comment * Set the Author's Initials of this comment
*/ */
public void setAuthorInitials(String initials) { public void setAuthorInitials(String initials) {
comment2000.setAuthorInitials(initials); _comment2000.setAuthorInitials(initials);
} }
/** /**
* Get the text of this comment * Get the text of this comment
*/ */
public String getText() { public String getText() {
return comment2000.getText(); return _comment2000.getText();
} }
/** /**
* Set the text of this comment * Set the text of this comment
*/ */
public void setText(String text) { public void setText(String text) {
comment2000.setText(text); _comment2000.setText(text);
} }
} }

View File

@ -1,20 +1,37 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hslf.model; package org.apache.poi.hslf.model;
import org.apache.poi.ddf.*;
import org.apache.poi.hslf.record.*;
import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.hslf.usermodel.SlideShow;
import org.apache.poi.util.LittleEndian;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.util.Iterator;
import org.apache.poi.ddf.EscherClientDataRecord;
import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherProperties;
import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.hslf.record.*;
import org.apache.poi.hslf.usermodel.SlideShow;
/** /**
* Represents a movie in a PowerPoint document. * Represents a movie in a PowerPoint document.
* *
* @author Yegor Kozlov * @author Yegor Kozlov
*/ */
public class MovieShape extends Picture { public final class MovieShape extends Picture {
public static final int DEFAULT_MOVIE_THUMBNAIL = -1; public static final int DEFAULT_MOVIE_THUMBNAIL = -1;
public static final int MOVIE_MPEG = 1; public static final int MOVIE_MPEG = 1;

View File

@ -1,7 +1,19 @@
/* /* ====================================================================
* To change this template, choose Tools | Templates Licensed to the Apache Software Foundation (ASF) under one or more
* and open the template in the editor. contributor license agreements. See the NOTICE file distributed with
*/ this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hwpf.model; package org.apache.poi.hwpf.model;
@ -14,21 +26,19 @@ import org.apache.poi.ddf.EscherRecord;
import org.apache.poi.ddf.EscherRecordFactory; import org.apache.poi.ddf.EscherRecordFactory;
/** /**
* Based on AbstractEscherRecordHolder fomr HSSF. * Based on AbstractEscherRecordHolder from HSSF.
* *
* @author Squeeself * @author Squeeself
*/ */
public class EscherRecordHolder public final class EscherRecordHolder {
{ private final ArrayList<EscherRecord> escherRecords;
protected ArrayList escherRecords = new ArrayList();
public EscherRecordHolder()
{
public EscherRecordHolder() {
escherRecords = new ArrayList<EscherRecord>();
} }
public EscherRecordHolder(byte[] data, int offset, int size) public EscherRecordHolder(byte[] data, int offset, int size) {
{ this();
fillEscherRecords(data, offset, size); fillEscherRecords(data, offset, size);
} }
@ -45,24 +55,21 @@ public class EscherRecordHolder
} }
} }
public List getEscherRecords() public List<EscherRecord> getEscherRecords() {
{
return escherRecords; return escherRecords;
} }
public String toString() public String toString() {
{
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
final String nl = System.getProperty("line.separator"); if (escherRecords.size() == 0) {
if (escherRecords.size() == 0) buffer.append("No Escher Records Decoded").append("\n");
buffer.append("No Escher Records Decoded" + nl); }
for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); ) Iterator<EscherRecord> iterator = escherRecords.iterator();
{ while (iterator.hasNext()) {
EscherRecord r = (EscherRecord) iterator.next(); EscherRecord r = iterator.next();
buffer.append(r.toString()); buffer.append(r.toString());
} }
return buffer.toString(); return buffer.toString();
} }
@ -72,7 +79,7 @@ public class EscherRecordHolder
* then return that. * then return that.
*/ */
public EscherContainerRecord getEscherContainer() { public EscherContainerRecord getEscherContainer() {
for(Iterator it = escherRecords.iterator(); it.hasNext();) { for(Iterator<EscherRecord> it = escherRecords.iterator(); it.hasNext();) {
Object er = it.next(); Object er = it.next();
if(er instanceof EscherContainerRecord) { if(er instanceof EscherContainerRecord) {
return (EscherContainerRecord)er; return (EscherContainerRecord)er;
@ -89,21 +96,20 @@ public class EscherRecordHolder
public EscherRecord findFirstWithId(short id) { public EscherRecord findFirstWithId(short id) {
return findFirstWithId(id, getEscherRecords()); return findFirstWithId(id, getEscherRecords());
} }
private EscherRecord findFirstWithId(short id, List records) { private static EscherRecord findFirstWithId(short id, List<EscherRecord> records) {
// Check at our level // Check at our level
for(Iterator it = records.iterator(); it.hasNext();) { for(Iterator<EscherRecord> it = records.iterator(); it.hasNext();) {
EscherRecord r = (EscherRecord)it.next(); EscherRecord r = it.next();
if(r.getRecordId() == id) { if(r.getRecordId() == id) {
return r; return r;
} }
} }
// Then check our children in turn // Then check our children in turn
for(Iterator it = records.iterator(); it.hasNext();) { for(Iterator<EscherRecord> it = records.iterator(); it.hasNext();) {
EscherRecord r = (EscherRecord)it.next(); EscherRecord r = it.next();
if(r.isContainerRecord()) { if(r.isContainerRecord()) {
EscherRecord found = EscherRecord found = findFirstWithId(id, r.getChildRecords());
findFirstWithId(id, r.getChildRecords());
if(found != null) { if(found != null) {
return found; return found;
} }

View File

@ -1,3 +1,20 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hssf.usermodel; package org.apache.poi.hssf.usermodel;
import junit.framework.AssertionFailedError; import junit.framework.AssertionFailedError;
@ -5,7 +22,7 @@ import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.HSSFTestDataSamples;
/** /**
* Tests for LinkTable * Tests for {@link LinkTable}
* *
* @author Josh Micich * @author Josh Micich
*/ */

View File

@ -1,3 +1,20 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.poifs.property; package org.apache.poi.poifs.property;
import junit.framework.Test; import junit.framework.Test;
@ -11,7 +28,7 @@ import junit.framework.TestSuite;
public final class AllPOIFSPropertyTests { public final class AllPOIFSPropertyTests {
public static Test suite() { public static Test suite() {
TestSuite result = new TestSuite("Tests for org.apache.poi.poifs.property"); TestSuite result = new TestSuite(AllPOIFSPropertyTests.class.getName());
result.addTestSuite(TestDirectoryProperty.class); result.addTestSuite(TestDirectoryProperty.class);
result.addTestSuite(TestDocumentProperty.class); result.addTestSuite(TestDocumentProperty.class);
result.addTestSuite(TestPropertyFactory.class); result.addTestSuite(TestPropertyFactory.class);