org.apache.commons.lang.ArrayUtils#indexOf ( )源码实例Demo

下面列出了org.apache.commons.lang.ArrayUtils#indexOf ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: kylin-on-parquet-v2   文件: CubeDesc.java
private TblColRef initDimensionColRef(DimensionDesc dim, String colName) {
    TblColRef col = model.findColumn(dim.getTable(), colName);

    // for backward compatibility
    if (KylinVersion.isBefore200(getVersion())) {
        // always use FK instead PK, FK could be shared by more than one lookup tables
        JoinDesc join = dim.getJoin();
        if (join != null) {
            int idx = ArrayUtils.indexOf(join.getPrimaryKeyColumns(), col);
            if (idx >= 0) {
                col = join.getForeignKeyColumns()[idx];
            }
        }
    }

    return initDimensionColRef(col);
}
 
源代码2 项目: systemds   文件: TfMetaUtils.java
public static int[] parseJsonObjectIDList(JSONObject spec, String[] colnames, String group) 
	throws JSONException
{
	int[] colList = new int[0];
	boolean ids = spec.containsKey("ids") && spec.getBoolean("ids");
	
	if( spec.containsKey(group) && spec.get(group) instanceof JSONArray )
	{
		JSONArray colspecs = (JSONArray)spec.get(group);
		colList = new int[colspecs.size()];
		for(int j=0; j<colspecs.size(); j++) {
			JSONObject colspec = (JSONObject) colspecs.get(j);
			colList[j] = ids ? colspec.getInt("id") : 
				(ArrayUtils.indexOf(colnames, colspec.get("name")) + 1);
			if( colList[j] <= 0 ) {
				throw new RuntimeException("Specified column '" +
					colspec.get(ids?"id":"name")+"' does not exist.");
			}
		}
		
		//ensure ascending order of column IDs
		Arrays.sort(colList);
	}
	
	return colList;
}
 
源代码3 项目: smarthome   文件: DisplayOptionsParser.java
/**
 * Returns all possible options from the given datapoint.
 */
private String[] getAvailableOptions(HmChannel channel, String datapointName) {
    HmDatapointInfo dpInfo = HmDatapointInfo.createValuesInfo(channel, datapointName);
    HmDatapoint dp = channel.getDatapoint(dpInfo);
    if (dp != null) {
        String[] options = (String[]) ArrayUtils.remove(dp.getOptions(), 0);
        for (String onOffString : onOff) {
            int onIdx = ArrayUtils.indexOf(options, onOffString);
            if (onIdx != -1) {
                options[onIdx] = datapointName + "_" + onOffString;
            }
        }
        return options;
    }
    return new String[0];
}
 
@Override
public void save() {
    // In this case, the 'Save' action corresponds to starting a scan with the specified options
    AccessControlScanStartOptions startOptions = new AccessControlScanStartOptions();
    startOptions.targetContext =
            ((ContextSelectComboBox) getField(FIELD_CONTEXT)).getSelectedContext();
    startOptions.targetUsers = usersSelectTable.getSelectedUsers();
    // If the un-authenticated user was selected, replace it with a 'null' user
    if (startOptions.targetUsers.remove(unauthenticatedUser)) {
        startOptions.targetUsers.add(null);
    }
    startOptions.raiseAlerts = ((JCheckBox) getField(FIELD_RAISE_ALERTS)).isSelected();
    // Just to make sure we have a reference here to MSG_RISK for taking care when refactoring
    // and that this still works if somehow the connection between index and value is lost, we
    // perform a quick search
    @SuppressWarnings("unchecked")
    String selectedAlertRisk =
            (String) ((JComboBox<String>) getField(FIELD_ALERTS_RISK)).getSelectedItem();
    startOptions.alertRiskLevel = ArrayUtils.indexOf(Alert.MSG_RISK, selectedAlertRisk);
    extension.startScan(startOptions);
}
 
源代码5 项目: kylin   文件: CubeDesc.java
private TblColRef initDimensionColRef(DimensionDesc dim, String colName) {
    TblColRef col = model.findColumn(dim.getTable(), colName);

    // for backward compatibility
    if (KylinVersion.isBefore200(getVersion())) {
        // always use FK instead PK, FK could be shared by more than one lookup tables
        JoinDesc join = dim.getJoin();
        if (join != null) {
            int idx = ArrayUtils.indexOf(join.getPrimaryKeyColumns(), col);
            if (idx >= 0) {
                col = join.getForeignKeyColumns()[idx];
            }
        }
    }

    return initDimensionColRef(col);
}
 
源代码6 项目: smarthome   文件: DisplayOptionsParser.java
/**
 * Returns the first found parameter index of the options.
 */
private int getIntParameter(String[] options, int currentValue, String parameter, String parameterName,
        String deviceAddress) {
    int idx = ArrayUtils.indexOf(options, parameter);
    if (idx != -1) {
        if (currentValue == 0) {
            logger.debug("{} option '{}' found at index {} for remote control '{}'", parameterName, parameter,
                    idx + 1, deviceAddress);
            return idx + 1;
        } else {
            logger.warn("{} option already set for remote control '{}', ignoring '{}'!", parameterName,
                    deviceAddress, parameter);
            return currentValue;
        }
    } else {
        return currentValue;
    }
}
 
源代码7 项目: pxf   文件: BridgeOutputBuilder.java
/**
 * Breaks raw bytes into lines. Used only for sampling.
 * <p>
 * When sampling a data source, we have to make sure that we deal with
 * actual rows (lines) and not bigger chunks of data such as used by
 * LineBreakAccessor for performance. The input byte array is broken into
 * lines, each one stored in the outputList. In case the read data doesn't
 * end with a line delimiter, which can happen when reading chunks of bytes,
 * the partial line is stored separately, and is being completed when
 * reading the next chunk of data.
 *
 * @param val input raw data to break into lines
 */
void convertTextDataToLines(byte[] val) {
    int len = val.length;
    int start = 0;
    int end = 0;
    byte[] line;
    BufferWritable writable;

    while (start < len) {
        end = ArrayUtils.indexOf(val, DELIM, start);
        if (end == ArrayUtils.INDEX_NOT_FOUND) {
            // data finished in the middle of the line
            end = len;
            isPartialLine = true;
        } else {
            end++; // include the DELIM character
            isPartialLine = false;
        }
        line = Arrays.copyOfRange(val, start, end);

        if (partialLine != null) {
            // partial data was completed
            ((BufferWritable) partialLine).append(line);
            writable = (BufferWritable) partialLine;
            partialLine = null;
        } else {
            writable = new BufferWritable(line);
        }

        if (isPartialLine) {
            partialLine = writable;
        } else {
            outputList.add(writable);
        }
        start = end;
    }
}
 
源代码8 项目: aion-germany   文件: RestrictionsManager.java
public synchronized static void deactivate(Restrictions restriction) {
	for (RestrictionMode mode : RestrictionMode.VALUES) {
		Restrictions[] restrictions = RESTRICTIONS[mode.ordinal()];

		for (int index; (index = ArrayUtils.indexOf(restrictions, restriction)) != -1;) {
			restrictions = (Restrictions[]) ArrayUtils.remove(restrictions, index);
		}

		RESTRICTIONS[mode.ordinal()] = restrictions;
	}
}
 
源代码9 项目: BUbiNG   文件: BURL.java
/** Extracts the host part from a scheme+authority by removing the scheme, the user info and the port number.
 *
 * @param schemeAuthority a scheme+authority.
 * @return the host part.
 */
public static String hostFromSchemeAndAuthority(final byte[] schemeAuthority){
	final int length = schemeAuthority.length;
	final int startOfAuthority = ArrayUtils.indexOf(schemeAuthority, (byte)':') + 3;
	int atPosition;
	for(atPosition = startOfAuthority; atPosition < length; atPosition++) if (schemeAuthority[atPosition] == (byte)'@') break;
	final int startOfHost = atPosition != length ? atPosition + 1 : startOfAuthority;

	int endOfHost;
	for(endOfHost = startOfHost; endOfHost < length; endOfHost++) if (schemeAuthority[endOfHost] == (byte)':') break;
	final char[] host = new char[endOfHost - startOfHost];
	for(int i = startOfHost; i < endOfHost; i++) host[i - startOfHost] = (char)schemeAuthority[i];
	return new String(host);
}
 
/**
 * Returns all possible value items from the remote control.
 */
private String[] getValueItems(String parameterName) {
    DatapointConfig dpConfig = new DatapointConfig(remoteControlAddress, "18", parameterName);
    HmValueItem hmValueItem = context.getStateHolder().getState(dpConfig);
    if (hmValueItem != null) {
        String[] valueList = (String[]) ArrayUtils.remove(hmValueItem.getValueList(), 0);
        int onIdx = ArrayUtils.indexOf(valueList, "ON");
        if (onIdx != -1) {
            valueList[onIdx] = parameterName + "_ON";
        }
        return valueList;
    }
    return new String[0];
}
 
源代码11 项目: systemds   文件: HopRewriteUtils.java
public static int getValidOpPos( OpOp2 input, OpOp2... validTab ) {
	return ArrayUtils.indexOf(validTab, input);
}
 
源代码12 项目: aion-germany   文件: PetFeedCalculator.java
public static PetFeedResult getReward(int fullCount, PetRewards rewardGroup, PetFeedProgress progress, int playerLevel) {
	if (progress.getHungryLevel() != PetHungryLevel.FULL || rewardGroup.getResults().size() == 0) {
		return null;
	}

	int pointsIndex = ArrayUtils.indexOf(fullCounts, (short) fullCount);
	if (pointsIndex == ArrayUtils.INDEX_NOT_FOUND) {
		return null;
	}

	if (progress.isLovedFeeded()) { // for cash feed
		if (rewardGroup.getResults().size() == 1) {
			return rewardGroup.getResults().get(0);
		}
		List<PetFeedResult> validRewards = new ArrayList<PetFeedResult>();
		int maxLevel = 0;
		for (PetFeedResult result : rewardGroup.getResults()) {
			int resultLevel = DataManager.ITEM_DATA.getItemTemplate(result.getItem()).getLevel();
			if (resultLevel > playerLevel) {
				continue;
			}
			if (resultLevel > maxLevel) {
				maxLevel = resultLevel;
				validRewards.clear();
			}
			validRewards.add(result);
		}
		if (validRewards.size() == 0) {
			return null;
		}
		if (validRewards.size() == 1) {
			return validRewards.get(0);
		}
		return validRewards.get(Rnd.get(validRewards.size()));
	}

	int rewardIndex = 0;
	int totalRewards = rewardGroup.getResults().size();
	for (int row = 1; row < pointValues.length; row++) {
		int[] points = pointValues[row];
		if (points[pointsIndex] <= progress.getTotalPoints()) {
			rewardIndex = Math.round((float) totalRewards / (pointValues.length - 1) * row) - 1;
		}
	}

	// Fix rounding discrepancy
	if (rewardIndex < 0) {
		rewardIndex = 0;
	}
	else if (rewardIndex > rewardGroup.getResults().size() - 1) {
		rewardIndex = rewardGroup.getResults().size() - 1;
	}

	return rewardGroup.getResults().get(rewardIndex);
}
 
源代码13 项目: Alink   文件: MultiClassMetrics.java
private int getLabelIndex(String label){
	int index = ArrayUtils.indexOf(getParams().get(LABEL_ARRAY), label);
	Preconditions.checkArgument(index >= 0, String.format("Not exist label %s", label));
	return index;
}
 
源代码14 项目: spring-boot   文件: CalUtils.java
public static String getWeekCNName(String weekEnName) {
	return weekCnNameArray[ArrayUtils.indexOf(weekEnNameArray, weekEnName)];
}
 
源代码15 项目: systemds   文件: HopRewriteUtils.java
public static int getValidOpPos( OpOp2 input, OpOp2... validTab ) {
	return ArrayUtils.indexOf(validTab, input);
}
 
源代码16 项目: tassal   文件: Corpus.java
public int getIndexProject(final String project) {
	return ArrayUtils.indexOf(projects, project);
}
 
源代码17 项目: lams   文件: ExceptionUtils.java
/**
 * <p>Tests if the list of method names used in the search for <code>Throwable</code>
 * objects include the given name.</p>
 * 
 * @param methodName  the methodName to search in the list.
 * @return if the list of method names used in the search for <code>Throwable</code>
 *  objects include the given name.
 * @since 2.1
 */
public static boolean isCauseMethodName(String methodName) {
    synchronized(CAUSE_METHOD_NAMES_LOCK) {
        return ArrayUtils.indexOf(CAUSE_METHOD_NAMES, methodName) >= 0;
    }
}
 
源代码18 项目: astor   文件: ExceptionUtils.java
/**
 * <p>Tests if the list of method names used in the search for <code>Throwable</code>
 * objects include the given name.</p>
 * 
 * @param methodName  the methodName to search in the list.
 * @return if the list of method names used in the search for <code>Throwable</code>
 *  objects include the given name.
 * @since 2.1
 */
public static boolean isCauseMethodName(String methodName) {
    return ArrayUtils.indexOf(CAUSE_METHOD_NAMES, methodName) >= 0;
}
 
源代码19 项目: rapidminer-studio   文件: MultiStepProgressBar.java
/**
 * Returns the step index for the given step name.  If multiple steps have the same name, this method will return
 * the index of the first occurrence.
 *
 * @param stepName
 * 		the step name
 * @return the corresponding step index
 */
public int getIndexForName(String stepName) {
	return ArrayUtils.indexOf(stepNames, stepName);
}
 
源代码20 项目: astor   文件: ExceptionUtils.java
/**
 * <p>Tests if the list of method names used in the search for <code>Throwable</code>
 * objects include the given name.</p>
 * 
 * @param methodName  the methodName to search in the list.
 * @return if the list of method names used in the search for <code>Throwable</code>
 *  objects include the given name.
 * @since 2.1
 */
public static boolean isCauseMethodName(String methodName) {
    return ArrayUtils.indexOf(CAUSE_METHOD_NAMES, methodName) >= 0;
}