Gets the field name to use when converting from a DBObject

@param dbObj the DBObject to scan for alternate names
@return the value of this field mapped from the DBObject
@see AlsoLoad
499546
public String getFirstFieldName(final DBObject dbObj) {
        String fieldName = getNameToStore();
        boolean foundField = false;
        for (final String n : getLoadNames()) {
            if (dbObj.containsField(n)) {
                if (!foundField) {
                    foundField = true;
                    fieldName = n;
                } else {
                    throw new MappingException(format("Found more than one field from @AlsoLoad %s", getLoadNames()));
                }
            }
        }
        return fieldName;
    }
296400
public String getFullyQualifiedFieldName() {
        if (!visitingField) {
            throw new IllegalStateException("getFullyQualifiedFieldName called while not visiting field");
        }
        if (fullyQualifiedFieldName == null) {
            fullyQualifiedFieldName = getDottedClassName() + "." + getFieldName() + " : " + getFieldSig();
        }
        return fullyQualifiedFieldName;
    }
216920
@SuppressWarnings("unchecked")
    public DataMapper<Object, DBObject> getDataMapper(Class<?> domainObjectClass) {
        if (additionalDataMappers != null) {
            for (DataMapper<Object, DBObject> each : additionalDataMappers) {
                if (each.canMapToData(domainObjectClass)) {
                    return each;
                }
            }
        }
        if (dataMapper.canMapToData(domainObjectClass)) {
            return (DataMapper<Object, DBObject>) dataMapper;
        }
        // no matching
        return null;
    }
272647
protected String getFieldNameOfAccesser(String methodName) {
		if (methodName.startsWith("get")) {
			return net.winroad.wrdoclet.utils.Util.uncapitalize(methodName.replaceFirst("get", ""));
		} else if (methodName.startsWith("set")) {
			return net.winroad.wrdoclet.utils.Util.uncapitalize(methodName.replaceFirst("set", ""));
		} else {
			return net.winroad.wrdoclet.utils.Util.uncapitalize(methodName.replaceFirst("is", ""));
		}
	}
217148
public static Object getObjectIndex(Object obj, double dblIndex,
                                        Context cx, Scriptable scope)
    {
        Scriptable sobj = toObjectOrNull(cx, obj, scope);
        if (sobj == null) {
            throw undefReadError(obj, toString(dblIndex));
        }

        int index = (int)dblIndex;
        if (index == dblIndex) {
            return getObjectIndex(sobj, index, cx);
        }
        String s = toString(dblIndex);
        return getObjectProp(sobj, s, cx);
    }
111060
public String getObjectId(Object obj)
    {
        Identity oid = null;
        PersistenceBroker broker = null;

        try
        {
            if (getCurrentDatabase() != null)
            {
                /**
                 * is there an open database we are calling getObjectId against? if yes, use it
                 */
                broker = PersistenceBrokerFactory.createPersistenceBroker(getCurrentDatabase().getPBKey());
            }
            else
            {
                log.warn("Can't find open database, try to use the default configuration");
                /**
                 * otherwise, use default.
                 */
                broker = PersistenceBrokerFactory.defaultPersistenceBroker();
            }

            oid = broker.serviceIdentity().buildIdentity(obj);
        }
        finally
        {
            if(broker != null)
            {
                broker.close();
            }
        }
        return new String(SerializationUtils.serialize(oid));
    }
643437
public static Object getFieldValue(Object obj, String name) {
        Class<?> clazz = obj.getClass();
        try {
            Field f = clazz.getDeclaredField(name);
            return f.get(obj);
        }
        catch (Exception e) {
            return null;
        }
    }
1124619
public String getDatabaseName(boolean bPhysicalName)
    {
        String strDbName = m_strDbName;
        if (bPhysicalName)
        {
            if ((this.getDatabaseType() & DBConstants.SYSTEM_DATABASE) != DBConstants.SYSTEM_DATABASE)
            {
                if ((this.getProperty(strDbName + DBSHARED_PARAM_SUFFIX) != null)
                    && (!m_strDbName.equalsIgnoreCase(this.getProperty(SQLParams.INTERNAL_DB_NAME)))
                    && ((this.getDatabaseType() & DBConstants.TABLE_DATA_TYPE_MASK) == DBConstants.SHARED_DATA))
                        strDbName = this.getProperty(strDbName + DBSHARED_PARAM_SUFFIX);	// Special processing - db name supplied
                else if ((this.getProperty(strDbName + DBUSER_PARAM_SUFFIX) != null)
                    && (!m_strDbName.equalsIgnoreCase(this.getProperty(SQLParams.INTERNAL_DB_NAME)))
                    && ((this.getDatabaseType() & DBConstants.TABLE_DATA_TYPE_MASK) == DBConstants.USER_DATA))
                        strDbName = this.getProperty(strDbName + DBUSER_PARAM_SUFFIX);	// Special processing - db name supplied
                else
                {
	                if (this.getProperty(DBConstants.DB_USER_PREFIX) != null)
	                    if (!m_strDbName.equalsIgnoreCase(this.getProperty(SQLParams.INTERNAL_DB_NAME)))
	                        if ((this.getDatabaseType() & DBConstants.TABLE_DATA_TYPE_MASK) == DBConstants.USER_DATA)
	                    		strDbName = Utility.addToPath(this.getProperty(DBConstants.DB_USER_PREFIX), strDbName, DB_NAME_SEPARATOR);    // User prefix - Only for user data
	                if (Utility.getSystemSuffix(this.getProperty(DBConstants.SYSTEM_NAME), this.getProperty(DBConstants.DEFAULT_SYSTEM_NAME)) != null)
	                    if (!m_strDbName.equalsIgnoreCase(this.getProperty(SQLParams.INTERNAL_DB_NAME)))
	                    {
	                        if ((this.getDatabaseType() & DBConstants.TABLE_DATA_TYPE_MASK) == DBConstants.USER_DATA)
	                        	strDbName = Utility.addToPath(strDbName, Utility.getSystemSuffix(this.getProperty(DBConstants.SYSTEM_NAME), this.getProperty(DBConstants.DEFAULT_SYSTEM_NAME)), DB_NAME_SEPARATOR);	 // System suffix
	                        else if ((this.getDatabaseType() & DBConstants.TABLE_DATA_TYPE_MASK) == DBConstants.SHARED_DATA)
	                        {  // The shared database name is never changed, EXCEPT if the mode is set. Then there are a few exceptions
	                            if ((this.getProperty(DBConstants.MODE) == null) || (this.getProperty(DBConstants.MODE).length() == 0) || (this.getProperty(DBConstants.MODE).equalsIgnoreCase(RUN_MODE)))
                                {  // Default = Regular (run) mode
                                    if ((DEV_DATABASE.equalsIgnoreCase(m_strDbName)) || (MAIN_DATABASE.equalsIgnoreCase(m_strDbName)))
                                        strDbName = Utility.addToPath(strDbName, Utility.getSystemSuffix(this.getProperty(DBConstants.SYSTEM_NAME), this.getProperty(DBConstants.DEFAULT_SYSTEM_NAME)), DB_NAME_SEPARATOR);  // Add System suffix
                                }
                                else
                                {   // Development mode
                                    if (this.getProperty(DBConstants.MODE).length() >= 3)
	                                    if (this.getProperty(DBConstants.MODE).substring(0, 3).equalsIgnoreCase(DEVELOPMENT_MODE))
	                                {
	                                    if (DEV_DATABASE.equalsIgnoreCase(m_strDbName))
                                            strDbName = Utility.addToPath(strDbName, Utility.getSystemSuffix(this.getProperty(DBConstants.SYSTEM_NAME), this.getProperty(DBConstants.DEFAULT_SYSTEM_NAME)), DB_NAME_SEPARATOR);  // System suffix	                                        
	                                    if (MAIN_DATABASE.equalsIgnoreCase(m_strDbName))
	                                        strDbName = Utility.addToPath(strDbName, DEV_MAIN_SUFFIX, DB_NAME_SEPARATOR);  // Development menus
	                                }
                                }
	                        }
	                    }
                }
//x                if (this.getLocale() != null) //**THIS IS DONE IN makeDBLocale**
//x                	if ((this.getDatabaseType() & DBConstants.TABLE_DATA_TYPE_MASK) == DBConstants.SHARED_DATA)
//x                		if (this.getLocale() != this.getProperty(DBConstants.SYSTEM_NAME))
//x                			strDbName = strDbName + '_' + this.getLocale();
                if ((this.getDatabaseType() & DBConstants.TABLE_DATA_TYPE_MASK) == DBConstants.USER_DATA)
                    strDbName = Utility.addToPath(strDbName, USER_SUFFIX, DB_NAME_SEPARATOR);
                else if ((this.getDatabaseType() & DBConstants.TABLE_DATA_TYPE_MASK) == DBConstants.SHARED_DATA)
                    strDbName = Utility.addToPath(strDbName, SHARED_SUFFIX, DB_NAME_SEPARATOR);
            }
        }
        return strDbName;
    }
1287493
public static ObjectNode getObj(ObjectNode obj, String fieldName) {
		return obj != null ? obj(obj.get(fieldName)) : null;
	}
1042241
public static function getDbPropertyName($dbFieldName)
    {
        if (!isset(self::$cachedDbPropertyNames[$dbFieldName])) {
            self::$cachedDbPropertyNames[$dbFieldName] = Str::separatorToCamel($dbFieldName);
        }

        return self::$cachedDbPropertyNames[$dbFieldName];
    }
1354170
private static String getFieldName(XmlSchemaChoice xsdChoice) {
        for (XmlSchemaChoiceMember alternative : xsdChoice.getItems()) {
            if (alternative instanceof XmlSchemaElement) {
                return getFieldName((XmlSchemaElement) alternative)
                        + CHOICE_FIELD_NAME_SUFFIX;
            }

        }
        throw new Xsd2ConverterException(
                "Choice without any alternative at line "
                        + xsdChoice.getLineNumber());
    }
1299262
@Override
    public String getName() {
        final String tableNamePrefix = StringUtils.isNotBlank(Latkes.getLocalProperty("jdbc.tablePrefix"))
                ? Latkes.getLocalProperty("jdbc.tablePrefix") + "_"
                : "";

        return tableNamePrefix + name;
    }
428058
public int convertFieldToIndex()
    {
        int index = -1;
        FieldInfo field = this.getField();
        if (field != null)
        {
            if (!field.isNull())
            {
                boolean bFound = false;
                Object bookmark = null;
                try   {
                    if (field instanceof ReferenceField)    // Always
                        if (((ReferenceField)field).getReferenceRecord() == m_record)
                            bookmark = ((ReferenceField)field).getReference().getHandle(DBConstants.BOOKMARK_HANDLE);
                } catch (DBException ex)    {
                    bookmark = null;
                }
                if (bookmark == null)
                    if (field instanceof IntegerField)
                        bookmark = field.getData();
                Object bookmarkRecord = null;
                try   {
                    bookmarkRecord = m_record.getTable().getHandle(m_iHandleType);
                } catch (DBException ex)    {
                } 

                if ((m_record.getEditMode() == Constants.EDIT_IN_PROGRESS) ||
                    (m_record.getEditMode() == Constants.EDIT_CURRENT))
                        if (bookmarkRecord != null)
                            if (bookmarkRecord.equals(bookmark))
                                bFound = true;  // Don't re-read the record... It is current!
                if (bFound == false)
                    if (bookmark != null)
                {   // First, try to look up the field (a bookmark) in the grid table.
                    index = m_gridTable.bookmarkToIndex(bookmark, DBConstants.BOOKMARK_HANDLE);   // Find the index of this record in the list
                    if (index != -1)
                    {
                        if (m_bIncludeBlankOption)
                            index++;
                        return index;
                    }

                    try   {
                        bFound = (m_record.getTable().setHandle(bookmark, m_iHandleType) != null);
                    } catch (DBException e)   {
                        bFound = false;
                    }
                } 
                if (bFound)
                {
                    index = m_gridTable.bookmarkToIndex(bookmark, DBConstants.BOOKMARK_HANDLE);   // Find the index of this record in the list
                    if (index != -1)
                    {
                        try {
                            m_gridTable.get(index); // Make sure I'm actually pointing to this record (fast - should be cached)
                        } catch (DBException e) {
                            e.printStackTrace();    // Never
                        } 
                    }
                    if (m_bIncludeBlankOption)
                        index++;
                    if (index != -1)
                        return index;
                }
            }
        }
        this.moveToIndex(-1);  // Move off any valid record
        if (m_bIncludeBlankOption)
            if (field != null)
                if (field.isNull())
                    return 0; // Null = Select the "Blank" line
        return -1;
    }
145833
private Optional<FieldAccessor> getSheetNameField(final Object beanObj, final AnnotationReader annoReader) throws AnnotationReadException {
        
        FieldAccessorFactory adpterFactory = new FieldAccessorFactory(annoReader);
        
        Class<?> clazz = beanObj.getClass();
        for(Method method : clazz.getMethods()) {
            method.setAccessible(true);
            if(!ClassUtils.isGetterMethod(method)) {
                continue;
            }
            
            if(!annoReader.hasAnnotation(method, XlsSheetName.class)) {
                continue;
            }
            
            return Optional.of(adpterFactory.create(method));
        }
        
        for(Field field : clazz.getDeclaredFields()) {
            field.setAccessible(true);
            
            if(!annoReader.hasAnnotation(field, XlsSheetName.class)) {
                continue;
            }
            
            return Optional.of(adpterFactory.create(field));
            
        }
        
        // not found
        return Optional.empty();
    }
628125
public String getFieldName() throws IOException {
    if (jsonParser.getCurrentToken() != JsonToken.FIELD_NAME) {
      throw new IOException("Expected a field of type " + JsonToken.FIELD_NAME +
                            ", but found a field of type " +
                            jsonParser.getCurrentToken());
    }
    return jsonParser.getCurrentName();
  }
121444
static void extractFieldValue(Object entity, DBObject dbObj, Attribute column) throws PropertyAccessException
    {
        try
        {
            Object valueObject = PropertyAccessorHelper.getObject(entity, (Field) column.getJavaMember());

            if (valueObject != null)
            {
                Class javaType = column.getJavaType();
                switch (AttributeType.getType(javaType))
                {
                case MAP:
                    Map mapObj = (Map) valueObject;
                    // BasicDBObjectBuilder builder =
                    // BasicDBObjectBuilder.start(mapObj);
                    BasicDBObjectBuilder b = new BasicDBObjectBuilder();
                    Iterator i = mapObj.entrySet().iterator();
                    while (i.hasNext())
                    {
                        Map.Entry entry = (Map.Entry) i.next();
                        b.add(entry.getKey().toString(),
                                MongoDBUtils.populateValue(entry.getValue(), entry.getValue().getClass()));
                    }
                    dbObj.put(((AbstractAttribute) column).getJPAColumnName(), b.get());
                    break;
                case SET:
                case LIST:
                    Collection collection = (Collection) valueObject;
                    BasicDBList basicDBList = new BasicDBList();
                    for (Object o : collection)
                    {
                        basicDBList.add(o);
                    }
                    dbObj.put(((AbstractAttribute) column).getJPAColumnName(), basicDBList);
                    break;
                case POINT:

                    Point p = (Point) valueObject;
                    double[] coordinate = new double[] { p.getX(), p.getY() };
                    dbObj.put(((AbstractAttribute) column).getJPAColumnName(), coordinate);
                    break;
                case ENUM:
                case PRIMITIVE:
                    dbObj.put(((AbstractAttribute) column).getJPAColumnName(),
                            MongoDBUtils.populateValue(valueObject, javaType));
                    break;
                }
            }
        }
        catch (PropertyAccessException paex)
        {
            log.error("Error while getting column {} value, caused by : .",
                    ((AbstractAttribute) column).getJPAColumnName(), paex);
            throw new PersistenceException(paex);
        }
    }
375034
protected void getFieldMappings()
            throws SQLException {

        final String[] keys = getKeysFromResultSet();

        //
        // find fields or setters for return class
        //
        HashMap<String, AccessibleObject> mapFields = new HashMap<String, AccessibleObject>(_columnCount * 2);
        for (int i = 1; i <= _columnCount; i++) {
            mapFields.put(keys[i], null);
        }

        // public methods
        Method[] classMethods = _returnTypeClass.getMethods();
        for (Method m : classMethods) {

            if (isSetterMethod(m)) {
                final String fieldName = m.getName().substring(3).toUpperCase();
                if (mapFields.containsKey(fieldName)) {

                    // check for overloads
                    Object field = mapFields.get(fieldName);
                    if (field == null) {
                        mapFields.put(fieldName, m);
                    } else {
                        throw new ControlException("Unable to choose between overloaded methods " + m.getName()
                                                   + " on the " + _returnTypeClass.getName() + " class. Mapping is done using "
                                                   + "a case insensitive comparision of SQL ResultSet columns to field "
                                                   + "names and public setter methods on the return class.");
                    }
                }
            }
        }

        // fix for 8813: include inherited and non-public fields
        for (Class clazz = _returnTypeClass; clazz != null && clazz != Object.class; clazz = clazz.getSuperclass()) {
            Field[] classFields = clazz.getDeclaredFields();
            for (Field f : classFields) {
                if (Modifier.isStatic(f.getModifiers())) continue;
                if (!Modifier.isPublic(f.getModifiers())) continue;
                String fieldName = f.getName().toUpperCase();
                if (!mapFields.containsKey(fieldName)) continue;

                Object field = mapFields.get(fieldName);
                if (field == null) {
                    mapFields.put(fieldName, f);
                }
            }
        }

        // finally actually init the fields array
        _fields = new AccessibleObject[_columnCount + 1];
        _fieldTypes = new int[_columnCount + 1];

        for (int i = 1; i < _fields.length; i++) {
            AccessibleObject f = mapFields.get(keys[i]);
            if (f == null) {
                throw new ControlException("Unable to map the SQL column " + keys[i]
                                           + " to a field on the " + _returnTypeClass.getName() +
                                           " class. Mapping is done using a case insensitive comparision of SQL ResultSet "
                                           + "columns to field names and public setter methods on the return class.");
            }

            _fields[i] = f;
            if (f instanceof Field) {
                _fieldTypes[i] = _tmf.getTypeId(((Field) f).getType());
            } else {
                _fieldTypes[i] = _tmf.getTypeId(((Method) f).getParameterTypes()[0]);
            }
        }
    }