Example usage for java.util TreeSet contains

List of usage examples for java.util TreeSet contains

Introduction

In this page you can find the example usage for java.util TreeSet contains.

Prototype

public boolean contains(Object o) 

Source Link

Document

Returns true if this set contains the specified element.

Usage

From source file:com.qpark.maven.plugin.flowmapper.AbstractGenerator.java

protected String getMapperDefinitions(final List<Entry<ComplexTypeChild, List<ComplexTypeChild>>> children,
        final Set<String> importedClasses) {
    final StringBuffer sb = new StringBuffer(1024);
    final TreeSet<String> usedInterfaces = new TreeSet<String>();
    children.stream().forEach(child -> child.getValue().stream().forEach(grandchild -> {
        final ComplexContent cc = this.getMapperDefinition(grandchild.getComplexType());
        if (cc != null && !usedInterfaces.contains(cc.getFQInterfaceName())) {
            usedInterfaces.add(cc.getFQInterfaceName());
            final String varName = Util.lowerize(cc.interfaceClassName);
            String className = cc.getFQInterfaceName();
            className = cc.getInterfaceName();
            sb.append("\t/** The ");
            // if (cc.isDirect) {/*from   w  w  w  .jav a2s.c  o m*/
            // sb.append("{@link DirectMappingType} ");
            // }
            sb.append("{@link ");
            sb.append(className);
            sb.append("}. */\n");
            sb.append("\t@Autowired\n");
            sb.append("\tprivate ");
            sb.append(className);
            sb.append(" ");
            sb.append(varName);
            sb.append(";\n");
        }
    }));
    return sb.toString();
}

From source file:de.uzk.hki.da.cb.ScanForPresentationAction.java

/**
 * Every file in the files list gets tested with respect to if a ConversionPolicies of contractor PRESENTER will apply to it.
 * If that is the case a ConversionInstruction gets generated for that file. Based on that information
 * a format conversion process will later be executed for that file. 
 * /*from   ww w .  jav  a  2s.c  o m*/
 * @author Sebastian Cuy, Daniel de Oliveira
 * @param pathToRepresentation physical path to source representation
 * @param files
 */
public List<ConversionInstruction> generateConversionInstructionsForPresentation(Package pkg,
        List<DAFile> files) {

    List<ConversionInstruction> cis = new ArrayList<ConversionInstruction>();

    TreeSet<String> neverConverted = this.neverConverted();
    for (DAFile file : files) {

        // get cps for fileanduser. do with cps: assemble

        String relPath = file.getRelative_path();
        logger.debug("File: " + relPath);

        if (neverConverted.contains(relPath)) {
            logger.debug("Skipping file: " + relPath);
        } else {
            logger.trace("Generating ConversionInstructions for PRESENTER: " + relPath);
            List<ConversionPolicy> policies = preservationSystem.getApplicablePolicies(file, true);
            if (o.grantsRight("PUBLICATION") && !wa.toFile(file).getName().toLowerCase().endsWith(".xml")
                    && !wa.toFile(file).getName().toLowerCase().endsWith(".rdf")
                    && !wa.toFile(file).getName().toLowerCase().endsWith(".xmp")
                    && (policies == null || policies.isEmpty())) {
                throw new RuntimeException("No policy found for file " + wa.toFile(file).getAbsolutePath() + "("
                        + file.getFormatPUID()
                        + ")! Package can not be published because it would be incomplete.");
            } else {
                if (FriendlyFilesUtils.isFriendlyFile(relPath, o.getFriendlyFileExtensions())) {
                    logger.debug("Friendly file: " + relPath);
                } else {
                    for (ConversionPolicy p : policies) {
                        logger.info("Found applicable Policy for FileFormat " + p.getSource_format() + " -> "
                                + p.getConversion_routine().getName() + "(" + file.getRelative_path() + ")");
                        ConversionInstruction ci = ciB.assembleConversionInstruction(wa, file, p);
                        ci.setTarget_folder(ci.getTarget_folder());
                        ci.setSource_file(file);

                        cis.add(ci);
                    }
                }
            }
        }
    }
    return cis;
}

From source file:com.b2international.index.SortIndexTest.java

@Test
public void sortLongField() throws Exception {
    final PrimitiveIterator.OfLong longIterator = new Random().longs().iterator();
    final TreeSet<Long> orderedItems = newTreeSet();
    final Map<String, Data> documents = newHashMap();

    for (int i = 0; i < NUM_DOCS; i++) {
        long item = 0L;
        while (item == 0L || orderedItems.contains(item)) {
            item = longIterator.nextLong();
        }/*from  w  w  w  .j a  v a 2s  .  c om*/
        orderedItems.add(item);

        final Data data = new Data();
        data.setLongField(item);
        documents.put(Integer.toString(i), data);
    }

    indexDocuments(documents);

    final Query<Data> ascendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS)
            .sortBy(SortBy.field("longField", Order.ASC)).build();

    checkDocumentOrder(ascendingQuery, data -> data.getLongField(), orderedItems, Long.class);

    final Query<Data> descendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS)
            .sortBy(SortBy.field("longField", Order.DESC)).build();

    checkDocumentOrder(descendingQuery, data -> data.getLongField(), orderedItems.descendingSet(), Long.class);
}

From source file:com.b2international.index.SortIndexTest.java

@Test
public void sortIntField() throws Exception {
    final PrimitiveIterator.OfInt intIterator = new Random().ints().iterator();
    final TreeSet<Integer> orderedItems = newTreeSet();
    final Map<String, Data> documents = newHashMap();

    for (int i = 0; i < NUM_DOCS; i++) {
        int item = 0;
        while (item == 0 || orderedItems.contains(item)) {
            item = intIterator.nextInt();
        }/*from www .  j  a  v  a2 s. c o  m*/
        orderedItems.add(item);

        final Data data = new Data();
        data.setIntField(item);
        documents.put(Integer.toString(i), data);
    }

    indexDocuments(documents);

    final Query<Data> ascendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS)
            .sortBy(SortBy.field("intField", Order.ASC)).build();

    checkDocumentOrder(ascendingQuery, data -> data.getIntField(), orderedItems, Integer.class);

    final Query<Data> descendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS)
            .sortBy(SortBy.field("intField", Order.DESC)).build();

    checkDocumentOrder(descendingQuery, data -> data.getIntField(), orderedItems.descendingSet(),
            Integer.class);
}

From source file:com.b2international.index.SortIndexTest.java

@Test
public void sortShortField() throws Exception {
    final PrimitiveIterator.OfInt intIterator = new Random().ints().iterator();
    final TreeSet<Short> orderedItems = newTreeSet();
    final Map<String, Data> documents = newHashMap();

    for (short i = 0; i < NUM_DOCS; i++) {
        short item = 0;
        while (item == 0 || orderedItems.contains(item)) {
            item = (short) intIterator.nextInt();
        }//from  w ww  . jav  a2  s.  c o m
        orderedItems.add(item);

        final Data data = new Data();
        data.setShortField(item);
        documents.put(Integer.toString(i), data);
    }

    indexDocuments(documents);

    final Query<Data> ascendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS)
            .sortBy(SortBy.field("shortField", Order.ASC)).build();

    checkDocumentOrder(ascendingQuery, data -> data.getShortField(), orderedItems, Short.class);

    final Query<Data> descendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS)
            .sortBy(SortBy.field("shortField", Order.DESC)).build();

    checkDocumentOrder(descendingQuery, data -> data.getShortField(), orderedItems.descendingSet(),
            Short.class);
}

From source file:com.b2international.index.SortIndexTest.java

@Test
public void sortStringField() throws Exception {
    final TreeSet<String> orderedItems = newTreeSet();
    final Map<String, Data> documents = newHashMap();

    for (int i = 0; i < NUM_DOCS; i++) {
        String item = null;//from  www.  j av  a 2 s  .c  om
        while (item == null || orderedItems.contains(item)) {
            item = RandomStringUtils.randomAlphabetic(10);
        }
        orderedItems.add(item);

        final Data data = new Data();
        data.setField1(item);
        documents.put(Integer.toString(i), data);
    }

    indexDocuments(documents);

    final Query<Data> ascendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS)
            .sortBy(SortBy.field("field1", Order.ASC)).build();

    checkDocumentOrder(ascendingQuery, data -> data.getField1(), orderedItems, String.class);

    final Query<Data> descendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS)
            .sortBy(SortBy.field("field1", Order.DESC)).build();

    checkDocumentOrder(descendingQuery, data -> data.getField1(), orderedItems.descendingSet(), String.class);
}

From source file:com.b2international.index.SortIndexTest.java

@Test
public void sortFloatField() throws Exception {
    final PrimitiveIterator.OfDouble doubleIterator = new Random().doubles().iterator();
    final TreeSet<Float> orderedItems = newTreeSet();
    final Map<String, Data> documents = newHashMap();

    for (int i = 0; i < NUM_DOCS; i++) {
        float item = 0.0f;
        while (item == 0.0f || orderedItems.contains(item)) {
            item = (float) doubleIterator.nextDouble();
        }//from   w ww.j  av  a 2s.co  m
        orderedItems.add(item);

        final Data data = new Data();
        data.setFloatField(item);
        documents.put(Integer.toString(i), data);
    }

    indexDocuments(documents);

    final Query<Data> ascendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS)
            .sortBy(SortBy.field("floatField", Order.ASC)).build();

    checkDocumentOrder(ascendingQuery, data -> data.getFloatField(), orderedItems, Float.class);

    final Query<Data> descendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS)
            .sortBy(SortBy.field("floatField", Order.DESC)).build();

    checkDocumentOrder(descendingQuery, data -> data.getFloatField(), orderedItems.descendingSet(),
            Float.class);
}

From source file:com.b2international.index.SortIndexTest.java

@Test
public void sortAnalyzedField() throws Exception {
    final TreeSet<String> orderedItems = newTreeSet();
    final Map<String, Data> documents = newHashMap();

    for (int i = 0; i < NUM_DOCS; i++) {
        String item = null;//ww w  .j  av  a 2 s .c o  m
        while (item == null || orderedItems.contains(item)) {
            item = RandomStringUtils.randomAlphabetic(10);
        }
        orderedItems.add(item);

        final Data data = new Data();
        data.setAnalyzedField(item);
        documents.put(Integer.toString(i), data);
    }

    indexDocuments(documents);

    final Query<Data> ascendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS)
            .sortBy(SortBy.field("analyzedField.exact", Order.ASC)).build();

    checkDocumentOrder(ascendingQuery, data -> data.getAnalyzedField(), orderedItems, String.class);

    final Query<Data> descendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS)
            .sortBy(SortBy.field("analyzedField.exact", Order.DESC)).build();

    checkDocumentOrder(descendingQuery, data -> data.getAnalyzedField(), orderedItems.descendingSet(),
            String.class);
}

From source file:com.b2international.index.SortIndexTest.java

@Test
public void sortBigDecimalField() throws Exception {
    final PrimitiveIterator.OfDouble doubleIterator = new Random().doubles().iterator();
    final TreeSet<BigDecimal> orderedItems = newTreeSet();
    final Map<String, Data> documents = newHashMap();

    for (int i = 0; i < NUM_DOCS; i++) {
        BigDecimal item = null;//from   w w  w. j a va 2s  .  co m
        while (item == null || orderedItems.contains(item)) {
            item = BigDecimal.valueOf(doubleIterator.nextDouble());
        }
        orderedItems.add(item);

        final Data data = new Data();
        data.setBigDecimalField(item);
        documents.put(Integer.toString(i), data);
    }

    indexDocuments(documents);

    final Query<Data> ascendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS)
            .sortBy(SortBy.field("bigDecimalField", Order.ASC)).build();

    checkDocumentOrder(ascendingQuery, data -> data.getBigDecimalField(), orderedItems, BigDecimal.class);

    final Query<Data> descendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS)
            .sortBy(SortBy.field("bigDecimalField", Order.DESC)).build();

    checkDocumentOrder(descendingQuery, data -> data.getBigDecimalField(), orderedItems.descendingSet(),
            BigDecimal.class);
}

From source file:FormatStorage1.IColumnDataFile.java

public void open(String fileName, ArrayList<Integer> idxs) throws IOException {
    this.columnprojects = new ArrayList<ArrayList<Integer>>();
    this.head = new IHead();
    this.readidxs = new TreeSet<Integer>();
    FileSystem fs = FileSystem.get(conf);
    FileStatus[] statuss = fs.globStatus(new Path(fileName + "_idx*"));
    this.cp2ifdfs.clear();
    this.idx2ifdfs.clear();
    if (idxs != null && idxs.size() > 0) {
        readidxs.addAll(idxs);/*from  www  .ja  v a  2  s.com*/
        for (int i = 0; i < statuss.length; i++) {
            String file = statuss[i].getPath().toString();
            IFormatDataFile ifdf = null;
            String idxstr = file.substring(file.lastIndexOf("_idx") + 4);
            String[] sts = idxstr.split("_");
            TreeSet<Integer> ts = new TreeSet<Integer>();
            for (int j = 0; j < sts.length; j++) {
                ts.add(Integer.parseInt(sts[j]));
            }

            boolean contains = false;
            for (Integer id : idxs) {
                if (ts.contains(id)) {
                    contains = true;
                    if (ifdf == null) {
                        ifdf = new IFormatDataFile(conf);
                        ifdf.open(file);
                    }
                    this.idx2ifdfs.put(id, ifdf);
                }
            }
            if (contains) {
                ArrayList<Integer> cp = new ArrayList<Integer>();
                cp.addAll(ts);
                this.columnprojects.add(cp);
                this.cp2ifdfs.put(cp, ifdf);
            }
        }

    } else {
        for (int i = 0; i < statuss.length; i++) {
            String file = statuss[i].getPath().toString();
            IFormatDataFile ifdf = null;
            String idxstr = file.substring(file.lastIndexOf("_idx") + 4);
            String[] sts = idxstr.split("_");
            TreeSet<Integer> ts = new TreeSet<Integer>();
            ifdf = new IFormatDataFile(conf);
            ifdf.open(file);

            for (int j = 0; j < sts.length; j++) {
                int id = Integer.parseInt(sts[j]);
                ts.add(id);
                this.idx2ifdfs.put(id, ifdf);
            }

            ArrayList<Integer> cp = new ArrayList<Integer>();
            cp.addAll(ts);
            this.readidxs.addAll(ts);
            this.columnprojects.add(cp);
            this.cp2ifdfs.put(cp, ifdf);
        }
    }
    this.fieldtypes = new HashMap<Integer, IRecord.IFType>();
    for (Integer idx : this.readidxs) {
        this.fieldtypes.put(idx, this.idx2ifdfs.get(idx).fileInfo().head().fieldMap().fieldtypes().get(idx));
    }
    workstatus = ConstVar.WS_Read;
}