当前位置: 首页>>代码示例>>Java>>正文


Java ArrayUtils.indexOf方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.ArrayUtils.indexOf方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtils.indexOf方法的具体用法?Java ArrayUtils.indexOf怎么用?Java ArrayUtils.indexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.ArrayUtils的用法示例。


在下文中一共展示了ArrayUtils.indexOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setPropertyValue

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
public boolean setPropertyValue(String propVal)
{
    if (propVal == null)
    {
        this.value = this.defaultValue;
        return false;
    }
    else
    {
        this.value = ArrayUtils.indexOf(this.propertyValues, propVal);

        if (this.value >= 0 && this.value < this.propertyValues.length)
        {
            return true;
        }
        else
        {
            this.value = this.defaultValue;
            return false;
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:23,代码来源:Property.java

示例2: WeightedSegmentsFormatter

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
public WeightedSegmentsFormatter(final String[] args) {
    if (args != null) {
        prependPriority = ArrayUtils.contains(args, "-pp") || ArrayUtils.contains(args, "-prependPriority");

        int index1 = ArrayUtils.indexOf(args, "-weight");
        if (index1 < args.length - 1) {
            final String weightString = args[index1 + 1];
            Validate.isTrue(NumberUtils.isParsable(weightString), "Please provide a numeric value for weight.");
            this.weight = Integer.parseInt(weightString);
        }

        int index2 = ArrayUtils.indexOf(args, "-separator");
        if (index2 < args.length - 1) {
            valueSeparator = args[index2 + 1];
        }
    }
}
 
开发者ID:KayLerch,项目名称:alexa-utterance-generator,代码行数:18,代码来源:WeightedSegmentsFormatter.java

示例3: getUtteranceFileKey

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
private static Optional<String> getUtteranceFileKey(final String[] args) {
    if (args != null) {
        int index = ArrayUtils.indexOf(args, "-f");
        if (index < args.length - 1) {
            return Optional.of(args[index + 1]);
        }
    }
    return Optional.empty();
}
 
开发者ID:KayLerch,项目名称:alexa-utterance-generator,代码行数:10,代码来源:UtteranceGenerator.java

示例4: last

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
 * Sets value to the last one in the set
 */
public final void last() {
    int index = ArrayUtils.indexOf(values, getValue());
    if (--index < 0)
        index = values.length - 1;
    this.setValue(values[index]);
}
 
开发者ID:ImpactDevelopment,项目名称:ClientAPI,代码行数:10,代码来源:MultiType.java

示例5: next

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
 * Sets value to the next one in the set
 */
public final void next() {
    int index = ArrayUtils.indexOf(values, getValue());
    if (++index >= values.length)
        index = 0;
    this.setValue(values[index]);
}
 
开发者ID:ImpactDevelopment,项目名称:ClientAPI,代码行数:10,代码来源:EnumType.java

示例6: objectFrom

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
 * Returns the specified Object from the Array if the object is present in
 * the array. If not, the first object present in the array will be
 * returned if the size of the array is greater than 1, if not, the
 * specified Object will be returned.
 *
 * @param object The value trying to be set
 * @param array The array that may/may not contain the value
 * @return The value found from the array
 */
public static <T> T objectFrom(T object, T[] array) {
    int index = ArrayUtils.indexOf(array, object);
    if (index != -1) {
        return array[index];
    } else {
        if (array.length > 0) {
            return array[0];
        } else {
            return object;
        }
    }
}
 
开发者ID:ImpactDevelopment,项目名称:ClientAPI,代码行数:23,代码来源:ClientAPIUtils.java

示例7: parentPositionInPreviousLayer

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
 * Finds the position of parent node of the current node in the previous layer, if it exists.
 *
 * @param node  the node for which the parent needs to be found
 * @param layer the layer in which the parent needs to be found
 * @return the position of parent node of the current node in the previous layer, if it exists, otherwise {@code -1}
 */
private int parentPositionInPreviousLayer(final LayoutableNode node, final LayoutableNode[] layer) {
    final Optional<Edge> possibleParent = node.getIncomingEdges().stream().findFirst();
    if (!possibleParent.isPresent()) {
        return -1;
    }
    final LayoutableNode parent = possibleParent.get().getFrom();

    return ArrayUtils.indexOf(layer, parent);
}
 
开发者ID:ProgrammingLife2017,项目名称:hygene,代码行数:17,代码来源:EdgeOptimizer.java

示例8: parseAvailableAppointmentTimes

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
public static List<Calendar> parseAvailableAppointmentTimes(String html) {
    int i = html.indexOf("<div id=\"divList\">");
    if(i == -1)
        return null;
    int j = html.indexOf("</div>", i);
    String divListHtml = html.substring(i, j + "</div>".length());
    List<Calendar> calendars = new ArrayList<Calendar>();
    Document doc = JsoupDocumentUtils.parseUTF8HTMLDocument(divListHtml);
    Elements as = doc.getElementsByTag("a");
    String[] monthSimpleNameArray = new String[]{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
    String[] weekSimpleNameArray = new String[]{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
    
    for(Iterator<Element> iter = as.iterator(); iter.hasNext(); ) {
        String timeStr = iter.next().text();
        if(timeStr.matches("\\w{3} \\d{1,2} \\w{3} at \\d{1,2}:\\d{1,2}.*")) {
            String[] parts = timeStr.split(" ");
            Calendar cal = Calendar.getInstance();
            cal.clear();
            int month = ArrayUtils.indexOf(monthSimpleNameArray, parts[2]);
            int dayOfWeek = ArrayUtils.indexOf(weekSimpleNameArray, parts[0]);
            if(month != -1 && dayOfWeek != -1) {
                cal.set(Calendar.MONTH, month);
                cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(parts[1]));
                cal.set(Calendar.DAY_OF_WEEK, dayOfWeek);
                if(parts.length > 5) {
                    switch(parts[5]){
                    case "AM": cal.set(Calendar.AM_PM, Calendar.AM);break;
                    case "PM": cal.set(Calendar.AM_PM, Calendar.PM); break;
                    }
                }
                String[] hms = parts[4].split(":");
                int hour = Integer.parseInt(hms[0]);
                cal.set(Calendar.HOUR, hour == 12 ? 0 : hour);//12小时制,值为0-11
                cal.set(Calendar.MINUTE, Integer.parseInt(hms[1]));
                calendars.add(cal);
            }
        }
    }
    return calendars;
}
 
开发者ID:hulang1024,项目名称:PTEAssistant,代码行数:41,代码来源:AppointmentParser.java

示例9: loopOverBanks

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
private static List<Bank> loopOverBanks(String[] args) {
	Integer[] input = ArrayConverters.asIntegerArray(args);
	List<Bank> banks = new ArrayList<>();

	int size = input.length;
	boolean noCycle = true;
	Bank bank;
	do {
		bank = new Bank(input); // it also works as init
		int indexOf = banks.indexOf(bank);
		if (indexOf != -1) { // it's the second time we see this bank, we found the loop's entry point
			noCycle = false; // stop this
			bank.hits = 2;
			banks.set(indexOf, bank);
		} else {
			bank.hits = 1; // it's the first time we see this bank
			banks.add(bank);
		}
		input = input.clone(); // cloned in order to avoid side effect on previous input
		int max = Arrays.stream(input).max(Integer::compareTo).get(); // bank's max value...
		int index = ArrayUtils.indexOf(input, max); // ... and its index
		input[index] = 0; // apply puzzle specs
		for (; max > 0; max--) {
			++input[++index % size]; // circular array
		}

	} while (noCycle);
	return banks;
}
 
开发者ID:if0nz,项目名称:advent-of-code-2017,代码行数:30,代码来源:Day06.java

示例10: parseBoolean

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
 * Parses boolean arguments.
 * @param search The string array to search through.
 * @param include A string that also means true.
 * @return The first index of the boolean argument. Returns -1 if not found.
 */
public static int parseBoolean(String[] search, String include) {
	
	String[] words = new String[]{"true", "yes", "allow", include};
	for (String word : words) {
		int index = ArrayUtils.indexOf(search, word);
		if (index > -1) {
			return index;
		}
	}
	return -1;
}
 
开发者ID:Tisawesomeness,项目名称:Minecord,代码行数:18,代码来源:MessageUtils.java

示例11: cost

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
 *
 * cost = -1 * ln(ak)
 *
 * @param Ycalc
 * @param Yobs
 * @return
 */
@Override
public double cost(SimpleMatrix Ycalc, SimpleMatrix Yobs) {
    //averiguamos q salida correspondia para calcular el ajuste
    //(el resto se hace cero ya que -1 * {y = k} * ln(ak), en las 
    // otras salidas {y != k} => 0
    int Yk = ArrayUtils.indexOf(Yobs.getMatrix().getData(), 1);
    //obtenemso la salida
    double aCalc = Ycalc.get(Yk);
    //realizamos los calculos
    return -1 * Math.log(aCalc);
}
 
开发者ID:mroodschild,项目名称:froog,代码行数:20,代码来源:CrossEntropyLoss.java

示例12: SMAPIFormatter

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
public SMAPIFormatter(final String[] args) {
    if (args != null) {
        int index = ArrayUtils.indexOf(args, "-in");
        if (index < args.length - 1) {
            final String invocationName = args[index + 1];
            Validate.notBlank(invocationName, "Please provide an invocation name.");
            Validate.isTrue(!invocationName.startsWith("-"), "Please provide a valid invocation name.");
            this.model = new SMAPIModel(invocationName);
        }
    }
}
 
开发者ID:KayLerch,项目名称:alexa-utterance-generator,代码行数:12,代码来源:SMAPIFormatter.java

示例13: SkillBuilderFormatter

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
public SkillBuilderFormatter(final String[] args) {
    if (args != null) {
        int index = ArrayUtils.indexOf(args, "-in");
        if (index < args.length - 1) {
            final String invocationName = args[index + 1];
            Validate.notBlank(invocationName, "Please provide an invocation name.");
            Validate.isTrue(!invocationName.startsWith("-"), "Please provide a valid invocation name.");
            this.model = new SkillBuilderModel(invocationName);
        }
    }
}
 
开发者ID:KayLerch,项目名称:alexa-utterance-generator,代码行数:12,代码来源:SkillBuilderFormatter.java

示例14: retrieveValue

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
@Override
protected Byte retrieveValue(Field field, Object te) throws Exception {
    Object[] enumTypes = field.getType().getEnumConstants();
    return (byte) ArrayUtils.indexOf(enumTypes, field.get(te));
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:6,代码来源:SyncedField.java

示例15: getPosOnCompass

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
private double getPosOnCompass(String s) {
    double yaw = Math.toRadians(MathHelper.wrapDegrees(Helper.getLocalPlayer().rotationYaw - 90)); // player yaw
    int index = ArrayUtils.indexOf(DIRECTIONS, s)+1; // directions index in the list
    return yaw + index * HALF_PI;
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:6,代码来源:CompassMod.java


注:本文中的org.apache.commons.lang3.ArrayUtils.indexOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。