本文整理汇总了Java中java.util.LinkedList.toArray方法的典型用法代码示例。如果您正苦于以下问题:Java LinkedList.toArray方法的具体用法?Java LinkedList.toArray怎么用?Java LinkedList.toArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.LinkedList
的用法示例。
在下文中一共展示了LinkedList.toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initTransformer
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* 初始化类字节码的转换器
*
* @param inst 用于管理字节码转换器
*/
private static void initTransformer(Instrumentation inst) throws UnmodifiableClassException {
LinkedList<Class> retransformClasses = new LinkedList<Class>();
CustomClassTransformer customClassTransformer = new CustomClassTransformer();
inst.addTransformer(customClassTransformer, true);
Class[] loadedClasses = inst.getAllLoadedClasses();
for (Class clazz : loadedClasses) {
for (final AbstractClassHook hook : customClassTransformer.getHooks()) {
if (hook.isClassMatched(clazz.getName().replace(".", "/"))) {
if (inst.isModifiableClass(clazz) && !clazz.getName().startsWith("java.lang.invoke.LambdaForm")) {
retransformClasses.add(clazz);
}
}
}
}
// hook已经加载的类
Class[] classes = new Class[retransformClasses.size()];
retransformClasses.toArray(classes);
if (classes.length > 0) {
inst.retransformClasses(classes);
}
}
示例2: getSlotIndexs
import java.util.LinkedList; //导入方法依赖的package包/类
public String[] getSlotIndexs(ConsoleAccess telnet) throws IOException,
AbortedException {
StringTokenizer st = this.getResults(telnet, "show slot");
Matcher matcher;
LinkedList<String> slotList = new LinkedList<String>();
while (st.hasMoreTokens()) {
matcher = slotIndexPattern.matcher(st.nextToken());
if (matcher.matches()) {
slotList.add(matcher.group(1));
}
}
if (slotList.size() == 0)
return (new String[0]);
return slotList.toArray(new String[0]);
}
示例3: getFields
import java.util.LinkedList; //导入方法依赖的package包/类
public static String[] getFields(String line, char separator)
{
if(line != null && !line.equals(""))
{
StringBuffer field = new StringBuffer();
LinkedList fieldArr = new LinkedList();
for(int i = 0; i < line.length(); i++)
{
char ch = line.charAt(i);
if(ch == separator)
{
fieldArr.add(field.toString().trim());
field = new StringBuffer();
} else
{
field.append(ch);
}
}
fieldArr.add(field.toString().trim());
return (String[])fieldArr.toArray(new String[fieldArr.size()]);
} else
{
return new String[0];
}
}
示例4: fixEnum
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* Decodes a javax.naming.NamingEnumeration.
* Java's NamingEnumeration is a kludge: it holds a list
* and a hidden exception waiting to be thrown after the last
* list element is retrieved. But there's no way to discover
* the hidden exception without retrieving all the list elements.
*/
private ArrayExc fixEnum( NamingEnumeration enumeration) {
LinkedList lst = new LinkedList();
Exception hiddenExc = null;
try { // catch the hidden exception
while (enumeration.hasMore()) {
lst.add( enumeration.next());
}
}
catch( NamingException nex) {
hiddenExc = nex;
}
Object[] vals = lst.toArray();
return new ArrayExc( vals, hiddenExc);
}
示例5: main
import java.util.LinkedList; //导入方法依赖的package包/类
public static void main(String[] args)
{
String[] colors = {"black", "blue", "yellow"};
LinkedList<String> links = new LinkedList<>(Arrays.asList(colors));
links.addLast("red"); // add as last item
links.add("pink"); // add to the end
links.add(3, "green"); // add at 3rd index
links.addFirst("cyan"); // add as first item
// get LinkedList elements as an array
colors = links.toArray(new String[links.size()]);
System.out.println("colors: ");
for (String color : colors)
System.out.println(color);
}
示例6: readArrayLengthDataProvider
import java.util.LinkedList; //导入方法依赖的package包/类
@DataProvider(name = "readArrayLengthDataProvider")
public static Object[][] readArrayLengthDataProvider() {
LinkedList<Object[]> cfgSet = new LinkedList<>();
for (int i : new int[]{0, 1, 42}) {
createListOfDummyArrays(i).stream().forEach((array) -> {
cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(array), i});
});
}
cfgSet.add(new Object[]{null, null});
cfgSet.add(new Object[]{JavaConstant.NULL_POINTER, null});
cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.intField), null});
cfgSet.add(new Object[]{JavaConstant.forInt(DUMMY_CLASS_INSTANCE.intField), null});
return cfgSet.toArray(new Object[0][0]);
}
示例7: getNames
import java.util.LinkedList; //导入方法依赖的package包/类
public static synchronized String[] getNames() {
if (names == null) {
LinkedList<String> list = new LinkedList<String>();
InputStream str
= PlatformClasses.class
.getResourceAsStream("/com/sun/tools/hat/resources/platform_names.txt");
if (str != null) {
try {
BufferedReader rdr
= new BufferedReader(new InputStreamReader(str));
for (;;) {
String s = rdr.readLine();
if (s == null) {
break;
} else if (s.length() > 0) {
list.add(s);
}
}
rdr.close();
str.close();
} catch (IOException ex) {
ex.printStackTrace();
// Shouldn't happen, and if it does, continuing
// is the right thing to do anyway.
}
}
names = list.toArray(new String[list.size()]);
}
return names;
}
示例8: testToArray1_BadArg
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* toArray(incompatible array type) throws ArrayStoreException
*/
public void testToArray1_BadArg() {
LinkedList l = new LinkedList();
l.add(new Integer(5));
try {
l.toArray(new String[10]);
shouldThrow();
} catch (ArrayStoreException success) {}
}
示例9: findMethodsByExactParameters
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* Returns an array of all methods declared/overridden in a class with the specified parameter types.
* <p>
* <p>The return type is optional, it will not be compared if it is {@code null}.
* Use {@code void.class} if you want to search for methods returning nothing.
*
* @param clazz The class to look in.
* @param returnType The return type, or {@code null} (see above).
* @param parameterTypes The parameter types.
* @return An array with matching methods, all set to accessible already.
*/
public static Method[] findMethodsByExactParameters(final Class<?> clazz, final Class<?> returnType,
final Class<?>... parameterTypes) {
final LinkedList<Method> result = new LinkedList<>();
for (final Method method : clazz.getDeclaredMethods()) {
if (returnType != null && returnType != method.getReturnType())
continue;
final Class<?>[] methodParameterTypes = method.getParameterTypes();
if (parameterTypes.length != methodParameterTypes.length)
continue;
boolean match = true;
for (int i = 0; i < parameterTypes.length; ++i) {
if (parameterTypes[i] != methodParameterTypes[i]) {
match = false;
break;
}
}
if (!match)
continue;
method.setAccessible(true);
result.add(method);
}
return result.toArray(new Method[result.size()]);
}
示例10: getTriangles
import java.util.LinkedList; //导入方法依赖的package包/类
public Polygon[] getTriangles() {
LinkedList<Polygon> polygons = new LinkedList<>();
int[] indices1 = getXTriangles();
int[] indices2 = getYTriangles();
int[] indices3 = getZTriangles();
int[] xPoints = getXVertices();
int[] yPoints = getYVertices();
int[] zPoints = getZVertices();
int len = indices1.length;
for (int i = 0; i < len; ++i) {
Point p1 = Calculations.tileToCanvas(gridX + xPoints[indices1[i]], gridY + zPoints[indices1[i]],
-yPoints[indices1[i]] + z);
Point p2 = Calculations.tileToCanvas(gridX + xPoints[indices2[i]], gridY + zPoints[indices2[i]],
-yPoints[indices2[i]] + z);
Point p3 = Calculations.tileToCanvas(gridX + xPoints[indices3[i]], gridY + zPoints[indices3[i]],
-yPoints[indices3[i]] + z);
if (p1 != null && p2 != null && p3 != null) {
if (p1.x >= 0 && p2.x >= 0 && p3.x >= 0) {
polygons.add(new Polygon(new int[]{ p1.x, p2.x, p3.x }, new int[]{ p1.y, p2.y, p3.y }, 3));
}
}
}
return polygons.toArray(new Polygon[polygons.size()]);
}
示例11: getEditorCookies
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* Returns editor cookies available for modified and not open files in the commit table
* @return
*/
@Override
protected EditorCookie[] getEditorCookies () {
LinkedList<EditorCookie> allCookies = new LinkedList<EditorCookie>();
if (controller != null) {
EditorCookie[] cookies = controller.getEditorCookies(true);
if (cookies.length > 0) {
allCookies.add(cookies[0]);
}
}
return allCookies.toArray(new EditorCookie[allCookies.size()]);
}
示例12: getSickKind
import java.util.LinkedList; //导入方法依赖的package包/类
public String[] getSickKind() {
LinkedList<String> temp=new LinkedList<>();
for(String name:sickKind.keySet())
temp.add(name);
if(temp.size()==0)
return null;
return (String[])temp.toArray(new String[temp.size()]);
}
示例13: getEditorCookies
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* Returns editor cookies available for modified and not open files in the commit table
* @return
*/
EditorCookie[] getEditorCookies() {
LinkedList<EditorCookie> allCookies = new LinkedList<EditorCookie>();
for (Map.Entry<File, MultiDiffPanel> e : displayedDiffs.entrySet()) {
EditorCookie[] cookies = e.getValue().getEditorCookies(true);
if (cookies.length > 0) {
allCookies.add(cookies[0]);
}
}
return allCookies.toArray(new EditorCookie[allCookies.size()]);
}
示例14: validate
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* Overall validation
* @param value Value to validate
* @throws OverallValidationException If validation fails
*/
protected void validate(PropertyBox value) throws OverallValidationException {
LinkedList<ValidationException> failures = new LinkedList<>();
for (Validator<PropertyBox> validator : getValidators()) {
try {
validator.validate(value);
} catch (ValidationException ve) {
failures.add(ve);
if (isStopOverallValidationAtFirstFailure()) {
break;
}
}
}
// collect validation exceptions, if any
if (!failures.isEmpty()) {
OverallValidationException validationException = (failures.size() == 1)
? new OverallValidationException(failures.getFirst().getMessage(),
failures.getFirst().getMessageCode(), failures.getFirst().getMessageArguments())
: new OverallValidationException(failures.toArray(new ValidationException[failures.size()]));
// notify validation status
notifyInvalidValidationStatus(validationException, getOverallValueComponent().orElse(null), null);
throw validationException;
}
// notify validation status
notifyValidValidationStatus(getOverallValueComponent().orElse(null), null);
}
示例15: getDrivers
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* Gets the registered JDBC drivers with the specified class name.
*
* @param drvClass driver class name; must not be null.
*
* @return a non-null array of JDBCDriver instances with the specified class name.
*
* @throws NullPointerException if the specified class name is null.
*/
public JDBCDriver[] getDrivers(String drvClass) {
if (drvClass == null) {
throw new NullPointerException();
}
LinkedList<JDBCDriver> res = new LinkedList<>();
JDBCDriver[] drvs = getDrivers();
for (int i = 0; i < drvs.length; i++) {
if (drvClass.equals(drvs[i].getClassName())) {
res.add(drvs[i]);
}
}
return res.toArray (new JDBCDriver[res.size ()]);
}