Example usage for java.util Vector getClass

List of usage examples for java.util Vector getClass

Introduction

In this page you can find the example usage for java.util Vector getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.objectsecurity.xwiki.objects.classes.SPARQListClass.java

public List<ListItem> getSPARQList(XWikiContext context) {
    LOG.info("SPARQListClass::getSPARQList: " + context);
    List<ListItem> list = getCachedSPARQList(context);
    String insertedValue = getInsertValue();
    String insertAtPosition = getInsertAtPosition();
    LOG.debug("insertedValue: `" + insertedValue + "'");
    LOG.debug("insertAtPosition: `" + insertAtPosition + "'");
    if (list == null) {
        XWiki xwiki = context.getWiki();
        String query = getQuery(context);

        if (query == null) {
            list = new ArrayList<ListItem>();
        } else {//from www .ja v  a  2s .c om
            try {
                Vector<Vector<String>> vec = Context.getInstance().query(query, new String[0]);
                LOG.debug("result of query: " + vec);
                LOG.debug("result of query: " + ((vec == null) ? "<null>" : vec.getClass().toString()));
                list = new ArrayList<ListItem>();
                for (int i = 0; i < vec.size(); i++) {
                    String name = vec.elementAt(i).elementAt(0);
                    LOG.debug("add name: " + name);
                    list.add(new ListItem(name));
                }
                // if ((xwiki.getHibernateStore() != null) && (!query.startsWith("/"))) {
                //     list = makeList(xwiki.search(query, context));
                // } else {
                //     list = makeList(((QueryPlugin) xwiki.getPlugin("query", context)).xpath(query).list());
                // }
            } catch (Exception e) {
                LOG.warn("exception while executing query", e);
                list = new ArrayList<ListItem>();
            }
        }
        if (insertAtPosition != null && !(insertAtPosition.equals("") || insertAtPosition.equals("----"))) {
            if (insertAtPosition.equals("beginning")) {
                list.add(0, new ListItem(insertedValue));
            } else if (insertAtPosition.equals("end")) {
                list.add(new ListItem(insertedValue));
            } else {
                throw new RuntimeException("Wrong insert position in SPARQ list: " + insertAtPosition);
            }
        }
        setCachedSPARQList(list, context);
    }

    StringBuilder logResult = new StringBuilder("list: [");
    for (int i = 0; i < list.size(); i++) {
        logResult.append("'").append(list.get(i)).append("',");
    }
    LOG.debug(logResult.append("]").toString());
    return list;
}