Java Field Name Get fieldName(String fieldName, String propName)

Here you can find the source of fieldName(String fieldName, String propName)

Description

Construct a complex field name from its component parts.

License

Apache License

Parameter

Parameter Description
fieldName the base field name
propName the property name

Return

the combined complex field name

Declaration

@Deprecated
public static String fieldName(String fieldName, String propName) 

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./* ww  w  .j  a v  a 2s . c  o m*/
 *******************************************************************************/

public class Main {
    /**
     * 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 ALT_SEP;

    /**
     * Construct a complex field name from its component parts.
     *
     * @param fieldName
     *            the base field name
     * @param propName
     *            the property name
     * @return the combined complex field name
     * @deprecated replace with either propertyField or bookkeepingField
     */
    @Deprecated
    public static String fieldName(String fieldName, String propName) {
        return fieldName(fieldName, propName, null);
    }

    /**
     * Construct a complex field name from its component parts.
     *
     * @param fieldName
     *            the base field name
     * @param propName
     *            the property name
     * @param altName
     *            the alternative name
     * @return the combined complex field name
     * @deprecated replace with either propertyField or bookkeepingField
     */
    @Deprecated
    public static String fieldName(String fieldName, String propName, String altName) {
        return propertyField(fieldName, propName, altName);
    }

    /**
     * Construct a complex field property name.
     *
     * @param fieldName
     *            the base field name
     * @param propName
     *            the property name
     * @param altName
     *            the alternative name
     * @return the combined complex field name
     */
    public static String propertyField(String fieldName, String propName, String altName) {
        String fieldPropName;
        boolean propGiven = propName != null && propName.length() > 0;
        if (!propGiven) {
            throw new RuntimeException("Must specify a property name");
        }
        if (fieldName == null || fieldName.length() == 0) {
            if (propGiven) {
                fieldPropName = propName;
            } else
                throw new RuntimeException("Must specify a base name, a property name or both");
        } else {
            fieldPropName = fieldName + (propGiven ? PROP_SEP + propName : "");
        }

        if (altName == null || altName.length() == 0) {
            return fieldPropName;
        }
        return fieldPropName + ALT_SEP + altName;
    }

    /**
     * Construct a complex field property name.
     *
     * @param fieldName
     *            the base field name
     * @param propName
     *            the property name
     * @return the combined complex field name
     */
    public static String propertyField(String fieldName, String propName) {
        return propertyField(fieldName, propName, null);
    }
}

Related

  1. capitalizeFieldName(final Field field)
  2. fieldName(String accessorName)
  3. fieldName(String className, String rawFieldName)
  4. fieldName(String getsetName)
  5. fieldName(String name)
  6. fieldName(String nodeName)
  7. fieldName(String underScore)