use of java.util.NavigableMap in project jdk8u_jdk by JetBrains.
the class EmptyNavigableMap method testTailMap.
/**
* Tests the tailMap() method.
*/
@Test(dataProvider = "NavigableMap<?,?>", dataProviderClass = EmptyNavigableMap.class)
public void testTailMap(String description, NavigableMap navigableMap) {
assertThrows(() -> {
navigableMap.tailMap(null);
}, NullPointerException.class, description + ": Must throw NullPointerException for null element");
assertThrows(() -> {
navigableMap.tailMap(new Object());
}, ClassCastException.class);
NavigableMap ss = navigableMap.tailMap("1", true);
assertEmptyNavigableMap(ss, description + ": Returned value is not empty navigable set.");
}
use of java.util.NavigableMap in project jdk8u_jdk by JetBrains.
the class EmptyNavigableMap method testheadMapRanges.
@Test(dataProvider = "NavigableMap<?,?>", dataProviderClass = EmptyNavigableMap.class)
public void testheadMapRanges(String description, NavigableMap navigableMap) {
NavigableMap subMap = navigableMap.headMap(BigInteger.ONE, true);
// same subset
subMap.headMap(BigInteger.ONE, true);
// slightly smaller
NavigableMap ns = subMap.headMap(BigInteger.ONE, false);
// slight exapansion
assertThrows(() -> {
ns.headMap(BigInteger.ONE, true);
}, IllegalArgumentException.class, description + ": Expansion should not be allowed");
// much smaller
subMap.headMap(isDescending(subMap) ? BigInteger.TEN : BigInteger.ZERO, true);
}
use of java.util.NavigableMap in project jdk8u_jdk by JetBrains.
the class EmptyNavigableMap method testTailMapRanges.
@Test(dataProvider = "NavigableMap<?,?>", dataProviderClass = EmptyNavigableMap.class)
public void testTailMapRanges(String description, NavigableMap navigableMap) {
NavigableMap subMap = navigableMap.tailMap(BigInteger.ONE, true);
// same subset
subMap.tailMap(BigInteger.ONE, true);
// slightly smaller
NavigableMap ns = subMap.tailMap(BigInteger.ONE, false);
// slight exapansion
assertThrows(() -> {
ns.tailMap(BigInteger.ONE, true);
}, IllegalArgumentException.class, description + ": Expansion should not be allowed");
// much smaller
subMap.tailMap(isDescending(subMap) ? BigInteger.ZERO : BigInteger.TEN, false);
}
use of java.util.NavigableMap in project poi by apache.
the class HSLFSlideShowImpl method initRecordOffsets.
private void initRecordOffsets(byte[] docstream, int usrOffset, NavigableMap<Integer, Record> recordMap, Map<Integer, Integer> offset2id) {
while (usrOffset != 0) {
UserEditAtom usr = (UserEditAtom) Record.buildRecordAtOffset(docstream, usrOffset);
recordMap.put(usrOffset, usr);
int psrOffset = usr.getPersistPointersOffset();
PersistPtrHolder ptr = (PersistPtrHolder) Record.buildRecordAtOffset(docstream, psrOffset);
recordMap.put(psrOffset, ptr);
for (Map.Entry<Integer, Integer> entry : ptr.getSlideLocationsLookup().entrySet()) {
Integer offset = entry.getValue();
Integer id = entry.getKey();
// reserve a slot for the record
recordMap.put(offset, null);
offset2id.put(offset, id);
}
usrOffset = usr.getLastUserEditAtomOffset();
// if the next user edit atom offset is already known, we would go into an endless loop
if (usrOffset > 0 && recordMap.containsKey(usrOffset)) {
// a user edit atom is usually located 36 byte before the smallest known record offset
usrOffset = recordMap.firstKey() - 36;
// check that we really are located on a user edit atom
int ver_inst = LittleEndian.getUShort(docstream, usrOffset);
int type = LittleEndian.getUShort(docstream, usrOffset + 2);
int len = LittleEndian.getInt(docstream, usrOffset + 4);
if (ver_inst == 0 && type == 4085 && (len == 0x1C || len == 0x20)) {
logger.log(POILogger.WARN, "Repairing invalid user edit atom");
usr.setLastUserEditAtomOffset(usrOffset);
} else {
throw new CorruptPowerPointFileException("Powerpoint document contains invalid user edit atom");
}
}
}
}
use of java.util.NavigableMap in project poi by apache.
the class HSLFSlideShowImpl method read.
private Record[] read(byte[] docstream, int usrOffset) throws IOException {
//sort found records by offset.
//(it is not necessary but SlideShow.findMostRecentCoreRecords() expects them sorted)
// offset -> record
NavigableMap<Integer, Record> records = new TreeMap<Integer, Record>();
// offset -> persistId
Map<Integer, Integer> persistIds = new HashMap<Integer, Integer>();
initRecordOffsets(docstream, usrOffset, records, persistIds);
HSLFSlideShowEncrypted decryptData = new HSLFSlideShowEncrypted(docstream, records);
for (Map.Entry<Integer, Record> entry : records.entrySet()) {
Integer offset = entry.getKey();
Record record = entry.getValue();
Integer persistId = persistIds.get(offset);
if (record == null) {
// all plain records have been already added,
// only new records need to be decrypted (tbd #35897)
decryptData.decryptRecord(docstream, persistId, offset);
record = Record.buildRecordAtOffset(docstream, offset);
entry.setValue(record);
}
if (record instanceof PersistRecord) {
((PersistRecord) record).setPersistId(persistId);
}
}
decryptData.close();
return records.values().toArray(new Record[records.size()]);
}
Aggregations