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


Java Iterables.toArray方法代码示例

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


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

示例1: loadLocaleData

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private void loadLocaleData(InputStream inputStreamIn) throws IOException
{
    inputStreamIn = net.minecraftforge.fml.common.FMLCommonHandler.instance().loadLanguage(properties, inputStreamIn);
    if (inputStreamIn == null) return;
    for (String s : IOUtils.readLines(inputStreamIn, Charsets.UTF_8))
    {
        if (!s.isEmpty() && s.charAt(0) != 35)
        {
            String[] astring = (String[])Iterables.toArray(SPLITTER.split(s), String.class);

            if (astring != null && astring.length == 2)
            {
                String s1 = astring[0];
                String s2 = PATTERN.matcher(astring[1]).replaceAll("%$1s");
                this.properties.put(s1, s2);
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:20,代码来源:Locale.java

示例2: loadLocaleData

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private void loadLocaleData(InputStream inputStreamIn) throws IOException
{
    for (String s : IOUtils.readLines(inputStreamIn, Charsets.UTF_8))
    {
        if (!s.isEmpty() && s.charAt(0) != 35)
        {
            String[] astring = (String[])Iterables.toArray(SPLITTER.split(s), String.class);

            if (astring != null && astring.length == 2)
            {
                String s1 = astring[0];
                String s2 = PATTERN.matcher(astring[1]).replaceAll("%$1s");
                this.properties.put(s1, s2);
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:18,代码来源:Locale.java

示例3: LanguageMap

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public LanguageMap()
{
    try
    {
        InputStream inputstream = LanguageMap.class.getResourceAsStream("/assets/minecraft/lang/en_us.lang");

        for (String s : IOUtils.readLines(inputstream, Charsets.UTF_8))
        {
            if (!s.isEmpty() && s.charAt(0) != 35)
            {
                String[] astring = (String[])Iterables.toArray(EQUAL_SIGN_SPLITTER.split(s), String.class);

                if (astring != null && astring.length == 2)
                {
                    String s1 = astring[0];
                    String s2 = NUMERIC_VARIABLE_PATTERN.matcher(astring[1]).replaceAll("%$1s");
                    this.languageList.put(s1, s2);
                }
            }
        }

        this.lastUpdateTimeInMilliseconds = System.currentTimeMillis();
    }
    catch (IOException var7)
    {
        ;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:29,代码来源:LanguageMap.java

示例4: parseRule

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private static ParsedTestRule parseRule(String rule) {
    String[] splittedRuleLine = Iterables.toArray(Splitter.on(EXPECTED_OUTPUT_SEPARATOR).split(rule), String.class);
    String unsplittedInputAndColumnNbr = splittedRuleLine[0];
    String[] splittedInputAndColumnNbr = Iterables.toArray(Splitter.on(INPUT_SEPARATOR).split(unsplittedInputAndColumnNbr), String.class);

    String input = splittedInputAndColumnNbr[0];
    String rawColumnNbr = splittedInputAndColumnNbr[1];
    Integer columnNbr = null;
    try {
        columnNbr = Integer.valueOf(rawColumnNbr.trim());
    } catch (NumberFormatException e) {
        throw new RuntimeException("Could not read columnNbr '" + rawColumnNbr + "'.", e);
    }
    String rawExpectedResult = splittedRuleLine[1].trim();

    String expectedResult = rawExpectedResult.replaceAll("(\\\\n)+", "\n");
    return new ParsedTestRule(input, columnNbr, expectedResult);
}
 
开发者ID:JanMosigItemis,项目名称:codingdojoleipzig,代码行数:19,代码来源:TestRuleParser.java

示例5: loadLocaleData

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public static void loadLocaleData(InputStream p_loadLocaleData_0_, Map p_loadLocaleData_1_) throws IOException
{
    for (String s : IOUtils.readLines(p_loadLocaleData_0_, Charsets.UTF_8))
    {
        if (!s.isEmpty() && s.charAt(0) != 35)
        {
            String[] astring = (String[])((String[])Iterables.toArray(splitter.split(s), String.class));

            if (astring != null && astring.length == 2)
            {
                String s1 = astring[0];
                String s2 = pattern.matcher(astring[1]).replaceAll("%$1s");
                p_loadLocaleData_1_.put(s1, s2);
            }
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:18,代码来源:Lang.java

示例6: loadLocaleData

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private void loadLocaleData(InputStream p_135021_1_) throws IOException
{
    for (String s : IOUtils.readLines(p_135021_1_, Charsets.UTF_8))
    {
        if (!s.isEmpty() && s.charAt(0) != 35)
        {
            String[] astring = (String[])Iterables.toArray(splitter.split(s), String.class);

            if (astring != null && astring.length == 2)
            {
                String s1 = astring[0];
                String s2 = pattern.matcher(astring[1]).replaceAll("%$1s");
                this.properties.put(s1, s2);
            }
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:18,代码来源:Locale.java

示例7: StringTranslate

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public StringTranslate()
{
    try
    {
        InputStream inputstream = StringTranslate.class.getResourceAsStream("/assets/minecraft/lang/en_US.lang");

        for (String s : IOUtils.readLines(inputstream, Charsets.UTF_8))
        {
            if (!s.isEmpty() && s.charAt(0) != 35)
            {
                String[] astring = (String[])Iterables.toArray(equalSignSplitter.split(s), String.class);

                if (astring != null && astring.length == 2)
                {
                    String s1 = astring[0];
                    String s2 = numericVariablePattern.matcher(astring[1]).replaceAll("%$1s");
                    this.languageList.put(s1, s2);
                }
            }
        }

        this.lastUpdateTimeInMilliseconds = System.currentTimeMillis();
    }
    catch (IOException var7)
    {
        ;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:29,代码来源:StringTranslate.java

示例8: getConsoleContentLines

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private String[] getConsoleContentLines() {
	final List<String> lines = newArrayList(getConsoleContent().split("\r\n?|\n"));
	// Instead of returning a single element array with an empty string, return with an empty array.
	if (lines.size() == 1 && "".equals(lines.get(0))) {
		return new String[0];
	}
	Collections.sort(lines);
	return Iterables.toArray(lines, String.class);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:10,代码来源:GHOLD_45_CheckIgnoreAnnotationAtClassLevel_PluginUITest.java

示例9: filter

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
 * Filters the elements from the array given as the argument. Always returns with a new array instance containing
 * all those elements from the original list whose class is assignable form the {@code predicate} class argument.
 *
 * @param array
 *            the input array to filter.
 * @param predicate
 *            the predicate class to filter.
 * @return a new type safe filtered array instance.
 */
public static <F, T extends F> T[] filter(final F[] array, final Class<T> predicate) {
	checkNotNull(array, "array");
	checkNotNull(predicate, "clazz");
	final int size = array.length;
	final List<T> result = Lists.newArrayListWithExpectedSize(size);
	for (int i = 0; i < size; i++) {
		final F actual = array[i];
		if (null != actual && predicate.isAssignableFrom(actual.getClass())) {
			result.add(predicate.cast(actual));
		}
	}
	return Iterables.toArray(result, predicate);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:24,代码来源:Arrays2.java

示例10: setupLoadOnly

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public void setupLoadOnly(String deobfFileName, boolean loadAll)
{
    try
    {
        File mapData = new File(deobfFileName);
        LZMAInputSupplier zis = new LZMAInputSupplier(new FileInputStream(mapData));
        CharSource srgSource = zis.asCharSource(Charsets.UTF_8);
        List<String> srgList = srgSource.readLines();
        rawMethodMaps = Maps.newHashMap();
        rawFieldMaps = Maps.newHashMap();
        Builder<String, String> builder = ImmutableBiMap.builder();
        Splitter splitter = Splitter.on(CharMatcher.anyOf(": ")).omitEmptyStrings().trimResults();
        for (String line : srgList)
        {
            String[] parts = Iterables.toArray(splitter.split(line),String.class);
            String typ = parts[0];
            if ("CL".equals(typ))
            {
                parseClass(builder, parts);
            }
            else if ("MD".equals(typ) && loadAll)
            {
                parseMethod(parts);
            }
            else if ("FD".equals(typ) && loadAll)
            {
                parseField(parts);
            }
        }
        classNameBiMap = builder.build();
    }
    catch (IOException ioe)
    {
        FMLRelaunchLog.log(Level.ERROR, "An error occurred loading the deobfuscation map data", ioe);
    }
    methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size());
    fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size());

}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:40,代码来源:FMLDeobfuscatingRemapper.java

示例11: testProjectFilterSubqueryPlan

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Test
  public void testProjectFilterSubqueryPlan() throws Exception {
    LogicalPlan plan = JdbcAssert
        .withModel(MODEL, "DONUTS")
        .sql(
            "select d['name'] as name, d['xx'] as xx from (\n" + " select _MAP['donuts'] as d from donuts)\n"
                + "where cast(d['ppu'] as double) > 0.6")
        .logicalPlan();
    PlanProperties planProperties = plan.getProperties();
    Assert.assertEquals("optiq", planProperties.generator.type);
    Assert.assertEquals("na", planProperties.generator.info);
    Assert.assertEquals(1, planProperties.version);
    Assert.assertEquals(PlanProperties.PlanType.LOGICAL, planProperties.type);
    Map<String, StoragePluginConfig> seConfigs = plan.getStorageEngines();
    StoragePluginConfig config = seConfigs.get("donuts-json");
//    Assert.assertTrue(config != null && config instanceof ClasspathRSE.ClasspathRSEConfig);
    config = seConfigs.get("queue");
//    Assert.assertTrue(config != null && config instanceof QueueRSE.QueueRSEConfig);
    Scan scan = findOnlyOperator(plan, Scan.class);
    Assert.assertEquals("donuts-json", scan.getStorageEngine());
    Filter filter = findOnlyOperator(plan, Filter.class);
    Assert.assertTrue(filter.getInput() instanceof Scan);
    Project[] projects = Iterables.toArray(findOperator(plan, Project.class), Project.class);
    Assert.assertEquals(2, projects.length);
    Assert.assertEquals(1, projects[0].getSelections().size());
    Assert.assertEquals(Filter.class, projects[0].getInput().getClass());
    Assert.assertEquals(2, projects[1].getSelections().size());
    Assert.assertEquals(Project.class, projects[1].getInput().getClass());
    Store store = findOnlyOperator(plan, Store.class);
    Assert.assertEquals("queue", store.getStorageEngine());
    Assert.assertEquals("output sink", store.getMemo());
    Assert.assertEquals(Project.class, store.getInput().getClass());
  }
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:34,代码来源:JdbcDataTest.java

示例12: matchInAnyOrder

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public void matchInAnyOrder(Iterable<Class<?>> classes) {
    Class<?>[] sorted = Iterables.toArray(classes, Class.class);
    Arrays.sort(sorted, new Comparator<Class<?>>() {
        @Override
        public int compare(Class<?> o1, Class<?> o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });
    matchExactly(sorted);
}
 
开发者ID:TNG,项目名称:ArchUnit,代码行数:11,代码来源:Assertions.java

示例13: getRevTree

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public static RevTree getRevTree(final Repository repository) {
    try (Git git = new Git(repository)) {
        Iterable<RevCommit> commits = git.log().all().call();
        RevCommit array[] = Iterables.toArray(commits, RevCommit.class);
        return array[0].getTree();
    } catch (GitAPIException | IOException ex) {
        Logger.getLogger(DbIndex.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    }
}
 
开发者ID:alexmy21,项目名称:gmds,代码行数:11,代码来源:DbIndex.java

示例14: setup

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public void setup(File mcDir, LaunchClassLoader classLoader, String deobfFileName)
{
    this.classLoader = classLoader;
    try
    {
        List<String> srgList;
        final String gradleStartProp = System.getProperty("net.minecraftforge.gradle.GradleStart.srg.srg-mcp");

        if (Strings.isNullOrEmpty(gradleStartProp))
        {
            // get as a resource
            InputStream classData = getClass().getResourceAsStream(deobfFileName);
            LZMAInputSupplier zis = new LZMAInputSupplier(classData);
            CharSource srgSource = zis.asCharSource(Charsets.UTF_8);
            srgList = srgSource.readLines();
            FMLRelaunchLog.fine("Loading deobfuscation resource %s with %d records", deobfFileName, srgList.size());
        }
        else
        {
            srgList = Files.readLines(new File(gradleStartProp), Charsets.UTF_8);
            FMLRelaunchLog.fine("Loading deobfuscation resource %s with %d records", gradleStartProp, srgList.size());
        }

        rawMethodMaps = Maps.newHashMap();
        rawFieldMaps = Maps.newHashMap();
        Builder<String, String> builder = ImmutableBiMap.builder();
        Splitter splitter = Splitter.on(CharMatcher.anyOf(": ")).omitEmptyStrings().trimResults();
        for (String line : srgList)
        {
            String[] parts = Iterables.toArray(splitter.split(line),String.class);
            String typ = parts[0];
            if ("CL".equals(typ))
            {
                parseClass(builder, parts);
            }
            else if ("MD".equals(typ))
            {
                parseMethod(parts);
            }
            else if ("FD".equals(typ))
            {
                parseField(parts);
            }
        }
        classNameBiMap = builder.build();
    }
    catch (IOException ioe)
    {
        FMLRelaunchLog.log(Level.ERROR, ioe, "An error occurred loading the deobfuscation map data");
    }
    methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size());
    fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size());
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:54,代码来源:FMLDeobfuscatingRemapper.java

示例15: adaptElements

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public IAdaptable[] adaptElements(final IAdaptable[] objects) {
	final ArrayList<IAdaptable> elements = newArrayList(getElements());
	elements.retainAll(newArrayList(objects));
	return Iterables.toArray(elements, IAdaptable.class);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:7,代码来源:WorkingSetAdapter.java


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