Java Examples for java.util.ArrayList

The following java examples will help you to understand the usage of java.util.ArrayList. These source code samples are taken from different open source projects.

Example 1
Project: android_platform_libcore-master  File: nodeinsertbeforenewchildexists.java View source code
/**
    * Runs the test case.
    * @throws Throwable Any uncaught exception causes test to fail
    */
public void runTest() throws Throwable {
    Document doc;
    NodeList elementList;
    Node employeeNode;
    NodeList childList;
    Node refChild;
    Node newChild;
    Node child;
    int length;
    String childName;
    Node insertedNode;
    java.util.List expectedWhitespace = new java.util.ArrayList();
    expectedWhitespace.add("#text");
    expectedWhitespace.add("#text");
    expectedWhitespace.add("name");
    expectedWhitespace.add("#text");
    expectedWhitespace.add("position");
    expectedWhitespace.add("#text");
    expectedWhitespace.add("salary");
    expectedWhitespace.add("#text");
    expectedWhitespace.add("gender");
    expectedWhitespace.add("#text");
    expectedWhitespace.add("employeeId");
    expectedWhitespace.add("address");
    expectedWhitespace.add("#text");
    java.util.List expectedNoWhitespace = new java.util.ArrayList();
    expectedNoWhitespace.add("name");
    expectedNoWhitespace.add("position");
    expectedNoWhitespace.add("salary");
    expectedNoWhitespace.add("gender");
    expectedNoWhitespace.add("employeeId");
    expectedNoWhitespace.add("address");
    java.util.List expected = new java.util.ArrayList();
    java.util.List result = new java.util.ArrayList();
    doc = (Document) load("staff", true);
    elementList = doc.getElementsByTagName("employee");
    employeeNode = elementList.item(1);
    childList = employeeNode.getChildNodes();
    length = (int) childList.getLength();
    if (equals(6, length)) {
        expected = expectedNoWhitespace;
        refChild = childList.item(5);
        newChild = childList.item(0);
    } else {
        expected = expectedWhitespace;
        refChild = childList.item(11);
        newChild = childList.item(1);
    }
    insertedNode = employeeNode.insertBefore(newChild, refChild);
    for (int indexN100DD = 0; indexN100DD < childList.getLength(); indexN100DD++) {
        child = (Node) childList.item(indexN100DD);
        childName = child.getNodeName();
        result.add(childName);
    }
    assertEquals("childNames", expected, result);
}
Example 2
Project: queueing-simulation-master  File: CustomXYURLGeneratorTests.java View source code
/**
     * Confirm that cloning works.
     */
public void testCloning() {
    CustomXYURLGenerator g1 = new CustomXYURLGenerator();
    List u1 = new java.util.ArrayList();
    u1.add("URL A1");
    u1.add("URL A2");
    u1.add("URL A3");
    g1.addURLSeries(u1);
    CustomXYURLGenerator g2 = null;
    try {
        g2 = (CustomXYURLGenerator) g1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(g1 != g2);
    assertTrue(g1.getClass() == g2.getClass());
    assertTrue(g1.equals(g2));
    // check independence
    List u2 = new java.util.ArrayList();
    u2.add("URL XXX");
    g1.addURLSeries(u2);
    assertFalse(g1.equals(g2));
    g2.addURLSeries(new java.util.ArrayList(u2));
    assertTrue(g1.equals(g2));
}
Example 3
Project: RoboBuggy-master  File: CustomCategoryURLGeneratorTest.java View source code
/**
     * Some checks for the equals() method.
     */
@Test
public void testEquals() {
    CustomCategoryURLGenerator g1 = new CustomCategoryURLGenerator();
    CustomCategoryURLGenerator g2 = new CustomCategoryURLGenerator();
    assertEquals(g1, g2);
    List<String> u1 = new java.util.ArrayList<String>();
    u1.add("URL A1");
    u1.add("URL A2");
    u1.add("URL A3");
    g1.addURLSeries(u1);
    assertFalse(g1.equals(g2));
    List<String> u2 = new java.util.ArrayList<String>();
    u2.add("URL A1");
    u2.add("URL A2");
    u2.add("URL A3");
    g2.addURLSeries(u2);
    assertEquals(g1, g2);
}
Example 4
Project: molgenis-master  File: AbstractCategoryAlgorithmGenerator.java View source code
public List<Category> convertToCategory(Attribute attribute) {
    List<Category> categories = new ArrayList<>();
    EntityType refEntity = attribute.getRefEntity();
    if (refEntity != null) {
        dataService.findAll(refEntity.getName()).forEach( entity -> {
            String code = DataConverter.toString(entity.get(refEntity.getIdAttribute().getName()));
            String label = DataConverter.toString(entity.get(refEntity.getLabelAttribute().getName()));
            Category category = Category.create(code, label, CategoryMapperUtil.convertDescriptionToAmount(label));
            if (!categories.contains(category)) {
                categories.add(category);
            }
        });
    }
    return categories;
}
Example 5
Project: schach-master  File: ListReader.java View source code
public static ArrayList<String> loadStrings(File aFile) {
    ArrayList<String> pVec = new ArrayList<String>();
    if (!aFile.exists())
        return pVec;
    try {
        BufferedReader pReader = new BufferedReader(new FileReader(aFile));
        String pLine;
        while ((pLine = pReader.readLine()) != null) {
            pLine = pLine.trim();
            if (pLine.startsWith("#") || pLine.equals(""))
                continue;
            pVec.add(pLine);
        }
        pReader.close();
    } catch (IOException aE) {
        aE.printStackTrace();
    }
    return pVec;
}
Example 6
Project: compomics-utilities-master  File: KeyUtils.java View source code
/**
     * Returns the key corresponding to a list of integers.
     *
     * @param list the list
     *
     * @return a key in the form of a string
     */
public static String getKey(ArrayList<Integer> list) {
    StringBuilder stringBuilder = new StringBuilder(2 * list.size());
    for (Integer value : list) {
        if (stringBuilder.length() > 0) {
            stringBuilder.append(SEPARATOR);
        }
        stringBuilder.append(value);
    }
    return stringBuilder.toString();
}
Example 7
Project: openjdk-master  File: ModuleTest.java View source code
@Test
public void testComplex(Path base) throws Exception {
    Path m1 = base.resolve("m1");
    ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1").exports("pack1").exports("pack3").exportsTo("packTo1", "m2").exportsTo("packTo3", "m3").requires("jdk.compiler").requires("m2", RequiresFlag.TRANSITIVE).requires("m3", RequiresFlag.STATIC).requires("m4", RequiresFlag.TRANSITIVE, RequiresFlag.STATIC).provides("java.util.List", "pack1.C", "pack2.D").uses("java.util.List").uses("java.nio.file.Path").requires("jdk.jdeps", RequiresFlag.STATIC, RequiresFlag.TRANSITIVE).requires("m5", RequiresFlag.STATIC).requires("m6", RequiresFlag.TRANSITIVE).requires("java.compiler").exportsTo("packTo4", "java.compiler").exportsTo("packTo2", "java.compiler").exports("pack4").exports("pack2").write(m1);
    tb.writeJavaFiles(m1, "package pack1; public class C extends java.util.ArrayList{ }", "package pack2; public class D extends java.util.ArrayList{ }", "package pack3; public class D extends java.util.ArrayList{ }", "package pack4; public class D extends java.util.ArrayList{ }");
    tb.writeJavaFiles(m1, "package packTo1; public class T1 {}", "package packTo2; public class T2 {}", "package packTo3; public class T3 {}", "package packTo4; public class T4 {}");
    tb.writeJavaFiles(base.resolve("m2"), "module m2 { }");
    tb.writeJavaFiles(base.resolve("m3"), "module m3 { }");
    tb.writeJavaFiles(base.resolve("m4"), "module m4 { }");
    tb.writeJavaFiles(base.resolve("m5"), "module m5 { }");
    tb.writeJavaFiles(base.resolve("m6"), "module m6 { }");
    compile(base, "--module-source-path", base.toString(), "-d", base.toString());
    testModuleAttribute(m1, moduleDescriptor);
}
Example 8
Project: Mint-Programming-Language-master  File: ViewStrings.java View source code
@Override
public Pointer apply(SmartList<Pointer> args) throws MintException {
    short i = 0;
    while (i < Short.MAX_VALUE) {
        try {
            HashMap<Integer, String> strs = Heap.strings;
            if (strs == null) {
                return EMPTY_LIST;
            }
            Table tbl = new Table();
            ArrayList<Integer> keys = new ArrayList<Integer>();
            Set<Integer> s = strs.keySet();
            for (int element : s) {
                keys.add(element);
            }
            s = null;
            for (int key : keys) {
                SmartList<Pointer> pair = new SmartList<Pointer>();
                pair.add(new Pointer(Constants.INT_TYPE, key));
                pair.add(Heap.allocateString(strs.get(key)));
                tbl.addBinding(pair);
            }
            return Heap.allocateTable(tbl);
        } catch (Throwable t) {
        }
        ++i;
    }
    try {
        return Heap.allocateString(Heap.strings.toString());
    } catch (Throwable t) {
        return ChangeString.ERROR;
    }
}
Example 9
Project: ohmagePhone-master  File: TimestampPromptBuilder.java View source code
@Override
public void build(Prompt prompt, String id, String displayType, String displayLabel, String promptText, String abbreviatedText, String explanationText, String defaultValue, String condition, String skippable, String skipLabel, ArrayList<KVLTriplet> properties) {
    TimestampPrompt timestampPrompt = (TimestampPrompt) prompt;
    timestampPrompt.setId(id);
    timestampPrompt.setDisplayType(displayType);
    timestampPrompt.setDisplayLabel(displayLabel);
    timestampPrompt.setPromptText(promptText);
    timestampPrompt.setAbbreviatedText(abbreviatedText);
    timestampPrompt.setExplanationText(explanationText);
    timestampPrompt.setDefaultValue(defaultValue);
    timestampPrompt.setCondition(condition);
    timestampPrompt.setSkippable(skippable);
    timestampPrompt.setSkipLabel(skipLabel);
    timestampPrompt.setProperties(properties);
}
Example 10
Project: LambdaDojo-master  File: S201LambdaInsteadOfAnonClass.java View source code
// 2-1 Lambda 式で書きかえてみましょう
private void rewriteByLambda() {
    // この匿名クラスを Lambda 式で書きかえ
    Comparator<Integer> comparator = new Comparator<Integer>() {

        @Override
        public int compare(Integer x, Integer y) {
            return Integer.compare(x, y);
        }
    };
    List<Integer> numbers = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        numbers.add(i);
    }
    Random random = new Random();
    for (int i = 0; i < 10; i++) {
        Integer number = numbers.remove(random.nextInt(10 - i));
        numbers.add(number);
    }
    System.out.println("Before Sort: " + numbers);
    // 整数のリストをソート
    Collections.sort(numbers, comparator);
    System.out.println("After Sort: " + numbers);
}
Example 11
Project: btpka3.github.com-master  File: TestRegex.java View source code
/**
     * 处理字符串时,常常会有转义字符。
     * 顺序很重要。reg1 和 reg2 中的或是调换顺序的。
     */
public static void testEscape() {
    // mysqldump出的VARCHAR字段可能会是这样 :
    // INSERT INTO `my_table` VALUES ('aa\'bb','',NULL,0),('cc\'dd','',NULL,0);
    String sql = "INSERT INTO `my_table` VALUES ('aa\\'bb','',NULL,0,'111'),('cc\\'dd','',NULL,0,'222');\n";
    String reg1 = "'(\\\\'|[^'])*'";
    Pattern p1 = Pattern.compile(reg1);
    Matcher m1 = p1.matcher(sql);
    List<String> reusltList1 = new ArrayList<String>();
    while (m1.find()) {
        reusltList1.add(m1.group(0));
    }
    System.out.println("reg1 match result : " + reusltList1);
    String reg2 = "'([^']|\\\\')*'";
    Pattern p2 = Pattern.compile(reg2);
    Matcher m2 = p2.matcher(sql);
    List<String> reusltList2 = new ArrayList<String>();
    while (m2.find()) {
        reusltList2.add(m2.group(0));
    }
    System.out.println("reg2 match result : " + reusltList2);
/*
         * output:
         * reg1 match result : ['aa\'bb', '', '111', 'cc\'dd', '', '222']
         * reg2 match result : ['aa\', ',', ',NULL,0,', '),(', 'dd', '', '222']
         */
}
Example 12
Project: expenditures-master  File: MissionProcessProvider.java View source code
@Override
public Collection getSearchResults(Map<String, String> argsMap, String value, int maxCount) {
    final String currentValue = StringUtils.trim(value);
    final List<MissionProcess> result = new ArrayList<MissionProcess>();
    final MissionSystem missionSystem = MissionSystem.getInstance();
    for (final MissionProcess missionProcess : missionSystem.getMissionProcessesSet()) {
        String[] processIdParts = missionProcess.getProcessNumber().split("/M");
        if (missionProcess.getProcessIdentification().equals(currentValue) || processIdParts[processIdParts.length - 1].equals(currentValue)) {
            result.add(missionProcess);
        }
    }
    return result;
}
Example 13
Project: xbnjava-master  File: OrderIntListXmpl.java View source code
public static final void main(String[] ignored) {
    int[] aiNums = new int[] { 1, 11, 29, 12, 13, 19, 7, 2, 6, 16, 10, 15, 112, 18, 20, 3, 8, 5, 9, 14 };
    System.out.println("Unsorted: " + Arrays.toString(aiNums));
    ArrayList<Integer> alNums = new ArrayList<Integer>(aiNums.length);
    for (int i : aiNums) {
        alNums.add(i);
    }
    Collections.sort(alNums);
    System.out.println("Sorted: " + Arrays.toString(alNums.toArray()));
    int ixOf12 = Collections.<Integer>binarySearch(alNums, 12);
    System.out.println("Index of number 12: " + ixOf12);
}
Example 14
Project: sonar-java-master  File: SerializableObjectInSessionCheck.java View source code
void foo() {
    javax.servlet.http.HttpSession session = request.getSession();
    // Noncompliant [[sc=37;ec=50]] {{Make "Address" serializable or don't store it in the session.}}
    session.setAttribute("address", new Address());
    // Noncompliant {{Make "Person" serializable or don't store it in the session.}}
    session.setAttribute("person", new Person());
    session.setAttribute("person", 1);
    session.setAttribute("person", new Integer(1));
    session.setAttribute("addressString", "address");
    session.setAttribute("intArray", new int[] { 1, 2 });
    session.setAttribute("stringArray", new String[] { "one", "two" });
    // Noncompliant {{Make "Person[]" serializable or don't store it in the session.}}
    session.setAttribute("personArray", new Person[] { new Person() });
    session.setAttribute("stringArrayList", new java.util.ArrayList<>(java.util.Arrays.asList("one", "two")));
    // Noncompliant {{Make "ArrayList" and its parameters serializable or don't store it in the session.}}
    session.setAttribute("personArrayList", new java.util.ArrayList<>(java.util.Arrays.asList(new Person(), new Person())));
    session.setAttribute("stringList", java.util.Arrays.asList("one", "two"));
    // Noncompliant {{Make "CustomStack" and its parameters serializable or don't store it in the session.}}
    session.setAttribute("nonSerializableParameterized", new CustomStack<String>());
}
Example 15
Project: milton2-master  File: SendMailScratch.java View source code
public static void main(String[] arr) {
    String host = "XXX";
    String user = "XXX";
    String password = "XXX";
    int port = 465;
    RemoteSmtpMailSender sender = new RemoteSmtpMailSender(host, user, password, port);
    sender.setUseSsl(true);
    sender.start();
    StandardMessageImpl sm = new StandardMessageImpl();
    sm.setFrom(MailboxAddress.parse("[email protected]"));
    List<MailboxAddress> to = new ArrayList();
    to.add(MailboxAddress.parse("[email protected]"));
    sm.setTo(to);
    sm.setSubject("hello!");
    sender.sendMail(sm);
}
Example 16
Project: castor-master  File: NodeBuilder.java View source code
/**
     * Build the object we expect when we unmarshal 'input.xml'.
     */
public Object buildInstance() {
    NodeList nodeList = new NodeList();
    Node nodeOne = new Node();
    nodeOne.setNodeNum(1);
    Node nodeTwo = new Node();
    nodeTwo.setNodeNum(2);
    Node nodeThree = new Node();
    nodeThree.setNodeNum(3);
    List siblings = new ArrayList();
    siblings.add(nodeTwo);
    siblings.add(nodeThree);
    nodeOne.setSiblings(siblings);
    siblings = new ArrayList();
    siblings.add(nodeOne);
    siblings.add(nodeThree);
    nodeTwo.setSiblings(siblings);
    siblings = new ArrayList();
    siblings.add(nodeOne);
    siblings.add(nodeTwo);
    nodeThree.setSiblings(siblings);
    nodeList.addNode(nodeOne);
    nodeList.addNode(nodeTwo);
    nodeList.addNode(nodeThree);
    return nodeList;
}
Example 17
Project: tapestry-model-master  File: MethodDescriptorFactoryImpl.java View source code
public ArrayList<IMethodDescriptor> buildMethodDescriptors(Class type, BeanInfo beanInfo) {
    ArrayList<IMethodDescriptor> result = new ArrayList<IMethodDescriptor>();
    for (MethodDescriptor beanMethodDescriptor : beanInfo.getMethodDescriptors()) {
        if (!Utils.isExcluded(beanMethodDescriptor.getMethod().getName(), methodExcludes)) {
            TynamoMethodDescriptorImpl methodDescriptor = new TynamoMethodDescriptorImpl(type, beanMethodDescriptor.getMethod().getName(), beanMethodDescriptor.getMethod().getReturnType(), beanMethodDescriptor.getMethod().getParameterTypes());
            //				methodDescriptor.setDisplayName(Utils.unCamelCase(beanMethodDescriptor.getDisplayName()));
            result.add(methodDescriptor);
        }
    }
    return result;
}
Example 18
Project: eclipse.jdt.ui-master  File: ControlBodyUpdates.java View source code
private void foo() {
    for (int i = 0; i < arraylists.get(0); i++) arraylists = null;
    for (int intValue : ints) arraylists = new ArrayList(arraylists.size());
    while (ints.length != 0) arraylists = null;
    if (arraylists == null)
        arraylists = null;
    int[] newRange = new int[8];
    for (int i = 0; i < arraylists.get(0); i++) {
        arraylists = null;
    }
    for (int intValue : ints) {
        arraylists = new ArrayList(arraylists.size());
    }
    while (ints.length != 0) {
        arraylists = null;
    }
    if (arraylists == null) {
        arraylists = null;
    }
    if (newRange[0] > 0)
        // line number start at 0!
        fNewStart = newRange[0] - 1;
    else
        fNewStart = 0;
    if (newRange[0] > 0) {
        // line number start at 0!
        fNewStart = newRange[0] - 1;
    } else {
        fNewStart = 0;
    }
}
Example 19
Project: TFC2-master  File: DungeonSchemManager.java View source code
public void loadRooms(String theme, ArrayList<String> roomNames, String path) {
    DungeonTheme themeObject;
    if (themeMap.containsKey(theme.toLowerCase()))
        themeObject = themeMap.get(theme.toLowerCase());
    else
        themeObject = new DungeonTheme(theme);
    themeObject.loadRooms(roomNames, path);
    themeMap.put(theme.toLowerCase(), themeObject);
}
Example 20
Project: violetumleditor-master  File: MenuUtils.java View source code
public static void alterMenuBar(JMenuBar menuBar) {
    MenuElement[] subMenuElements = menuBar.getSubElements();
    List<MenuElement> menuEntryStack = new ArrayList<MenuElement>();
    if (subMenuElements.length > 0) {
        menuEntryStack.addAll(Arrays.asList(subMenuElements));
    }
    while (!menuEntryStack.isEmpty()) {
        MenuElement menuElement = menuEntryStack.get(0);
        if (menuElement instanceof JMenuItem) {
            final JMenuItem menuItem = (JMenuItem) menuElement;
            menuItem.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    System.out.println(menuItem.getName());
                }
            });
        }
        MenuElement[] subElements = menuElement.getSubElements();
        if (subElements.length > 0) {
            menuEntryStack.addAll(Arrays.asList(subElements));
        }
        menuEntryStack.remove(0);
    }
}
Example 21
Project: CarpoolBackend-master  File: UserSearchHistoryResource.java View source code
@Get
public Representation getUserSearchHistory() {
    int userId = -1;
    ArrayList<SearchRepresentation> searchHistory = new ArrayList<SearchRepresentation>();
    JSONArray resultArr = new JSONArray();
    try {
        userId = Integer.parseInt(this.getAttribute("id"));
        searchHistory = AwsMain.getUserSearchHistory(userId);
        resultArr = JSONFactory.toJSON(searchHistory);
    } catch (Exception e) {
        return this.doException(e);
    }
    Representation response = new JsonRepresentation(resultArr);
    addCORSHeader();
    return response;
}
Example 22
Project: OpenClinica-master  File: SubjectStatusFilter.java View source code
//AVAILABLE, PENDING, PRIVATE, UNAVAILABLE, LOCKED, DELETED,
// AUTO_DELETED, SIGNED, FROZEN,SOURCE_DATA_VERIFICATION
@Override
protected List<Option> getOptions() {
    List<Option> options = new ArrayList<Option>();
    options.add(new Option("available", "Available"));
    options.add(new Option("pending", "Pending"));
    options.add(new Option("private", "Private"));
    options.add(new Option("unavailable", "Unavailable"));
    options.add(new Option("locked", "Locked"));
    options.add(new Option("deleted", "Deleted"));
    options.add(new Option("auto_deleted", "Auto deleted"));
    options.add(new Option("signed", "Signed"));
    options.add(new Option("frozen", "Frozen"));
    options.add(new Option("source_data_verification", "SDV"));
    return options;
}
Example 23
Project: jade_agents-master  File: ArrayList.java View source code
/**
     * @see jade.util.leap.Collection interface
     */
public Iterator iterator() {
    return new Iterator() {

        java.util.Iterator it = ArrayList.this.realHiddenList.iterator();

        /**
             * Method declaration
             * 
             * @return
             * 
             */
        public boolean hasNext() {
            return it.hasNext();
        }

        /**
             * Method declaration
             * 
             * @return
             * 
             */
        public Object next() {
            return it.next();
        }

        /**
             * Method declaration
             * 
             */
        public void remove() {
            it.remove();
        }
    };
}
Example 24
Project: spring-framework-2.5.x-master  File: ListFactoryBean.java View source code
protected Object createInstance() {
    if (this.sourceList == null) {
        throw new IllegalArgumentException("'sourceList' is required");
    }
    List result = null;
    if (this.targetListClass != null) {
        result = (List) BeanUtils.instantiateClass(this.targetListClass);
    } else {
        result = new ArrayList(this.sourceList.size());
    }
    Class valueType = null;
    if (this.targetListClass != null && JdkVersion.isAtLeastJava15()) {
        valueType = GenericCollectionTypeResolver.getCollectionType(this.targetListClass);
    }
    if (valueType != null) {
        TypeConverter converter = getBeanTypeConverter();
        for (Iterator it = this.sourceList.iterator(); it.hasNext(); ) {
            result.add(converter.convertIfNecessary(it.next(), valueType));
        }
    } else {
        result.addAll(this.sourceList);
    }
    return result;
}
Example 25
Project: nmonvisualizer-master  File: TopasOutParser.java View source code
// topas -a outputs sorted data; unsort it by looking for the header records and outputting them first
// once the ZZZZ records are parsed output them then all the corresponding data records for that timestamp
public NMONDataSet parse(String filename, TimeZone timeZone, boolean scaleProcessesByCPU) throws IOException {
    File file = new File(filename);
    BufferedReader in = null;
    StringWriter writer = null;
    try {
        in = new BufferedReader(new FileReader(file));
        writer = new StringWriter((int) file.length());
        // LinkedHashMap so insertion order is maintained; removes need to reparse headers later
        Map<String, List<String>> headersToLines = new java.util.LinkedHashMap<String, List<String>>(32);
        List<String> headers = new java.util.ArrayList<String>(32);
        List<String> timestamps = new java.util.ArrayList<String>(128);
        String line = null;
        while ((line = in.readLine()) != null) {
            int idx = line.indexOf(",");
            String header = line.substring(0, idx);
            if ("AAA".equals(header)) {
                // put all the AAA records at the top by writing them out now
                writer.write(line);
                writer.write('\n');
            } else if ("ZZZZ".equals(header)) {
                timestamps.add(line);
            } else {
                // save all the data by header name
                List<String> lines = headersToLines.get(header);
                if (lines == null) {
                    LOGGER.trace("found {} " + "header", header);
                    lines = new java.util.ArrayList<String>(218);
                    headersToLines.put(header, lines);
                }
                if (line.charAt(idx + 1) == 'T') {
                    lines.add(line);
                } else {
                    if ("LPAR".equals(header)) {
                        // fix capitalization of LPAR data to match NMON
                        line = "LPAR,LPAR Stats,PhysicalCPU,virtualCPUs,logicalCPUs,poolCPUs,entitled,weight,PoolIdle,usedAllCPU%,usedPoolCPU%,SharedCPU";
                    }
                    headers.add(line);
                }
            }
        }
        LOGGER.debug("found {} " + "data types", headers.size());
        LOGGER.debug("found {} " + "ZZZZ timestamps", timestamps.size());
        LOGGER.debug("found {} " + "data types", headersToLines.size());
        for (String header : headers) {
            writer.write(header);
            writer.write('\n');
        }
        // assume all arrays are the same size, i.e. there is data at each timestamp for all values
        for (int i = 0; i < timestamps.size(); i++) {
            writer.write(timestamps.get(i));
            writer.write('\n');
            for (List<String> lines : headersToLines.values()) {
                writer.write(lines.get(i));
                writer.write('\n');
            }
        }
        return nmonParser.parse(filename, new StringReader(writer.toString()), timeZone, scaleProcessesByCPU);
    } finally {
        if (in != null) {
            in.close();
        }
        if (writer != null) {
            writer.close();
        }
    }
}
Example 26
Project: cloudbees-api-client-master  File: CloudResourceProvider.java View source code
/**
     * Lists up all the cloud resources.
     */
public Iterator<CloudResource> iterator() {
    try {
        JsonNode res = getOwner().retrieve().get("resources");
        if (res == null || !res.isArray())
            throw new IllegalStateException("Expected a JSON array but " + getOwner() + " gave us " + res);
        ReferencedResource[] dto = CloudResource.MAPPER.readValue(res, ReferencedResource[].class);
        List<CloudResource> r = new ArrayList<CloudResource>(dto.length);
        for (ReferencedResource rr : dto) {
            r.add(rr.toCloudResource(getOwner()));
        }
        return r.iterator();
    } catch (IOException e) {
        throw new Error(e);
    }
}
Example 27
Project: dr-radio-android-master  File: Netvaerksstatus.java View source code
@Override
public void onReceive(Context context, Intent intent) {
    NetworkInfo networkInfo = App.connectivityManager.getActiveNetworkInfo();
    Status nyStatus;
    if (networkInfo == null || !networkInfo.isConnected()) {
        nyStatus = Status.INGEN;
    } else if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
        nyStatus = Status.WIFI;
    } else {
        nyStatus = Status.MOBIL;
    }
    if (status != nyStatus) {
        status = nyStatus;
        Log.d("Netvaerksstatus\n" + intent + "\n" + networkInfo);
        //if (App.fejlsøgning) App.kortToast("Netvaerksstatus\n" + status);
        for (Runnable o : new ArrayList<Runnable>(observatører)) o.run();
    }
}
Example 28
Project: openmap-master  File: SimpleBeanObjectBeanInfo.java View source code
public PropertyDescriptor[] getPropertyDescriptors() {
    ArrayList<PropertyDescriptor> list = new ArrayList<PropertyDescriptor>(4);
    try {
        list.add(new PropertyDescriptor("id", SimpleBeanObject.class));
        list.add(new PropertyDescriptor("latitude", SimpleBeanObject.class));
        list.add(new PropertyDescriptor("longitude", SimpleBeanObject.class));
        list.add(new PropertyDescriptor("bearingInDeg", SimpleBeanObject.class));
    } catch (IntrospectionException e) {
        e.printStackTrace();
    }
    return list.toArray(new PropertyDescriptor[list.size()]);
}
Example 29
Project: R2015-master  File: TestMain.java View source code
public static void main(String[] args) {
    System.out.println("Hello");
    printArray(new int[] { 1, 2, 3 });
    List<String> li = new ArrayList<String>();
    for (int i = 0; i < 6; i++) {
        li.add("element " + i);
    }
    for (int count = 0; count < li.size(); count++) {
        System.out.println(count + " " + li.get(count));
    }
    li.remove(1);
    System.out.println("After 1st removal (element 1 removed) --------------------");
    for (int count = 0; count < li.size(); count++) {
        System.out.println(count + " " + li.get(count));
    }
    li.remove(3);
    System.out.println("After 2nd removal (element 3 (4 in original) removed) --------------------");
    for (int count = 0; count < li.size(); count++) {
        System.out.println(count + " " + li.get(count));
    }
    System.out.println(li.get(2));
}
Example 30
Project: WS171-development-master  File: ClassSourcerTest.java View source code
@Test
public void testTemplateClassSource() throws Exception {
    StringWriter sw = new StringWriter();
    ClassReader cr = new ClassReader("data/TestTemplateClass");
    ClassSourcer jw = new ClassSourcer(new Output(sw));
    cr.accept(jw, 0);
    assertSourceEquals("package data;\n" + "public class TestTemplateClass<T extends java.io.InputStream, U extends java.lang.Object> extends java.lang.Object {\n" + "    private final java.util.Map<T, U> mMap_T_U;\n" + "    public java.util.Map<java.util.ArrayList<T>, java.util.Map<java.lang.String, java.util.ArrayList<U>>> mMap_T_S_U;\n" + "    public TestTemplateClass() {\n" + "        throw new RuntimeException(\"Stub\");\n" + "    }\n" + "    public java.util.Map<T, U> getMap_T_U() {\n" + "        throw new RuntimeException(\"Stub\");\n" + "    }\n" + "    public java.util.Map<java.util.ArrayList<T>, java.util.Map<java.lang.String, java.util.ArrayList<U>>> getMap_T_S_U() {\n" + "        throw new RuntimeException(\"Stub\");\n" + "    }\n" + "    public void draw(java.util.List<? extends org.w3c.dom.css.Rect> arg0) {\n" + "        throw new RuntimeException(\"Stub\");\n" + "    }\n" + "    public static <T extends java.lang.Comparable<? super T>> void sort(java.util.List<T> arg0) {\n" + "        throw new RuntimeException(\"Stub\");\n" + "    }\n" + "    public <X extends T, Y extends java.lang.Object> void getMap(java.util.List<T> arg0, java.util.Map<T, U> arg1, java.util.Map<X, java.util.Set<? super Y>> arg2) {\n" + "        throw new RuntimeException(\"Stub\");\n" + "    }\n" + "}", sw.toString());
}
Example 31
Project: tuberun_android-master  File: NearbyStationsForDeparturesFetcher.java View source code
@Override
protected ArrayList<Station> doInBackground(Location... at) {
    // android.os.Debug.waitForDebugger();
    ArrayList<Station> res = new ArrayList<Station>();
    DatabaseHelper myDbHelper = new DatabaseHelper(context);
    try {
        myDbHelper.openDataBase();
        res = myDbHelper.getEverythingNearbyForDepartures((long) (at[0].getLatitude() * 1000000), (long) (at[0].getLongitude() * 1000000));
        res = getNearbyStations(at[0], res, 8);
    } catch (Exception e) {
        Log.w("NearbyStationsForDeparturesFetcher", e);
    } finally {
        myDbHelper.close();
    }
    return res;
}
Example 32
Project: OrganicBuilder-master  File: RandomConstructor.java View source code
@Override
public Configuration construct() throws GeneratorException {
    final Collection<Atom> atoms = new ArrayList<Atom>();
    float currentWidth = 5 * Atom.getAtomSize();
    float currentHeight = 5 * Atom.getAtomSize();
    final float maximumWidth = partialConfiguration.getWidth() - currentWidth;
    final float maximumHeigth = partialConfiguration.getHeight() - currentHeight;
    while (currentHeight < maximumHeigth) {
        if (currentWidth >= maximumWidth) {
            currentWidth = Atom.getAtomSize();
            currentHeight += 6 * Atom.getAtomSize();
        } else {
            atoms.add(Atoms.createMobileAtomWithRandomSpeed(getRandomAtomType(), getRandomState(), currentWidth, currentHeight));
            currentWidth += 6 * Atom.getAtomSize();
        }
    }
    return new Configuration(partialConfiguration.getHeight(), partialConfiguration.getWidth(), atoms);
}
Example 33
Project: SimpleRep-master  File: RequestProcessor.java View source code
private ProcessingStatus processFlow(MessageContext unprocessedMsg, ArrayList<AbstractHandler> handlers) {
    for (AbstractHandler h : handlers) {
        if (h.invoke(unprocessedMsg) == ProcessingStatus.ABORT) {
            return ProcessingStatus.ABORT;
        }
    }
    return ProcessingStatus.CONTINUE;
}
Example 34
Project: dlna-master  File: FileFilterUtil.java View source code
public static List<File> getFiles(String path, String[] postfix) {
    File file = new File(path);
    File[] files = file.listFiles();
    List<File> lists = new ArrayList();
    if (files == null || files.length == 0) {
        return null;
    }
    for (int i = 0; i < files.length; i++) {
        File childFile = files[i];
        System.out.println("" + childFile.getPath());
        if (childFile.isFile()) {
            childFile.getName();
            int index = childFile.getName().lastIndexOf(".");
            index++;
            String name = childFile.getName().substring(index, childFile.getName().length());
            for (int j = 0; j < postfix.length; j++) {
                if (name.equalsIgnoreCase(postfix[j])) {
                    lists.add(childFile);
                }
            }
        } else if (childFile.isDirectory() && formateToDepth(childFile.getAbsolutePath())) {
            List<File> lsts = getFiles(childFile.getAbsolutePath(), postfix);
            if (lsts != null && lsts.size() != 0) {
                lists.addAll(lsts);
            }
        }
    }
    return lists;
}
Example 35
Project: oobd-master  File: JcaCRLStore.java View source code
private static Collection convertCRLs(Collection collection) throws CRLException {
    List list = new ArrayList(collection.size());
    for (Iterator it = collection.iterator(); it.hasNext(); ) {
        Object crl = it.next();
        if (crl instanceof X509CRL) {
            try {
                list.add(new X509CRLHolder(((X509CRL) crl).getEncoded()));
            } catch (IOException e) {
                throw new CRLException("cannot read encoding: " + e.getMessage());
            }
        } else {
            list.add((X509CRLHolder) crl);
        }
    }
    return list;
}
Example 36
Project: teiid-designer-master  File: ModelObjectTableModelFactory.java View source code
public static ModelObjectTableModel createModelObjectTableModel(boolean supportsDescriptions, EClass tabClass, ArrayList instanceList) {
    UiPlugin.getDefault().getEObjectPropertiesOrderPreferences().addOrUpdateProperty(tabClass.getName(), LOCATION_KEY);
    UiPlugin.getDefault().getEObjectPropertiesOrderPreferences().addOrUpdateEObject(tabClass.getName(), (EObject) instanceList.get(0));
    if (supportsDescriptions) {
        UiPlugin.getDefault().getEObjectPropertiesOrderPreferences().addOrUpdateProperty(tabClass.getName(), DESCRIPTION_KEY);
    }
    ModelObjectTableModel model = new ModelObjectTableModel(tabClass.getName(), instanceList, supportsDescriptions);
    return model;
}
Example 37
Project: erlide-master  File: LaunchUtils.java View source code
public static IProject[] getErlangLaunchConfigurationProjects(final ILaunchConfiguration configuration) throws CoreException {
    final String projectNamesString = configuration.getAttribute(ErlRuntimeAttributes.PROJECTS, "");
    final String[] projectNames = projectNamesString.split(";");
    final List<IProject> projects = new ArrayList<>();
    final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    for (final String s : projectNames) {
        if (s != null && s.length() > 0) {
            final IProject p = root.getProject(s);
            if (p != null) {
                projects.add(p);
            }
        }
    }
    return projects.toArray(new IProject[projects.size()]);
}
Example 38
Project: liferay-ide-master  File: FindJavaProblemsHandler.java View source code
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    try {
        Liferay7UpgradeAssistantSettings settings = UpgradeAssistantSettingsUtil.getObjectFromStore(Liferay7UpgradeAssistantSettings.class);
        String[] projectLocations = settings.getJavaProjectLocations();
        List<IPath> locations = new ArrayList<>();
        for (String projectLocation : projectLocations) {
            locations.add(new Path(projectLocation));
        }
        new MigrateProjectHandler().findMigrationProblems(locations.toArray(new IPath[0]));
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}
Example 39
Project: AudioPlayer-master  File: QianQianParser.java View source code
public static List<LyricResults> parseXml(String xml) {
    List<LyricResults> list = new ArrayList<LyricResults>();
    try {
        XmlPullParser xrp = XmlPullParserFactory.newInstance().newPullParser();
        xrp.setInput(new StringReader(xml));
        // 直到文档的结尾处
        while (xrp.getEventType() != XmlResourceParser.END_DOCUMENT) {
            // 如果遇到了开始标签
            if (xrp.getEventType() == XmlResourceParser.START_TAG) {
                String // 获取标签的名字
                tagName = // 获取标签的名字
                xrp.getName();
                if (tagName.equals("lrc")) {
                    LyricResults result = new LyricResults();
                    result.id = Integer.valueOf(// 通过属性名来获取属性值
                    xrp.getAttributeValue(// 通过属性名来获取属性值
                    0));
                    result.artist = // 通过属性索引来获取属性值
                    xrp.getAttributeValue(// 通过属性索引来获取属性值
                    1);
                    result.track = xrp.getAttributeValue(2);
                    list.add(result);
                }
            }
            // 获取解析下一个事件
            xrp.next();
        }
    } catch (XmlPullParserException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return list.size() == 0 ? null : list;
}
Example 40
Project: hci-2011-2-master  File: Util.java View source code
public static List<? extends Map<String, ?>> getMapped(List<?> objects, String[] desired_fields) {
    ArrayList<Map<String, ?>> list = new ArrayList<Map<String, ?>>();
    for (Object object : objects) {
        HashMap<String, Object> map = new HashMap<String, Object>();
        Class<? extends Object> c = object.getClass();
        for (Field field : c.getFields()) {
            Annotation[] ann = (Annotation[]) field.getAnnotations();
            for (Annotation annotation : ann) {
                if (annotation instanceof Element || annotation instanceof Attribute) {
                    try {
                        boolean is_in = false;
                        for (String desired_field : desired_fields) {
                            if (desired_field.equals(field.getName())) {
                                is_in = true;
                                break;
                            }
                        }
                        if (is_in) {
                            map.put(field.getName(), field.get(object));
                        }
                    } catch (IllegalArgumentException e) {
                        e.printStackTrace();
                    } catch (IllegalAccessException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        list.add(map);
    }
    return list;
}
Example 41
Project: dashboard-master  File: HudsonBuildStatusImpl.java View source code
@Override
public List<Dot> getValue() {
    List<Build> builds = service.getBuilds(project);
    ArrayList<Dot> result = new ArrayList<Dot>();
    for (int i = 0; i < Math.min(5, builds.size()); i++) {
        Build build = builds.get(i);
        if (build.isBuilding()) {
            result.add(new Dot(DotColor.GRAY, build.getJob().getCode()));
        } else {
            switch(build.getResult()) {
                case SUCCESS:
                    result.add(new Dot(DotColor.GREEN, build.getJob().getCode()));
                    break;
                case UNSTABLE:
                    result.add(new Dot(DotColor.YELLOW, build.getJob().getCode()));
                    break;
                case FAILURE:
                    result.add(new Dot(DotColor.RED, build.getJob().getCode()));
                    break;
            }
        }
    }
    return result;
}
Example 42
Project: cloudtm-data-platform-master  File: ConverterClassAwareDmlCompiler.java View source code
public static void main(String[] args) throws Exception {
    final int c = args.length;
    final int offset = c - 3;
    final File dir = new File(args[offset]);
    final String[] baseArgs;
    if (dir.exists() && dir.isDirectory()) {
        final List<String> dmlFilenames = new ArrayList<String>();
        for (final File file : dir.listFiles()) {
            if (file.isFile() && file.getName().endsWith(".dml")) {
                dmlFilenames.add(file.getCanonicalPath());
            }
        }
        Collections.sort(dmlFilenames);
        List<URL> pluginDmlUrlList = PluginDmlUrlLoader.getPluginDmlUrlList();
        baseArgs = new String[c - 3 + dmlFilenames.size() + pluginDmlUrlList.size()];
        System.arraycopy(args, 0, baseArgs, 0, offset);
        int i = offset;
        for (URL pluginDmlUrl : pluginDmlUrlList) {
            baseArgs[i++] = pluginDmlUrl.toExternalForm();
        }
        for (final String dmlFilename : dmlFilenames) {
            baseArgs[i++] = dmlFilename;
        }
    } else {
        baseArgs = Arrays.copyOfRange(args, 0, c - 2);
    }
    DmlCompiler.main(baseArgs);
}
Example 43
Project: cdo-master  File: SelectionHandler.java View source code
protected List<Object> getSelectedObjects(ExecutionEvent event) {
    List<Object> objects = new ArrayList<Object>();
    ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
    if (selection != null & selection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        for (@SuppressWarnings("unchecked") Iterator<Object> iterator = structuredSelection.iterator(); iterator.hasNext(); ) {
            Object element = iterator.next();
            objects.add(element);
        }
    }
    return objects;
}
Example 44
Project: Eclipse-Postfix-Code-Completion-master  File: FileFinder.java View source code
private static void find0(File f, String pattern, ArrayList collector) {
    if (f.isDirectory()) {
        String[] files = f.list();
        if (files == null)
            return;
        for (int i = 0, max = files.length; i < max; i++) {
            File current = new File(f, files[i]);
            if (current.isDirectory()) {
                find0(current, pattern, collector);
            } else {
                if (current.getName().toUpperCase().endsWith(pattern)) {
                    collector.add(current.getAbsolutePath());
                }
            }
        }
    }
}
Example 45
Project: Android_Blog_Demos-master  File: Droid.java View source code
public static List<Droid> generateDatas() {
    List<Droid> datas = new ArrayList<Droid>();
    datas.add(new Droid("Lorem ipsum dolor sit amet, orci nullam cra", "3分钟前", -1, "alex"));
    datas.add(new Droid("Omnis aptent magnis suspendisse ipsum, semper egestas", "12分钟前", R.drawable.joanna, "john"));
    datas.add(new Droid("eu nibh, rhoncus wisi posuere lacus, ad erat egestas", "17分钟前", -1, "7heaven"));
    datas.add(new Droid("eu nibh, rhoncus wisi posuere lacus, ad erat egestas", "33分钟前", R.drawable.shailen, "Lseven"));
    return datas;
}
Example 46
Project: revapi-master  File: TestUseChainReporting.java View source code
@Test
public void testCustomReportedCodes() throws Exception {
    String config = "{\"revapi\": {\"java\": {\"reportUsesFor\": [\"java.method.addedToInterface\"]}}}";
    List<Report> reports = new ArrayList<>();
    runAnalysis(new CollectingReporter(reports), config, new String[] { "v1/methods/Added.java" }, new String[] { "v2/methods/Added.java" });
    List<Difference> diffs = reports.stream().flatMap( r -> r.getDifferences().stream()).filter( d -> "java.method.addedToInterface".equals(d.code)).filter( d -> d.description != null && d.description.endsWith("Use chain of the type in the old API: <null>\nUse chain of the" + " type in the new API: ")).collect(Collectors.toList());
    Assert.assertTrue(diffs.isEmpty());
}
Example 47
Project: jnlp-master  File: TestNLP.java View source code
public static void main(String[] args) throws Exception {
    NLP nlp = new NLP("这个东西真心很赞");
    System.out.println(nlp.words());
    System.out.println(nlp.tags());
    System.out.println(nlp.sentiments());
    System.out.println(nlp.pinyin());
    nlp = new NLP("「繁體字」「繁體中文」的叫法在臺灣亦很常見。");
    System.out.println(nlp.han());
    String text = "自然语言处理是计算机科学领域与人工智能领域中的一个重要方向。\r\n它研究能实现人与计算机之间用自然语言进行有效通信的各种理论和方法。\r\n自然语言处理是一门融语言学、计算机科学、数学于一体的科学。\r\n因此,这一领域的研究将涉及自然语言,即人们日常使用的语言,\r\n所以它与语言学的研究有着密切的联系,但又有重要的区别。\r\n自然语言处理并不是一般地研究自然语言,\r\n而在于研制能有效地实现自然语言通信的计算机系统,\r\n特别是其中的软件系统。因而它是计算机科学的一部分。";
    nlp = new NLP(text);
    System.out.println(nlp.keywords(5));
    System.out.println(nlp.summary(3));
    System.out.println(nlp.sentences());
    List<List<String>> test = new ArrayList<List<String>>();
    test.add(Arrays.asList("这篇", "文章"));
    test.add(Arrays.asList("那篇", "论文"));
    test.add(Arrays.asList("这个"));
    nlp = new NLP(test);
    System.out.println(nlp.tf());
    System.out.println(nlp.idf());
    System.out.println(nlp.sim(Arrays.asList("文章")));
}
Example 48
Project: alien4cloud-master  File: MockLocationConfigurerFactory.java View source code
public ILocationConfiguratorPlugin newInstance(String locationType) {
    if (MockOrchestratorFactory.OPENSTACK.equals(locationType)) {
        return applicationContext.getBean(MockOpenStackLocationConfigurer.class);
    }
    if (MockOrchestratorFactory.AWS.equals(locationType)) {
        return applicationContext.getBean(MockAmazonLocationConfigurer.class);
    }
    return new ILocationConfiguratorPlugin() {

        @Override
        public List<PluginArchive> pluginArchives() {
            return new ArrayList<>();
        }

        @Override
        public List<String> getResourcesTypes() {
            return new ArrayList<>();
        }

        @Override
        public Map<String, MatchingConfiguration> getMatchingConfigurations() {
            return new HashMap<>();
        }

        @Override
        public List<LocationResourceTemplate> instances(ILocationResourceAccessor resourceAccessor) {
            return null;
        }
    };
}
Example 49
Project: aws-sdk-android-master  File: ListWithAutoConstructFlagTest.java View source code
@Test
public void testListWithAutoConstructFlag() {
    ListWithAutoConstructFlag<String> noArgs = new ListWithAutoConstructFlag<String>();
    ListWithAutoConstructFlag<String> collect = new ListWithAutoConstructFlag<String>(new ArrayList<String>());
    ListWithAutoConstructFlag<String> capacity = new ListWithAutoConstructFlag<String>(5);
    assertFalse(noArgs.isAutoConstruct());
    assertFalse(collect.isAutoConstruct());
    assertFalse(capacity.isAutoConstruct());
    noArgs.setAutoConstruct(true);
    collect.setAutoConstruct(true);
    capacity.setAutoConstruct(true);
    assertTrue(noArgs.isAutoConstruct());
    assertTrue(collect.isAutoConstruct());
    assertTrue(capacity.isAutoConstruct());
}
Example 50
Project: GlowstonePlusPlus-master  File: GlowChargeFadeMatcher.java View source code
@Override
public ItemStack getResult(ItemStack[] matrix) {
    ItemStack charge = null;
    List<Color> colors = new ArrayList<>();
    for (ItemStack item : matrix) {
        if (item == null)
            continue;
        switch(item.getType()) {
            case INK_SACK:
                Dye dye = (Dye) item.getData();
                colors.add(dye.getColor().getFireworkColor());
                break;
            case FIREWORK_CHARGE:
                charge = item;
                break;
            default:
                // Wrong item on matrix
                return null;
        }
    }
    // No charge, or no colors
    if (charge == null || colors.isEmpty())
        return null;
    FireworkEffectMeta meta = (FireworkEffectMeta) charge.getItemMeta();
    FireworkEffect old = meta.getEffect();
    FireworkEffect newEffect = FireworkEffect.builder().with(old.getType()).withColor(old.getColors()).flicker(old.hasFlicker()).trail(old.hasTrail()).withFade(colors).build();
    meta.setEffect(newEffect);
    ItemStack ret = charge.clone();
    ret.setItemMeta(meta);
    return ret;
}
Example 51
Project: hibernate-core-ogm-master  File: InterceptFieldClassFileTransformerTest.java View source code
/**
	 * Tests that class file enhancement works.
	 * 
	 * @throws Exception in case the test fails.
	 */
public void testEnhancement() throws Exception {
    List<String> entities = new ArrayList<String>();
    entities.add("org.hibernate.ejb.test.instrument.Simple");
    // sanity check that the class is unmodified and does not contain getFieldHandler()
    try {
        org.hibernate.ejb.test.instrument.Simple.class.getDeclaredMethod("getFieldHandler");
        fail();
    } catch (NoSuchMethodException nsme) {
    }
    // use custom class loader which enhances the class
    InstrumentedClassLoader cl = new InstrumentedClassLoader(Thread.currentThread().getContextClassLoader());
    cl.setEntities(entities);
    Class clazz = cl.loadClass(entities.get(0));
    // javassist is our default byte code enhancer. Enhancing will eg add the method getFieldHandler()
    // see org.hibernate.bytecode.internal.javassist.FieldTransformer
    Method method = clazz.getDeclaredMethod("getFieldHandler");
    assertNotNull(method);
}