public boolean isChildOf(Keyword word) { Iterator parents = getParentIterator(); while (parents.hasNext()) { Keyword par = (Keyword) parents.next(); if (par == null) return (false); else if (par.equals(word)) return (true); else return (par.isChildOf(word)); } return false; }
public void processLine(String line) throws Exception { line = line.trim(); if (line.length() > 0 && line.substring(0, 1).equals("#")) { return; } String[] chunks = line.split(" "); String command = chunks[0]; String[] params = new String[chunks.length -1]; for (int i = 1; i< chunks.length; i++) { params[i - 1] = chunks[i]; } switch (Keyword.toKeyword(command)) { case q: case quit: throw new RuntimeException("quit!"); case trans: case t: translateSpelling(params[0]); break; case h: case help: InputStream stream = Console.class.getResourceAsStream("ConsoleHelp.txt"); BufferedReader in = new BufferedReader(new InputStreamReader(stream)); String tmpLine = null; while((tmpLine = in.readLine()) != null) out(tmpLine); stream.close(); break; default: throw new RuntimeException("unknown command " + command); } }
public static EnumDefinition dropKeywordCreateEnum( EnumDefinition enumDefinition, Keyword keyword, boolean saveEnum) { if (enumDefinition == null) { enumDefinition = new EnumDefinition(keyword.toString(), saveEnum); } enumDefinition.setKeyword(keyword); return enumDefinition; }
public static Vector extractKeywordFromText(String text) { // see if there are any existing keywords represented // in this text // Get all keywords Vector extractedKeywords = new Vector(); Iterator keywords = allKeywords.iterator(); while (keywords.hasNext()) { Keyword keyword = (Keyword) keywords.next(); if (text != null && keyword.toString() != null && text.toLowerCase().indexOf(keyword.toString().toLowerCase()) > -1) { extractedKeywords.addElement(keyword); } } return extractedKeywords; }
public UndefinedBooleanExpressionPanel(UndefinedBooleanExpression expr) { setLayout(new FlowLayout(FlowLayout.LEFT)); setBackground(Color.white); // setBorder // (BorderFactory.createLineBorder(Color.red, // 2)); if (expr.getLeftHandSide() instanceof Keyword && expr.getRightHandSide() instanceof EnumLevelList) { Keyword keyword = (Keyword) expr.getLeftHandSide(); EnumLevelList ll = (EnumLevelList) expr.getRightHandSide(); // System.out.println("keyword " + keyword); JLabel keywordLabel = new JLabel(keyword.toString() + ARROW); // keywordLabel.setFont(new Font("Arial",10,Font.BOLD)); add(keywordLabel); if (ll.isNumericList()) add(getNumericLevels(ll)); else add(getStringLevels(ll)); } else add(new JLabel("Improperly defined boolean expression")); }
private Vector getChildren(Keyword keyword, Vector allKids) { allKids.addElement(keyword); // System.out.println("Addtoallkids " + keyword + " " + allKids ); Vector children = keyword.getChildren(); if (children != null) { Iterator i = children.iterator(); while (i.hasNext()) { Keyword child = (Keyword) i.next(); getChildren(child, allKids); } } return allKids; }
public boolean dropOn(Object dropOnObject) { if (dropOnObject instanceof Keyword) { Keyword parentKeyword = null; Keyword newParentKeyword = (Keyword) dropOnObject; // Add child to new parent newParentKeyword.addChild(this); // Add new parent to child setPar(newParentKeyword); update(); newParentKeyword.update(); return true; } else if (dropOnObject instanceof PersistibleWithKeywords) { // System.out.println("droping a keyword on " + dropOnObject); // THis seems to cause a duplicate entry addDescribedInstance((PersistibleWithKeywords) dropOnObject); update(); ((PersistibleWithKeywords) dropOnObject).link(this); ((PersistibleWithKeywords) dropOnObject).update(); return true; } return false; }
private void addKeyword(Hashtable table, Keyword word, Keyword parent) { boolean recurse = true; if (table.containsKey(word)) recurse = false; if (parent == null) table.put(word, String.valueOf(-1)); else table.put(word, parent); if (recurse) { Iterator it = word.getChildren().iterator(); while (it.hasNext()) { addKeyword(table, (Keyword) it.next(), word); } } }
public static EnumDefinition dropKeywordCreateEnum(Keyword keyword, boolean saveEnum) { EnumDefinition enumDefinition = new EnumDefinition(keyword.toString(), saveEnum); enumDefinition.setKeyword(keyword); return enumDefinition; }
public static void main(String[] args) { Keyword t = new Keyword("TEST KEYWORD"); t.update(); oncotcap.Oncotcap.getDataSource().commit(); }