Moving modules around so the runtime is under one master pom and can be built without building other modules that are in the repository
2 * Back 2 Browser Bytecode Translator
3 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. Look for COPYING file in the top folder.
16 * If not, see http://opensource.org/licenses/GPL-2.0.
18 package org.apidesign.vm4brwsr;
20 import java.io.UnsupportedEncodingException;
24 * @author Jaroslav Tulach <jtulach@netbeans.org>
26 public class StringSample {
27 public static final String HELLO = "Hello World!";
28 private static int counter;
30 private final int cnt;
31 public StringSample() {
36 public static char sayHello(int indx) {
37 return HELLO.charAt(indx);
40 public static boolean equalToHello(int from, int to) {
41 return "Hello".equals(HELLO.substring(from, to));
44 public static String fromChars(char a, char b, char c) {
45 char[] arr = { a, b, c };
46 return new String(arr).toString();
49 public static String charsFromNumbers() {
50 return chars((char)65, (char)66, (char)67);
53 public static String charsFromChars() {
54 return chars('A', 'B', 'C');
57 public static String chars(char a, char b, char c) {
58 return ("" + a + b +c).toString();
61 public static String replace(String s, char a, char b) {
62 return s.replace(a, b);
65 public static int hashCode(String h) {
69 public static boolean isStringInstance() {
70 return chars('a', (char)30, 'b') instanceof String;
73 public static String getBytes(String s) throws UnsupportedEncodingException {
74 byte[] arr = s.getBytes("UTF-8");
75 StringBuilder sb = new StringBuilder();
76 for (int i = 0; i < arr.length; i++) {
77 sb.append(arr[i]).append(" ");
79 return sb.toString().toString();
82 public static String insertBuffer() {
83 StringBuilder sb = new StringBuilder();
85 sb.insert(0, "Ahoj ");
87 return sb.toString().toString();
90 public static int countAB(String txt) {
92 for (int i = 0; i < txt.length(); i++) {
93 switch (txt.charAt(i)) {
94 case 'A': cnt++; break;
95 case 'B': cnt += 2; break;
101 public static int stringSwitch(String txt) {
103 case "jedna": return 1;
104 case "dve": return 2;
105 case "tri": return 3;
106 case "ctyri": return 4;
111 public static String toStringTest(int howMuch) {
113 StringSample ss = null;
114 for (int i = 0; i < howMuch; i++) {
115 ss = new StringSample();
117 return ss.toString().toString();
120 public static String concatStrings() {
121 return (toStringTest(1) + "\\\n\r\t").toString();
124 public static int compare(String a, String b) {
125 return a.compareTo(b);
129 public String toString() {