Search in sources :

Example 61 with NavigableMap

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.");
}
Also used : NavigableMap(java.util.NavigableMap) Test(org.testng.annotations.Test)

Example 62 with NavigableMap

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);
}
Also used : NavigableMap(java.util.NavigableMap) Test(org.testng.annotations.Test)

Example 63 with NavigableMap

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);
}
Also used : NavigableMap(java.util.NavigableMap) Test(org.testng.annotations.Test)

Example 64 with NavigableMap

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");
            }
        }
    }
}
Also used : PersistPtrHolder(org.apache.poi.hslf.record.PersistPtrHolder) CorruptPowerPointFileException(org.apache.poi.hslf.exceptions.CorruptPowerPointFileException) UserEditAtom(org.apache.poi.hslf.record.UserEditAtom) HashMap(java.util.HashMap) Map(java.util.Map) NavigableMap(java.util.NavigableMap) TreeMap(java.util.TreeMap)

Example 65 with NavigableMap

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()]);
}
Also used : PersistRecord(org.apache.poi.hslf.record.PersistRecord) HashMap(java.util.HashMap) Record(org.apache.poi.hslf.record.Record) PositionDependentRecord(org.apache.poi.hslf.record.PositionDependentRecord) PersistRecord(org.apache.poi.hslf.record.PersistRecord) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap) Map(java.util.Map) NavigableMap(java.util.NavigableMap) TreeMap(java.util.TreeMap)

Aggregations

NavigableMap (java.util.NavigableMap)173 Map (java.util.Map)85 TreeMap (java.util.TreeMap)62 SortedMap (java.util.SortedMap)35 ArrayList (java.util.ArrayList)34 List (java.util.List)27 HashMap (java.util.HashMap)21 Iterator (java.util.Iterator)21 Cell (org.apache.hadoop.hbase.Cell)20 Result (org.apache.hadoop.hbase.client.Result)19 Set (java.util.Set)14 Get (org.apache.hadoop.hbase.client.Get)14 IOException (java.io.IOException)12 KeyValue (org.apache.hadoop.hbase.KeyValue)11 Test (org.junit.Test)11 Put (org.apache.hadoop.hbase.client.Put)10 Entry (java.util.Map.Entry)9 Update (co.cask.cdap.data2.dataset2.lib.table.Update)7 ImmutableMap (com.google.common.collect.ImmutableMap)7 TestSuite (junit.framework.TestSuite)7