Example usage for com.google.common.base Splitter fixedLength

List of usage examples for com.google.common.base Splitter fixedLength

Introduction

In this page you can find the example usage for com.google.common.base Splitter fixedLength.

Prototype

@CheckReturnValue
public static Splitter fixedLength(final int length) 

Source Link

Document

Returns a splitter that divides strings into pieces of the given length.

Usage

From source file:com.mycelium.wallet.Utils.java

public static String stringChopper(String string, int chopLength, String joiner) {
    String[] parts = Iterables.toArray(Splitter.fixedLength(chopLength).split(string), String.class);
    return Joiner.on(joiner).join(parts);
}

From source file:ai.grakn.graql.GraqlShell.java

private void executeQuery(String queryString) throws IOException {
    // Split query into chunks
    Iterable<String> splitQuery = Splitter.fixedLength(QUERY_CHUNK_SIZE).split(queryString);

    for (String queryChunk : splitQuery) {
        session.sendJson(Json.object(ACTION, ACTION_QUERY, QUERY, queryChunk));
    }/*w  ww  .  ja va 2s. c om*/

    session.sendJson(Json.object(ACTION, ACTION_END));
    handleMessagesFromServer();

    // Flush the console so the output is all displayed before the next command
    console.flush();
}

From source file:ee.ria.xroad.common.util.CryptoUtils.java

/**
 * Calculates digest of the certificate and encodes it as uppercase hex with the given delimiter every 2 characters.
 * @param cert the certificate//from  w w  w.  j a  v  a2  s  . c o m
 * @param delimiter the delimiter to use
 * @return calculated certificate hex hash String
 * @throws Exception if any errors occur
 */
public static String calculateDelimitedCertHexHash(X509Certificate cert, String delimiter) throws Exception {
    return String.join(delimiter, Splitter.fixedLength(2).split(calculateCertHexHash(cert).toUpperCase()));
}

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

private AddressStructurePT convertAddressToAddressPT(String addressDetail, String zipCode, String zipCodeRegion,
        String street) {/*from   w w  w  . ja  v a2  s.c o m*/
    AddressStructurePT companyAddress;
    companyAddress = new AddressStructurePT();
    companyAddress.setCountry("PT");
    companyAddress.setAddressDetail(Splitter.fixedLength(60).splitToList(addressDetail).get(0));
    companyAddress.setCity(Splitter.fixedLength(49).splitToList(zipCodeRegion).get(0));
    companyAddress.setPostalCode(zipCode);
    companyAddress.setRegion(zipCodeRegion);
    companyAddress.setStreetName(Splitter.fixedLength(49).splitToList(street).get(0));
    return companyAddress;
}

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

private AddressStructure convertAddressToSAFTAddress(String country, String addressDetail, String zipCode,
        String zipCodeRegion, String street) {
    AddressStructure companyAddress;/*from   w  ww  .  ja  v a  2  s . c o m*/
    companyAddress = new AddressStructure();
    companyAddress.setCountry(country);
    if (addressDetail != null) {
        companyAddress.setAddressDetail(Splitter.fixedLength(60).splitToList(addressDetail).get(0));
    } else {
        companyAddress.setAddressDetail(".");
    }
    if (zipCodeRegion != null) {
        companyAddress.setCity(Splitter.fixedLength(49).splitToList(zipCodeRegion).get(0));
    } else {
        companyAddress.setCity(".");
    }
    companyAddress.setPostalCode(zipCode);
    companyAddress.setRegion(zipCodeRegion);
    if (street != null) {
        companyAddress.setStreetName(Splitter.fixedLength(49).splitToList(street).get(0));
    } else {
        companyAddress.setStreetName(".");
    }
    return companyAddress;
}