/** * Create an outline business object from a class name and a list of interface names * @param className the class name * @param implementations a space separated list of interface names * @return the materialised business object * @throws ClassNotFoundException if className can't be found */ public static FastPathObject instantiateObject(String className, String implementations) throws ClassNotFoundException { Set<String> classNames = new HashSet<String>(); if (className != null && !"".equals(className) && !"".equals(className.trim())) { classNames.add(className.trim()); } if (implementations != null) { classNames.addAll(StringUtil.tokenize(implementations)); } if (classNames.size() == 0) { throw new RuntimeException("attempted to create an object without specifying any " + "classes or interfaces"); } return createObject(convertToClasses(classNames)); }
/** * Generate a package qualified class name within the specified model from a space separated * list of namespace qualified names * * @param classNames the list of namepace qualified names * @param model the relevant model * @return the package qualified names */ public static String generateClassNames(String classNames, Model model) { if (classNames == null) { return null; } StringBuffer sb = new StringBuffer(); for (String s : StringUtil.tokenize(classNames)) { sb.append(model.getPackageName() + "." + XmlUtil.getFragmentFromURI(s + " ")); } return sb.toString().trim(); } }
/** * Create an outline business object from a class name and a list of interface names * @param className the class name * @param implementations a space separated list of interface names * @return the materialised business object * @throws ClassNotFoundException if className can't be found */ public static FastPathObject instantiateObject(String className, String implementations) throws ClassNotFoundException { Set<String> classNames = new HashSet<String>(); if (className != null && !"".equals(className) && !"".equals(className.trim())) { classNames.add(className.trim()); } if (implementations != null) { classNames.addAll(StringUtil.tokenize(implementations)); } if (classNames.size() == 0) { throw new RuntimeException("attempted to create an object without specifying any " + "classes or interfaces"); } return createObject(convertToClasses(classNames)); }
/** * Generate a package qualified class name within the specified model from a space separated * list of namespace qualified names * * @param classNames the list of namepace qualified names * @param model the relevant model * @return the package qualified names */ public static String generateClassNames(String classNames, Model model) { if (classNames == null) { return null; } StringBuffer sb = new StringBuffer(); for (String s : StringUtil.tokenize(classNames)) { sb.append(model.getPackageName() + "." + XmlUtil.getFragmentFromURI(s + " ")); } return sb.toString().trim(); } }
public void testTokenize() throws Exception { try { StringUtil.tokenize(null); fail("Expected NullPointerException"); } catch (NullPointerException e) { } assertEquals(StringUtil.tokenize(""), new ArrayList<String>()); assertEquals(StringUtil.tokenize(" "), new ArrayList<String>()); assertEquals(StringUtil.tokenize(" one"), Arrays.asList(new Object[] {"one"})); assertEquals(StringUtil.tokenize(" one two"), Arrays.asList(new Object[] {"one", "two"})); }
try { bc = new BagConstraint(qf, ConstraintOp.IN, toIntegers(new HashSet<String>(StringUtil.tokenize(refs.getRefIds())))); } catch (Exception e) { throw new RuntimeException("failed to find some referenced Items from "
try { bc = new BagConstraint(qf, ConstraintOp.IN, toIntegers(new HashSet<String>(StringUtil.tokenize(refs.getRefIds())))); } catch (Exception e) { throw new RuntimeException("failed to find some referenced Items from "
/** * Convert a data model item to an XML one * @param item the data model Item * @return an equivalent XML Item */ public static Item convert(org.intermine.model.fulldata.Item item) { Item newItem = new Item(item.getIdentifier(), item.getClassName(), item.getImplementations()); for (org.intermine.model.fulldata.Attribute attr : item.getAttributes()) { newItem.setAttribute(attr.getName(), attr.getValue()); } for (org.intermine.model.fulldata.Reference ref : item.getReferences()) { newItem.setReference(ref.getName(), ref.getRefId()); } for (org.intermine.model.fulldata.ReferenceList refs : item.getCollections()) { newItem.setCollection(refs.getName(), StringUtil.tokenize(refs.getRefIds())); } return newItem; }
/** * Convert a data model item to an XML one * @param item the data model Item * @return an equivalent XML Item */ public static Item convert(org.intermine.model.fulldata.Item item) { Item newItem = new Item(item.getIdentifier(), item.getClassName(), item.getImplementations()); for (org.intermine.model.fulldata.Attribute attr : item.getAttributes()) { newItem.setAttribute(attr.getName(), attr.getValue()); } for (org.intermine.model.fulldata.Reference ref : item.getReferences()) { newItem.setReference(ref.getName(), ref.getRefId()); } for (org.intermine.model.fulldata.ReferenceList refs : item.getCollections()) { newItem.setCollection(refs.getName(), StringUtil.tokenize(refs.getRefIds())); } return newItem; }