Writing preparations
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353285 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5c7551531b
commit
5819887172
@ -205,4 +205,27 @@ public class ClassID
|
||||
dst[i + offset] = bytes[i];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Checks whether this <code>ClassID</code> is equal to another
|
||||
* object.</p>
|
||||
*
|
||||
* @param o the object to compare this <code>PropertySet</code> with
|
||||
* @return <code>true</code> if the objects are equal, else
|
||||
* <code>false</code>.</p>
|
||||
*/
|
||||
public boolean equals(final Object o)
|
||||
{
|
||||
if (o == null || !(o instanceof ClassID))
|
||||
return false;
|
||||
final ClassID cid = (ClassID) o;
|
||||
if (bytes.length != cid.bytes.length)
|
||||
return false;
|
||||
for (int i = 0; i < bytes.length; i++)
|
||||
if (bytes[i] != cid.bytes[i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public class Property
|
||||
private static final int CP_UNICODE = 1200;
|
||||
|
||||
/** <p>The property's ID.</p> */
|
||||
private int id;
|
||||
protected int id;
|
||||
|
||||
|
||||
/**
|
||||
@ -116,7 +116,7 @@ public class Property
|
||||
|
||||
|
||||
/** <p>The property's type.</p> */
|
||||
private long type;
|
||||
protected long type;
|
||||
|
||||
|
||||
/**
|
||||
@ -132,7 +132,7 @@ public class Property
|
||||
|
||||
|
||||
/** <p>The property's value.</p> */
|
||||
private Object value;
|
||||
protected Object value;
|
||||
|
||||
|
||||
/**
|
||||
@ -191,6 +191,15 @@ public class Property
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Creates an empty property. It must be filled using the set method to
|
||||
* be usable.</p>
|
||||
*/
|
||||
protected Property()
|
||||
{}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Reads a dictionary.</p>
|
||||
*
|
||||
@ -275,4 +284,11 @@ public class Property
|
||||
throw new UnsupportedOperationException("FIXME: Not yet implemented.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
throw new UnsupportedOperationException("FIXME: Not yet implemented.");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,10 +54,12 @@
|
||||
*/
|
||||
package org.apache.poi.hpsf;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.hpsf.wellknown.SectionIDMap;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
@ -636,4 +638,38 @@ public class PropertySet
|
||||
return ((Section) sections.get(0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Returns <code>true</code> if the <code>PropertySet</code> is equal
|
||||
* to the specified parameter, else <code>false</code>.</p>
|
||||
*
|
||||
* @param o the object to compare this <code>PropertySet</code> with
|
||||
*/
|
||||
public boolean equals(final Object o)
|
||||
{
|
||||
if (o == null || !(o instanceof PropertySet))
|
||||
return false;
|
||||
final PropertySet ps = (PropertySet) o;
|
||||
int byteOrder1 = ps.getByteOrder();
|
||||
int byteOrder2 = getByteOrder();
|
||||
ClassID classId1 = ps.getClassID();
|
||||
ClassID classID2 = getClassID();
|
||||
int format1 = ps.getFormat();
|
||||
int format2 = getFormat();
|
||||
int osVersion1 = ps.getOSVersion();
|
||||
int osVersion2 = getOSVersion();
|
||||
int sectionCount1 = ps.getSectionCount();
|
||||
int sectionCount2 = getSectionCount();
|
||||
if (byteOrder1 != byteOrder2 ||
|
||||
!classId1.equals(classID2) ||
|
||||
format1 != format2 ||
|
||||
osVersion1 != osVersion2 ||
|
||||
sectionCount1 != sectionCount2)
|
||||
return false;
|
||||
|
||||
/* Compare the sections: */
|
||||
return Util.equals(getSections(), ps.getSections());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ public class Section
|
||||
/**
|
||||
* @see #getPropertyCount
|
||||
*/
|
||||
protected int propertyCount;
|
||||
private int propertyCount;
|
||||
|
||||
|
||||
/**
|
||||
@ -156,7 +156,7 @@ public class Section
|
||||
/**
|
||||
* @see #getProperties
|
||||
*/
|
||||
protected Property[] properties;
|
||||
private Property[] properties;
|
||||
|
||||
|
||||
/**
|
||||
@ -169,6 +169,16 @@ public class Section
|
||||
return properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Sets this section's properties.</p>
|
||||
*
|
||||
* @param properties This section's new properties.
|
||||
*/
|
||||
protected void setProperties(final Property[] properties)
|
||||
{
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -423,4 +433,25 @@ public class Section
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Checks whether this section is equal to another object.</p>
|
||||
*
|
||||
* @param o The object to cpmpare this section with
|
||||
* @return <code>true</code> if the objects are equal, <code>false</code> if
|
||||
* not
|
||||
*/
|
||||
public boolean equals(final Object o)
|
||||
{
|
||||
if (o == null || !(o instanceof Section))
|
||||
return false;
|
||||
final Section s = (Section) o;
|
||||
if (!s.getFormatID().equals(getFormatID()))
|
||||
return false;
|
||||
if (s.getPropertyCount() != getPropertyCount())
|
||||
return false;
|
||||
return Util.equals(s.getProperties(), getProperties());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,6 +54,7 @@
|
||||
*/
|
||||
package org.apache.poi.hpsf;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@ -190,4 +191,59 @@ public class Util
|
||||
return new Date(ms_since_19700101);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Checks whether two collections are equal. Two collections
|
||||
* C<sub>1</sub> and C<sub>2</sub> are equal, if the following conditions
|
||||
* are true:</p>
|
||||
*
|
||||
* <ul>
|
||||
*
|
||||
* <li><p>For each c<sub>1<em>i</em></sub> (element of C<sub>1</sub>) there
|
||||
* is a c<sub>2<em>j</em></sub> (element of C<sub>2</sub>), and
|
||||
* c<sub>1<em>i</em></sub> equals c<sub>2<em>j</em></sub>.</p></li>
|
||||
*
|
||||
* <li><p>For each c<sub>2<em>i</em></sub> (element of C<sub>2</sub>) there
|
||||
* is a c<sub>1<em>j</em></sub> (element of C<sub>1</sub>) and
|
||||
* c<sub>2<em>i</em></sub> equals c<sub>1<em>j</em></sub>.</p></li>
|
||||
*
|
||||
* </ul>
|
||||
*
|
||||
* @param c1 the first collection
|
||||
* @param c2 the second collection
|
||||
* @return <code>true</code> if the collections are equal, else
|
||||
* <code>false</code>.
|
||||
*/
|
||||
public static boolean equals(final Collection c1, final Collection c2)
|
||||
{
|
||||
final Object[] o1 = c1.toArray();
|
||||
final Object[] o2 = c2.toArray();
|
||||
return internalEquals(o1, o2);
|
||||
}
|
||||
|
||||
public static boolean equals(final Object[] c1, final Object[] c2)
|
||||
{
|
||||
final Object[] o1 = (Object[]) c1.clone();
|
||||
final Object[] o2 = (Object[]) c2.clone();
|
||||
return internalEquals(o1, o2);
|
||||
}
|
||||
|
||||
private static boolean internalEquals(final Object[] o1, final Object[] o2)
|
||||
{
|
||||
for (int i1 = 0; i1 < o1.length; i1++)
|
||||
{
|
||||
boolean matchFound = false;
|
||||
for (int i2 = 0; !matchFound && i2 < o1.length; i2++)
|
||||
if (o1[i1].equals(o2[i2]))
|
||||
{
|
||||
matchFound = true;
|
||||
o2[i2] = null;
|
||||
}
|
||||
if (!matchFound)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user