Example usage for java.math BigInteger ONE

List of usage examples for java.math BigInteger ONE

Introduction

In this page you can find the example usage for java.math BigInteger ONE.

Prototype

BigInteger ONE

To view the source code for java.math BigInteger ONE.

Click Source Link

Document

The BigInteger constant one.

Usage

From source file:org.candlepin.util.X509CRLStreamWriterTest.java

@Test
public void testAddEntryToEmptyCRL() throws Exception {
    Date oneHourAgo = new Date(new Date().getTime() - 60L * 60L * 1000L);
    Date oneHourHence = new Date(new Date().getTime() + 60L * 60L * 1000L);

    X509v2CRLBuilder crlBuilder = new X509v2CRLBuilder(issuer, oneHourAgo);
    crlBuilder.addExtension(X509Extension.authorityKeyIdentifier, false,
            new AuthorityKeyIdentifierStructure(keyPair.getPublic()));
    /* With a CRL number of 127, incrementing it should cause the number of bytes in the length
     * portion of the TLV to increase by one.*/
    crlBuilder.addExtension(X509Extension.cRLNumber, false, new CRLNumber(new BigInteger("127")));
    crlBuilder.setNextUpdate(oneHourHence);
    X509CRLHolder holder = crlBuilder.build(signer);

    File crlToChange = writeCRL(holder);

    File outfile = new File(folder.getRoot(), "new.crl");
    X509CRLStreamWriter stream = new X509CRLStreamWriter(crlToChange, (RSAPrivateKey) keyPair.getPrivate(),
            (RSAPublicKey) keyPair.getPublic());

    // Add enough items to cause the number of length bytes to change
    Set<BigInteger> newSerials = new HashSet<BigInteger>(Arrays.asList(new BigInteger("2358215310"),
            new BigInteger("7231352433"), new BigInteger("8233181205"), new BigInteger("1455615868"),
            new BigInteger("4323487764"), new BigInteger("6673256679")));

    for (BigInteger i : newSerials) {
        stream.add(i, new Date(), CRLReason.privilegeWithdrawn);
    }//from   www .  jav a 2s . c  om

    stream.preScan(crlToChange).lock();
    OutputStream o = new BufferedOutputStream(new FileOutputStream(outfile));
    stream.write(o);
    o.close();

    X509CRL changedCrl = readCRL();

    Set<BigInteger> discoveredSerials = new HashSet<BigInteger>();

    for (X509CRLEntry entry : changedCrl.getRevokedCertificates()) {
        discoveredSerials.add(entry.getSerialNumber());
    }

    X509CRL originalCrl = new JcaX509CRLConverter().setProvider(BC).getCRL(holder);

    assertNotNull(changedCrl.getNextUpdate());

    long changedCrlUpdateDelta = changedCrl.getNextUpdate().getTime() - changedCrl.getThisUpdate().getTime();

    // We're allowing a tolerance of a few milliseconds to deal with minor timing issues
    long deltaTolerance = 3;
    long deltaDiff = changedCrlUpdateDelta - (oneHourHence.getTime() - oneHourAgo.getTime());

    assertTrue(Math.abs(deltaDiff) <= deltaTolerance);
    assertThat(changedCrl.getThisUpdate(), greaterThan(originalCrl.getThisUpdate()));

    assertEquals(newSerials, discoveredSerials);
    assertEquals(originalCrl.getIssuerX500Principal(), changedCrl.getIssuerX500Principal());

    ASN1ObjectIdentifier crlNumberOID = X509Extension.cRLNumber;
    byte[] oldCrlNumberBytes = originalCrl.getExtensionValue(crlNumberOID.getId());
    byte[] newCrlNumberBytes = changedCrl.getExtensionValue(crlNumberOID.getId());

    DEROctetString oldOctet = (DEROctetString) DERTaggedObject.fromByteArray(oldCrlNumberBytes);
    DEROctetString newOctet = (DEROctetString) DERTaggedObject.fromByteArray(newCrlNumberBytes);
    DERInteger oldNumber = (DERInteger) DERTaggedObject.fromByteArray(oldOctet.getOctets());
    DERInteger newNumber = (DERInteger) DERTaggedObject.fromByteArray(newOctet.getOctets());
    assertEquals(oldNumber.getValue().add(BigInteger.ONE), newNumber.getValue());

    ASN1ObjectIdentifier authorityKeyOID = X509Extension.authorityKeyIdentifier;
    byte[] oldAuthorityKeyId = originalCrl.getExtensionValue(authorityKeyOID.getId());
    byte[] newAuthorityKeyId = changedCrl.getExtensionValue(authorityKeyOID.getId());
    assertArrayEquals(oldAuthorityKeyId, newAuthorityKeyId);
}

From source file:com.amazon.carbonado.repo.jdbc.TestH2.java

@Override
protected BigInteger expected(BigInteger bi) {
    // Used to detect that BigIntegerAdapter was selected.
    return bi.add(BigInteger.ONE);
}

From source file:edu.vt.cs.cnd2xsd.Cnd2XsdConverter.java

private void convert(OutputStream stream) {
    OutputStream fout = stream;//from  w  w w  .j  av  a  2  s.c  o  m
    try {

        SchemaElement schemaRoot = new SchemaElement();

        schemaRoot.setElementFormDefault(FormChoice.QUALIFIED);
        schemaRoot.setTargetNamespace(this.namespace);
        JAXBContext jc = JAXBContext.newInstance(SchemaElement.class);
        Marshaller m = jc.createMarshaller();
        List<OpenAttrs> rootAttrList = schemaRoot.getIncludesAndImportsAndRedefines();
        ElementElement rootElement = new ElementElement();
        QName qname = new QName(this.namespace, this.rootType);
        rootElement.setType(qname);
        rootElement.setName(this.root);
        rootAttrList.add(rootElement);

        //the first level nodes that are children of rsrRoot are those nodes that
        //do not have any parent nodes in the cnd.

        for (NodeType nt : ntypes) {

            log.debug("NodeType:" + nt.getName());

            //check if we already have that node - if we have then update it

            QName name = getQualifiedName(nt.getName());

            ComplexTypeElement ctype = (ComplexTypeElement) getComplexType(rootAttrList, name.getLocalPart(),
                    attrMap.containsKey(nt.getName()) ? attrMap.get(nt.getName()) : null);

            for (NodeType pt : nt.getDeclaredSupertypes()) {
                log.debug("  DeclaredSuperType:" + pt.getName());
                //based on the supertypes we will have to make decisions
                if (attrMap.containsKey(pt.getName())) {
                    //check if we have to create a node
                    String[] attrs = attrMap.get(pt.getName());
                    if (attrs != null) {
                        //get the qualified name
                        QName ename = getQualifiedName(pt.getName());
                        //create a complex type
                        //check if the complex type already there in the rootAttrList
                        ComplexType ctf = findComplexType(rootAttrList, ename.getLocalPart());

                        if (ctf == null) {
                            ctf = new ComplexTypeElement();
                            ctf.setName(ename.getLocalPart());
                            //add the attributes
                            for (String attr : attrs) {
                                Attribute attribute = new Attribute();
                                QName type = new QName(Constants.XML_NAMESPACE, Constants.STRING);
                                attribute.setType(type);
                                attribute.setName(attr);
                                ctf.getAttributesAndAttributeGroups().add(attribute);
                            }

                            //add this complex type to the attribute list of the root element
                            rootAttrList.add(ctf);
                        }

                        //create an element of the above complex type and add as element
                        ElementElement element = new ElementElement();
                        element.setName(ename.getLocalPart());
                        element.setType(new QName(this.namespace, ctf.getName()));
                        element.setMinOccurs(BigInteger.ONE);
                        element.setMaxOccurs("1");
                        //element.setType(new QName(ctf.));
                        //now add this element to the top level complex type's sequence
                        ctype.getSequence().getElementsAndGroupsAndAlls().add(element);

                    }
                }
                //the supertype is not a pre-define type - we then have to add it as an element
                else {

                    QName qn = getQualifiedName(pt.getName());
                    ComplexType ctf = getComplexType(rootAttrList, qn.getLocalPart(),
                            attrMap.containsKey(nt.getName()) ? attrMap.get(nt.getName()) : null);

                    //create an element of the above type and add as element
                    ElementElement element = new ElementElement();
                    element.setName(qn.getLocalPart());
                    element.setType(new QName(this.namespace, ctf.getName()));
                    element.setMinOccurs(BigInteger.ONE);
                    element.setMaxOccurs("1");

                    //element.setType(new QName(ctf.));
                    //now add this element to the top level complex type's sequence
                    ctype.getSequence().getElementsAndGroupsAndAlls().add(element);

                }
            }

            for (NodeDefinition nd : nt.getDeclaredChildNodeDefinitions()) {
                log.debug("  Declared ChildNode Definition:" + nd.getName());
                //check default primary type
                NodeType defaultNT = nd.getDefaultPrimaryType();
                if (defaultNT == null) {
                    log.debug("Default Primary Type for the node:" + nd.getName() + " is null");
                    //look for the primary type
                    NodeType[] nts = nd.getRequiredPrimaryTypes();
                    if (ntypes == null) {
                        log.debug("No required primary type for node:" + nd.getName());
                    } else {
                        defaultNT = nts[0];
                        log.debug("Assuming first primary  type:" + defaultNT.getName() + " for node:"
                                + nd.getName());
                    }

                }
                log.debug("  Default Primary Type Name:" + defaultNT.getName());
                ElementElement element = new ElementElement();
                if (nd.getName().equals("*")) {
                    QName qn = getQualifiedName(defaultNT.getName());
                    ComplexType ct = getComplexType(rootAttrList, qn.getLocalPart(),
                            attrMap.containsKey(nt.getName()) ? attrMap.get(nt.getName()) : null);

                    //QName ename = getQualifiedName(ct.getName());
                    element.setName(ct.getName());
                    element.setType(new QName(this.namespace, ct.getName()));
                    element.setMinOccurs(nd.isMandatory() ? BigInteger.ONE : BigInteger.ZERO);
                    //add an attribute called nodename so that it can be used to identify the node
                    QName type = new QName(Constants.XML_NAMESPACE, Constants.STRING);
                    Attribute attribute = new Attribute();
                    attribute.setType(type);
                    attribute.setName("nodename");
                    ct.getAttributesAndAttributeGroups().add(attribute);

                    if (nd.allowsSameNameSiblings()) {
                        element.setMaxOccurs(Constants.UNBOUNDED);
                    }

                } else {

                    QName qn = getQualifiedName(defaultNT.getName());
                    ComplexType ct = getComplexType(rootAttrList, qn.getLocalPart(),
                            attrMap.containsKey(nt.getName()) ? attrMap.get(nt.getName()) : null);

                    QName ename = getQualifiedName(nd.getName());
                    element.setName(ename.getLocalPart());
                    element.setType(new QName(this.namespace, ct.getName()));
                    element.setMinOccurs(nd.isMandatory() ? BigInteger.ONE : BigInteger.ZERO);

                    if (nd.allowsSameNameSiblings()) {
                        element.setMaxOccurs(Constants.UNBOUNDED);
                    }

                }
                ctype.getSequence().getElementsAndGroupsAndAlls().add(element);

            }

            for (PropertyDefinition pDef : nt.getPropertyDefinitions()) {
                log.debug("    Attr Name:" + pDef.getName());
                log.debug("    Req type:" + pDef.getRequiredType());
                log.debug("    Declaring Node type:" + pDef.getDeclaringNodeType().getName());
                if (pDef.getDeclaringNodeType().getName().equals(nt.getName())) {

                    QName qn = getQualifiedName(pDef.getName());
                    if (!pDef.isMultiple()) {
                        Attribute attr = new Attribute();
                        if (isUnsupportedType(pDef.getRequiredType())) {
                            attr.setType(new QName(Constants.XML_NAMESPACE, Constants.STRING));

                        } else {
                            attr.setType(new QName(Constants.XML_NAMESPACE,
                                    PropertyType.nameFromValue(pDef.getRequiredType()).toLowerCase()));
                        }
                        attr.setName(qn.getLocalPart());
                        //handle default value
                        Value[] defaultValues = pDef.getDefaultValues();
                        if (defaultValues != null && defaultValues.length > 0) {
                            attr.setDefault(defaultValues[0].getString());
                        }

                        ctype.getAttributesAndAttributeGroups().add(attr);
                    } else {
                        ComplexType ctf = getComplexType(rootAttrList, qn.getLocalPart(),
                                attrMap.containsKey(nt.getName()) ? attrMap.get(nt.getName()) : null);
                        if (ctf != null) {
                            ElementElement element = new ElementElement();
                            element.setName(qn.getLocalPart());
                            element.setMinOccurs(BigInteger.ZERO);
                            element.setMaxOccurs(Constants.UNBOUNDED);
                            if (isUnsupportedType(pDef.getRequiredType())) {
                                element.setType(new QName(Constants.XML_NAMESPACE, Constants.STRING));

                            } else {
                                element.setType(new QName(Constants.XML_NAMESPACE,
                                        PropertyType.nameFromValue(pDef.getRequiredType()).toLowerCase()));
                            }
                            ctf.getSequence().getElementsAndGroupsAndAlls().add(element);

                        }

                        //now create an element of the above type
                        ElementElement element = new ElementElement();
                        element.setName(qn.getLocalPart());
                        element.setType(new QName(this.namespace, ctf.getName()));
                        ctype.getSequence().getElementsAndGroupsAndAlls().add(element);

                    }

                }

            }

        }
        //decide what to put under rootNode

        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        //fout = new FileOutputStream(fileName);
        m.marshal(schemaRoot, fout);

    } catch (Exception ex) {
        log.debug("Exception:" + ex.getMessage());
        ex.printStackTrace();
    } finally {
        if (fout != null) {
            try {
                fout.close();
            } catch (IOException ex) {
                log.error("Exception caught: {}", ex.getMessage());
            }
        }
    }

}

From source file:org.fenixedu.treasury.services.integration.erp.ERPExporter.java

private String generateERPFile(FinantialInstitution institution, DateTime fromDate, DateTime toDate,
        List<? extends FinantialDocument> allDocuments, Boolean generateAllCustomers,
        Boolean generateAllProducts,
        java.util.function.UnaryOperator<AuditFile> preProcessFunctionBeforeSerialize) {

    // Build SAFT-AuditFile
    AuditFile auditFile = new AuditFile();
    // ThreadInformation information = 
    // SaftThreadRegister.retrieveCurrentThreadInformation();

    // Build SAFT-HEADER (Chapter 1 in AuditFile)
    Header header = this.createSAFTHeader(fromDate, toDate, institution, ERP_HEADER_VERSION_1_00_00);
    // SetHeader//from   w w w  . j a  v  a 2 s.co  m
    auditFile.setHeader(header);

    // Build Master-Files
    oecd.standardauditfile_tax.pt_1.AuditFile.MasterFiles masterFiles = new oecd.standardauditfile_tax.pt_1.AuditFile.MasterFiles();

    // SetMasterFiles
    auditFile.setMasterFiles(masterFiles);

    // Build SAFT-MovementOfGoods (Customer and Products are built inside)
    // ProductsTable (Chapter 2.4 in AuditFile)
    List<oecd.standardauditfile_tax.pt_1.Product> productList = masterFiles.getProduct();
    Map<String, oecd.standardauditfile_tax.pt_1.Product> productMap = new HashMap<String, oecd.standardauditfile_tax.pt_1.Product>();
    Set<String> productCodes = new HashSet<String>();

    // ClientsTable (Chapter 2.2 in AuditFile)
    List<oecd.standardauditfile_tax.pt_1.Customer> customerList = masterFiles.getCustomer();
    Map<String, oecd.standardauditfile_tax.pt_1.Customer> customerMap = new HashMap<String, oecd.standardauditfile_tax.pt_1.Customer>();

    // Readd All  Clients if needed
    if (generateAllCustomers) {
        logger.info("Reading all Customers in Institution " + institution.getCode());

        Set<Customer> allCustomers = new HashSet<Customer>();
        for (DebtAccount debt : institution.getDebtAccountsSet()) {
            allCustomers.add(debt.getCustomer());
        }

        // Update the Total Objects Count
        // information.setTotalCounter(allCustomers.size() +
        // allProducts.size() + allDocuments.size() * 10);

        int i = 0;
        for (Customer customer : allCustomers) {
            oecd.standardauditfile_tax.pt_1.Customer saftCustomer = this
                    .convertCustomerToSAFTCustomer(customer);
            // information.setCurrentCounter(information.getCurrentCounter()
            // + 1);
            customerMap.put(saftCustomer.getCustomerID(), saftCustomer);
            i++;
            if (i % 100 == 0) {
                logger.info("Processing " + i + "/" + allCustomers.size() + " Customers in Institution "
                        + institution.getCode());
            }
        }
    }
    // Readd All Products if needed
    if (generateAllProducts) {

        logger.info("Reading all Customers in Institution " + institution.getCode());
        Set<Product> allProducts = institution.getAvailableProductsSet();
        int i = 0;
        for (Product product : allProducts) {
            if (!productCodes.contains(product.getCode())) {
                oecd.standardauditfile_tax.pt_1.Product saftProduct = this.convertProductToSAFTProduct(product);
                productCodes.add(product.getCode());
                productMap.put(saftProduct.getProductCode(), saftProduct);
            }

            i++;
            if (i % 100 == 0) {
                logger.info("Processing " + i + "/" + allProducts.size() + " Products in Institution "
                        + institution.getCode());
            }

            // information.setCurrentCounter(information.getCurrentCounter()
            // + 1);
        }
    } else {
        // information.setTotalCounter(allDocuments.size() * 10);
        // Update the Total Objects Count
        // information.setCurrentCounter(0);
    }

    // TaxTable (Chapter 2.5 in AuditFile)
    oecd.standardauditfile_tax.pt_1.TaxTable taxTable = new oecd.standardauditfile_tax.pt_1.TaxTable();
    masterFiles.setTaxTable(taxTable);

    for (Vat vat : institution.getVatsSet()) {
        taxTable.getTaxTableEntry().add(this.convertVATtoTaxTableEntry(vat, institution));
    }

    // Set MovementOfGoods in SourceDocuments(AuditFile)
    oecd.standardauditfile_tax.pt_1.SourceDocuments sourceDocuments = new oecd.standardauditfile_tax.pt_1.SourceDocuments();
    auditFile.setSourceDocuments(sourceDocuments);

    SourceDocuments.SalesInvoices invoices = new SourceDocuments.SalesInvoices();
    SourceDocuments.WorkingDocuments workingDocuments = new SourceDocuments.WorkingDocuments();
    Payments paymentsDocuments = new Payments();

    BigInteger numberOfPaymentsDocuments = BigInteger.ZERO;
    BigDecimal totalDebitOfPaymentsDocuments = BigDecimal.ZERO;
    BigDecimal totalCreditOfPaymentsDocuments = BigDecimal.ZERO;

    BigInteger numberOfWorkingDocuments = BigInteger.ZERO;
    BigDecimal totalDebitOfWorkingDocuments = BigDecimal.ZERO;
    BigDecimal totalCreditOfWorkingDocuments = BigDecimal.ZERO;

    invoices.setNumberOfEntries(BigInteger.ZERO);
    invoices.setTotalCredit(BigDecimal.ZERO);
    invoices.setTotalDebit(BigDecimal.ZERO);

    //        int i = 0;
    for (FinantialDocument document : allDocuments) {
        if ((document.isCreditNote() || document.isDebitNote())
                && (document.isClosed() || document.isAnnulled())) {
            try {
                WorkDocument workDocument = convertToSAFTWorkDocument((Invoice) document, customerMap,
                        productMap);
                workingDocuments.getWorkDocument().add(workDocument);

                // AcumulateValues
                numberOfWorkingDocuments = numberOfWorkingDocuments.add(BigInteger.ONE);
                if (!document.isAnnulled()) {
                    if (document.isDebitNote()) {
                        totalDebitOfWorkingDocuments = totalDebitOfWorkingDocuments
                                .add(workDocument.getDocumentTotals().getNetTotal());
                    } else if (document.isCreditNote()) {
                        totalCreditOfWorkingDocuments = totalCreditOfWorkingDocuments
                                .add(workDocument.getDocumentTotals().getNetTotal());
                    }
                }

                //                    i++;

            } catch (Exception ex) {
                logger.error("Error processing document " + document.getUiDocumentNumber() + ": "
                        + ex.getLocalizedMessage());
                throw ex;
            }
        } else {
            logger.info("Ignoring document " + document.getUiDocumentNumber() + " because is not closed yet.");
        }

    }
    // Update Totals of Workingdocuments
    workingDocuments.setNumberOfEntries(numberOfWorkingDocuments);
    workingDocuments.setTotalCredit(totalCreditOfWorkingDocuments.setScale(2, RoundingMode.HALF_EVEN));
    workingDocuments.setTotalDebit(totalDebitOfWorkingDocuments.setScale(2, RoundingMode.HALF_EVEN));

    sourceDocuments.setWorkingDocuments(workingDocuments);

    //PROCESSING PAYMENTS TABLE

    paymentsDocuments.setNumberOfEntries(BigInteger.ZERO);
    paymentsDocuments.setTotalCredit(BigDecimal.ZERO);
    paymentsDocuments.setTotalDebit(BigDecimal.ZERO);
    for (FinantialDocument document : allDocuments) {
        if (document.isSettlementNote() && (document.isClosed() || document.isAnnulled())) {
            try {
                Payment paymentDocument = convertToSAFTPaymentDocument((SettlementNote) document, customerMap,
                        productMap);
                paymentsDocuments.getPayment().add(paymentDocument);

                // AcumulateValues
                numberOfPaymentsDocuments = numberOfPaymentsDocuments.add(BigInteger.ONE);
                if (!document.isAnnulled()) {
                    totalCreditOfPaymentsDocuments = totalCreditOfPaymentsDocuments
                            .add(((SettlementNote) document).getTotalCreditAmount());
                    totalDebitOfPaymentsDocuments = totalDebitOfPaymentsDocuments
                            .add(((SettlementNote) document).getTotalDebitAmount());
                }
                //                    i++;
            } catch (Exception ex) {
                // persistenceSupport.flush();
                logger.error("Error processing document " + document.getUiDocumentNumber() + ": "
                        + ex.getLocalizedMessage());
                throw ex;
            }
        } else {
            logger.info("Ignoring document " + document.getUiDocumentNumber() + " because is not closed yet.");
        }

    }

    // Update Totals of Payment Documents
    paymentsDocuments.setNumberOfEntries(numberOfPaymentsDocuments);
    paymentsDocuments.setTotalCredit(totalCreditOfPaymentsDocuments.setScale(2, RoundingMode.HALF_EVEN));
    paymentsDocuments.setTotalDebit(totalDebitOfPaymentsDocuments.setScale(2, RoundingMode.HALF_EVEN));
    sourceDocuments.setPayments(paymentsDocuments);

    // Update the Customer Table in SAFT
    for (oecd.standardauditfile_tax.pt_1.Customer customer : customerMap.values()) {
        customerList.add(customer);
    }

    // Update the Product Table in SAFT
    for (oecd.standardauditfile_tax.pt_1.Product product : productMap.values()) {
        productList.add(product);
    }

    if (preProcessFunctionBeforeSerialize != null) {
        auditFile = preProcessFunctionBeforeSerialize.apply(auditFile);
    }
    String xml = exportAuditFileToXML(auditFile);

    logger.info("SAFT File export concluded with success.");
    return xml;
}

From source file:cc.redberry.core.number.Rational.java

@Override
public boolean isOne() {
    //Here we do not use fraction.equals() because it has low performence
    return fraction.getNumerator().equals(BigInteger.ONE) && fraction.getDenominator().equals(BigInteger.ONE);//equals(BigFraction.ONE);
}

From source file:co.rsk.peg.BridgeStorageProviderTest.java

private BtcTransaction createTransaction() {
    BtcTransaction tx = new BtcTransaction(networkParameters);
    tx.addInput(PegTestUtils.createHash(), transactionOffset++,
            ScriptBuilder.createInputScript(new TransactionSignature(BigInteger.ONE, BigInteger.TEN)));

    return tx;// w  w  w.  j  av a  2s.  c  om
}

From source file:cc.redberry.core.number.Rational.java

@Override
public boolean isMinusOne() {
    //Here we do not use fraction.equals() because it has low performence
    return fraction.getNumerator().equals(BI_MINUS_ONE) && fraction.getDenominator().equals(BigInteger.ONE);//equals(BigFraction.ONE);
}

From source file:com.google.uzaygezen.core.hbase.HBaseQueryTest.java

private List<FilteredIndexRange<Object, BigIntegerRange>> query(MockHTable table, List<BigIntegerRange> region,
        SpaceFillingCurve sfc, int maxRanges,
        Map<Pow2LengthBitSetRange, NodeValue<BigIntegerContent>> rolledupMap) {
    List<? extends List<BigIntegerRange>> x = ImmutableList.of(region);
    BigIntegerContent zero = new BigIntegerContent(BigInteger.ZERO);
    Object filter = "";
    BigIntegerContent one = new BigIntegerContent(BigInteger.ONE);
    RegionInspector<Object, BigIntegerContent> simpleRegionInspector = SimpleRegionInspector.create(x, one,
            Functions.constant(filter), BigIntegerRangeHome.INSTANCE, zero);
    final RegionInspector<Object, BigIntegerContent> regionInspector;
    if (rolledupMap == null) {
        regionInspector = simpleRegionInspector;
    } else {//from   w  ww .  ja v a  2 s  . com
        regionInspector = MapRegionInspector.create(rolledupMap, simpleRegionInspector, false, zero, one);
    }
    // Not using using sub-ranges here.
    PlainFilterCombiner<Object, BigInteger, BigIntegerContent, BigIntegerRange> combiner = new PlainFilterCombiner<>(
            filter);
    QueryBuilder<Object, BigIntegerRange> queryBuilder = BacktrackingQueryBuilder.create(regionInspector,
            combiner, maxRanges, true, BigIntegerRangeHome.INSTANCE, zero);
    sfc.accept(new ZoomingSpaceVisitorAdapter(sfc, queryBuilder));
    Query<Object, BigIntegerRange> query = queryBuilder.get();
    return query.getFilteredIndexRanges();
}

From source file:cc.redberry.core.number.Rational.java

@Override
public boolean isInteger() {
    return fraction.getDenominator().compareTo(BigInteger.ONE) == 0;
}

From source file:org.apache.juddi.samples.JuddiAdminService.java

void setReplicationConfig(String authtoken) throws Exception {
    List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList();
    System.out.println();//from   w w  w  . j  a va2 s.  c  o m
    System.out.println("Select a node (from *this config)");
    for (int i = 0; i < uddiNodeList.size(); i++) {
        System.out.print(i + 1);
        System.out.println(") " + uddiNodeList.get(i).getName() + uddiNodeList.get(i).getDescription());
    }
    System.out.println("Node #: ");
    int index = Integer.parseInt(System.console().readLine()) - 1;
    String node = uddiNodeList.get(index).getName();
    Transport transport = clerkManager.getTransport(node);

    JUDDIApiPortType juddiApiService = transport.getJUDDIApiService();
    System.out.println("fetching...");
    //NodeList allNodes = juddiApiService.getAllNodes(authtoken);
    ReplicationConfiguration replicationNodes = null;
    try {
        replicationNodes = juddiApiService.getReplicationNodes(authtoken);
    } catch (Exception ex) {
        System.out.println("Error getting replication config");
        ex.printStackTrace();
        replicationNodes = new ReplicationConfiguration();

    }
    String input = "";
    while (!"d".equalsIgnoreCase(input) && !"q".equalsIgnoreCase(input)) {
        System.out.println("Current Config:");
        JAXB.marshal(replicationNodes, System.out);
        System.out.println("1) Remove a replication node");
        System.out.println("2) Add a replication node");
        System.out.println("3) Remove an Edge");
        System.out.println("4) Add an Edge");
        System.out.println("5) Set Registry Contact");
        System.out.println("6) Add Operator info");
        System.out.println("7) Remove Operator info");
        System.out.println("d) Done, save changes");
        System.out.println("q) Quit and abandon changes");

        input = System.console().readLine();
        if (input.equalsIgnoreCase("1")) {
            menu_RemoveReplicationNode(replicationNodes);
        } else if (input.equalsIgnoreCase("2")) {
            menu_AddReplicationNode(replicationNodes, juddiApiService, authtoken);
        } else if (input.equalsIgnoreCase("d")) {
            if (replicationNodes.getCommunicationGraph() == null) {
                replicationNodes.setCommunicationGraph(new CommunicationGraph());
            }
            if (replicationNodes.getRegistryContact() == null) {
                replicationNodes.setRegistryContact(new ReplicationConfiguration.RegistryContact());
            }
            if (replicationNodes.getRegistryContact().getContact() == null) {
                replicationNodes.getRegistryContact().setContact(new Contact());
                replicationNodes.getRegistryContact().getContact().getPersonName()
                        .add(new PersonName("unknown", null));
            }

            replicationNodes.setSerialNumber(0L);
            replicationNodes.setTimeOfConfigurationUpdate("");
            replicationNodes.setMaximumTimeToGetChanges(BigInteger.ONE);
            replicationNodes.setMaximumTimeToSyncRegistry(BigInteger.ONE);

            JAXB.marshal(replicationNodes, System.out);
            juddiApiService.setReplicationNodes(authtoken, replicationNodes);
        }

    }
    if (input.equalsIgnoreCase("d")) {
        //save the changes
        DispositionReport setReplicationNodes = juddiApiService.setReplicationNodes(authtoken,
                replicationNodes);
        System.out.println("Saved!, dumping config from the server");
        replicationNodes = juddiApiService.getReplicationNodes(authtoken);
        JAXB.marshal(replicationNodes, System.out);

    } else {
        //quit this sub menu
        System.out.println("aborting!");
    }

}