當前位置: 首頁>>代碼示例>>Java>>正文


Java ArrayList.toArray方法代碼示例

本文整理匯總了Java中java.util.ArrayList.toArray方法的典型用法代碼示例。如果您正苦於以下問題:Java ArrayList.toArray方法的具體用法?Java ArrayList.toArray怎麽用?Java ArrayList.toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.ArrayList的用法示例。


在下文中一共展示了ArrayList.toArray方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getValves

import java.util.ArrayList; //導入方法依賴的package包/類
/**
 * Return the set of Valves in the pipeline associated with this
 * Container, including the basic Valve (if any).  If there are no
 * such Valves, a zero-length array is returned.
 */
public Valve[] getValves() {

	ArrayList valveList = new ArrayList();
    Valve current = first;
    if (current == null) {
    	current = basic;
    }
    while (current != null) {
    	valveList.add(current);
    	current = current.getNext();
    }

    return ((Valve[]) valveList.toArray(new Valve[0]));

}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:21,代碼來源:StandardPipeline.java

示例2: decodeWaypointConstraint

import java.util.ArrayList; //導入方法依賴的package包/類
/**
 * Decodes a waypoint constraint.
 *
 * @return waypoint constraint object.
 */
private Constraint decodeWaypointConstraint() {
    JsonNode waypoints = nullIsIllegal(json.get(ConstraintCodec.WAYPOINTS),
            ConstraintCodec.WAYPOINTS + ConstraintCodec.MISSING_MEMBER_MESSAGE);
    if (waypoints.size() < 1) {
        throw new IllegalArgumentException(
                "obstacles array in obstacles constraint must have at least one value");
    }

    ArrayList<DeviceId> waypointEntries = new ArrayList<>(waypoints.size());
    IntStream.range(0, waypoints.size())
            .forEach(index ->
                    waypointEntries.add(DeviceId.deviceId(waypoints.get(index).asText())));

    return new WaypointConstraint(
            waypointEntries.toArray(new DeviceId[waypoints.size()]));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:22,代碼來源:DecodeConstraintCodecHelper.java

示例3: getResourceLinks

import java.util.ArrayList; //導入方法依賴的package包/類
/**
 * Return the MBean Names of all the defined resource link references for 
 * this application.
 */
public String[] getResourceLinks() {
    
    ContextResourceLink[] resourceLinks = 
                        ((NamingResources)this.resource).findResourceLinks();
    ArrayList results = new ArrayList();
    for (int i = 0; i < resourceLinks.length; i++) {
        try {
            ObjectName oname =
                MBeanUtils.createObjectName(managed.getDomain(), resourceLinks[i]);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            throw new IllegalArgumentException
                ("Cannot create object name for resource " + resourceLinks[i]);
        }
    }
    return ((String[]) results.toArray(new String[results.size()]));

}
 
開發者ID:c-rainstorm,項目名稱:jerrydog,代碼行數:23,代碼來源:NamingResourcesMBean.java

示例4: getSign

import java.util.ArrayList; //導入方法依賴的package包/類
public static String getSign(Map<String,Object> map, String key){
	ArrayList<String> list = new ArrayList<String>();
	for(Map.Entry<String,Object> entry:map.entrySet()){
		if(!"".equals(entry.getValue())){
			list.add(entry.getKey() + "=" + entry.getValue() + "&");
		}
	}
	int size = list.size();
	String [] arrayToSort = list.toArray(new String[size]);
	Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER);
	StringBuilder sb = new StringBuilder();
	for(int i = 0; i < size; i ++) {
		sb.append(arrayToSort[i]);
	}
	String result = sb.toString();
	result += "key=" + key;
	_log.debug("Sign Before MD5:" + result);
	result = md5(result, encodingCharset).toUpperCase();
	_log.debug("Sign Result:" + result);
	return result;
}
 
開發者ID:jmdhappy,項目名稱:xxpay-master,代碼行數:22,代碼來源:PayDigestUtil.java

示例5: getChildren

import java.util.ArrayList; //導入方法依賴的package包/類
public XppDom[] getChildren(final String name) {
    if (null == childList) {
        return new XppDom[0];
    } else {
        final ArrayList<XppDom> children = new ArrayList<XppDom>();
        final int size = childList.size();

        for (int i = 0; i < size; i++) {
            final XppDom configuration = childList.get(i);
            if (name.equals(configuration.getName())) {
                children.add(configuration);
            }
        }

        return children.toArray(new XppDom[0]);
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:18,代碼來源:XppDom.java

示例6: readSpecFile

import java.util.ArrayList; //導入方法依賴的package包/類
/**
* Read and parse a Unicode data file.
*
* @param file   a file specifying the Unicode data file to be read
* @return   an array of UnicodeSpec objects, one for each line of the
*           Unicode data file that could be successfully parsed as
*           specifying Unicode character attributes
*/

public static UnicodeSpec[] readSpecFile(File file, int plane) throws FileNotFoundException {
    ArrayList<UnicodeSpec> list = new ArrayList<>(3000);
    UnicodeSpec[] result = null;
    int count = 0;
    BufferedReader f = new BufferedReader(new FileReader(file));
    String line = null;
    loop:
    while(true) {
        try {
            line = f.readLine();
        }
        catch (IOException e) {
            break loop;
        }
        if (line == null) break loop;
        UnicodeSpec item = parse(line.trim());
        int specPlane = item.getCodePoint() >>> 16;
        if (specPlane < plane) continue;
        if (specPlane > plane) break;

        if (item != null) {
            list.add(item);
        }
    }
    result = new UnicodeSpec[list.size()];
    list.toArray(result);
    return result;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:38,代碼來源:UnicodeSpec.java

示例7: resolveAnnotationValue

import java.util.ArrayList; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
protected static <T> T resolveAnnotationValue(Class<T> expectedType, AnnotationValue value) {
    if (value == null) {
        return null;
    }
    if (expectedType.isArray()) {
        ArrayList<Object> result = new ArrayList<>();
        List<AnnotationValue> l = (List<AnnotationValue>) value.getValue();
        for (AnnotationValue el : l) {
            result.add(resolveAnnotationValue(expectedType.getComponentType(), el));
        }
        return (T) result.toArray((Object[]) Array.newInstance(expectedType.getComponentType(), result.size()));
    }
    Object unboxedValue = value.getValue();
    if (unboxedValue != null) {
        if (expectedType == TypeMirror.class && unboxedValue instanceof String) {
            /*
             * Happens if type is invalid when using the ECJ compiler. The ECJ does not match
             * AP-API specification here.
             */
            return null;
        }
        if (!expectedType.isAssignableFrom(unboxedValue.getClass())) {
            throw new ClassCastException(unboxedValue.getClass().getName() + " not assignable from " + expectedType.getName());
        }
    }
    return (T) unboxedValue;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:29,代碼來源:AbstractVerifier.java

示例8: findApplicationListeners

import java.util.ArrayList; //導入方法依賴的package包/類
/**
 * Return the set of application listener class names configured
 * for this application.
 */
@Override
public String[] findApplicationListeners() {

    ArrayList<String> list =
            new ArrayList<String>(applicationListeners.length);
    for (ApplicationListener applicationListener: applicationListeners) {
        list.add(applicationListener.getClassName());
    }
    
    return list.toArray(new String[list.size()]);

}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:17,代碼來源:StandardContext.java

示例9: generateTestConfigs

import java.util.ArrayList; //導入方法依賴的package包/類
protected TestConfig[] generateTestConfigs(int numberOfTests, TestDoc[] testDocs, TestFieldSetting[] fieldSettings) {
    ArrayList<TestConfig> configs = new ArrayList<>();
    for (int i = 0; i < numberOfTests; i++) {

        ArrayList<String> selectedFields = null;
        if (randomBoolean()) {
            // used field selection
            selectedFields = new ArrayList<>();
            if (randomBoolean()) {
                selectedFields.add("Doesnt_exist"); // this will be ignored.
            }
            for (TestFieldSetting field : fieldSettings)
                if (randomBoolean()) {
                    selectedFields.add(field.name);
                }

            if (selectedFields.size() == 0) {
                selectedFields = null; // 0 length set is not supported.
            }

        }
        TestConfig config = new TestConfig(testDocs[randomInt(testDocs.length - 1)], selectedFields == null ? null
                : selectedFields.toArray(new String[]{}), randomBoolean(), randomBoolean(), randomBoolean());

        configs.add(config);
    }
    // always adds a test that fails
    configs.add(new TestConfig(new TestDoc("doesnt_exist", new TestFieldSetting[]{}, new String[]{}).index("doesn't_exist").alias("doesn't_exist"),
            new String[]{"doesnt_exist"}, true, true, true).expectedException(org.elasticsearch.index.IndexNotFoundException.class));

    refresh();

    return configs.toArray(new TestConfig[configs.size()]);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:35,代碼來源:AbstractTermVectorsTestCase.java

示例10: getByCommand

import java.util.ArrayList; //導入方法依賴的package包/類
public static InetAddress[] getByCommand() {
    try {
        LineNumberReader lnr = new LineNumberReader(new InputStreamReader(Runtime.getRuntime
                ().exec("getprop").getInputStream()));
        ArrayList<InetAddress> servers = new ArrayList(5);
        while (true) {
            String line = lnr.readLine();
            if (line == null) {
                break;
            }
            int split = line.indexOf("]: [");
            if (split != -1) {
                String property = line.substring(1, split);
                String value = line.substring(split + 4, line.length() - 1);
                if (property.endsWith(".dns") || property.endsWith(".dns1") || property
                        .endsWith(".dns2") || property.endsWith(".dns3") || property.endsWith
                        (".dns4")) {
                    InetAddress ip = InetAddress.getByName(value);
                    if (ip != null) {
                        value = ip.getHostAddress();
                        if (!(value == null || value.length() == 0)) {
                            servers.add(ip);
                        }
                    }
                }
            }
        }
        if (servers.size() > 0) {
            return (InetAddress[]) servers.toArray(new InetAddress[servers.size()]);
        }
    } catch (IOException e) {
        Logger.getLogger("AndroidDnsServer").log(Level.WARNING, "Exception in findDNSByExec",
                e);
    }
    return null;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:37,代碼來源:AndroidDnsServer.java

示例11: getValues

import java.util.ArrayList; //導入方法依賴的package包/類
String[] getValues() {
    ArrayList valueList = new ArrayList();
    FormControl[] controls = getControls();
    for (int i = 0; i < controls.length; i++) {
        valueList.addAll( Arrays.asList( controls[i].getValues() ) );
    }
    return (String[]) valueList.toArray( new String[ valueList.size() ] );
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:9,代碼來源:FormParameter.java

示例12: initializeTableA

import java.util.ArrayList; //導入方法依賴的package包/類
public static VoltTable initializeTableA() {
    ArrayList<VoltTable.ColumnInfo> columns = new ArrayList<VoltTable.ColumnInfo>();
    String prefix = "A";

    columns.add(new VoltTable.ColumnInfo(prefix + "_ID", VoltType.BIGINT));
    addStringColumns(columns, 20, prefix);
    addIntegerColumns(columns, 20, prefix);

    VoltTable.ColumnInfo cols[] = new VoltTable.ColumnInfo[columns.size()];
    return (new VoltTable(columns.toArray(cols)));
}
 
開發者ID:s-store,項目名稱:s-store,代碼行數:12,代碼來源:MarkovTables.java

示例13: splitOnTokens

import java.util.ArrayList; //導入方法依賴的package包/類
/**
 * Splits a string into a number of tokens.
 * The text is split by '?' and '*'.
 * Where multiple '*' occur consecutively they are collapsed into a single '*'.
 * 
 * @param text  the text to split
 * @return the array of tokens, never null
 */
static String[] splitOnTokens(String text) {
    // used by wildcardMatch
    // package level so a unit test may run on this
    
    if (text.indexOf('?') == -1 && text.indexOf('*') == -1) {
        return new String[] { text };
    }

    char[] array = text.toCharArray();
    ArrayList<String> list = new ArrayList<String>();
    StringBuilder buffer = new StringBuilder();
    for (int i = 0; i < array.length; i++) {
        if (array[i] == '?' || array[i] == '*') {
            if (buffer.length() != 0) {
                list.add(buffer.toString());
                buffer.setLength(0);
            }
            if (array[i] == '?') {
                list.add("?");
            } else if (list.size() == 0 ||
                    (i > 0 && list.get(list.size() - 1).equals("*") == false)) {
                list.add("*");
            }
        } else {
            buffer.append(array[i]);
        }
    }
    if (buffer.length() != 0) {
        list.add(buffer.toString());
    }

    return list.toArray( new String[ list.size() ] );
}
 
開發者ID:fesch,項目名稱:Moenagade,代碼行數:42,代碼來源:FilenameUtils.java

示例14: setOriginalParser

import java.util.ArrayList; //導入方法依賴的package包/類
public void setOriginalParser(ArrayList<String> vargs) throws Exception
{
   
    String[] args = new String[vargs.size()];
    args = vargs.toArray(args);
    
    this.m_origianlParser = ArgumentsParser.load(args,
            ArgumentsParser.PARAM_CATALOG
            );
    
    catalog = this.m_origianlParser.catalog;
}
 
開發者ID:s-store,項目名稱:s-store,代碼行數:13,代碼來源:AnotherArgumentsParser.java

示例15: computeLineText

import java.util.ArrayList; //導入方法依賴的package包/類
private void computeLineText(FontMetrics fm) {
	String text = exprData.text;
	int[] badness = exprData.badness;

	if (fm.stringWidth(text) <= width) {
		lineText = new String[] { text };
		return;
	}

	int startPos = 0;
	ArrayList<String> lines = new ArrayList<String>();
	while (startPos < text.length()) {
		int stopPos = startPos + 1;
		String bestLine = text.substring(startPos, stopPos);
		if (stopPos >= text.length()) {
			lines.add(bestLine);
			break;
		}
		int bestStopPos = stopPos;
		int lineWidth = fm.stringWidth(bestLine);
		int bestBadness = badness[stopPos] + (width - lineWidth) * BADNESS_PER_PIXEL;
		while (stopPos < text.length()) {
			++stopPos;
			String line = text.substring(startPos, stopPos);
			lineWidth = fm.stringWidth(line);
			if (lineWidth > width)
				break;

			int lineBadness = badness[stopPos] + (width - lineWidth) * BADNESS_PER_PIXEL;
			if (lineBadness < bestBadness) {
				bestBadness = lineBadness;
				bestStopPos = stopPos;
				bestLine = line;
			}
		}
		lines.add(bestLine);
		startPos = bestStopPos;
	}
	lineText = lines.toArray(new String[lines.size()]);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:41,代碼來源:ExpressionView.java


注:本文中的java.util.ArrayList.toArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。