Example usage for org.apache.commons.lang StringUtils substring

List of usage examples for org.apache.commons.lang StringUtils substring

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils substring.

Prototype

public static String substring(String str, int start, int end) 

Source Link

Document

Gets a substring from the specified String avoiding exceptions.

Usage

From source file:com.prowidesoftware.swift.model.MxSwiftMessage.java

/**
 * Updates sender, receiver and reference from parameter header
 * @param h//from  www  .j  a  v  a  2s. co m
 * @return true if at least some property was updated
 */
private boolean _update(BusinessHeader h) {
    boolean updated = false;
    if (h != null) {
        final String from = h.from();
        if (from != null) {
            super.sender = StringUtils.substring(from, 0, 8);
            updated = true;
        }

        final String to = h.to();
        if (to != null) {
            super.receiver = StringUtils.substring(to, 0, 8);
            updated = true;
        }

        final String reference = h.reference();
        if (reference != null) {
            setReference(h.reference());
            updated = true;
        }
    }
    return updated;
}

From source file:eionet.meta.imp.VocabularyRDFImportHandler.java

/**
 * Constructor for RDFHandler to import rdf into vocabulary.
 *
 * @param folderContextRoot/*from w  w  w  . j  ava 2s. c  o m*/
 *            base uri for vocabulary.
 * @param concepts
 *            concepts of vocabulary
 * @param boundElements
 *            bound elements to vocabulary.
 * @param boundElementsToIds
 *            bound elements ids.
 * @param boundURIs
 *            rdf namespaces for bound elements
 * @param workingLanguage
 *            working language, only first two letters are used
 * @param createNewDataElementsForPredicates
 *            create new data elements for seen predicates
 * @param ddNamespace
 *            dd instance namespace
 * @throws ServiceException
 *             when digest algorithm cannot be found
 */
public VocabularyRDFImportHandler(String folderContextRoot, List<VocabularyConcept> concepts,
        Map<String, Integer> boundElementsToIds, Map<String, List<String>> boundElements,
        Map<String, String> boundURIs, boolean createNewDataElementsForPredicates, String workingLanguage,
        String ddNamespace) throws ServiceException {
    super(folderContextRoot, concepts, boundElementsToIds);
    this.boundElements = boundElements;
    this.createNewDataElementsForPredicates = createNewDataElementsForPredicates;
    this.boundURIs = boundURIs;
    this.attributePositions = new HashMap<String, Map<String, Integer>>();
    this.predicateUpdatesAtConcepts = new HashMap<String, Set<Integer>>();
    this.notBoundPredicates = new HashSet<String>();
    this.identifierOfPredicate = new HashMap<String, String>();
    this.conceptsUpdatedForAttributes = new HashMap<String, Set<Integer>>();
    this.conceptsUpdatedForAttributes.put(SKOS_CONCEPT_ATTRIBUTE_NS + ":" + PREF_LABEL, new HashSet<Integer>());
    this.conceptsUpdatedForAttributes.put(SKOS_CONCEPT_ATTRIBUTE_NS + ":" + DEFINITION, new HashSet<Integer>());
    this.conceptsUpdatedForAttributes.put(SKOS_CONCEPT_ATTRIBUTE_NS + ":" + NOTATION, new HashSet<Integer>());
    this.lastCandidateForConceptAttribute = new HashMap<String, Literal>();
    // get first two letters of working language since, it can be like en-US
    this.workingLanguage = StringUtils.substring(workingLanguage, 0, 2);
    this.ddNamespace = ddNamespace;
    this.seenStatementsHashCodes = new HashSet<BigInteger>();
    try {
        this.messageDigestInstance = MessageDigest.getInstance(HASHING_ALGORITHM);
    } catch (NoSuchAlgorithmException e) {
        throw new ServiceException(e.getMessage());
    }
}

From source file:com.collegesource.interfaces.student.BannerStudentFinder.java

/**
 * Create a StuMaster object from the search results map.
 * //  www.  j a va 2 s . co  m
 * @param map
 */
private StuMaster createStudent(Map<String, Object> map) {
    StuMaster stuMaster = new StuMaster();
    StuDemo stuDemo = new StuDemo();
    StuDemoPK stuDemoPk = new StuDemoPK();

    stuMaster.setInstid(studentInstid);
    stuMaster.setInstidq(studentInstidq);
    stuMaster.setStuno(StringUtils.trimToEmpty((String) map.get("spriden_id")));

    stuDemoPk.setSourceId(studentInstid);
    stuDemoPk.setStuMaster(stuMaster);

    String name = StringUtils.trimToEmpty(StringUtils.substring((String) map.get("stuname"), 0, 35));

    stuDemo.setStuname(name);
    stuDemo.setStuidq(studentInstidq);
    stuDemo.setComp_id(stuDemoPk);

    List<StuDemo> demoList = new ArrayList<StuDemo>();
    demoList.add(stuDemo);

    stuMaster.setStuDemos(demoList);
    logger.debug("Created StuMaster with Banner Records: " + stuMaster);
    logger.debug("Student Name[" + stuDemo.getStuname() + "]");
    return stuMaster;
}

From source file:fr.paris.lutece.plugins.directory.modules.pdfproducerarchive.utils.FilesUtils.java

/**
 * Method to limit the name length by 50 caracters
 * @param strPathName name of directory/*  w  ww  .j  a v a2s  . c o m*/
 * @return the new limited name
 */
private static String limitLengthName(String strPathName) {
    return StringUtils.substring(strPathName, 0, MAX_LIMIT_NAME_DIRECTORY);
}

From source file:com.evolveum.midpoint.repo.sql.query.definition.ClassDefinitionParser.java

private String getPropertyName(String methodName) {
    int startIndex = 3; //method name starts with "get"
    if (methodName.startsWith("is")) {
        startIndex = 2;/*from   ww  w  .jav a 2  s .  c  o m*/
    }

    char first = Character.toLowerCase(methodName.charAt(startIndex));
    return Character.toString(first) + StringUtils.substring(methodName, startIndex + 1, methodName.length());
}

From source file:com.prowidesoftware.swift.model.BIC.java

/**
 * Gets the 2 chars country code of the BIC, which are the 5th and 6th characters
 * @since 7.7/* w  w  w .  ja va 2s  .c  o  m*/
 */
public String country() {
    return StringUtils.substring(this.bic8, 4, 6);
}

From source file:com.prowidesoftware.swift.model.MxSwiftMessage.java

/**
 * Updates sender, receiver and reference from the group header element (only present in a subset of Mx messages)
 * @return true if at least some property was updated
 *//*from   w w  w . j a  va 2  s .  c  om*/
private boolean _update(MxNode n) {
    boolean updated = false;
    final MxNode groupHeader = n.findFirstByName("GrpHdr");
    if (groupHeader != null) {
        MxNode senderBic = groupHeader.findFirst("./InstgAgt/FinInstnId/BIC");
        if (senderBic != null) {
            sender = StringUtils.substring(senderBic.getValue(), 0, 8);
            ;
            updated = true;
        }
        MxNode receiverBic = groupHeader.findFirst("./InstdAgt/FinInstnId/BIC");
        if (receiverBic != null) {
            receiver = StringUtils.substring(receiverBic.getValue(), 0, 8);
            ;
            updated = true;
        }
        MxNode reference = groupHeader.findFirst("./MsgId");
        if (reference != null) {
            setReference(reference.getValue());
            updated = true;
        }
    }
    return updated;
}

From source file:com.prowidesoftware.swift.model.BIC.java

/**
 * Gets the first 4 characters of the BIC; corresponding to the institution code
 * @since 7.8.5/*w  ww .j  av a  2  s  .co  m*/
 */
public String institution() {
    return StringUtils.substring(this.bic8, 0, 4);
}

From source file:com.prowidesoftware.swift.model.field.SwiftParseUtils.java

/**
 * Returns the alphabetic starting substring of the value.
 * The split is made when the first numeric character is found.
 * For example:<br />//  w ww  . ja  v a 2 s. c  o m
 * ABCD2345,33 will be return ABCD<br />
 * If the value does not contain any alphabetic character <code>null</code> is returned.
 *
 * @param value
 * @return s
 */
public static String getAlphaPrefix(final String value) {
    if (value != null && value.length() > 0) {
        int i = 0;
        while (i < value.length() && !StringUtils.isNumeric("" + value.charAt(i))) {
            i++;
        }
        if (i > 0) {
            return StringUtils.substring(value, 0, i);
        }
    }
    return null;
}

From source file:com.google.gdt.eclipse.designer.builders.participant.MyCompilationParticipant.java

/**
 * @return the name of GWT module that contains given class, may be <code>null</code>.
 */// ww w  .j a v a  2s . com
private static String getEnclosingModule(IResourcesProvider resourcesProvider, String className)
        throws Exception {
    String packageName = CodeUtils.getPackage(className);
    while (packageName.length() != 0) {
        List<String> files = resourcesProvider.listFiles(packageName.replace('.', '/'));
        for (String file : files) {
            if (file.indexOf('/') == -1 && file.endsWith(".gwt.xml")) {
                String shortModuleName = StringUtils.substring(file, 0, -".gwt.xml".length());
                return packageName + "." + shortModuleName;
            }
        }
        // go up
        packageName = CodeUtils.getPackage(packageName);
    }
    return null;
}