Package net.jcores.jre.cores

Examples of net.jcores.jre.cores.CoreString


        System.out.println($("hello", "you", "world", null).hasAll());

        $("Hello world").log();

        final CoreString lines = $("test.txt").file().text().split("\n").filter("asd");
        CoreString filter = lines.filter("asd");
        System.out.println(filter.as(CoreString.class).file());

        System.out.println($(" asjl lk saklj dlkasj dlkdj alsdj as").split(" ").size());

        $("documentation/TODO.txt").file().text().split("\n").split(" ").filter(".*ish.*").print();
        $("documentation/TODO.txt").file().text().map(new F1<String, File>() {
            public File f(String x) {
                return new File(x.toLowerCase());
            }
        }).as(CoreObject.class);//.print();

        F0 f[] = new F0[] { new F0Impl(), new F0Impl(), new F0Impl() };
        $(f).each(F0.class).f();

        $(f).as(ExtensionCore.class).yoyo();
        //$(f).as(CoreSerializer.class).store("test.xml");
        //System.out.println($("test.xml").as(CoreSerializer.class).load().size());

        /*
        $(F0.class).implementor(F0Impl.class);
        for (int i = 0; i < 100000; i++) {
           // F0 spawn = $(F0.class).spawn();
            if (i % 1000 == 0) {
                //size = $(F0.class).spawned().size();
                //System.out.println(size);
            }
        }*/

        CoreString c1 = $($(f).list()).as(CoreString.class);
        CoreString c2 = $($("hello", "world").list()).as(CoreString.class);
        System.out.println(c1.size());
        System.out.println(c2.size());
        System.out.println($("hello").as(CoreObject.class).call("toUpperCase").get(0));

        System.out.println("---");
        CoreObject<String> expand = $("", "", "").map(new F1<String, String[]>() {
            public String[] f(String x) {
                return new String[] { "Hello", "owlrd" };
            }
        }).expand(String.class).as(CoreString.class);
        System.out.println(expand.size());

        CoreString e2 = $("", "", "").map(new F1<String, List<String>>() {
            public List<String> f(String x) {
                ArrayList<String> arrayList = new ArrayList<String>();
                arrayList.add("X");
                arrayList.add("y");
                arrayList.add("z");
                return arrayList;
            }
        }).expand(String.class).as(CoreString.class);
        String join = e2.join(" ");
        System.out.println("'" + join + "'");

        $("debug1.txt", "debug2.txt").file().delete().append(join);

        //System.out.println(array[0]);
View Full Code Here


    /**
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        CoreString input = $("Evaluated.txt").file().text().string().split("\n");

        CoreObject<String> x0 = x(input, 0);
        CoreObject<String> x1 = x(input, 1);
        CoreObject<String> x2 = x(input, 2);
        CoreObject<String> x3 = x(input, 3);
        CoreObject<String> x4 = x(input, 4);

        for (int a = 0; a < x0.size(); a++) {
            for (int b = 0; b < x1.size(); b++) {
                for (int c = 0; c < x2.size(); c++) {
                    for (int d = 0; d < x3.size(); d++) {
                        for (int e = 0; e < x4.size(); e++) {
                            String s = $(x0.get(a),x1.get(b),x2.get(c),x3.get(d),x4.get(e)).string().join(",") ;
                            if(!input.containssubstr(s))
                            System.out.println(s +": " + input.containssubstr(s));
                           
                        }

                    }

View Full Code Here

   

    /** Tests if async() works. */
    @Test
    public void testAsync() {
        final CoreString c = $("a", "b", "c", "d", "e");
        final F1<String, String> f = new F1<String, String>() {
            @Override
            public String f(String x) {
                $.sys.sleep(100);
                return x + x;
            }
        };
       
        CoreObject<String> result = c.async(f).await();
        Assert.assertEquals("aabbccddee", result.string().join());
       
        CoreObject<String> result2 = c.async(f, KillSwitch.TIMED(150)).await();
        Assert.assertTrue(result2.contains("aa"));
        Assert.assertFalse(result2.contains("cc"));
    }
View Full Code Here

   

    /** */
    @Test
    public void testIndex() {
        final CoreString cs = $(Data.sn);
        Assert.assertEquals(2, cs.index("2").i(0));
        Assert.assertEquals(20, cs.index("10", "20").i(1));
    }
View Full Code Here

    */
   
    /** Test if the iterator works as expected */
    @Test
    public void testAllAny() {
        final CoreString c = $(null, "a", "b", null, null, "c", null);
        Assert.assertTrue(c.hasAny());
        Assert.assertFalse(c.hasAll());

        CoreObject<Object> d = $(new Object[] { null });
        Assert.assertFalse(d.hasAny());
        Assert.assertFalse(d.hasAll());
       
       
        CoreString e = $("a", "b");
        Assert.assertTrue(e.hasAny());
        Assert.assertTrue(e.hasAll());

    }
View Full Code Here

    /** */
    @Test
    public void testSerialize() {
        $("hello", "world").as(CoreObject.class).serialize("test.jcores");
        final CoreString converted = $("test.jcores").file().deserialize(String.class).string();
        $.report();
        Assert.assertEquals("helloworld", converted.join());

        $(Data.strings(10000)).as(CoreObject.class).serialize("big.file");
    }
View Full Code Here

     *
     * @param object The Strings to wrap.
     * @return A CoreString wrapping the given strings.
     */
    public static CoreString $(String... object) {
        return new CoreString($, object);
    }
View Full Code Here

TOP

Related Classes of net.jcores.jre.cores.CoreString

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.