Java String Length Get lengthTokensField(String fieldName)

Here you can find the source of lengthTokensField(String fieldName)

Description

length Tokens Field

License

Apache License

Declaration

public static String lengthTokensField(String fieldName) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010, 2012 Institute for Dutch Lexicology
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.//from w  w w .  j a v  a2  s. c o  m
 *******************************************************************************/

public class Main {
    private static final String LENGTH_TOKENS_BOOKKEEP_NAME = "length_tokens";
    /**
     * String used to separate the base field name (say, contents) and the field property (pos,
     * lemma, etc.)
     */
    static String PROP_SEP;
    /**
     * String used to separate the field/property name (say, contents_lemma) and the alternative
     * (e.g. "s" for case-sensitive)
     */
    static String BOOKKEEPING_SEP;

    public static String lengthTokensField(String fieldName) {
        return bookkeepingField(fieldName, LENGTH_TOKENS_BOOKKEEP_NAME);
    }

    /**
     * Construct a complex field bookkeeping subfield name.
     *
     * @param fieldName
     *            the base field name
     * @param propName
     *            the property name, or null if this is bookkeeping for the whole complex field
     * @param bookkeepName
     *            name of the bookkeeping value
     * @return the combined complex field name
     */
    public static String bookkeepingField(String fieldName, String propName, String bookkeepName) {
        String fieldPropName;
        boolean propGiven = propName != null && propName.length() > 0;
        if (fieldName == null || fieldName.length() == 0) {
            if (propGiven) {
                fieldPropName = propName;
            } else
                throw new RuntimeException("Must specify a base name, a property name or both: " + fieldName + ", "
                        + propName + ", " + bookkeepName);
        } else {
            fieldPropName = fieldName + (propGiven ? PROP_SEP + propName : "");
        }

        if (bookkeepName == null || bookkeepName.length() == 0)
            return fieldPropName;
        return fieldPropName + BOOKKEEPING_SEP + bookkeepName;
    }

    /**
     * Construct a complex field bookkeeping subfield name.
     *
     * @param fieldName
     *            the base field name
     * @param bookkeepName
     *            name of the bookkeeping value
     * @return the combined complex field name
     */
    public static String bookkeepingField(String fieldName, String bookkeepName) {
        return bookkeepingField(fieldName, null, bookkeepName);
    }
}

Related

  1. lengthMinusColors(String thisStr)
  2. lengthMinusTrailingWhitespace(String line)
  3. lengthOfCommonPrefix(String s1, String s2)
  4. lengthOfStartingWhitespace(String s)
  5. lengthOfString(final String cadena)
  6. lengthToString(double value, boolean proportional)
  7. lengthUCP(String s)
  8. lengthUnicode(String s)
  9. lengthWithinLimits(String string, int min, int max)