rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
if (className == null) { return null; }
protected BeanInfo getBeanInfo(String className) throws BeanDefinitionStoreException { BeanInfo info = null; Class type = null; try { type = loadClass(className); } catch (ClassNotFoundException e) { throw new BeanDefinitionStoreException("Failed to load type: " + className + ". Reason: " + e, e); } try { info = Introspector.getBeanInfo(type); } catch (IntrospectionException e) { throw new BeanDefinitionStoreException("Failed to introspect type: " + className + ". Reason: " + e, e); } return info; }
p.getChildren().add(WFUtil.getText(" ")); HtmlOutputText t = WFUtil.getTextVB(ref + "categoryNames"); t.setConverter(new WFCommaSeparatedListConverter()); g = WFUtil.group(localizer.getHeaderTextVB("categories"), WFUtil.getHeaderText(": ")); g.getChildren().add(t); p.getChildren().add(g);
private UIComponent getDetailPanel() { WFResourceUtil localizer = WFResourceUtil.getResourceUtilArticle(); HtmlPanelGrid p = WFPanelUtil.getPlainFormPanel(1); //Add the detailed info p = WFPanelUtil.getPlainFormPanel(1); p.getChildren().add(WFUtil.getHeaderTextVB(ref + "headline")); p.getChildren().add(WFUtil.getText(" ")); p.getChildren().add(WFUtil.getTextVB(ref + "teaser")); p.getChildren().add(WFUtil.getText(" ")); WFPlainOutputText bodyText = new WFPlainOutputText(); WFUtil.setValueBinding(bodyText, "value", ref + "body"); p.getChildren().add(bodyText); p.getChildren().add(WFUtil.getBreak()); p.getChildren().add(new WFPlainOutputText("<hr/>")); UIComponent g = WFUtil.group(localizer.getHeaderTextVB("author"), WFUtil.getHeaderText(": ")); g.getChildren().add(WFUtil.getTextVB(ref + "author")); p.getChildren().add(g); p.getChildren().add(WFUtil.getText(" ")); g = WFUtil.group(localizer.getHeaderTextVB("created"), WFUtil.getHeaderText(": ")); g.getChildren().add(WFUtil.getTextVB(ref + "creationDate")); p.getChildren().add(g); p.getChildren().add(WFUtil.getText(" ")); g = WFUtil.group(localizer.getHeaderTextVB("status"), WFUtil.getHeaderText(": ")); g.getChildren().add(WFUtil.getTextVB(ref + "status")); p.getChildren().add(g); p.getChildren().add(WFUtil.getText(" ")); HtmlOutputText t = WFUtil.getTextVB(ref + "categoryNames"); t.setConverter(new WFCommaSeparatedListConverter()); g = WFUtil.group(localizer.getHeaderTextVB("categories"), WFUtil.getHeaderText(": ")); g.getChildren().add(t); p.getChildren().add(g); p.getChildren().add(WFUtil.getText(" ")); g = WFUtil.group(localizer.getHeaderTextVB("current_version"), WFUtil.getHeaderText(": "));// g.getChildren().add(WFUtil.getTextVB(ref + "versionId")); g.getChildren().add(WFUtil.getTextVB(ref + "versionName")); p.getChildren().add(g); p.getChildren().add(WFUtil.getText(" ")); g = WFUtil.group(localizer.getHeaderTextVB("comment"), WFUtil.getHeaderText(": ")); g.getChildren().add(WFUtil.getTextVB(ref + "comment")); p.getChildren().add(g); p.getChildren().add(WFUtil.getText(" ")); g = WFUtil.group(localizer.getHeaderTextVB("source"), WFUtil.getHeaderText(": ")); g.getChildren().add(WFUtil.getTextVB(ref + "source")); p.getChildren().add(g); p.getChildren().add(WFUtil.getText(" ")); WebDAVFileDetails details = new WebDAVFileDetails(); WFUtil.setValueBinding(details,"currentResourcePath",ref+"resourcePath"); p.getChildren().add(details); return p; }
format = new String(g.getOptarg());
format = g.getOptarg();
public static void main(String[] args) throws Exception { long startTime = System.currentTimeMillis(); LongOpt[] longOpts = new LongOpt[4]; longOpts[0] = new LongOpt("format", LongOpt.REQUIRED_ARGUMENT, null, 'f'); longOpts[1] = new LongOpt("datafile", LongOpt.REQUIRED_ARGUMENT, null, 'd'); longOpts[2] = new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'); longOpts[3] = new LongOpt("source", LongOpt.REQUIRED_ARGUMENT, null, 's'); Getopt g = new Getopt(Main.class.getName(), args, ":f:d:o:s:", longOpts); int c; while ((c = g.getopt()) != -1) { switch (c) { case 'f': format = new String(g.getOptarg()); if (!format.equalsIgnoreCase("html") && !format.equalsIgnoreCase("xml")) { throw new Exception("Error: format \"" + format + "\" must be either html or xml"); } break; case 'd': dataFile = new File(g.getOptarg()); if (!dataFile.exists()) { throw new Exception("Error: data file " + dataFile.getAbsolutePath() + " does not exist"); } if (dataFile.isDirectory()) { throw new Exception("Error: data file " + dataFile.getAbsolutePath() + " cannot be a directory"); } break; case 'o': outputDir = new File(g.getOptarg()); if (outputDir.exists() && outputDir.isFile()) { throw new Exception("Error: destination directory " + outputDir + " already exists and is a file"); } outputDir.mkdirs(); break; case 's': sourceDir = new File(g.getOptarg()); if (!sourceDir.exists()) { throw new Exception("Error: source directory " + sourceDir + " does not exist"); } if (sourceDir.isFile()) { throw new Exception("Error: source directory " + sourceDir + " should be a directory, not a file"); } break; } } if (logger.isDebugEnabled()) { logger.debug("format is " + format); logger.debug("dataFile is " + dataFile.getAbsolutePath()); logger.debug("outputDir is " + outputDir.getAbsolutePath()); logger.debug("sourceDir is " + sourceDir.getAbsolutePath()); } if (dataFile == null) dataFile = new File(CoverageDataFileHandler.FILE_NAME); ProjectData projectData = CoverageDataFileHandler .loadCoverageData(dataFile); if (format.equalsIgnoreCase("html")) { new HTMLReport(projectData, outputDir, sourceDir); } else if (format.equalsIgnoreCase("xml")) { new XMLReport(projectData, outputDir, sourceDir); } long stopTime = System.currentTimeMillis(); System.out .println("Reporting time: " + (stopTime - startTime) + "ms"); }
ByteArrayInputStream bais = new ByteArrayInputStream(body.getBytes()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); tidy.parse(bais, baos); String articleOut = baos.toString();
tidy.setCharEncoding(Configuration.UTF8); ByteArrayInputStream bais; try { bais = new ByteArrayInputStream(body.getBytes("UTF-8")); ByteArrayOutputStream baos = new ByteArrayOutputStream(); tidy.parse(bais, baos); body = baos.toString(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); }
protected void prettifyBody() { String body = getBody(); if(body!=null){// System.out.println("ArticleIn = "+articleIn); //Use JTidy to clean up the html Tidy tidy = new Tidy(); tidy.setXHTML(true); tidy.setXmlOut(true); ByteArrayInputStream bais = new ByteArrayInputStream(body.getBytes()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); tidy.parse(bais, baos); String articleOut = baos.toString();// System.out.println("ArticleOut = "+articleOut); setBody(articleOut); } }
setBody(articleOut);
setBody(body);
protected void prettifyBody() { String body = getBody(); if(body!=null){// System.out.println("ArticleIn = "+articleIn); //Use JTidy to clean up the html Tidy tidy = new Tidy(); tidy.setXHTML(true); tidy.setXmlOut(true); ByteArrayInputStream bais = new ByteArrayInputStream(body.getBytes()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); tidy.parse(bais, baos); String articleOut = baos.toString();// System.out.println("ArticleOut = "+articleOut); setBody(articleOut); } }
if (!cMacro && Expression.isTrue(c))
if (!cMacro && Expression.isTrue(c)) {
public Object build(DirectiveBuilder builder, BuildContext bc) throws BuildException { Object c = builder.getArg(IF_COND, bc); boolean cMacro = (c instanceof Macro); int elseifCount; DirectiveArgs elseArgs; DirectiveArgs[] elseifArgs = null; // If condition is static and true -- just return the block if (!cMacro && Expression.isTrue(c)) return (Block) builder.getArg(IF_BLOCK, bc); elseArgs = builder.getSubdirective(IF_ELSE); elseifArgs = builder.getRepeatingSubdirective(IF_ELSEIF); elseifCount = (elseifArgs == null) ? 0 : elseifArgs.length; // OK, how about no else-if subdirectives? if (elseifCount == 0) { // If condition is static and false -- just return the else block if (!cMacro) { return (elseArgs != null) ? elseArgs.getArg(ELSE_BLOCK, bc) : ""; } else { // Just one condition -- the IF condition, and maybe an ELSE block conditions = new Macro[1]; blocks = new Block[1]; conditions[0] = (Macro) c; blocks[0] = (Block) builder.getArg(IF_BLOCK, bc); if (elseArgs != null) elseBlock = (Block) elseArgs.getArg(ELSE_BLOCK, bc); return this; } } else { // This is the ugly case -- we have to guess at how many conditions // we'll have. We start with 1 + count(#elseof), and if any can be // folded out at compile time, we just won't use the whole thing int i=0; nConditions=elseifCount; if (cMacro) ++nConditions; conditions = new Macro[nConditions]; blocks = new Block[nConditions]; if (cMacro) { conditions[0] = (Macro) c; blocks[0] = (Block) builder.getArg(IF_BLOCK, bc); ++i; } for (int j=0; j < elseifCount; j++) { c = elseifArgs[j].getArg(ELSEIF_COND, bc); if (c instanceof Macro) { conditions[i] = (Macro) c; blocks[i] = (Block) elseifArgs[j].getArg(ELSEIF_BLOCK, bc); ++i; } else if (Expression.isTrue(c)) { elseBlock = (Block) elseifArgs[j].getArg(ELSEIF_BLOCK, bc); // If all the previous got folded out as false, then just return the // block from this condition, otherwise stash it in the elseBlock // and we're done with #elseif directives if (i == 0) return elseBlock; else break; } else { // Just skip this #elseif directive } } // If we didn't promote one of the elseif blocks to else, get the else if (elseBlock == null && elseArgs != null) { elseBlock = (Block) elseArgs.getArg(ELSE_BLOCK, bc); // If there are no valid conditions, just return the else block if (i == 0) return elseBlock; } if (i < nConditions) { // If we folded out some cases, we would want to resize the arrays, // but since the space doesn't really matter, we'll save time by // just remembering how big they really are. nConditions = i; } } return this; }
nConditions=elseifCount; if (cMacro) ++nConditions;
nConditions=elseifCount + (cMacro? 1 : 0);
public Object build(DirectiveBuilder builder, BuildContext bc) throws BuildException { Object c = builder.getArg(IF_COND, bc); boolean cMacro = (c instanceof Macro); int elseifCount; DirectiveArgs elseArgs; DirectiveArgs[] elseifArgs = null; // If condition is static and true -- just return the block if (!cMacro && Expression.isTrue(c)) return (Block) builder.getArg(IF_BLOCK, bc); elseArgs = builder.getSubdirective(IF_ELSE); elseifArgs = builder.getRepeatingSubdirective(IF_ELSEIF); elseifCount = (elseifArgs == null) ? 0 : elseifArgs.length; // OK, how about no else-if subdirectives? if (elseifCount == 0) { // If condition is static and false -- just return the else block if (!cMacro) { return (elseArgs != null) ? elseArgs.getArg(ELSE_BLOCK, bc) : ""; } else { // Just one condition -- the IF condition, and maybe an ELSE block conditions = new Macro[1]; blocks = new Block[1]; conditions[0] = (Macro) c; blocks[0] = (Block) builder.getArg(IF_BLOCK, bc); if (elseArgs != null) elseBlock = (Block) elseArgs.getArg(ELSE_BLOCK, bc); return this; } } else { // This is the ugly case -- we have to guess at how many conditions // we'll have. We start with 1 + count(#elseof), and if any can be // folded out at compile time, we just won't use the whole thing int i=0; nConditions=elseifCount; if (cMacro) ++nConditions; conditions = new Macro[nConditions]; blocks = new Block[nConditions]; if (cMacro) { conditions[0] = (Macro) c; blocks[0] = (Block) builder.getArg(IF_BLOCK, bc); ++i; } for (int j=0; j < elseifCount; j++) { c = elseifArgs[j].getArg(ELSEIF_COND, bc); if (c instanceof Macro) { conditions[i] = (Macro) c; blocks[i] = (Block) elseifArgs[j].getArg(ELSEIF_BLOCK, bc); ++i; } else if (Expression.isTrue(c)) { elseBlock = (Block) elseifArgs[j].getArg(ELSEIF_BLOCK, bc); // If all the previous got folded out as false, then just return the // block from this condition, otherwise stash it in the elseBlock // and we're done with #elseif directives if (i == 0) return elseBlock; else break; } else { // Just skip this #elseif directive } } // If we didn't promote one of the elseif blocks to else, get the else if (elseBlock == null && elseArgs != null) { elseBlock = (Block) elseArgs.getArg(ELSE_BLOCK, bc); // If there are no valid conditions, just return the else block if (i == 0) return elseBlock; } if (i < nConditions) { // If we folded out some cases, we would want to resize the arrays, // but since the space doesn't really matter, we'll save time by // just remembering how big they really are. nConditions = i; } } return this; }
state = ServiceState.STARTING; serviceMonitor.serviceStopping(createServiceEvent());
public void destroy(StopStrategy stopStrategy) throws IllegalServiceStateException, UnsatisfiedConditionsException { // if we are not restartable, we need to stop try { if (!stop(stopStrategy)) { throw new IllegalServiceStateException("Service did not stop", serviceName); } } catch (UnsatisfiedConditionsException e) { throw e; } if (!serviceFactory.isRestartable()) { lock("destroy"); try { if (state != ServiceState.STOPPED) { try { // destroy the service serviceFactory.destroyService(standardServiceContext); } catch (Throwable e) { serviceMonitor.serviceStopError(createErrorServiceEvent(e)); } destroyAllConditions(serviceMonitor); service = null; startTime = 0; state = ServiceState.STOPPED; serviceMonitor.serviceStopped(createServiceEvent()); } } finally { unlock(); } } // cool we can unregistered serviceMonitor.serviceUnregistered(createServiceEvent()); }
serviceMonitor.serviceRegistered(createServiceEvent()); if (!serviceFactory.isRestartable()) { serviceMonitor.serviceRunning(createServiceEvent()); }
public void initialize() throws IllegalServiceStateException, UnsatisfiedConditionsException, Exception { // if we are not restartable, we need to start immediately, otherwise we are not going to register this service if (!serviceFactory.isRestartable()) { try { start(false, StartStrategies.UNREGISTER); } catch (UnregisterServiceException e) { Throwable cause = e.getCause(); if (cause instanceof Exception) { throw (Exception) cause; } else if (cause instanceof Error) { throw (Error) cause; } else { throw new AssertionError(cause); } } // a non restartable service uses a special stop conditions object that picks up stop conditions as they // are added. When the stop() method is called on a non-restartable service all of the stop conditions // registered with the service factory are initialized (if not already initialized), and the isSatisfied // method is called. This should cause the stop logic of a stop condition to fire. lock("initialize"); try { stopConditions = new NonRestartableStopConditions(kernel, serviceName, classLoader, serviceFactory.getStartConditions(), lock, serviceFactory); } finally { unlock(); } } // cool we are registered serviceMonitor.serviceRegistered(createServiceEvent()); // if we are not restartable, we need to notify everyone we just started if (!serviceFactory.isRestartable()) { serviceMonitor.serviceRunning(createServiceEvent()); } }
managerFutures = new ArrayList();
managerFutures = new ArrayList(serviceManagers.values());
public void destroy() throws KernelErrorsError { // we gather all errors that occur during shutdown and throw them as on huge exception List errors = new ArrayList(); List managerFutures; synchronized (serviceManagers) { managerFutures = new ArrayList(); serviceManagers.clear(); } List managers = new ArrayList(managerFutures.size()); for (Iterator iterator = managerFutures.iterator(); iterator.hasNext();) { Future future = (Future) iterator.next(); try { managers.add(future.get()); } catch (InterruptedException e) { // ignore -- this should not happen errors.add(new AssertionError(e)); } catch (ExecutionException e) { // good -- one less manager to deal with } } // Be nice and try to stop asynchronously errors.addAll(stopAll(managers, StopStrategies.ASYNCHRONOUS)); // Be really nice and try to stop asynchronously again errors.addAll(stopAll(managers, StopStrategies.ASYNCHRONOUS)); // We have been nice enough now nuke them errors.addAll(stopAll(managers, StopStrategies.FORCE)); // All managers are gaurenteed to be destroyed now for (Iterator iterator = managers.iterator(); iterator.hasNext();) { ServiceManager serviceManager = (ServiceManager) iterator.next(); try { serviceManager.destroy(StopStrategies.FORCE); } catch (UnsatisfiedConditionsException e) { // this should not happen, because we force stopped errors.add(new AssertionError(e)); } catch (IllegalServiceStateException e) { // this should not happen, because we force stopped errors.add(new AssertionError(e)); } catch (RuntimeException e) { errors.add(new AssertionError(e)); } catch (Error e) { errors.add(new AssertionError(e)); } } if (!errors.isEmpty()) { throw new KernelErrorsError(errors); } }
contactList.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("Ctrl F6"), "viewNotes");
contactList.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control F6"), "viewNotes");
public void initialize() { contactList = SparkManager.getWorkspace().getContactList(); contactList.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("Ctrl F6"), "viewNotes"); contactList.getActionMap().put("viewNotes", new AbstractAction("viewNotes") { public void actionPerformed(ActionEvent evt) { // Retrieve notes and dispaly in editor. retrieveNotes(); } }); contactList.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("Ctrl F5"), "viewTasks"); contactList.getActionMap().put("viewTasks", new AbstractAction("viewTasks") { public void actionPerformed(ActionEvent evt) { // Retrieve notes and dispaly in editor. showTaskList(); } }); }
contactList.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("Ctrl F5"), "viewTasks");
contactList.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control F5"), "viewTasks");
public void initialize() { contactList = SparkManager.getWorkspace().getContactList(); contactList.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("Ctrl F6"), "viewNotes"); contactList.getActionMap().put("viewNotes", new AbstractAction("viewNotes") { public void actionPerformed(ActionEvent evt) { // Retrieve notes and dispaly in editor. retrieveNotes(); } }); contactList.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("Ctrl F5"), "viewTasks"); contactList.getActionMap().put("viewTasks", new AbstractAction("viewTasks") { public void actionPerformed(ActionEvent evt) { // Retrieve notes and dispaly in editor. showTaskList(); } }); }
Collection contacts = contactList.getSelectedUsers();
Collection contacts = contactList.getActiveGroup().getContactItems();
public void actionPerformed(ActionEvent actionEvent) { Collection contacts = contactList.getSelectedUsers(); startConference(contacts); }
PresenceListener presenceListener = new PresenceListener() { public void presenceChanged(Presence presence) { for(ChatRoom room : SparkManager.getChatManager().getChatContainer().getChatRooms()){ if(room instanceof GroupChatRoom){ GroupChatRoom groupChatRoom = (GroupChatRoom)room; String jid = groupChatRoom.getMultiUserChat().getRoom(); String to = presence.getTo(); presence.setTo(jid); SparkManager.getConnection().sendPacket(presence); presence.setTo(to); } } } }; SparkManager.getSessionManager().addPresenceListener(presenceListener);
public void initialize() { ServiceDiscoveryManager manager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection()); mucSupported = manager.includesFeature("http://jabber.org/protocol/muc"); if (mucSupported) { // Load the conference data from Private Data loadBookmarks(); // Add an invitation listener. addInvitationListener(); addChatRoomListener(); addPopupListeners(); // Add Join Conference Button to StatusBar // Get command panel and add View Online/Offline, Add Contact StatusBar statusBar = SparkManager.getWorkspace().getStatusBar(); JPanel commandPanel = statusBar.getCommandPanel(); RolloverButton joinConference = new RolloverButton(SparkRes.getImageIcon(SparkRes.CONFERENCE_IMAGE_16x16)); joinConference.setToolTipText(Res.getString("message.join.conference.room")); commandPanel.add(joinConference); joinConference.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ConferenceRooms rooms = new ConferenceRooms(bookedMarkedConferences.getTree(), getDefaultServiceName()); rooms.invoke(); } }); } }
OrCondition(Condition l, Condition r) { _l = l; _r = r; System.out.println("Condition: " + l + " || + " + r); }
OrCondition(Condition l, Condition r) { _l = l; _r = r; }
OrCondition(Condition l, Condition r) { _l = l; _r = r; System.out.println("Condition: " + l + " || + " + r); }
public static void flood(String directory, String fileName, String fileExt, int numOfFiles, int linesPerFile) { File dir = new File(directory); if (dir.exists() && dir.isDirectory()) { for (int i = 1; i <= numOfFiles; i++) { try { File file = new File(directory + "/" + fileName + i + "." + fileExt); LOGGER.info("Writing file: " + file.getAbsolutePath()); FileWriter writer = new FileWriter(file); for (int l = 1; l <= linesPerFile; l++) { writer.write("This is a test file. blah.... blah.... blah....\n"); } } catch(IOException ioe) { LOGGER.error("Error while writing file.", ioe); } } } }
public static void flood(String directory, String fileName, String fileExt, int numOfFiles, int linesPerFile) { File dir = new File(directory); if (dir.exists() && dir.isDirectory()) { for (int i = 1; i <= numOfFiles; i++) { FileWriter writer = null; try { File file = new File(directory + "/" + fileName + i + "." + fileExt); LOGGER.info("Writing file: " + file.getAbsolutePath()); writer = new FileWriter(file); for (int l = 1; l <= linesPerFile; l++) { writer.write("This is a test file. blah.... blah.... blah....\n"); } } catch (IOException ioe) { LOGGER.error("Error while writing file.", ioe); } finally { if (writer != null) try { writer.close(); } catch (IOException e) { } } } } }
public static void flood(String directory, String fileName, String fileExt, int numOfFiles, int linesPerFile) { File dir = new File(directory); if (dir.exists() && dir.isDirectory()) { for (int i = 1; i <= numOfFiles; i++) { try { File file = new File(directory + "/" + fileName + i + "." + fileExt); LOGGER.info("Writing file: " + file.getAbsolutePath()); FileWriter writer = new FileWriter(file); for (int l = 1; l <= linesPerFile; l++) { writer.write("This is a test file. blah.... blah.... blah....\n"); } } catch(IOException ioe) { LOGGER.error("Error while writing file.", ioe); } } } }
System.err.println ("pageName: " + pageName);
protected WikiPage createNewPage (WikiSystem wiki, WebContext wc, WikiUser user) throws Exception { // get the page elements from the request String editor = user.getIdentifier(); String text = wc.getForm ("TEXT"); boolean moderated = wc.getForm ("MODERATED") != null && wc.getForm("MODERATED").equals ("true"); String keywords = wc.getForm ("RELATED_TITLES"); String pageName = wc.getForm ("save"); // create the page System.err.println ("pageName: " + pageName); WikiPage newPage = wiki.createPage (pageName, editor, text); newPage.setRelatedTitles (keywordsToStringArray(keywords)); newPage.setIsModerated(moderated); System.err.println ("pageName: " + newPage.getTitle()); // make sure to save the page wiki.savePage (newPage); return newPage; }
System.err.println ("pageName: " + newPage.getTitle());
protected WikiPage createNewPage (WikiSystem wiki, WebContext wc, WikiUser user) throws Exception { // get the page elements from the request String editor = user.getIdentifier(); String text = wc.getForm ("TEXT"); boolean moderated = wc.getForm ("MODERATED") != null && wc.getForm("MODERATED").equals ("true"); String keywords = wc.getForm ("RELATED_TITLES"); String pageName = wc.getForm ("save"); // create the page System.err.println ("pageName: " + pageName); WikiPage newPage = wiki.createPage (pageName, editor, text); newPage.setRelatedTitles (keywordsToStringArray(keywords)); newPage.setIsModerated(moderated); System.err.println ("pageName: " + newPage.getTitle()); // make sure to save the page wiki.savePage (newPage); return newPage; }
in = getClass().getClassLoader().getResourceAsStream(uri);
ClassLoader cl = parserContext.getReaderContext().getReader().getBeanClassLoader(); if (cl != null) { in = cl.getResourceAsStream(uri); }
protected InputStream loadResource(String uri) { if (System.getProperty("xbean.dir") != null) { File f = new File(System.getProperty("xbean.dir") + uri); try { return new FileInputStream(f); } catch (FileNotFoundException e) { // Ignore } } // lets try the thread context class loader first InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(uri); if (in == null) { in = getClass().getClassLoader().getResourceAsStream(uri); if (in == null) { log.debug("Could not find resource: " + uri); } } return in; }
log.debug("Could not find resource: " + uri);
in = getClass().getClassLoader().getResourceAsStream(uri); if (in == null) { log.debug("Could not find resource: " + uri); }
protected InputStream loadResource(String uri) { if (System.getProperty("xbean.dir") != null) { File f = new File(System.getProperty("xbean.dir") + uri); try { return new FileInputStream(f); } catch (FileNotFoundException e) { // Ignore } } // lets try the thread context class loader first InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(uri); if (in == null) { in = getClass().getClassLoader().getResourceAsStream(uri); if (in == null) { log.debug("Could not find resource: " + uri); } } return in; }
return "* ";
return _number > 0 ? "" + (++_number) : "* ";
protected String renderListItem() { return "* "; }
+ new String(curBuf.buffer, 0, curBuf.curPos + 1);
+ new String(curBuf.buffer, 0, curBuf.curPos);
public final String GetImage() { if (tokenBeginBuf == curBuf) return new String(curBuf.buffer, tokenBeginPos, curBuf.curPos - tokenBeginPos + 1); else return new String(otherBuf.buffer, tokenBeginPos, otherBuf.dataLen - tokenBeginPos) + new String(curBuf.buffer, 0, curBuf.curPos + 1); }
while (j < l && Character.isSpaceChar(s.charAt(j)))
while (j < l && isSpaceChar(s.charAt(j)))
final public void eatLeadingWsNl() { int i, j, l; i = size() - 1; if ( i < 0 || i+1 == literalMark ) return; Object o = elementAt(i); if (! (o instanceof String)) return; String s = (String) o; j = 0; l = s.length(); while (j < l && Character.isSpaceChar(s.charAt(j))) j++; if (j < l) { if (s.charAt(j) == '\r') j++; else if (s.charAt(j) == '\n') { j++; if (j < l && s.charAt(j) == '\r') j++; } } if (j >= l) remove(i); else if (j > 0) setElementAt(s.substring(j), i); markLiteral(); }
final public void eatOneWs() { int i, j; i = size() - 1; if ( i < 0 || i+1 == literalMark ) return; Object o = elementAt(i); if (! (o instanceof String)) return; String s = (String) o; j = eatOneWs(s, s.length() - 1); if (j < 0) remove(i); else if (j < s.length() - 1) setElementAt(s.substring(0, j+1), i); markLiteral();
private final static int eatOneWs(String s, int pos) { if (pos >= 0 && isSpaceChar(s.charAt(pos))) pos--; return pos;
final public void eatOneWs() { int i, j; i = size() - 1; if ( i < 0 || i+1 == literalMark ) return; Object o = elementAt(i); if (! (o instanceof String)) return; String s = (String) o; j = eatOneWs(s, s.length() - 1); if (j < 0) remove(i); else if (j < s.length() - 1) setElementAt(s.substring(0, j+1), i); markLiteral(); }
while (pos >= 0 && Character.isSpaceChar(s.charAt(pos)))
while (pos >= 0 && isSpaceChar(s.charAt(pos)))
private final static int eatWs(String s, int pos) { while (pos >= 0 && Character.isSpaceChar(s.charAt(pos))) pos--; return pos; }
_searchPublishedFrom = new Date(); _searchText = "searchtext";
public SearchArticleBean() { _searchPublishedFrom = new Date(); _searchText = "searchtext"; }
return 4;
return 6;
public int getNumberOfColumns() { return 4; }
String localeString = ""; SearchExpression namePatternExpression = s.compare(CompareOperator.LIKE, IWSlideConstants.PROPERTY_DISPLAY_NAME,"%"+localeString+".article");
SearchExpression namePatternExpression = s.compare(CompareOperator.LIKE, IWSlideConstants.PROPERTY_DISPLAY_NAME,"%.article"); whereExpression = namePatternExpression;
public SearchRequest getSearchRequest(String scope, Locale locale) throws SearchException { SearchRequest s = new SearchRequest(); s.addSelection(IWSlideConstants.PROPERTY_CREATION_DATE); s.addSelection(IWSlideConstants.PROPERTY_CATEGORY); s.addScope(new SearchScope(scope)); SearchExpression whereExpression = null; String localeString = ""; //((locale!=null)?locale.getLanguage():""); SearchExpression namePatternExpression = s.compare(CompareOperator.LIKE, IWSlideConstants.PROPERTY_DISPLAY_NAME,"%"+localeString+".article"); SearchExpression creationDateFromExpression = null; if(getSearchPublishedFrom() != null){ creationDateFromExpression = s.compare(CompareOperator.GTE, IWSlideConstants.PROPERTY_CREATION_DATE,getSearchPublishedFrom()); whereExpression = s.and(namePatternExpression,creationDateFromExpression); } SearchExpression creationDateToExpression = null; if(getSearchPublishedTo() != null){ creationDateToExpression = s.compare(CompareOperator.LTE, IWSlideConstants.PROPERTY_CREATION_DATE,getSearchPublishedTo()); whereExpression = s.and(whereExpression,creationDateToExpression); } // List categoryExpressions = new ArrayList(); if(!getSearchCategoryId().equals("-1")){ SearchExpression categoryExpression = s.compare(CompareOperator.LIKE,IWSlideConstants.PROPERTY_CATEGORY,"%"+getSearchCategoryId()+"%"); whereExpression = s.and(whereExpression,categoryExpression); } if(getSearchAuthor()!=null){ SearchExpression authorExpression = s.compare(CompareOperator.LIKE,IWSlideConstants.PROPERTY_CREATOR_DISPLAY_NAME,"%"+getSearchAuthor()+"%"); whereExpression = s.and(whereExpression,authorExpression); } // }// whereExpression = s.and(whereExpression,categoryExpression);// for (Iterator iter = categoryList.iterator(); iter.hasNext();) {// String categoryName = (String) iter.next();// categoryExpressions.add(s.compare(CompareOperator.LIKE,IWSlideConstants.PROPERTY_CATEGORY,"%"+categoryName+"%"));// }// Iterator expr = categoryExpressions.iterator();// if(expr.hasNext()){// SearchExpression categoryExpression = (SearchExpression)expr.next();// while(expr.hasNext()){// categoryExpression = s.or(categoryExpression,(SearchExpression)expr.next());// }// whereExpression = s.and(whereExpression,categoryExpression);// }// } SearchExpression containsExpression = null; if(getSearchText() != null && !"".equals(getSearchText())){ containsExpression = s.contains(getSearchText()); if(whereExpression!=null){ whereExpression = s.and(whereExpression,containsExpression); }else{ whereExpression = containsExpression; } } s.setWhereExpression(whereExpression); System.out.println("------------------------"); System.out.println(s.asString()); System.out.println("------------------------"); return s; }
creationDateFromExpression = s.compare(CompareOperator.GTE, IWSlideConstants.PROPERTY_CREATION_DATE,getSearchPublishedFrom()); whereExpression = s.and(namePatternExpression,creationDateFromExpression);
Date from = getSearchPublishedFrom(); IWTimestamp stamp = new IWTimestamp(from); stamp.addDays(-1); from = stamp.getDate(); creationDateFromExpression = s.compare(CompareOperator.GTE, IWSlideConstants.PROPERTY_CREATION_DATE,from); whereExpression = s.and(whereExpression,creationDateFromExpression);
public SearchRequest getSearchRequest(String scope, Locale locale) throws SearchException { SearchRequest s = new SearchRequest(); s.addSelection(IWSlideConstants.PROPERTY_CREATION_DATE); s.addSelection(IWSlideConstants.PROPERTY_CATEGORY); s.addScope(new SearchScope(scope)); SearchExpression whereExpression = null; String localeString = ""; //((locale!=null)?locale.getLanguage():""); SearchExpression namePatternExpression = s.compare(CompareOperator.LIKE, IWSlideConstants.PROPERTY_DISPLAY_NAME,"%"+localeString+".article"); SearchExpression creationDateFromExpression = null; if(getSearchPublishedFrom() != null){ creationDateFromExpression = s.compare(CompareOperator.GTE, IWSlideConstants.PROPERTY_CREATION_DATE,getSearchPublishedFrom()); whereExpression = s.and(namePatternExpression,creationDateFromExpression); } SearchExpression creationDateToExpression = null; if(getSearchPublishedTo() != null){ creationDateToExpression = s.compare(CompareOperator.LTE, IWSlideConstants.PROPERTY_CREATION_DATE,getSearchPublishedTo()); whereExpression = s.and(whereExpression,creationDateToExpression); } // List categoryExpressions = new ArrayList(); if(!getSearchCategoryId().equals("-1")){ SearchExpression categoryExpression = s.compare(CompareOperator.LIKE,IWSlideConstants.PROPERTY_CATEGORY,"%"+getSearchCategoryId()+"%"); whereExpression = s.and(whereExpression,categoryExpression); } if(getSearchAuthor()!=null){ SearchExpression authorExpression = s.compare(CompareOperator.LIKE,IWSlideConstants.PROPERTY_CREATOR_DISPLAY_NAME,"%"+getSearchAuthor()+"%"); whereExpression = s.and(whereExpression,authorExpression); } // }// whereExpression = s.and(whereExpression,categoryExpression);// for (Iterator iter = categoryList.iterator(); iter.hasNext();) {// String categoryName = (String) iter.next();// categoryExpressions.add(s.compare(CompareOperator.LIKE,IWSlideConstants.PROPERTY_CATEGORY,"%"+categoryName+"%"));// }// Iterator expr = categoryExpressions.iterator();// if(expr.hasNext()){// SearchExpression categoryExpression = (SearchExpression)expr.next();// while(expr.hasNext()){// categoryExpression = s.or(categoryExpression,(SearchExpression)expr.next());// }// whereExpression = s.and(whereExpression,categoryExpression);// }// } SearchExpression containsExpression = null; if(getSearchText() != null && !"".equals(getSearchText())){ containsExpression = s.contains(getSearchText()); if(whereExpression!=null){ whereExpression = s.and(whereExpression,containsExpression); }else{ whereExpression = containsExpression; } } s.setWhereExpression(whereExpression); System.out.println("------------------------"); System.out.println(s.asString()); System.out.println("------------------------"); return s; }
if(getSearchAuthor()!=null){ SearchExpression authorExpression = s.compare(CompareOperator.LIKE,IWSlideConstants.PROPERTY_CREATOR_DISPLAY_NAME,"%"+getSearchAuthor()+"%");
String author = getSearchAuthor(); if(author!=null && !"".equals(author)){ SearchExpression authorExpression = s.compare(CompareOperator.LIKE,IWSlideConstants.PROPERTY_CREATOR_DISPLAY_NAME,"%"+author+"%");
public SearchRequest getSearchRequest(String scope, Locale locale) throws SearchException { SearchRequest s = new SearchRequest(); s.addSelection(IWSlideConstants.PROPERTY_CREATION_DATE); s.addSelection(IWSlideConstants.PROPERTY_CATEGORY); s.addScope(new SearchScope(scope)); SearchExpression whereExpression = null; String localeString = ""; //((locale!=null)?locale.getLanguage():""); SearchExpression namePatternExpression = s.compare(CompareOperator.LIKE, IWSlideConstants.PROPERTY_DISPLAY_NAME,"%"+localeString+".article"); SearchExpression creationDateFromExpression = null; if(getSearchPublishedFrom() != null){ creationDateFromExpression = s.compare(CompareOperator.GTE, IWSlideConstants.PROPERTY_CREATION_DATE,getSearchPublishedFrom()); whereExpression = s.and(namePatternExpression,creationDateFromExpression); } SearchExpression creationDateToExpression = null; if(getSearchPublishedTo() != null){ creationDateToExpression = s.compare(CompareOperator.LTE, IWSlideConstants.PROPERTY_CREATION_DATE,getSearchPublishedTo()); whereExpression = s.and(whereExpression,creationDateToExpression); } // List categoryExpressions = new ArrayList(); if(!getSearchCategoryId().equals("-1")){ SearchExpression categoryExpression = s.compare(CompareOperator.LIKE,IWSlideConstants.PROPERTY_CATEGORY,"%"+getSearchCategoryId()+"%"); whereExpression = s.and(whereExpression,categoryExpression); } if(getSearchAuthor()!=null){ SearchExpression authorExpression = s.compare(CompareOperator.LIKE,IWSlideConstants.PROPERTY_CREATOR_DISPLAY_NAME,"%"+getSearchAuthor()+"%"); whereExpression = s.and(whereExpression,authorExpression); } // }// whereExpression = s.and(whereExpression,categoryExpression);// for (Iterator iter = categoryList.iterator(); iter.hasNext();) {// String categoryName = (String) iter.next();// categoryExpressions.add(s.compare(CompareOperator.LIKE,IWSlideConstants.PROPERTY_CATEGORY,"%"+categoryName+"%"));// }// Iterator expr = categoryExpressions.iterator();// if(expr.hasNext()){// SearchExpression categoryExpression = (SearchExpression)expr.next();// while(expr.hasNext()){// categoryExpression = s.or(categoryExpression,(SearchExpression)expr.next());// }// whereExpression = s.and(whereExpression,categoryExpression);// }// } SearchExpression containsExpression = null; if(getSearchText() != null && !"".equals(getSearchText())){ containsExpression = s.contains(getSearchText()); if(whereExpression!=null){ whereExpression = s.and(whereExpression,containsExpression); }else{ whereExpression = containsExpression; } } s.setWhereExpression(whereExpression); System.out.println("------------------------"); System.out.println(s.asString()); System.out.println("------------------------"); return s; }
showResults = true;
public void search() { searching = true; updateDataModel(new Integer(0),new Integer(0)); searching = false; }
String id = articleItemBean[i].getFolderLocation()+"/"+articleItemBean[i].getHeadline()+".xml";
String id = articleItemBean[i].getFolderLocation()+"/"+articleItemBean[i].getHeadline()+ArticleItemBean.ARTICLE_SUFFIX;
public void updateDataModel(Integer start, Integer rows) { if (_dataModel == null) { _dataModel = new WFDataModel(); } ArticleItemBean[] articleItemBean; try { articleItemBean = (ArticleItemBean[]) ArticleListBean.loadAllArticlesInFolder(ContentUtil.ARTICLE_PATH).toArray(new ArticleItemBean[0]); int availableRows = articleItemBean.length; int nrOfRows = rows.intValue(); if (nrOfRows == 0) { nrOfRows = availableRows; } int maxRow = Math.min(start.intValue() + nrOfRows,availableRows); for (int i = start.intValue(); i < maxRow; i++) { String id = articleItemBean[i].getFolderLocation()+"/"+articleItemBean[i].getHeadline()+".xml"; ArticleListBean bean = new ArticleListBean(id, articleItemBean[i].getHeadline(), "", articleItemBean[i].getAuthor(), articleItemBean[i].getStatus()); _dataModel.set(bean, i); } _dataModel.setRowCount(availableRows); } catch (XmlException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public ArticleListBean(String id, String headline, String published, String author, String status) { _id = id; _headline = headline; _published = published; _author = author; _status = status; _testStyle = ""; }
public ArticleListBean() {}
public ArticleListBean(String id, String headline, String published, String author, String status) { _id = id; _headline = headline; _published = published; _author = author; _status = status; _testStyle = ""; }
WebdavRootResource rootResource = session.getWebdavRootResource();
WebdavResource folderResource = session.getWebdavResource(folder);
public static List loadAllArticlesInFolder(String folder) throws XmlException, IOException{ List list = new ArrayList(); // File[] articleFile = folder.listFiles(); IWUserContext iwuc = IWContext.getInstance(); IWApplicationContext iwac = iwuc.getApplicationContext(); IWSlideSession session = (IWSlideSession)IBOLookup.getSessionInstance(iwuc,IWSlideSession.class); IWSlideService service = (IWSlideService)IBOLookup.getServiceInstance(iwac,IWSlideService.class); WebdavRootResource rootResource = session.getWebdavRootResource(); String[] file = rootResource.list(); for(int i=0;i<file.length;i++){// System.out.println("Attempting to load "+articleFile[i].toString()); System.out.println("Attempting to load "+file[i].toString()); ArticleItemBean article = new ArticleItemBean();// article.load(articleFile[i].toString()); article.load(folder+"/"+file[i]); list.add(article); } return list; }
String[] file = rootResource.list();
String[] file = folderResource.list();
public static List loadAllArticlesInFolder(String folder) throws XmlException, IOException{ List list = new ArrayList(); // File[] articleFile = folder.listFiles(); IWUserContext iwuc = IWContext.getInstance(); IWApplicationContext iwac = iwuc.getApplicationContext(); IWSlideSession session = (IWSlideSession)IBOLookup.getSessionInstance(iwuc,IWSlideSession.class); IWSlideService service = (IWSlideService)IBOLookup.getServiceInstance(iwac,IWSlideService.class); WebdavRootResource rootResource = session.getWebdavRootResource(); String[] file = rootResource.list(); for(int i=0;i<file.length;i++){// System.out.println("Attempting to load "+articleFile[i].toString()); System.out.println("Attempting to load "+file[i].toString()); ArticleItemBean article = new ArticleItemBean();// article.load(articleFile[i].toString()); article.load(folder+"/"+file[i]); list.add(article); } return list; }
System.out.println("Attempting to load "+file[i].toString()); ArticleItemBean article = new ArticleItemBean(); article.load(folder+"/"+file[i]); list.add(article);
try { System.out.println("Attempting to load "+file[i].toString()); ArticleItemBean article = new ArticleItemBean(); article.load(folder+"/"+file[i]); list.add(article); }catch(Exception e) { e.printStackTrace(); }
public static List loadAllArticlesInFolder(String folder) throws XmlException, IOException{ List list = new ArrayList(); // File[] articleFile = folder.listFiles(); IWUserContext iwuc = IWContext.getInstance(); IWApplicationContext iwac = iwuc.getApplicationContext(); IWSlideSession session = (IWSlideSession)IBOLookup.getSessionInstance(iwuc,IWSlideSession.class); IWSlideService service = (IWSlideService)IBOLookup.getServiceInstance(iwac,IWSlideService.class); WebdavRootResource rootResource = session.getWebdavRootResource(); String[] file = rootResource.list(); for(int i=0;i<file.length;i++){// System.out.println("Attempting to load "+articleFile[i].toString()); System.out.println("Attempting to load "+file[i].toString()); ArticleItemBean article = new ArticleItemBean();// article.load(articleFile[i].toString()); article.load(folder+"/"+file[i]); list.add(article); } return list; }
HttpURL root = new HttpURL(service.getWebdavServerURL()+path, "root", "root");
HttpURL contentRoot = service.getWebdavServerURL(path); contentRoot.setUserinfo("root","root");
public void load(String path) throws XmlException, IOException{ IWUserContext iwuc = IWContext.getInstance(); IWApplicationContext iwac = iwuc.getApplicationContext(); IWSlideSession session = (IWSlideSession)IBOLookup.getSessionInstance(iwuc,IWSlideSession.class); IWSlideService service = (IWSlideService)IBOLookup.getServiceInstance(iwac,IWSlideService.class); //TODO have to find the host machine url to load the resource.// WebdavResource webdavResource = session.getWebdavResource(getWebdavServletURL(iwuc)+path);// WebdavFile webdavFile = session.getWebdavFile(); HttpURL root = new HttpURL(service.getWebdavServerURL()+path, "root", "root");// root.setUserinfo("root","root"); WebdavResource webdavResource = new WebdavResource(root); ArticleDocument articleDoc; articleDoc = ArticleDocument.Factory.parse(webdavResource.getMethodDataAsString()); ArticleDocument.Article article = articleDoc.getArticle();// ArticleItemBean articleBean = new ArticleItemBean(); setHeadline(article.getHeadline()); setBody(article.getBody()); setTeaser(article.getTeaser()); setAuthor(article.getAuthor()); setSource(article.getSource()); setComment(article.getComment()); String category = ""; int lastSlash = path.lastIndexOf('/'); if(lastSlash>0) { category = path.substring(0,lastSlash); } setMainCategory(category); // System.out.println("loaded "+getBody()); }
WebdavResource webdavResource = new WebdavResource(root);
WebdavResource webdavResource = new WebdavResource(contentRoot);
public void load(String path) throws XmlException, IOException{ IWUserContext iwuc = IWContext.getInstance(); IWApplicationContext iwac = iwuc.getApplicationContext(); IWSlideSession session = (IWSlideSession)IBOLookup.getSessionInstance(iwuc,IWSlideSession.class); IWSlideService service = (IWSlideService)IBOLookup.getServiceInstance(iwac,IWSlideService.class); //TODO have to find the host machine url to load the resource.// WebdavResource webdavResource = session.getWebdavResource(getWebdavServletURL(iwuc)+path);// WebdavFile webdavFile = session.getWebdavFile(); HttpURL root = new HttpURL(service.getWebdavServerURL()+path, "root", "root");// root.setUserinfo("root","root"); WebdavResource webdavResource = new WebdavResource(root); ArticleDocument articleDoc; articleDoc = ArticleDocument.Factory.parse(webdavResource.getMethodDataAsString()); ArticleDocument.Article article = articleDoc.getArticle();// ArticleItemBean articleBean = new ArticleItemBean(); setHeadline(article.getHeadline()); setBody(article.getBody()); setTeaser(article.getTeaser()); setAuthor(article.getAuthor()); setSource(article.getSource()); setComment(article.getComment()); String category = ""; int lastSlash = path.lastIndexOf('/'); if(lastSlash>0) { category = path.substring(0,lastSlash); } setMainCategory(category); // System.out.println("loaded "+getBody()); }
out.println("<div class=\"footer\">"); out .println("Reports generated by <a href=\"http: out.println("</div>");
private void generateOverview(Package pkg) throws IOException { String filename; if (pkg == null) { filename = "frame-summary.html"; } else { filename = "frame-summary-" + pkg.getName() + ".html"; } File file = new File(outputDir, filename); PrintStream out = null; try { out = new PrintStream(new FileOutputStream(file)); out.println("<html>"); out.println("<head>"); out.println("<title>Coverage Report</title>"); out .println("<link title=\"Style\" type=\"text/css\" rel=\"stylesheet\" href=\"css/main.css\" />"); out .println("<link title=\"Style\" type=\"text/css\" rel=\"stylesheet\" href=\"css/sortabletable.css\" />"); out .println("<script type=\"text/javascript\" src=\"js/popup.js\"></script>"); out .println("<script type=\"text/javascript\" src=\"js/sortabletable.js\"></script>"); out .println("<script type=\"text/javascript\" src=\"js/percentagesorttype.js\"></script>"); out.println("</head>"); out.println("<body>"); out.print("<h5>Coverage Report - "); out.print(pkg == null ? "All Packages" : pkg.getName()); out.println("</h5>"); out.println("<p>"); out.println("<table class=\"report\" id=\"packageResults\">"); out.println("<thead>"); out.println("<tr>"); out.println(" <td class=\"heading\">Package</td>"); out.println(" <td class=\"heading\"># Classes</td>"); out.println(generateCommonTableColumns()); out.println("</tr>"); out.println("</thead>"); out.println("<tbody>"); Set packages; if (pkg == null) { // Output a summary line for all packages out.println(generateTableRowForTotal()); // Get packages packages = coverage.getPackages(); } else { // Output a line for the current package out.println(generateTableRowForPackage(pkg)); // Get subpackages packages = coverage.getSubPackages(pkg); } // Output a line for each package or subpackage if (packages.size() > 0) { Iterator iter = packages.iterator(); while (iter.hasNext()) { Package subpkg = (Package)iter.next(); out.println(generateTableRowForPackage(subpkg)); } } out.println("</tbody>"); out.println("</table>"); out.println("<script type=\"text/javascript\">"); out .println("var packageTable = new SortableTable(document.getElementById(\"packageResults\"),"); out .println(" [\"String\", \"Number\", \"Percentage\", \"Percentage\", \"Number\", \"Number\", \"Number\"]);"); out.println("packageTable.sort(0);"); out.println("</script>"); out.println("</p>"); // Get the list of classes in this package Set classes; if (pkg == null) { classes = new TreeSet(); if (coverage.getClasses().size() > 0) { Iterator iter = coverage.getClasses().iterator(); while (iter.hasNext()) { Clazz clazz = (Clazz)iter.next(); if (clazz.getPackageName() == null) { classes.add(clazz); } } } } else { classes = pkg.getClasses(); } // Output a line for each class if (classes.size() > 0) { out.println("<p>"); out.println("<table class=\"report\" id=\"classResults\">"); out.println(generateTableHeaderForClasses()); out.println("<tbody>"); Iterator iter = classes.iterator(); while (iter.hasNext()) { Clazz clazz = (Clazz)iter.next(); out.println(generateTableRowForClass(clazz)); } out.println("</tbody>"); out.println("</table>"); out.println("<script type=\"text/javascript\">"); out .println("var classTable = new SortableTable(document.getElementById(\"classResults\"),"); out .println(" [\"String\", \"Percentage\", \"Percentage\", \"Number\", \"Number\", \"Number\"]);"); out.println("classTable.sort(0);"); out.println("</script>"); out.println("</p>"); } out.println("</body>"); out.println("</html>"); } finally { if (out != null) { out.close(); } } }
out.println("<div class=\"footer\">"); out .println("Reports generated by <a href=\"http: out.println("</div>");
private void generateSourceFile(Clazz clazz) throws IOException { String filename = clazz.getLongName() + ".html"; File file = new File(outputDir, filename); PrintStream out = null; try { out = new PrintStream(new FileOutputStream(file)); out.println("<html>"); out.println("<head>"); out.println("<title>Coverage Report</title>"); out .println("<link title=\"Style\" type=\"text/css\" rel=\"stylesheet\" href=\"css/main.css\" />"); out .println("<script type=\"text/javascript\" src=\"js/popup.js\"></script>"); out.println("</head>"); out.println("<body>"); out.print("<h5>Coverage Report - "); if (clazz.getPackageName() != null) { out.print(clazz.getPackageName() + "."); } out.print(clazz.getName()); out.println("</h5>"); // Output the coverage summary for this class out.println("<p>"); out.println("<table class=\"report\">"); out.println(generateTableHeaderForClasses()); out.println(generateTableRowForClass(clazz)); out.println("</table>"); out.println("</p>"); // Output this class's source code with syntax and coverage highlighting out.println("<p>"); out .println("<table cellspacing=\"0\" cellpadding=\"0\" class=\"src\">"); BufferedReader br = null; try { br = new BufferedReader(new FileReader(new File(sourceDir, clazz.getLongFileName()))); String lineStr; JavaToHtml javaToHtml = new JavaToHtml(); int lineNumber = 1; while ((lineStr = br.readLine()) != null) { out.println("<tr>"); if (clazz.isValidSourceLine(lineNumber)) { long numberOfHits = clazz.getNumberOfHits(lineNumber); out.println(" <td class=\"numLineCover\">&nbsp;" + lineNumber + "</td>"); if (numberOfHits > 0) { out .println(" <td class=\"nbHitsCovered\">&nbsp;" + numberOfHits + "</td>"); out .println(" <td class=\"src\"><pre class=\"src\">&nbsp;" + javaToHtml.process(lineStr) + "</pre></td>"); } else { out .println(" <td class=\"nbHitsUncovered\">&nbsp;" + numberOfHits + "</td>"); out .println(" <td class=\"src\"><pre class=\"src\"><span class=\"srcUncovered\">&nbsp;" + javaToHtml.process(lineStr) + "</span></pre></td>"); } } else { out.println(" <td class=\"numLine\">&nbsp;" + lineNumber + "</td>"); out.println(" <td class=\"nbHits\">&nbsp;</td>"); out .println(" <td class=\"src\"><pre class=\"src\">&nbsp;" + javaToHtml.process(lineStr) + "</pre></td>"); } out.println("</tr>"); lineNumber++; } } finally { if (br != null) { br.close(); } } out.println("</table>"); out.println("</p>"); out.println("</body>"); out.println("</html>"); } finally { if (out != null) { out.close(); } } }
ret.append(generateTableColumnsFromData(lineCoverage, branchCoverage, ccn));
if (clazz.getNumberOfLines() == 0) { ret.append(generateTableColumnsForNA(ccn)); } else { ret.append(generateTableColumnsFromData(lineCoverage, branchCoverage, ccn)); }
private String generateTableRowForClass(Clazz clazz) { StringBuffer ret = new StringBuffer(); double lineCoverage = clazz.getLineCoverageRate(); double branchCoverage = clazz.getBranchCoverageRate(); double ccn = Util.getCCN( new File(sourceDir, clazz.getLongFileName()), false); ret.append(" <tr>"); ret.append("<td class=\"text\"><a href=\"" + clazz.getLongName() + ".html\">" + clazz.getName() + "</a></td>"); ret.append(generateTableColumnsFromData(lineCoverage, branchCoverage, ccn)); ret.append("</tr>"); return ret.toString(); }
WFErrorMessages em = new WFErrorMessages(); em.addErrorMessage(SEARCH_PUBLISHED_FROM_ID); em.addErrorMessage(SEARCH_PUBLISHED_TO_ID);
WFMessages em = new WFMessages(); em.addMessageToDisplay(SEARCH_PUBLISHED_FROM_ID); em.addMessageToDisplay(SEARCH_PUBLISHED_TO_ID);
private UIComponent getSearchPanel() { String ref = LIST_ARTICLES_BEAN_ID + "."; String bref = WFPage.CONTENT_BUNDLE + "."; WFContainer mainContainer = new WFContainer(); WFErrorMessages em = new WFErrorMessages(); em.addErrorMessage(SEARCH_PUBLISHED_FROM_ID); em.addErrorMessage(SEARCH_PUBLISHED_TO_ID); mainContainer.add(em); HtmlPanelGrid p = WFPanelUtil.getFormPanel(3); p.getChildren().add(WFUtil.group(WFUtil.getTextVB(bref + "published_from"), WFUtil.getText(":"))); p.getChildren().add(WFUtil.group(WFUtil.getTextVB(bref + "published_to"), WFUtil.getText(":"))); p.getChildren().add(WFUtil.group(WFUtil.getTextVB(bref + "category"), WFUtil.getText(":"))); HtmlInputText searchPublishedFromInput = WFUtil.getInputText(SEARCH_PUBLISHED_FROM_ID, ref + "searchPublishedFrom"); searchPublishedFromInput.setSize(20); searchPublishedFromInput.setConverter(new WFDateConverter()); p.getChildren().add(searchPublishedFromInput); HtmlInputText searchPublishedToInput = WFUtil.getInputText(SEARCH_PUBLISHED_TO_ID, ref + "searchPublishedTo"); searchPublishedToInput.setSize(20); searchPublishedToInput.setConverter(new WFDateConverter()); p.getChildren().add(searchPublishedToInput); //HtmlSelectOneMenu searchCategoryMenu = WFUtil.getSelectOneMenu(SEARCH_CATEGORY_ID, ref + "categories", ref + "searchCategoryId"); //searchCategoryMenu.setConverter(new IntegerConverter()); //p.getChildren().add(searchCategoryMenu); mainContainer.add(p); mainContainer.add(WFUtil.getText(" ")); p = WFPanelUtil.getPlainFormPanel(1); p.getChildren().add(WFUtil.getButtonVB(LIST_BUTTON_ID, bref + "list", this)); mainContainer.add(p); return mainContainer; }
System.out.println("Stored language "+getLanguage());
public void store() throws IDOStoreException{ boolean storeOk = true; clearErrorKeys(); if (getHeadline().trim().equals("")) { addErrorKey(KEY_ERROR_HEADLINE_EMPTY); storeOk = false; } if (getBody().trim().equals("")) { addErrorKey(KEY_ERROR_BODY_EMPTY); storeOk = false; } // if (getRequestedStatus() != null && getRequestedStatus().equals(ContentItemCase.STATUS_PUBLISHED)) {// if (getCase().getPublishedFromDate() == null) {// addErrorKey(KEY_ERROR_PUBLISHED_FROM_DATE_EMPTY);// storeOk = false;// }// } //Need to create article.setCategory(getCategory()); // String filename = getHeadline();// if(null==filename || filename.length()==0) {// filename = "empty";// }/* File path = new File(getFolder()); if(!path.exists()) { path.mkdirs(); }*/ try { IWUserContext iwuc = IWContext.getInstance(); IWApplicationContext iwac = iwuc.getApplicationContext(); IWSlideSession session = (IWSlideSession)IBOLookup.getSessionInstance(iwuc,IWSlideSession.class); IWSlideService service = (IWSlideService)IBOLookup.getServiceInstance(iwac,IWSlideService.class); WebdavRootResource rootResource = session.getWebdavRootResource(); String uri = service.getWebdavServerURI(); String folderLoaction = getFolderLocation();// String filePath = service.getWebdavServerURI()+getFolderLocation();// boolean success = rootResource.mkcolMethod(filePath);// createPath(getFolderLocation()); IWSlideService slideService = (IWSlideService)IBOLookup.getServiceInstance(iwac,IWSlideService.class); String path = getArticlePath(service); File file = new File(path); slideService.createAllFoldersInPath(file.getParent()); System.out.println("URI = "+uri); System.out.println("Folder location = "+folderLoaction); String article = getAsXML();// System.out.println("success "+success);// success = // String filename = createFileName(service); System.out.println("Stored language "+getLanguage()); rootResource.putMethod(session.getURI(path),article); try { load(getArticlePath(service)); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); }// System.out.println("success "+success);// String webdavServletURL = getWebdavServletURL(iwuc)+"/"+getFolder();// System.out.println("webdavServletURL = "+webdavServletURL);// System.out.println("webdavServerURL = "+service.getWebdavServerURL());// WebdavResource webdavResource = session.getWebdavResource(session.getWebdavServerURL().toString());// WebdavResource webdavResource = session.getWebdavResource("http://localhost:8080/servlet/webdav");// WebdavResource webdavResource = new WebdavResource("http://localhost:8080/servlet/webdav/"); // WebdavFile webdavFile = session.getWebdavFile();// WebdavFile path = new WebdavFile(webdavFile, getFolder());// path.mkdirs();// webdavResource = session.getWebdavResource(getWebdavServletURL(iwuc)+getFolder()+"/"+filename+ARTICLE_SUFFIX);// WebdavResource webdavResource = session.getWebdavResource("http://localhost:8080/servlet/webdav/"+filename+ARTICLE_SUFFIX);// IWSlideService iwss = new IWSlideService();// HttpURL root = new HttpURL("http://localhost:8080/servlet/webdav/files/");// WebdavResource webdavResource = new WebdavResource("http://localhost:8080/servlet/webdav/files/"+filename+ARTICLE_SUFFIX);// WebdavFile webdavFile = session.getWebdavFile();// webdavResource.putMethod(new File(filename+ARTICLE_SUFFIX)); /* HttpURL root = new HttpURL("http://localhost:8080/servlet/webdav/files/"+filename+ARTICLE_SUFFIX); root.setUserinfo("root","root"); WebdavFile webdavFile = new WebdavFile(webdavResource.getHttpURL()); webdavResource.close(); */// HttpURL root = new HttpURL("http://localhost:8080/servlet/webdav/files/"+filename+ARTICLE_SUFFIX, "root", "root");// root.setUserinfo("root","root"); // WebdavFile webdavFile = new WebdavFile("http://localhost:8080/servlet/webdav/files/"+filename+ARTICLE_SUFFIX, "root", "root");// webdavFile.createNewFile();// if(!webdavFile.exists()) {// } // articleDoc.save(new File(getFolder()+"/"+filename+ARTICLE_SUFFIX));// articleDoc.save(webdavFile);// webdavFile.close(); } catch (IOException e1) { storeOk = false; // TODO Auto-generated catch block e1.printStackTrace(); } if (storeOk) { if (getRequestedStatus() != null) { setStatus(getRequestedStatus()); setRequestedStatus(null); } }else { throw new ArticleStoreException(); } }
load(getArticlePath(service));
load(path);
public void store() throws IDOStoreException{ boolean storeOk = true; clearErrorKeys(); if (getHeadline().trim().equals("")) { addErrorKey(KEY_ERROR_HEADLINE_EMPTY); storeOk = false; } if (getBody().trim().equals("")) { addErrorKey(KEY_ERROR_BODY_EMPTY); storeOk = false; } // if (getRequestedStatus() != null && getRequestedStatus().equals(ContentItemCase.STATUS_PUBLISHED)) {// if (getCase().getPublishedFromDate() == null) {// addErrorKey(KEY_ERROR_PUBLISHED_FROM_DATE_EMPTY);// storeOk = false;// }// } //Need to create article.setCategory(getCategory()); // String filename = getHeadline();// if(null==filename || filename.length()==0) {// filename = "empty";// }/* File path = new File(getFolder()); if(!path.exists()) { path.mkdirs(); }*/ try { IWUserContext iwuc = IWContext.getInstance(); IWApplicationContext iwac = iwuc.getApplicationContext(); IWSlideSession session = (IWSlideSession)IBOLookup.getSessionInstance(iwuc,IWSlideSession.class); IWSlideService service = (IWSlideService)IBOLookup.getServiceInstance(iwac,IWSlideService.class); WebdavRootResource rootResource = session.getWebdavRootResource(); String uri = service.getWebdavServerURI(); String folderLoaction = getFolderLocation();// String filePath = service.getWebdavServerURI()+getFolderLocation();// boolean success = rootResource.mkcolMethod(filePath);// createPath(getFolderLocation()); IWSlideService slideService = (IWSlideService)IBOLookup.getServiceInstance(iwac,IWSlideService.class); String path = getArticlePath(service); File file = new File(path); slideService.createAllFoldersInPath(file.getParent()); System.out.println("URI = "+uri); System.out.println("Folder location = "+folderLoaction); String article = getAsXML();// System.out.println("success "+success);// success = // String filename = createFileName(service); System.out.println("Stored language "+getLanguage()); rootResource.putMethod(session.getURI(path),article); try { load(getArticlePath(service)); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); }// System.out.println("success "+success);// String webdavServletURL = getWebdavServletURL(iwuc)+"/"+getFolder();// System.out.println("webdavServletURL = "+webdavServletURL);// System.out.println("webdavServerURL = "+service.getWebdavServerURL());// WebdavResource webdavResource = session.getWebdavResource(session.getWebdavServerURL().toString());// WebdavResource webdavResource = session.getWebdavResource("http://localhost:8080/servlet/webdav");// WebdavResource webdavResource = new WebdavResource("http://localhost:8080/servlet/webdav/"); // WebdavFile webdavFile = session.getWebdavFile();// WebdavFile path = new WebdavFile(webdavFile, getFolder());// path.mkdirs();// webdavResource = session.getWebdavResource(getWebdavServletURL(iwuc)+getFolder()+"/"+filename+ARTICLE_SUFFIX);// WebdavResource webdavResource = session.getWebdavResource("http://localhost:8080/servlet/webdav/"+filename+ARTICLE_SUFFIX);// IWSlideService iwss = new IWSlideService();// HttpURL root = new HttpURL("http://localhost:8080/servlet/webdav/files/");// WebdavResource webdavResource = new WebdavResource("http://localhost:8080/servlet/webdav/files/"+filename+ARTICLE_SUFFIX);// WebdavFile webdavFile = session.getWebdavFile();// webdavResource.putMethod(new File(filename+ARTICLE_SUFFIX)); /* HttpURL root = new HttpURL("http://localhost:8080/servlet/webdav/files/"+filename+ARTICLE_SUFFIX); root.setUserinfo("root","root"); WebdavFile webdavFile = new WebdavFile(webdavResource.getHttpURL()); webdavResource.close(); */// HttpURL root = new HttpURL("http://localhost:8080/servlet/webdav/files/"+filename+ARTICLE_SUFFIX, "root", "root");// root.setUserinfo("root","root"); // WebdavFile webdavFile = new WebdavFile("http://localhost:8080/servlet/webdav/files/"+filename+ARTICLE_SUFFIX, "root", "root");// webdavFile.createNewFile();// if(!webdavFile.exists()) {// } // articleDoc.save(new File(getFolder()+"/"+filename+ARTICLE_SUFFIX));// articleDoc.save(webdavFile);// webdavFile.close(); } catch (IOException e1) { storeOk = false; // TODO Auto-generated catch block e1.printStackTrace(); } if (storeOk) { if (getRequestedStatus() != null) { setStatus(getRequestedStatus()); setRequestedStatus(null); } }else { throw new ArticleStoreException(); } }
&& (!(line.charAt(currentIndex) == '"') || (line .charAt(currentIndex - 1) == '\\')));
&& (!(line.charAt(currentIndex) == '"') || ((line .charAt(currentIndex - 1) == '\\') && (line .charAt(currentIndex - 2) != '\\'))));
private String processLine(final String line) { if (line == null) throw new IllegalArgumentException("\"line\" can not be null."); if ((line.indexOf('\n') != -1) || (line.indexOf('\r') != -1)) throw new IllegalArgumentException( "\"line\" can not contain newline or carriage return characters."); StringBuffer ret = new StringBuffer(); int currentIndex = 0; while (currentIndex != line.length()) { if (state == State.DEFAULT) { if ((currentIndex + 2 < line.length()) && line.substring(currentIndex, currentIndex + 3) .equals("/**")) { state = State.COMMENT_JAVADOC; } else if ((currentIndex + 1 < line.length()) && line.substring(currentIndex, currentIndex + 2) .equals("/*")) { state = State.COMMENT_MULTI; } else if ((currentIndex + 1 < line.length()) && (line.substring(currentIndex, currentIndex + 2) .equals("//"))) { state = State.COMMENT_SINGLE; } else if (Character.isJavaIdentifierStart(line .charAt(currentIndex))) { state = State.KEYWORD; } else if (line.charAt(currentIndex) == '\'') { state = State.QUOTE_SINGLE; } else if (line.charAt(currentIndex) == '"') { state = State.QUOTE_DOUBLE; } else { // Default: No highlighting. ret.append(escapeEntity(line.charAt(currentIndex++))); } } // End of State.DEFAULT else if ((state == State.COMMENT_MULTI) || (state == State.COMMENT_JAVADOC)) { // Print everything from the current character until the // closing */ No exceptions. ret.append("<span class=\"comment\">"); while ((currentIndex != line.length()) && !((currentIndex + 1 < line.length()) && (line .substring(currentIndex, currentIndex + 2) .equals("*/")))) { ret.append(escapeEntity(line.charAt(currentIndex++))); } if (currentIndex == line.length()) { ret.append("</span>"); } else { ret.append("*/</span>"); state = State.DEFAULT; currentIndex += 2; } } // End of State.COMMENT_MULTI else if (state == State.COMMENT_SINGLE) { // Print everything from the current character until the // end of the line ret.append("<span class=\"comment\">"); while (currentIndex != line.length()) { ret.append(escapeEntity(line.charAt(currentIndex++))); } ret.append("</span>"); state = State.DEFAULT; } // End of State.COMMENT_SINGLE else if (state == State.KEYWORD) { StringBuffer tmp = new StringBuffer(); do { tmp.append(line.charAt(currentIndex++)); } while ((currentIndex != line.length()) && (Character.isJavaIdentifierPart(line .charAt(currentIndex)))); if (javaKeywords.contains(tmp.toString())) ret.append("<span class=\"keyword\">" + tmp + "</span>"); else if (javaPrimitiveLiterals.contains(tmp.toString())) ret.append("<span class=\"keyword\">" + tmp + "</span>"); else if (javaPrimitiveTypes.contains(tmp.toString())) ret.append("<span class=\"keyword\">" + tmp + "</span>"); else ret.append(tmp); if (tmp.toString().equals("import")) state = State.IMPORT_NAME; else if (tmp.toString().equals("package")) state = State.PACKAGE_NAME; else state = State.DEFAULT; } // End of State.KEYWORD else if (state == State.IMPORT_NAME) { ret.append(escapeEntity(line.charAt(currentIndex++))); state = State.DEFAULT; } // End of State.IMPORT_NAME else if (state == State.PACKAGE_NAME) { ret.append(escapeEntity(line.charAt(currentIndex++))); state = State.DEFAULT; } // End of State.PACKAGE_NAME else if (state == State.QUOTE_DOUBLE) { // Print everything from the current character until the // closing ", checking for \" ret.append("<span class=\"string\">"); do { ret.append(escapeEntity(line.charAt(currentIndex++))); } while ((currentIndex != line.length()) && (!(line.charAt(currentIndex) == '"') || (line .charAt(currentIndex - 1) == '\\'))); if (currentIndex == line.length()) { ret.append("</span>"); } else { ret.append("\"</span>"); state = State.DEFAULT; currentIndex++; } } // End of State.QUOTE_DOUBLE else if (state == State.QUOTE_SINGLE) { // Print everything from the current character until the // closing ', checking for \' ret.append("<span class=\"string\">"); do { ret.append(escapeEntity(line.charAt(currentIndex++))); } while ((currentIndex != line.length()) && (!(line.charAt(currentIndex) == '\'') || (line .charAt(currentIndex - 1) == '\\'))); if (currentIndex == line.length()) { ret.append("</span>"); } else { ret.append("\"</span>"); state = State.DEFAULT; currentIndex++; } } // End of State.QUOTE_SINGLE else { // Default: No highlighting. ret.append(escapeEntity(line.charAt(currentIndex++))); } // End of unknown state } return ret.toString(); }
&& (!(line.charAt(currentIndex) == '\'') || (line .charAt(currentIndex - 1) == '\\')));
&& (!(line.charAt(currentIndex) == '\'') || ((line .charAt(currentIndex - 1) == '\\') && (line .charAt(currentIndex - 2) != '\\'))));
private String processLine(final String line) { if (line == null) throw new IllegalArgumentException("\"line\" can not be null."); if ((line.indexOf('\n') != -1) || (line.indexOf('\r') != -1)) throw new IllegalArgumentException( "\"line\" can not contain newline or carriage return characters."); StringBuffer ret = new StringBuffer(); int currentIndex = 0; while (currentIndex != line.length()) { if (state == State.DEFAULT) { if ((currentIndex + 2 < line.length()) && line.substring(currentIndex, currentIndex + 3) .equals("/**")) { state = State.COMMENT_JAVADOC; } else if ((currentIndex + 1 < line.length()) && line.substring(currentIndex, currentIndex + 2) .equals("/*")) { state = State.COMMENT_MULTI; } else if ((currentIndex + 1 < line.length()) && (line.substring(currentIndex, currentIndex + 2) .equals("//"))) { state = State.COMMENT_SINGLE; } else if (Character.isJavaIdentifierStart(line .charAt(currentIndex))) { state = State.KEYWORD; } else if (line.charAt(currentIndex) == '\'') { state = State.QUOTE_SINGLE; } else if (line.charAt(currentIndex) == '"') { state = State.QUOTE_DOUBLE; } else { // Default: No highlighting. ret.append(escapeEntity(line.charAt(currentIndex++))); } } // End of State.DEFAULT else if ((state == State.COMMENT_MULTI) || (state == State.COMMENT_JAVADOC)) { // Print everything from the current character until the // closing */ No exceptions. ret.append("<span class=\"comment\">"); while ((currentIndex != line.length()) && !((currentIndex + 1 < line.length()) && (line .substring(currentIndex, currentIndex + 2) .equals("*/")))) { ret.append(escapeEntity(line.charAt(currentIndex++))); } if (currentIndex == line.length()) { ret.append("</span>"); } else { ret.append("*/</span>"); state = State.DEFAULT; currentIndex += 2; } } // End of State.COMMENT_MULTI else if (state == State.COMMENT_SINGLE) { // Print everything from the current character until the // end of the line ret.append("<span class=\"comment\">"); while (currentIndex != line.length()) { ret.append(escapeEntity(line.charAt(currentIndex++))); } ret.append("</span>"); state = State.DEFAULT; } // End of State.COMMENT_SINGLE else if (state == State.KEYWORD) { StringBuffer tmp = new StringBuffer(); do { tmp.append(line.charAt(currentIndex++)); } while ((currentIndex != line.length()) && (Character.isJavaIdentifierPart(line .charAt(currentIndex)))); if (javaKeywords.contains(tmp.toString())) ret.append("<span class=\"keyword\">" + tmp + "</span>"); else if (javaPrimitiveLiterals.contains(tmp.toString())) ret.append("<span class=\"keyword\">" + tmp + "</span>"); else if (javaPrimitiveTypes.contains(tmp.toString())) ret.append("<span class=\"keyword\">" + tmp + "</span>"); else ret.append(tmp); if (tmp.toString().equals("import")) state = State.IMPORT_NAME; else if (tmp.toString().equals("package")) state = State.PACKAGE_NAME; else state = State.DEFAULT; } // End of State.KEYWORD else if (state == State.IMPORT_NAME) { ret.append(escapeEntity(line.charAt(currentIndex++))); state = State.DEFAULT; } // End of State.IMPORT_NAME else if (state == State.PACKAGE_NAME) { ret.append(escapeEntity(line.charAt(currentIndex++))); state = State.DEFAULT; } // End of State.PACKAGE_NAME else if (state == State.QUOTE_DOUBLE) { // Print everything from the current character until the // closing ", checking for \" ret.append("<span class=\"string\">"); do { ret.append(escapeEntity(line.charAt(currentIndex++))); } while ((currentIndex != line.length()) && (!(line.charAt(currentIndex) == '"') || (line .charAt(currentIndex - 1) == '\\'))); if (currentIndex == line.length()) { ret.append("</span>"); } else { ret.append("\"</span>"); state = State.DEFAULT; currentIndex++; } } // End of State.QUOTE_DOUBLE else if (state == State.QUOTE_SINGLE) { // Print everything from the current character until the // closing ', checking for \' ret.append("<span class=\"string\">"); do { ret.append(escapeEntity(line.charAt(currentIndex++))); } while ((currentIndex != line.length()) && (!(line.charAt(currentIndex) == '\'') || (line .charAt(currentIndex - 1) == '\\'))); if (currentIndex == line.length()) { ret.append("</span>"); } else { ret.append("\"</span>"); state = State.DEFAULT; currentIndex++; } } // End of State.QUOTE_SINGLE else { // Default: No highlighting. ret.append(escapeEntity(line.charAt(currentIndex++))); } // End of unknown state } return ret.toString(); }
ret.append("\"</span>");
ret.append("\'</span>");
private String processLine(final String line) { if (line == null) throw new IllegalArgumentException("\"line\" can not be null."); if ((line.indexOf('\n') != -1) || (line.indexOf('\r') != -1)) throw new IllegalArgumentException( "\"line\" can not contain newline or carriage return characters."); StringBuffer ret = new StringBuffer(); int currentIndex = 0; while (currentIndex != line.length()) { if (state == State.DEFAULT) { if ((currentIndex + 2 < line.length()) && line.substring(currentIndex, currentIndex + 3) .equals("/**")) { state = State.COMMENT_JAVADOC; } else if ((currentIndex + 1 < line.length()) && line.substring(currentIndex, currentIndex + 2) .equals("/*")) { state = State.COMMENT_MULTI; } else if ((currentIndex + 1 < line.length()) && (line.substring(currentIndex, currentIndex + 2) .equals("//"))) { state = State.COMMENT_SINGLE; } else if (Character.isJavaIdentifierStart(line .charAt(currentIndex))) { state = State.KEYWORD; } else if (line.charAt(currentIndex) == '\'') { state = State.QUOTE_SINGLE; } else if (line.charAt(currentIndex) == '"') { state = State.QUOTE_DOUBLE; } else { // Default: No highlighting. ret.append(escapeEntity(line.charAt(currentIndex++))); } } // End of State.DEFAULT else if ((state == State.COMMENT_MULTI) || (state == State.COMMENT_JAVADOC)) { // Print everything from the current character until the // closing */ No exceptions. ret.append("<span class=\"comment\">"); while ((currentIndex != line.length()) && !((currentIndex + 1 < line.length()) && (line .substring(currentIndex, currentIndex + 2) .equals("*/")))) { ret.append(escapeEntity(line.charAt(currentIndex++))); } if (currentIndex == line.length()) { ret.append("</span>"); } else { ret.append("*/</span>"); state = State.DEFAULT; currentIndex += 2; } } // End of State.COMMENT_MULTI else if (state == State.COMMENT_SINGLE) { // Print everything from the current character until the // end of the line ret.append("<span class=\"comment\">"); while (currentIndex != line.length()) { ret.append(escapeEntity(line.charAt(currentIndex++))); } ret.append("</span>"); state = State.DEFAULT; } // End of State.COMMENT_SINGLE else if (state == State.KEYWORD) { StringBuffer tmp = new StringBuffer(); do { tmp.append(line.charAt(currentIndex++)); } while ((currentIndex != line.length()) && (Character.isJavaIdentifierPart(line .charAt(currentIndex)))); if (javaKeywords.contains(tmp.toString())) ret.append("<span class=\"keyword\">" + tmp + "</span>"); else if (javaPrimitiveLiterals.contains(tmp.toString())) ret.append("<span class=\"keyword\">" + tmp + "</span>"); else if (javaPrimitiveTypes.contains(tmp.toString())) ret.append("<span class=\"keyword\">" + tmp + "</span>"); else ret.append(tmp); if (tmp.toString().equals("import")) state = State.IMPORT_NAME; else if (tmp.toString().equals("package")) state = State.PACKAGE_NAME; else state = State.DEFAULT; } // End of State.KEYWORD else if (state == State.IMPORT_NAME) { ret.append(escapeEntity(line.charAt(currentIndex++))); state = State.DEFAULT; } // End of State.IMPORT_NAME else if (state == State.PACKAGE_NAME) { ret.append(escapeEntity(line.charAt(currentIndex++))); state = State.DEFAULT; } // End of State.PACKAGE_NAME else if (state == State.QUOTE_DOUBLE) { // Print everything from the current character until the // closing ", checking for \" ret.append("<span class=\"string\">"); do { ret.append(escapeEntity(line.charAt(currentIndex++))); } while ((currentIndex != line.length()) && (!(line.charAt(currentIndex) == '"') || (line .charAt(currentIndex - 1) == '\\'))); if (currentIndex == line.length()) { ret.append("</span>"); } else { ret.append("\"</span>"); state = State.DEFAULT; currentIndex++; } } // End of State.QUOTE_DOUBLE else if (state == State.QUOTE_SINGLE) { // Print everything from the current character until the // closing ', checking for \' ret.append("<span class=\"string\">"); do { ret.append(escapeEntity(line.charAt(currentIndex++))); } while ((currentIndex != line.length()) && (!(line.charAt(currentIndex) == '\'') || (line .charAt(currentIndex - 1) == '\\'))); if (currentIndex == line.length()) { ret.append("</span>"); } else { ret.append("\"</span>"); state = State.DEFAULT; currentIndex++; } } // End of State.QUOTE_SINGLE else { // Default: No highlighting. ret.append(escapeEntity(line.charAt(currentIndex++))); } // End of unknown state } return ret.toString(); }
public void setHeadline(Object o) { setValue(FIELDNAME_HEADLINE, o.toString()); }
public void setHeadline(String s) { setValue(FIELDNAME_HEADLINE, s); }
public void setHeadline(Object o) { setValue(FIELDNAME_HEADLINE, o.toString()); }
Variable var = VariableBuilder.newVariable(_names,bc,_filtered); return var.evaluate(bc);
try { Object ret = bc.getLocal(_names); if (_filtered) { Filter f = bc.getFilter(Variable.makePropertyNames(_names)); bc.push(ret); ret = f.evaluate(bc); bc.pop(); } return ret; } catch (Exception e) { throw new BuildException("Property error occured during parameter " + "build pocess: " + e); }
public final Object build(BuildContext bc) throws BuildException { Variable var = VariableBuilder.newVariable(_names,bc,_filtered); return var.evaluate(bc); }
List<NoteTreeNode> treeNodes = dd.getTree().getSelectedNodes(); for (NoteTreeNode treeNode : treeNodes) { DisplayedNote dn = treeNode.getDisplayedNote(); if (dn.getTab() == null) { dd.getTabFolder().addNoteTab(dn); } else { dn.getTab().select(); }
List<DisplayedNote> selectedNotes = dd.getTree().getSelectedNotes(); for (DisplayedNote selectedNote : selectedNotes) { selectedNote.displayTab(dd.getTabFolder());
public void displayTab(Event e) { List<NoteTreeNode> treeNodes = dd.getTree().getSelectedNodes(); for (NoteTreeNode treeNode : treeNodes) { DisplayedNote dn = treeNode.getDisplayedNote(); if (dn.getTab() == null) { dd.getTabFolder().addNoteTab(dn); } else { dn.getTab().select(); } } }
roomsTable.setValueAt(new JLabel(SparkRes.getImageIcon(SparkRes.BOOKMARK_ICON)), selectedRow, 0);
roomsTable.getTableModel().setValueAt(new JLabel(SparkRes.getImageIcon(SparkRes.BOOKMARK_ICON)), selectedRow, 0);
private void bookmarkRoom(String serviceName, Tree serviceTree) { int selectedRow = roomsTable.getSelectedRow(); if (-1 == selectedRow) { JOptionPane.showMessageDialog(dlg, Res.getString("message.select.add.room.to.add"), Res.getString("title.group.chat"), JOptionPane.INFORMATION_MESSAGE); return; } final String roomJID = (String)roomsTable.getValueAt(selectedRow, 2) + "@" + serviceName; final String roomName = (String)roomsTable.getValueAt(selectedRow, 1); // Check to see what type of room this is. try { final RoomInfo roomInfo = MultiUserChat.getRoomInfo(SparkManager.getConnection(), roomJID); if (!roomInfo.isPersistent()) { JOptionPane.showMessageDialog(dlg, Res.getString("message.bookmark.temporary.room.error"), Res.getString("title.error"), JOptionPane.ERROR_MESSAGE); return; } } catch (Exception e) { // Do not return } JiveTreeNode rootNode = (JiveTreeNode)serviceTree.getModel().getRoot(); TreePath rootPath = serviceTree.findByName(serviceTree, new String[]{rootNode.toString(), serviceName}); boolean isBookmarked = isBookmarked(roomJID); if (!isBookmarked) { JiveTreeNode node = (JiveTreeNode)serviceTree.getLastSelectedPathComponent(); if (node == null) { TreePath path = serviceTree.findByName(serviceTree, new String[]{rootNode.toString(), Conferences.getDefaultServiceName()}); node = (JiveTreeNode)path.getLastPathComponent(); } JiveTreeNode roomNode = new JiveTreeNode(roomName, false, SparkRes.getImageIcon(SparkRes.BOOKMARK_ICON)); roomNode.setAssociatedObject(roomJID); node.add(roomNode); final DefaultTreeModel model = (DefaultTreeModel)serviceTree.getModel(); model.nodeStructureChanged(node); serviceTree.expandPath(rootPath); roomsTable.setValueAt(new JLabel(SparkRes.getImageIcon(SparkRes.BOOKMARK_ICON)), selectedRow, 0); addBookmarkUI(false); } else { // Remove bookmark TreePath path = serviceTree.findByName(serviceTree, new String[]{rootNode.toString(), serviceName, roomName}); JiveTreeNode node = (JiveTreeNode)path.getLastPathComponent(); final DefaultTreeModel model = (DefaultTreeModel)serviceTree.getModel(); model.removeNodeFromParent(node); roomsTable.setValueAt(new JLabel(SparkRes.getImageIcon(SparkRes.BLANK_IMAGE)), selectedRow, 0); addBookmarkUI(true); } }
roomsTable.setValueAt(new JLabel(SparkRes.getImageIcon(SparkRes.BLANK_IMAGE)), selectedRow, 0);
roomsTable.getTableModel().setValueAt(new JLabel(SparkRes.getImageIcon(SparkRes.BLANK_IMAGE)), selectedRow, 0);
private void bookmarkRoom(String serviceName, Tree serviceTree) { int selectedRow = roomsTable.getSelectedRow(); if (-1 == selectedRow) { JOptionPane.showMessageDialog(dlg, Res.getString("message.select.add.room.to.add"), Res.getString("title.group.chat"), JOptionPane.INFORMATION_MESSAGE); return; } final String roomJID = (String)roomsTable.getValueAt(selectedRow, 2) + "@" + serviceName; final String roomName = (String)roomsTable.getValueAt(selectedRow, 1); // Check to see what type of room this is. try { final RoomInfo roomInfo = MultiUserChat.getRoomInfo(SparkManager.getConnection(), roomJID); if (!roomInfo.isPersistent()) { JOptionPane.showMessageDialog(dlg, Res.getString("message.bookmark.temporary.room.error"), Res.getString("title.error"), JOptionPane.ERROR_MESSAGE); return; } } catch (Exception e) { // Do not return } JiveTreeNode rootNode = (JiveTreeNode)serviceTree.getModel().getRoot(); TreePath rootPath = serviceTree.findByName(serviceTree, new String[]{rootNode.toString(), serviceName}); boolean isBookmarked = isBookmarked(roomJID); if (!isBookmarked) { JiveTreeNode node = (JiveTreeNode)serviceTree.getLastSelectedPathComponent(); if (node == null) { TreePath path = serviceTree.findByName(serviceTree, new String[]{rootNode.toString(), Conferences.getDefaultServiceName()}); node = (JiveTreeNode)path.getLastPathComponent(); } JiveTreeNode roomNode = new JiveTreeNode(roomName, false, SparkRes.getImageIcon(SparkRes.BOOKMARK_ICON)); roomNode.setAssociatedObject(roomJID); node.add(roomNode); final DefaultTreeModel model = (DefaultTreeModel)serviceTree.getModel(); model.nodeStructureChanged(node); serviceTree.expandPath(rootPath); roomsTable.setValueAt(new JLabel(SparkRes.getImageIcon(SparkRes.BOOKMARK_ICON)), selectedRow, 0); addBookmarkUI(false); } else { // Remove bookmark TreePath path = serviceTree.findByName(serviceTree, new String[]{rootNode.toString(), serviceName, roomName}); JiveTreeNode node = (JiveTreeNode)path.getLastPathComponent(); final DefaultTreeModel model = (DefaultTreeModel)serviceTree.getModel(); model.removeNodeFromParent(node); roomsTable.setValueAt(new JLabel(SparkRes.getImageIcon(SparkRes.BLANK_IMAGE)), selectedRow, 0); addBookmarkUI(true); } }
this.nextCheck = now + checkInterval;
this.nextCheck = Clock.TIME + checkInterval;
public TimedReloadContext(CacheReloadContext reloadContext,long checkInterval) { super(); this.reloadContext = reloadContext; this.checkInterval = checkInterval; this.nextCheck = now + checkInterval; }
if (now >= nextCheck) { nextCheck = now + checkInterval;
if (Clock.TIME >= nextCheck) { nextCheck = Clock.TIME + checkInterval;
public boolean shouldReload() { //long time = System.currentTimeMillis(); if (now >= nextCheck) { nextCheck = now + checkInterval; return reloadContext.shouldReload(); } else { return false; } }
final boolean setImpl (final Object inst, final Object[] args) throws PropertyException, NoSuchMethodException { for (int i = 0; i < setCount; i++) { Object arg = args[args.length - 1]; if (_setParams[i].isPrimitive())
final boolean setImpl(final Object inst, final Object[] args) throws PropertyException, NoSuchMethodException { for (int i = 0; i < setCount; i++) { Object arg = args[args.length - 1]; if (_setParams[i].isPrimitive()) { if (arg.getClass() == _setPrimitiveType[i])
final boolean setImpl (final Object inst, final Object[] args) throws PropertyException, NoSuchMethodException { //which method to use? check params for first match for (int i = 0; i < setCount; i++) { Object arg = args[args.length - 1]; // XXX: null values are blocked by the next line if (_setParams[i].isPrimitive()) { if (arg.getClass() == _setPrimitiveType[i]) { try { PropertyOperator.invoke(_setMethods[i], inst, args); return true; } catch (Exception e) { // ignore exception } } } else if (arg == null || _setParams[i].isInstance(args[args.length - 1])) { PropertyOperator.invoke(_setMethods[i], inst, args); return true; } } return false; }
if (arg.getClass() == _setPrimitiveType[i]) { try { PropertyOperator.invoke(_setMethods[i], inst, args); return true; } catch (Exception e) { } }
try { PropertyOperator.invoke(_setMethods[i], inst, args); return true; } catch (Exception e) { }
final boolean setImpl (final Object inst, final Object[] args) throws PropertyException, NoSuchMethodException { //which method to use? check params for first match for (int i = 0; i < setCount; i++) { Object arg = args[args.length - 1]; // XXX: null values are blocked by the next line if (_setParams[i].isPrimitive()) { if (arg.getClass() == _setPrimitiveType[i]) { try { PropertyOperator.invoke(_setMethods[i], inst, args); return true; } catch (Exception e) { // ignore exception } } } else if (arg == null || _setParams[i].isInstance(args[args.length - 1])) { PropertyOperator.invoke(_setMethods[i], inst, args); return true; } } return false; }
else if (arg == null || _setParams[i].isInstance(args[args.length - 1])) { PropertyOperator.invoke(_setMethods[i], inst, args); return true; } } return false; }
} else if (arg == null || _setParams[i].isInstance(args[args.length - 1])) { PropertyOperator.invoke(_setMethods[i], inst, args); return true; } } return false; }
final boolean setImpl (final Object inst, final Object[] args) throws PropertyException, NoSuchMethodException { //which method to use? check params for first match for (int i = 0; i < setCount; i++) { Object arg = args[args.length - 1]; // XXX: null values are blocked by the next line if (_setParams[i].isPrimitive()) { if (arg.getClass() == _setPrimitiveType[i]) { try { PropertyOperator.invoke(_setMethods[i], inst, args); return true; } catch (Exception e) { // ignore exception } } } else if (arg == null || _setParams[i].isInstance(args[args.length - 1])) { PropertyOperator.invoke(_setMethods[i], inst, args); return true; } } return false; }
public PropertyOperator (final Class target, PropertyOperatorCache cache) throws SecurityException, PropertyException { Accessor acc; _cache = cache; Field[] fields = target.getFields(); for (int i = 0; i < fields.length; i++) { if (Modifier.isPublic(fields[i].getModifiers()))
public PropertyOperator(final Class target, PropertyOperatorCache cache) throws SecurityException, PropertyException { Accessor acc; _cache = cache; Field[] fields = target.getFields(); for (int i = 0; i < fields.length; i++) { if (Modifier.isPublic(fields[i].getModifiers())) { acc = new FieldAccessor(fields[i]); _unaryAccessors.put(acc.getName(), acc); } } if (target.isArray()) _unaryAccessors.put("length", _lengthAccessor); Vector methods = getMethods(target); Method meth; Class[] params; String name,propName; for (int i = 0; i < methods.size(); i++) { meth = ((Method) methods.elementAt(i)); if (!isMethodAllowed(meth)) continue; name = meth.getName(); params = meth.getParameterTypes(); int plength = params.length; acc = (Accessor) _directAccessors.get(name); if (acc != null) { ((DirectAccessor) acc).addMethod(meth, params); } else { acc = new DirectAccessor(name, meth, params); _directAccessors.put(name, acc); } if ((name.startsWith("get") || name.startsWith("set")) || name.equals("put")) { propName = name.substring(3); if (((plength == 0) && name.startsWith("get")) || ((plength == 1) && name.startsWith("set")))
public PropertyOperator (final Class target, PropertyOperatorCache cache) throws SecurityException, PropertyException { Accessor acc; // Save the cache _cache = cache; // introspect fields first Field[] fields = target.getFields(); for (int i = 0; i < fields.length; i++) { if (Modifier.isPublic(fields[i].getModifiers())) { acc = new FieldAccessor(fields[i]); _unaryAccessors.put(acc.getName(), acc); } } if (target.isArray()) _unaryAccessors.put("length", _lengthAccessor); // introspect methods second Vector methods = getMethods(target); Method meth; Class[] params; String name,propName; for (int i = 0; i < methods.size(); i++) { meth = ((Method) methods.elementAt(i)); if (!isMethodAllowed(meth)) continue; name = meth.getName(); params = meth.getParameterTypes(); int plength = params.length; // add direct accessor acc = (Accessor) _directAccessors.get(name); if (acc != null) { ((DirectAccessor) acc).addMethod(meth, params); } else { acc = new DirectAccessor(name, meth, params); _directAccessors.put(name, acc); } // check for get/set/put method if ((name.startsWith("get") || name.startsWith("set")) || name.equals("put")) { propName = name.substring(3); if (((plength == 0) && name.startsWith("get")) || ((plength == 1) && name.startsWith("set"))) { // unary get/set method acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } else if ((plength > 0) && ( (params[0].isInstance("string") && ((plength == 2) && name.equals("put"))) || ((plength == 1) && name.equals("get")))) { // hashtable get/put if (_hashAccessor != null) { _hashAccessor.addMethod(meth, params); } else { _hashAccessor = new BinaryMethodAccessor(propName, meth, params); } } else if ((plength > 0) && (params[0].isInstance("string")) && (((plength == 1) && name.startsWith("get")) || ((plength == 2) && name.startsWith("set")))) { // binary get/set method acc = (Accessor) _binaryAccessors.get(propName); if (acc != null) { ((MethodAccessor) acc).addMethod(meth, params); } else { acc = new BinaryMethodAccessor(propName, meth, params); _binaryAccessors.put(propName, acc); } } } else if (name.startsWith("is") && meth.getReturnType() == java.lang.Boolean.TYPE) { if (plength == 0) { // unary accessor method propName = name.substring(2); acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } } else if (name.equals("elements") || name.equals("enumeration") || name.equals("iterator") || name.equals("toArray")) { if (params.length == 0) { Class returnType = meth.getReturnType(); // iterator supercedes enumeration supercedes Object[] Class iterClass = Iterator.class; boolean iterA = iterClass.isAssignableFrom(returnType); if ( iterA || (((iteratorMethod == null) || iteratorMethod.getName().equals("toArray")) && Object[].class.isAssignableFrom(returnType) || Enumeration.class.isAssignableFrom(returnType))) { iteratorMethod = meth; } } } } }
acc = new FieldAccessor(fields[i]); _unaryAccessors.put(acc.getName(), acc);
acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); }
public PropertyOperator (final Class target, PropertyOperatorCache cache) throws SecurityException, PropertyException { Accessor acc; // Save the cache _cache = cache; // introspect fields first Field[] fields = target.getFields(); for (int i = 0; i < fields.length; i++) { if (Modifier.isPublic(fields[i].getModifiers())) { acc = new FieldAccessor(fields[i]); _unaryAccessors.put(acc.getName(), acc); } } if (target.isArray()) _unaryAccessors.put("length", _lengthAccessor); // introspect methods second Vector methods = getMethods(target); Method meth; Class[] params; String name,propName; for (int i = 0; i < methods.size(); i++) { meth = ((Method) methods.elementAt(i)); if (!isMethodAllowed(meth)) continue; name = meth.getName(); params = meth.getParameterTypes(); int plength = params.length; // add direct accessor acc = (Accessor) _directAccessors.get(name); if (acc != null) { ((DirectAccessor) acc).addMethod(meth, params); } else { acc = new DirectAccessor(name, meth, params); _directAccessors.put(name, acc); } // check for get/set/put method if ((name.startsWith("get") || name.startsWith("set")) || name.equals("put")) { propName = name.substring(3); if (((plength == 0) && name.startsWith("get")) || ((plength == 1) && name.startsWith("set"))) { // unary get/set method acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } else if ((plength > 0) && ( (params[0].isInstance("string") && ((plength == 2) && name.equals("put"))) || ((plength == 1) && name.equals("get")))) { // hashtable get/put if (_hashAccessor != null) { _hashAccessor.addMethod(meth, params); } else { _hashAccessor = new BinaryMethodAccessor(propName, meth, params); } } else if ((plength > 0) && (params[0].isInstance("string")) && (((plength == 1) && name.startsWith("get")) || ((plength == 2) && name.startsWith("set")))) { // binary get/set method acc = (Accessor) _binaryAccessors.get(propName); if (acc != null) { ((MethodAccessor) acc).addMethod(meth, params); } else { acc = new BinaryMethodAccessor(propName, meth, params); _binaryAccessors.put(propName, acc); } } } else if (name.startsWith("is") && meth.getReturnType() == java.lang.Boolean.TYPE) { if (plength == 0) { // unary accessor method propName = name.substring(2); acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } } else if (name.equals("elements") || name.equals("enumeration") || name.equals("iterator") || name.equals("toArray")) { if (params.length == 0) { Class returnType = meth.getReturnType(); // iterator supercedes enumeration supercedes Object[] Class iterClass = Iterator.class; boolean iterA = iterClass.isAssignableFrom(returnType); if ( iterA || (((iteratorMethod == null) || iteratorMethod.getName().equals("toArray")) && Object[].class.isAssignableFrom(returnType) || Enumeration.class.isAssignableFrom(returnType))) { iteratorMethod = meth; } } } } }
} if (target.isArray()) _unaryAccessors.put("length", _lengthAccessor); Vector methods = getMethods(target); Method meth; Class[] params; String name,propName; for (int i = 0; i < methods.size(); i++) { meth = ((Method) methods.elementAt(i)); if (!isMethodAllowed(meth)) continue; name = meth.getName(); params = meth.getParameterTypes(); int plength = params.length; acc = (Accessor) _directAccessors.get(name); if (acc != null)
else if ((plength > 0) && (params[0].isInstance("string") && (((plength == 2) && name.equals("put")) || ((plength == 1) && name.equals("get")))))
public PropertyOperator (final Class target, PropertyOperatorCache cache) throws SecurityException, PropertyException { Accessor acc; // Save the cache _cache = cache; // introspect fields first Field[] fields = target.getFields(); for (int i = 0; i < fields.length; i++) { if (Modifier.isPublic(fields[i].getModifiers())) { acc = new FieldAccessor(fields[i]); _unaryAccessors.put(acc.getName(), acc); } } if (target.isArray()) _unaryAccessors.put("length", _lengthAccessor); // introspect methods second Vector methods = getMethods(target); Method meth; Class[] params; String name,propName; for (int i = 0; i < methods.size(); i++) { meth = ((Method) methods.elementAt(i)); if (!isMethodAllowed(meth)) continue; name = meth.getName(); params = meth.getParameterTypes(); int plength = params.length; // add direct accessor acc = (Accessor) _directAccessors.get(name); if (acc != null) { ((DirectAccessor) acc).addMethod(meth, params); } else { acc = new DirectAccessor(name, meth, params); _directAccessors.put(name, acc); } // check for get/set/put method if ((name.startsWith("get") || name.startsWith("set")) || name.equals("put")) { propName = name.substring(3); if (((plength == 0) && name.startsWith("get")) || ((plength == 1) && name.startsWith("set"))) { // unary get/set method acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } else if ((plength > 0) && ( (params[0].isInstance("string") && ((plength == 2) && name.equals("put"))) || ((plength == 1) && name.equals("get")))) { // hashtable get/put if (_hashAccessor != null) { _hashAccessor.addMethod(meth, params); } else { _hashAccessor = new BinaryMethodAccessor(propName, meth, params); } } else if ((plength > 0) && (params[0].isInstance("string")) && (((plength == 1) && name.startsWith("get")) || ((plength == 2) && name.startsWith("set")))) { // binary get/set method acc = (Accessor) _binaryAccessors.get(propName); if (acc != null) { ((MethodAccessor) acc).addMethod(meth, params); } else { acc = new BinaryMethodAccessor(propName, meth, params); _binaryAccessors.put(propName, acc); } } } else if (name.startsWith("is") && meth.getReturnType() == java.lang.Boolean.TYPE) { if (plength == 0) { // unary accessor method propName = name.substring(2); acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } } else if (name.equals("elements") || name.equals("enumeration") || name.equals("iterator") || name.equals("toArray")) { if (params.length == 0) { Class returnType = meth.getReturnType(); // iterator supercedes enumeration supercedes Object[] Class iterClass = Iterator.class; boolean iterA = iterClass.isAssignableFrom(returnType); if ( iterA || (((iteratorMethod == null) || iteratorMethod.getName().equals("toArray")) && Object[].class.isAssignableFrom(returnType) || Enumeration.class.isAssignableFrom(returnType))) { iteratorMethod = meth; } } } } }
((DirectAccessor) acc).addMethod(meth, params);
if (_hashAccessor != null) { _hashAccessor.addMethod(meth, params); } else { _hashAccessor = new BinaryMethodAccessor(propName, meth, params); }
public PropertyOperator (final Class target, PropertyOperatorCache cache) throws SecurityException, PropertyException { Accessor acc; // Save the cache _cache = cache; // introspect fields first Field[] fields = target.getFields(); for (int i = 0; i < fields.length; i++) { if (Modifier.isPublic(fields[i].getModifiers())) { acc = new FieldAccessor(fields[i]); _unaryAccessors.put(acc.getName(), acc); } } if (target.isArray()) _unaryAccessors.put("length", _lengthAccessor); // introspect methods second Vector methods = getMethods(target); Method meth; Class[] params; String name,propName; for (int i = 0; i < methods.size(); i++) { meth = ((Method) methods.elementAt(i)); if (!isMethodAllowed(meth)) continue; name = meth.getName(); params = meth.getParameterTypes(); int plength = params.length; // add direct accessor acc = (Accessor) _directAccessors.get(name); if (acc != null) { ((DirectAccessor) acc).addMethod(meth, params); } else { acc = new DirectAccessor(name, meth, params); _directAccessors.put(name, acc); } // check for get/set/put method if ((name.startsWith("get") || name.startsWith("set")) || name.equals("put")) { propName = name.substring(3); if (((plength == 0) && name.startsWith("get")) || ((plength == 1) && name.startsWith("set"))) { // unary get/set method acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } else if ((plength > 0) && ( (params[0].isInstance("string") && ((plength == 2) && name.equals("put"))) || ((plength == 1) && name.equals("get")))) { // hashtable get/put if (_hashAccessor != null) { _hashAccessor.addMethod(meth, params); } else { _hashAccessor = new BinaryMethodAccessor(propName, meth, params); } } else if ((plength > 0) && (params[0].isInstance("string")) && (((plength == 1) && name.startsWith("get")) || ((plength == 2) && name.startsWith("set")))) { // binary get/set method acc = (Accessor) _binaryAccessors.get(propName); if (acc != null) { ((MethodAccessor) acc).addMethod(meth, params); } else { acc = new BinaryMethodAccessor(propName, meth, params); _binaryAccessors.put(propName, acc); } } } else if (name.startsWith("is") && meth.getReturnType() == java.lang.Boolean.TYPE) { if (plength == 0) { // unary accessor method propName = name.substring(2); acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } } else if (name.equals("elements") || name.equals("enumeration") || name.equals("iterator") || name.equals("toArray")) { if (params.length == 0) { Class returnType = meth.getReturnType(); // iterator supercedes enumeration supercedes Object[] Class iterClass = Iterator.class; boolean iterA = iterClass.isAssignableFrom(returnType); if ( iterA || (((iteratorMethod == null) || iteratorMethod.getName().equals("toArray")) && Object[].class.isAssignableFrom(returnType) || Enumeration.class.isAssignableFrom(returnType))) { iteratorMethod = meth; } } } } }
else
else if ((plength > 0) && (params[0].isInstance("string")) && (((plength == 1) && name.startsWith("get")) || ((plength == 2) && name.startsWith("set"))))
public PropertyOperator (final Class target, PropertyOperatorCache cache) throws SecurityException, PropertyException { Accessor acc; // Save the cache _cache = cache; // introspect fields first Field[] fields = target.getFields(); for (int i = 0; i < fields.length; i++) { if (Modifier.isPublic(fields[i].getModifiers())) { acc = new FieldAccessor(fields[i]); _unaryAccessors.put(acc.getName(), acc); } } if (target.isArray()) _unaryAccessors.put("length", _lengthAccessor); // introspect methods second Vector methods = getMethods(target); Method meth; Class[] params; String name,propName; for (int i = 0; i < methods.size(); i++) { meth = ((Method) methods.elementAt(i)); if (!isMethodAllowed(meth)) continue; name = meth.getName(); params = meth.getParameterTypes(); int plength = params.length; // add direct accessor acc = (Accessor) _directAccessors.get(name); if (acc != null) { ((DirectAccessor) acc).addMethod(meth, params); } else { acc = new DirectAccessor(name, meth, params); _directAccessors.put(name, acc); } // check for get/set/put method if ((name.startsWith("get") || name.startsWith("set")) || name.equals("put")) { propName = name.substring(3); if (((plength == 0) && name.startsWith("get")) || ((plength == 1) && name.startsWith("set"))) { // unary get/set method acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } else if ((plength > 0) && ( (params[0].isInstance("string") && ((plength == 2) && name.equals("put"))) || ((plength == 1) && name.equals("get")))) { // hashtable get/put if (_hashAccessor != null) { _hashAccessor.addMethod(meth, params); } else { _hashAccessor = new BinaryMethodAccessor(propName, meth, params); } } else if ((plength > 0) && (params[0].isInstance("string")) && (((plength == 1) && name.startsWith("get")) || ((plength == 2) && name.startsWith("set")))) { // binary get/set method acc = (Accessor) _binaryAccessors.get(propName); if (acc != null) { ((MethodAccessor) acc).addMethod(meth, params); } else { acc = new BinaryMethodAccessor(propName, meth, params); _binaryAccessors.put(propName, acc); } } } else if (name.startsWith("is") && meth.getReturnType() == java.lang.Boolean.TYPE) { if (plength == 0) { // unary accessor method propName = name.substring(2); acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } } else if (name.equals("elements") || name.equals("enumeration") || name.equals("iterator") || name.equals("toArray")) { if (params.length == 0) { Class returnType = meth.getReturnType(); // iterator supercedes enumeration supercedes Object[] Class iterClass = Iterator.class; boolean iterA = iterClass.isAssignableFrom(returnType); if ( iterA || (((iteratorMethod == null) || iteratorMethod.getName().equals("toArray")) && Object[].class.isAssignableFrom(returnType) || Enumeration.class.isAssignableFrom(returnType))) { iteratorMethod = meth; } } } } }
acc = new DirectAccessor(name, meth, params); _directAccessors.put(name, acc);
acc = (Accessor) _binaryAccessors.get(propName); if (acc != null) { ((MethodAccessor) acc).addMethod(meth, params); } else { acc = new BinaryMethodAccessor(propName, meth, params); _binaryAccessors.put(propName, acc); }
public PropertyOperator (final Class target, PropertyOperatorCache cache) throws SecurityException, PropertyException { Accessor acc; // Save the cache _cache = cache; // introspect fields first Field[] fields = target.getFields(); for (int i = 0; i < fields.length; i++) { if (Modifier.isPublic(fields[i].getModifiers())) { acc = new FieldAccessor(fields[i]); _unaryAccessors.put(acc.getName(), acc); } } if (target.isArray()) _unaryAccessors.put("length", _lengthAccessor); // introspect methods second Vector methods = getMethods(target); Method meth; Class[] params; String name,propName; for (int i = 0; i < methods.size(); i++) { meth = ((Method) methods.elementAt(i)); if (!isMethodAllowed(meth)) continue; name = meth.getName(); params = meth.getParameterTypes(); int plength = params.length; // add direct accessor acc = (Accessor) _directAccessors.get(name); if (acc != null) { ((DirectAccessor) acc).addMethod(meth, params); } else { acc = new DirectAccessor(name, meth, params); _directAccessors.put(name, acc); } // check for get/set/put method if ((name.startsWith("get") || name.startsWith("set")) || name.equals("put")) { propName = name.substring(3); if (((plength == 0) && name.startsWith("get")) || ((plength == 1) && name.startsWith("set"))) { // unary get/set method acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } else if ((plength > 0) && ( (params[0].isInstance("string") && ((plength == 2) && name.equals("put"))) || ((plength == 1) && name.equals("get")))) { // hashtable get/put if (_hashAccessor != null) { _hashAccessor.addMethod(meth, params); } else { _hashAccessor = new BinaryMethodAccessor(propName, meth, params); } } else if ((plength > 0) && (params[0].isInstance("string")) && (((plength == 1) && name.startsWith("get")) || ((plength == 2) && name.startsWith("set")))) { // binary get/set method acc = (Accessor) _binaryAccessors.get(propName); if (acc != null) { ((MethodAccessor) acc).addMethod(meth, params); } else { acc = new BinaryMethodAccessor(propName, meth, params); _binaryAccessors.put(propName, acc); } } } else if (name.startsWith("is") && meth.getReturnType() == java.lang.Boolean.TYPE) { if (plength == 0) { // unary accessor method propName = name.substring(2); acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } } else if (name.equals("elements") || name.equals("enumeration") || name.equals("iterator") || name.equals("toArray")) { if (params.length == 0) { Class returnType = meth.getReturnType(); // iterator supercedes enumeration supercedes Object[] Class iterClass = Iterator.class; boolean iterA = iterClass.isAssignableFrom(returnType); if ( iterA || (((iteratorMethod == null) || iteratorMethod.getName().equals("toArray")) && Object[].class.isAssignableFrom(returnType) || Enumeration.class.isAssignableFrom(returnType))) { iteratorMethod = meth; } } } } }
if ((name.startsWith("get") || name.startsWith("set")) || name.equals("put"))
} else if (name.startsWith("is") && meth.getReturnType() == java.lang.Boolean.TYPE) { if (plength == 0)
public PropertyOperator (final Class target, PropertyOperatorCache cache) throws SecurityException, PropertyException { Accessor acc; // Save the cache _cache = cache; // introspect fields first Field[] fields = target.getFields(); for (int i = 0; i < fields.length; i++) { if (Modifier.isPublic(fields[i].getModifiers())) { acc = new FieldAccessor(fields[i]); _unaryAccessors.put(acc.getName(), acc); } } if (target.isArray()) _unaryAccessors.put("length", _lengthAccessor); // introspect methods second Vector methods = getMethods(target); Method meth; Class[] params; String name,propName; for (int i = 0; i < methods.size(); i++) { meth = ((Method) methods.elementAt(i)); if (!isMethodAllowed(meth)) continue; name = meth.getName(); params = meth.getParameterTypes(); int plength = params.length; // add direct accessor acc = (Accessor) _directAccessors.get(name); if (acc != null) { ((DirectAccessor) acc).addMethod(meth, params); } else { acc = new DirectAccessor(name, meth, params); _directAccessors.put(name, acc); } // check for get/set/put method if ((name.startsWith("get") || name.startsWith("set")) || name.equals("put")) { propName = name.substring(3); if (((plength == 0) && name.startsWith("get")) || ((plength == 1) && name.startsWith("set"))) { // unary get/set method acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } else if ((plength > 0) && ( (params[0].isInstance("string") && ((plength == 2) && name.equals("put"))) || ((plength == 1) && name.equals("get")))) { // hashtable get/put if (_hashAccessor != null) { _hashAccessor.addMethod(meth, params); } else { _hashAccessor = new BinaryMethodAccessor(propName, meth, params); } } else if ((plength > 0) && (params[0].isInstance("string")) && (((plength == 1) && name.startsWith("get")) || ((plength == 2) && name.startsWith("set")))) { // binary get/set method acc = (Accessor) _binaryAccessors.get(propName); if (acc != null) { ((MethodAccessor) acc).addMethod(meth, params); } else { acc = new BinaryMethodAccessor(propName, meth, params); _binaryAccessors.put(propName, acc); } } } else if (name.startsWith("is") && meth.getReturnType() == java.lang.Boolean.TYPE) { if (plength == 0) { // unary accessor method propName = name.substring(2); acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } } else if (name.equals("elements") || name.equals("enumeration") || name.equals("iterator") || name.equals("toArray")) { if (params.length == 0) { Class returnType = meth.getReturnType(); // iterator supercedes enumeration supercedes Object[] Class iterClass = Iterator.class; boolean iterA = iterClass.isAssignableFrom(returnType); if ( iterA || (((iteratorMethod == null) || iteratorMethod.getName().equals("toArray")) && Object[].class.isAssignableFrom(returnType) || Enumeration.class.isAssignableFrom(returnType))) { iteratorMethod = meth; } } } } }
propName = name.substring(3); if (((plength == 0) && name.startsWith("get")) || ((plength == 1) && name.startsWith("set"))) { acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } else if ((plength > 0) && ( (params[0].isInstance("string") && ((plength == 2) && name.equals("put"))) || ((plength == 1) && name.equals("get")))) { if (_hashAccessor != null) { _hashAccessor.addMethod(meth, params); } else { _hashAccessor = new BinaryMethodAccessor(propName, meth, params); } } else if ((plength > 0) && (params[0].isInstance("string")) && (((plength == 1) && name.startsWith("get")) || ((plength == 2) && name.startsWith("set")))) { acc = (Accessor) _binaryAccessors.get(propName); if (acc != null) { ((MethodAccessor) acc).addMethod(meth, params); } else { acc = new BinaryMethodAccessor(propName, meth, params); _binaryAccessors.put(propName, acc); } }
propName = name.substring(2); acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); }
public PropertyOperator (final Class target, PropertyOperatorCache cache) throws SecurityException, PropertyException { Accessor acc; // Save the cache _cache = cache; // introspect fields first Field[] fields = target.getFields(); for (int i = 0; i < fields.length; i++) { if (Modifier.isPublic(fields[i].getModifiers())) { acc = new FieldAccessor(fields[i]); _unaryAccessors.put(acc.getName(), acc); } } if (target.isArray()) _unaryAccessors.put("length", _lengthAccessor); // introspect methods second Vector methods = getMethods(target); Method meth; Class[] params; String name,propName; for (int i = 0; i < methods.size(); i++) { meth = ((Method) methods.elementAt(i)); if (!isMethodAllowed(meth)) continue; name = meth.getName(); params = meth.getParameterTypes(); int plength = params.length; // add direct accessor acc = (Accessor) _directAccessors.get(name); if (acc != null) { ((DirectAccessor) acc).addMethod(meth, params); } else { acc = new DirectAccessor(name, meth, params); _directAccessors.put(name, acc); } // check for get/set/put method if ((name.startsWith("get") || name.startsWith("set")) || name.equals("put")) { propName = name.substring(3); if (((plength == 0) && name.startsWith("get")) || ((plength == 1) && name.startsWith("set"))) { // unary get/set method acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } else if ((plength > 0) && ( (params[0].isInstance("string") && ((plength == 2) && name.equals("put"))) || ((plength == 1) && name.equals("get")))) { // hashtable get/put if (_hashAccessor != null) { _hashAccessor.addMethod(meth, params); } else { _hashAccessor = new BinaryMethodAccessor(propName, meth, params); } } else if ((plength > 0) && (params[0].isInstance("string")) && (((plength == 1) && name.startsWith("get")) || ((plength == 2) && name.startsWith("set")))) { // binary get/set method acc = (Accessor) _binaryAccessors.get(propName); if (acc != null) { ((MethodAccessor) acc).addMethod(meth, params); } else { acc = new BinaryMethodAccessor(propName, meth, params); _binaryAccessors.put(propName, acc); } } } else if (name.startsWith("is") && meth.getReturnType() == java.lang.Boolean.TYPE) { if (plength == 0) { // unary accessor method propName = name.substring(2); acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } } else if (name.equals("elements") || name.equals("enumeration") || name.equals("iterator") || name.equals("toArray")) { if (params.length == 0) { Class returnType = meth.getReturnType(); // iterator supercedes enumeration supercedes Object[] Class iterClass = Iterator.class; boolean iterA = iterClass.isAssignableFrom(returnType); if ( iterA || (((iteratorMethod == null) || iteratorMethod.getName().equals("toArray")) && Object[].class.isAssignableFrom(returnType) || Enumeration.class.isAssignableFrom(returnType))) { iteratorMethod = meth; } } } } }
else if (name.startsWith("is") && meth.getReturnType() == java.lang.Boolean.TYPE)
} else if (name.equals("elements") || name.equals("enumeration") || name.equals("iterator") || name.equals("toArray")) { if (params.length == 0)
public PropertyOperator (final Class target, PropertyOperatorCache cache) throws SecurityException, PropertyException { Accessor acc; // Save the cache _cache = cache; // introspect fields first Field[] fields = target.getFields(); for (int i = 0; i < fields.length; i++) { if (Modifier.isPublic(fields[i].getModifiers())) { acc = new FieldAccessor(fields[i]); _unaryAccessors.put(acc.getName(), acc); } } if (target.isArray()) _unaryAccessors.put("length", _lengthAccessor); // introspect methods second Vector methods = getMethods(target); Method meth; Class[] params; String name,propName; for (int i = 0; i < methods.size(); i++) { meth = ((Method) methods.elementAt(i)); if (!isMethodAllowed(meth)) continue; name = meth.getName(); params = meth.getParameterTypes(); int plength = params.length; // add direct accessor acc = (Accessor) _directAccessors.get(name); if (acc != null) { ((DirectAccessor) acc).addMethod(meth, params); } else { acc = new DirectAccessor(name, meth, params); _directAccessors.put(name, acc); } // check for get/set/put method if ((name.startsWith("get") || name.startsWith("set")) || name.equals("put")) { propName = name.substring(3); if (((plength == 0) && name.startsWith("get")) || ((plength == 1) && name.startsWith("set"))) { // unary get/set method acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } else if ((plength > 0) && ( (params[0].isInstance("string") && ((plength == 2) && name.equals("put"))) || ((plength == 1) && name.equals("get")))) { // hashtable get/put if (_hashAccessor != null) { _hashAccessor.addMethod(meth, params); } else { _hashAccessor = new BinaryMethodAccessor(propName, meth, params); } } else if ((plength > 0) && (params[0].isInstance("string")) && (((plength == 1) && name.startsWith("get")) || ((plength == 2) && name.startsWith("set")))) { // binary get/set method acc = (Accessor) _binaryAccessors.get(propName); if (acc != null) { ((MethodAccessor) acc).addMethod(meth, params); } else { acc = new BinaryMethodAccessor(propName, meth, params); _binaryAccessors.put(propName, acc); } } } else if (name.startsWith("is") && meth.getReturnType() == java.lang.Boolean.TYPE) { if (plength == 0) { // unary accessor method propName = name.substring(2); acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } } else if (name.equals("elements") || name.equals("enumeration") || name.equals("iterator") || name.equals("toArray")) { if (params.length == 0) { Class returnType = meth.getReturnType(); // iterator supercedes enumeration supercedes Object[] Class iterClass = Iterator.class; boolean iterA = iterClass.isAssignableFrom(returnType); if ( iterA || (((iteratorMethod == null) || iteratorMethod.getName().equals("toArray")) && Object[].class.isAssignableFrom(returnType) || Enumeration.class.isAssignableFrom(returnType))) { iteratorMethod = meth; } } } } }
if (plength == 0) { propName = name.substring(2); acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } }
Class returnType = meth.getReturnType(); Class iterClass = Iterator.class; boolean iterA = iterClass.isAssignableFrom(returnType); if ( iterA || (((iteratorMethod == null) || iteratorMethod.getName().equals("toArray")) && Object[].class.isAssignableFrom(returnType) || Enumeration.class.isAssignableFrom(returnType))) { iteratorMethod = meth; }
public PropertyOperator (final Class target, PropertyOperatorCache cache) throws SecurityException, PropertyException { Accessor acc; // Save the cache _cache = cache; // introspect fields first Field[] fields = target.getFields(); for (int i = 0; i < fields.length; i++) { if (Modifier.isPublic(fields[i].getModifiers())) { acc = new FieldAccessor(fields[i]); _unaryAccessors.put(acc.getName(), acc); } } if (target.isArray()) _unaryAccessors.put("length", _lengthAccessor); // introspect methods second Vector methods = getMethods(target); Method meth; Class[] params; String name,propName; for (int i = 0; i < methods.size(); i++) { meth = ((Method) methods.elementAt(i)); if (!isMethodAllowed(meth)) continue; name = meth.getName(); params = meth.getParameterTypes(); int plength = params.length; // add direct accessor acc = (Accessor) _directAccessors.get(name); if (acc != null) { ((DirectAccessor) acc).addMethod(meth, params); } else { acc = new DirectAccessor(name, meth, params); _directAccessors.put(name, acc); } // check for get/set/put method if ((name.startsWith("get") || name.startsWith("set")) || name.equals("put")) { propName = name.substring(3); if (((plength == 0) && name.startsWith("get")) || ((plength == 1) && name.startsWith("set"))) { // unary get/set method acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } else if ((plength > 0) && ( (params[0].isInstance("string") && ((plength == 2) && name.equals("put"))) || ((plength == 1) && name.equals("get")))) { // hashtable get/put if (_hashAccessor != null) { _hashAccessor.addMethod(meth, params); } else { _hashAccessor = new BinaryMethodAccessor(propName, meth, params); } } else if ((plength > 0) && (params[0].isInstance("string")) && (((plength == 1) && name.startsWith("get")) || ((plength == 2) && name.startsWith("set")))) { // binary get/set method acc = (Accessor) _binaryAccessors.get(propName); if (acc != null) { ((MethodAccessor) acc).addMethod(meth, params); } else { acc = new BinaryMethodAccessor(propName, meth, params); _binaryAccessors.put(propName, acc); } } } else if (name.startsWith("is") && meth.getReturnType() == java.lang.Boolean.TYPE) { if (plength == 0) { // unary accessor method propName = name.substring(2); acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } } else if (name.equals("elements") || name.equals("enumeration") || name.equals("iterator") || name.equals("toArray")) { if (params.length == 0) { Class returnType = meth.getReturnType(); // iterator supercedes enumeration supercedes Object[] Class iterClass = Iterator.class; boolean iterA = iterClass.isAssignableFrom(returnType); if ( iterA || (((iteratorMethod == null) || iteratorMethod.getName().equals("toArray")) && Object[].class.isAssignableFrom(returnType) || Enumeration.class.isAssignableFrom(returnType))) { iteratorMethod = meth; } } } } }
else if (name.equals("elements") || name.equals("enumeration") || name.equals("iterator") || name.equals("toArray")) { if (params.length == 0) { Class returnType = meth.getReturnType(); Class iterClass = Iterator.class; boolean iterA = iterClass.isAssignableFrom(returnType); if ( iterA || (((iteratorMethod == null) || iteratorMethod.getName().equals("toArray")) && Object[].class.isAssignableFrom(returnType) || Enumeration.class.isAssignableFrom(returnType))) { iteratorMethod = meth; } } } } }
} } }
public PropertyOperator (final Class target, PropertyOperatorCache cache) throws SecurityException, PropertyException { Accessor acc; // Save the cache _cache = cache; // introspect fields first Field[] fields = target.getFields(); for (int i = 0; i < fields.length; i++) { if (Modifier.isPublic(fields[i].getModifiers())) { acc = new FieldAccessor(fields[i]); _unaryAccessors.put(acc.getName(), acc); } } if (target.isArray()) _unaryAccessors.put("length", _lengthAccessor); // introspect methods second Vector methods = getMethods(target); Method meth; Class[] params; String name,propName; for (int i = 0; i < methods.size(); i++) { meth = ((Method) methods.elementAt(i)); if (!isMethodAllowed(meth)) continue; name = meth.getName(); params = meth.getParameterTypes(); int plength = params.length; // add direct accessor acc = (Accessor) _directAccessors.get(name); if (acc != null) { ((DirectAccessor) acc).addMethod(meth, params); } else { acc = new DirectAccessor(name, meth, params); _directAccessors.put(name, acc); } // check for get/set/put method if ((name.startsWith("get") || name.startsWith("set")) || name.equals("put")) { propName = name.substring(3); if (((plength == 0) && name.startsWith("get")) || ((plength == 1) && name.startsWith("set"))) { // unary get/set method acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } else if ((plength > 0) && ( (params[0].isInstance("string") && ((plength == 2) && name.equals("put"))) || ((plength == 1) && name.equals("get")))) { // hashtable get/put if (_hashAccessor != null) { _hashAccessor.addMethod(meth, params); } else { _hashAccessor = new BinaryMethodAccessor(propName, meth, params); } } else if ((plength > 0) && (params[0].isInstance("string")) && (((plength == 1) && name.startsWith("get")) || ((plength == 2) && name.startsWith("set")))) { // binary get/set method acc = (Accessor) _binaryAccessors.get(propName); if (acc != null) { ((MethodAccessor) acc).addMethod(meth, params); } else { acc = new BinaryMethodAccessor(propName, meth, params); _binaryAccessors.put(propName, acc); } } } else if (name.startsWith("is") && meth.getReturnType() == java.lang.Boolean.TYPE) { if (plength == 0) { // unary accessor method propName = name.substring(2); acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { ((MethodAccessor) acc).addMethod(meth, params); } } else { acc = new UnaryMethodAccessor(propName, meth, params); _unaryAccessors.put(propName, acc); } } } else if (name.equals("elements") || name.equals("enumeration") || name.equals("iterator") || name.equals("toArray")) { if (params.length == 0) { Class returnType = meth.getReturnType(); // iterator supercedes enumeration supercedes Object[] Class iterClass = Iterator.class; boolean iterA = iterClass.isAssignableFrom(returnType); if ( iterA || (((iteratorMethod == null) || iteratorMethod.getName().equals("toArray")) && Object[].class.isAssignableFrom(returnType) || Enumeration.class.isAssignableFrom(returnType))) { iteratorMethod = meth; } } } } }
private void addMethod (HashMap hm, Method m) { if (!isMethodAllowed(m)) return; String name = m.getName(); Object o = hm.get(name); if (o == null) { hm.put(name, m);
private void addMethod(HashMap hm, Method m) { if (!isMethodAllowed(m)) return; String name = m.getName(); Object o = hm.get(name); if (o == null) { hm.put(name, m); return; } Vector v; if (o instanceof Method) { v = new Vector(); v.addElement(o); hm.put(name, v); } else { v = (Vector) o; } Class ptypes[] = m.getParameterTypes(); for (int i = 0; i < v.size(); i++) { Class curTypes[] = ((Method) v.elementAt(i)).getParameterTypes(); int order = precedes(ptypes, curTypes); if (order < 0) { v.insertElementAt(m, i);
private void addMethod (HashMap hm, Method m) { if (!isMethodAllowed(m)) return; String name = m.getName(); Object o = hm.get(name); if (o == null) { hm.put(name, m); return; } Vector v; if (o instanceof Method) { v = new Vector(); v.addElement(o); hm.put(name, v); } else { v = (Vector) o; } Class ptypes[] = m.getParameterTypes(); for (int i = 0; i < v.size(); i++) { Class curTypes[] = ((Method) v.elementAt(i)).getParameterTypes(); int order = precedes(ptypes, curTypes); if (order < 0) { v.insertElementAt(m, i); return; } else if (order == 0) { // ignore duplicate method return; } } v.addElement(m); }
} Vector v; if (o instanceof Method) { v = new Vector(); v.addElement(o); hm.put(name, v); } else { v = (Vector) o; } Class ptypes[] = m.getParameterTypes(); for (int i = 0; i < v.size(); i++) { Class curTypes[] = ((Method) v.elementAt(i)).getParameterTypes(); int order = precedes(ptypes, curTypes); if (order < 0) { v.insertElementAt(m, i); return; } else if (order == 0) { return; } } v.addElement(m); }
} else if (order == 0) { return; } } v.addElement(m); }
private void addMethod (HashMap hm, Method m) { if (!isMethodAllowed(m)) return; String name = m.getName(); Object o = hm.get(name); if (o == null) { hm.put(name, m); return; } Vector v; if (o instanceof Method) { v = new Vector(); v.addElement(o); hm.put(name, v); } else { v = (Vector) o; } Class ptypes[] = m.getParameterTypes(); for (int i = 0; i < v.size(); i++) { Class curTypes[] = ((Method) v.elementAt(i)).getParameterTypes(); int order = precedes(ptypes, curTypes); if (order < 0) { v.insertElementAt(m, i); return; } else if (order == 0) { // ignore duplicate method return; } } v.addElement(m); }
private void getAllMethods (HashMap meths, Class c) throws SecurityException { if (Modifier.isPublic(c.getModifiers())) { Method m[] = c.getDeclaredMethods(); for (int i = 0; i < m.length; i++)
private void getAllMethods(HashMap meths, Class c) throws SecurityException { if (Modifier.isPublic(c.getModifiers())) { Method m[] = c.getDeclaredMethods(); for (int i = 0; i < m.length; i++) { if (Modifier.isPublic(m[i].getModifiers()))
private void getAllMethods (HashMap meths, Class c) throws SecurityException { if (Modifier.isPublic(c.getModifiers())) { Method m[] = c.getDeclaredMethods(); for (int i = 0; i < m.length; i++) { if (Modifier.isPublic(m[i].getModifiers())) { addMethod(meths, m[i]); } } } Class iface[] = c.getInterfaces(); for (int i = 0; i < iface.length; i++) { getAllMethods(meths, iface[i]); } Class sup = c.getSuperclass(); if (sup != null) { getAllMethods(meths, sup); } }
if (Modifier.isPublic(m[i].getModifiers())) { addMethod(meths, m[i]); }
addMethod(meths, m[i]);
private void getAllMethods (HashMap meths, Class c) throws SecurityException { if (Modifier.isPublic(c.getModifiers())) { Method m[] = c.getDeclaredMethods(); for (int i = 0; i < m.length; i++) { if (Modifier.isPublic(m[i].getModifiers())) { addMethod(meths, m[i]); } } } Class iface[] = c.getInterfaces(); for (int i = 0; i < iface.length; i++) { getAllMethods(meths, iface[i]); } Class sup = c.getSuperclass(); if (sup != null) { getAllMethods(meths, sup); } }
} Class iface[] = c.getInterfaces(); for (int i = 0; i < iface.length; i++) { getAllMethods(meths, iface[i]); } Class sup = c.getSuperclass(); if (sup != null) { getAllMethods(meths, sup); } }
} } Class iface[] = c.getInterfaces(); for (int i = 0; i < iface.length; i++) { getAllMethods(meths, iface[i]); } Class sup = c.getSuperclass(); if (sup != null) { getAllMethods(meths, sup); } }
private void getAllMethods (HashMap meths, Class c) throws SecurityException { if (Modifier.isPublic(c.getModifiers())) { Method m[] = c.getDeclaredMethods(); for (int i = 0; i < m.length; i++) { if (Modifier.isPublic(m[i].getModifiers())) { addMethod(meths, m[i]); } } } Class iface[] = c.getInterfaces(); for (int i = 0; i < iface.length; i++) { getAllMethods(meths, iface[i]); } Class sup = c.getSuperclass(); if (sup != null) { getAllMethods(meths, sup); } }
private Vector getMethods (Class c) { Vector v = new Vector(); HashMap h = new HashMap(); getAllMethods(h, c); Iterator iter = h.values().iterator(); while (iter.hasNext()) { Object elem = iter.next(); if (elem instanceof Method)
private Vector getMethods(Class c) { Vector v = new Vector(); HashMap h = new HashMap(); getAllMethods(h, c); Iterator iter = h.values().iterator(); while (iter.hasNext()) { Object elem = iter.next(); if (elem instanceof Method) { v.addElement(elem); } else { Vector v1 = (Vector) elem; for (int i = 0; i < v1.size(); i++)
private Vector getMethods (Class c) { Vector v = new Vector(); HashMap h = new HashMap(); getAllMethods(h, c); Iterator iter = h.values().iterator(); while (iter.hasNext()) { Object elem = iter.next(); if (elem instanceof Method) { v.addElement(elem); } else { Vector v1 = (Vector) elem; for (int i = 0; i < v1.size(); i++) { v.addElement(v1.elementAt(i)); } } } return v; }
v.addElement(elem);
v.addElement(v1.elementAt(i));
private Vector getMethods (Class c) { Vector v = new Vector(); HashMap h = new HashMap(); getAllMethods(h, c); Iterator iter = h.values().iterator(); while (iter.hasNext()) { Object elem = iter.next(); if (elem instanceof Method) { v.addElement(elem); } else { Vector v1 = (Vector) elem; for (int i = 0; i < v1.size(); i++) { v.addElement(v1.elementAt(i)); } } } return v; }
else { Vector v1 = (Vector) elem; for (int i = 0; i < v1.size(); i++) { v.addElement(v1.elementAt(i)); } } } return v; }
} } return v; }
private Vector getMethods (Class c) { Vector v = new Vector(); HashMap h = new HashMap(); getAllMethods(h, c); Iterator iter = h.values().iterator(); while (iter.hasNext()) { Object elem = iter.next(); if (elem instanceof Method) { v.addElement(elem); } else { Vector v1 = (Vector) elem; for (int i = 0; i < v1.size(); i++) { v.addElement(v1.elementAt(i)); } } } return v; }
public Object getProperty (final Context context, final Object instance, final Object[] names, int start, int end) throws PropertyException { String propName; Object nextPropValue = null; Accessor acc = null; if (names[start] instanceof String) { propName = (String) names[start]; } else if (names[start] instanceof PropertyMethod) { PropertyMethod pm = (PropertyMethod) names[start]; propName = pm.getName(); acc = (Accessor) _directAccessors.get(propName); Object[] args = pm.getArguments(context); if (acc == null) { if (isMethodRestricted(instance.getClass(), propName)) throw new PropertyException.RestrictedMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); }
public Object getProperty(final Context context, final Object instance, final Object[] names, int start, int end) throws PropertyException { String propName; Object nextPropValue = null; Accessor acc = null; if (names[start] instanceof String) { propName = (String) names[start]; } else if (names[start] instanceof PropertyMethod) { PropertyMethod pm = (PropertyMethod) names[start]; propName = pm.getName(); acc = (Accessor) _directAccessors.get(propName); Object[] args = pm.getArguments(context); if (acc == null) { if (isMethodRestricted(instance.getClass(), propName)) throw new PropertyException.RestrictedMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } try { nextPropValue = acc.get(instance, args); start++; } catch (NoSuchMethodException e) { throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } } else { propName = names[start].toString(); } if (acc == null) { acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) {
public Object getProperty (final Context context, final Object instance, final Object[] names, int start, int end) throws PropertyException { String propName; Object nextPropValue = null; Accessor acc = null; if (names[start] instanceof String) { propName = (String) names[start]; } else if (names[start] instanceof PropertyMethod) { PropertyMethod pm = (PropertyMethod) names[start]; propName = pm.getName(); acc = (Accessor) _directAccessors.get(propName); Object[] args = pm.getArguments(context); if (acc == null) { if (isMethodRestricted(instance.getClass(), propName)) throw new PropertyException.RestrictedMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } try { nextPropValue = acc.get(instance, args); start++; } catch (NoSuchMethodException e) { throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } } else { propName = names[start].toString(); } // unary? if (acc == null) { acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { try { nextPropValue = acc.get(instance); start++; } catch (NoSuchMethodException e) { acc = null; } } } // binary? if (acc == null) { acc = (Accessor) _binaryAccessors.get(propName);// if ((acc != null) && ((start + 1) <= end)) if ((acc != null) && ((start + 1) <= names.length)) { try { nextPropValue = acc.get(instance, (String) names[start + 1]); start += 2; } catch (NoSuchMethodException e) { acc = null; } catch (ClassCastException e) { // names[start + 1] was not a String, just move on // this catch is more efficient than using instanceof // since 90% of the time it really will be a string acc = null; } } else { acc = null; } } // hash? if (acc == null) { acc = _hashAccessor; try { if (acc != null) { nextPropValue = acc.get(instance, propName); start++; } } catch (NoSuchMethodException e) { acc = null; } } if (acc == null) { // user tried to access a property of a property that doesn't exist // ex: $TestObject.FirstName.NotThere // check if object is restricted if (isMethodRestricted(instance.getClass(), "get" + propName) || isMethodRestricted(instance.getClass(), "set" + propName)) throw new PropertyException.RestrictedPropertyException( propName, fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchPropertyException( propName, fillInName(names, start), instance.getClass().getName()); } if ( start <= end) { try { return _cache.getOperator(nextPropValue) .getProperty(context, nextPropValue, names, start, end); } catch (NullPointerException e) { // $Foo.getNull().SomeProperty is what makes this happen throw new PropertyException("$" + fillInName(names, start) + " is null. Cannot access ." + names[end]); } } else { return nextPropValue; } }
nextPropValue = acc.get(instance, args); start++;
nextPropValue = acc.get(instance); start++;
public Object getProperty (final Context context, final Object instance, final Object[] names, int start, int end) throws PropertyException { String propName; Object nextPropValue = null; Accessor acc = null; if (names[start] instanceof String) { propName = (String) names[start]; } else if (names[start] instanceof PropertyMethod) { PropertyMethod pm = (PropertyMethod) names[start]; propName = pm.getName(); acc = (Accessor) _directAccessors.get(propName); Object[] args = pm.getArguments(context); if (acc == null) { if (isMethodRestricted(instance.getClass(), propName)) throw new PropertyException.RestrictedMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } try { nextPropValue = acc.get(instance, args); start++; } catch (NoSuchMethodException e) { throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } } else { propName = names[start].toString(); } // unary? if (acc == null) { acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { try { nextPropValue = acc.get(instance); start++; } catch (NoSuchMethodException e) { acc = null; } } } // binary? if (acc == null) { acc = (Accessor) _binaryAccessors.get(propName);// if ((acc != null) && ((start + 1) <= end)) if ((acc != null) && ((start + 1) <= names.length)) { try { nextPropValue = acc.get(instance, (String) names[start + 1]); start += 2; } catch (NoSuchMethodException e) { acc = null; } catch (ClassCastException e) { // names[start + 1] was not a String, just move on // this catch is more efficient than using instanceof // since 90% of the time it really will be a string acc = null; } } else { acc = null; } } // hash? if (acc == null) { acc = _hashAccessor; try { if (acc != null) { nextPropValue = acc.get(instance, propName); start++; } } catch (NoSuchMethodException e) { acc = null; } } if (acc == null) { // user tried to access a property of a property that doesn't exist // ex: $TestObject.FirstName.NotThere // check if object is restricted if (isMethodRestricted(instance.getClass(), "get" + propName) || isMethodRestricted(instance.getClass(), "set" + propName)) throw new PropertyException.RestrictedPropertyException( propName, fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchPropertyException( propName, fillInName(names, start), instance.getClass().getName()); } if ( start <= end) { try { return _cache.getOperator(nextPropValue) .getProperty(context, nextPropValue, names, start, end); } catch (NullPointerException e) { // $Foo.getNull().SomeProperty is what makes this happen throw new PropertyException("$" + fillInName(names, start) + " is null. Cannot access ." + names[end]); } } else { return nextPropValue; } }
throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName());
acc = null;
public Object getProperty (final Context context, final Object instance, final Object[] names, int start, int end) throws PropertyException { String propName; Object nextPropValue = null; Accessor acc = null; if (names[start] instanceof String) { propName = (String) names[start]; } else if (names[start] instanceof PropertyMethod) { PropertyMethod pm = (PropertyMethod) names[start]; propName = pm.getName(); acc = (Accessor) _directAccessors.get(propName); Object[] args = pm.getArguments(context); if (acc == null) { if (isMethodRestricted(instance.getClass(), propName)) throw new PropertyException.RestrictedMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } try { nextPropValue = acc.get(instance, args); start++; } catch (NoSuchMethodException e) { throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } } else { propName = names[start].toString(); } // unary? if (acc == null) { acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { try { nextPropValue = acc.get(instance); start++; } catch (NoSuchMethodException e) { acc = null; } } } // binary? if (acc == null) { acc = (Accessor) _binaryAccessors.get(propName);// if ((acc != null) && ((start + 1) <= end)) if ((acc != null) && ((start + 1) <= names.length)) { try { nextPropValue = acc.get(instance, (String) names[start + 1]); start += 2; } catch (NoSuchMethodException e) { acc = null; } catch (ClassCastException e) { // names[start + 1] was not a String, just move on // this catch is more efficient than using instanceof // since 90% of the time it really will be a string acc = null; } } else { acc = null; } } // hash? if (acc == null) { acc = _hashAccessor; try { if (acc != null) { nextPropValue = acc.get(instance, propName); start++; } } catch (NoSuchMethodException e) { acc = null; } } if (acc == null) { // user tried to access a property of a property that doesn't exist // ex: $TestObject.FirstName.NotThere // check if object is restricted if (isMethodRestricted(instance.getClass(), "get" + propName) || isMethodRestricted(instance.getClass(), "set" + propName)) throw new PropertyException.RestrictedPropertyException( propName, fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchPropertyException( propName, fillInName(names, start), instance.getClass().getName()); } if ( start <= end) { try { return _cache.getOperator(nextPropValue) .getProperty(context, nextPropValue, names, start, end); } catch (NullPointerException e) { // $Foo.getNull().SomeProperty is what makes this happen throw new PropertyException("$" + fillInName(names, start) + " is null. Cannot access ." + names[end]); } } else { return nextPropValue; } }
} else { propName = names[start].toString(); } if (acc == null) { acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { try { nextPropValue = acc.get(instance); start++; } catch (NoSuchMethodException e) { acc = null; } } } if (acc == null) { acc = (Accessor) _binaryAccessors.get(propName); if ((acc != null) && ((start + 1) <= names.length)) { try { nextPropValue = acc.get(instance, (String) names[start + 1]); start += 2; } catch (NoSuchMethodException e) { acc = null; } catch (ClassCastException e) { acc = null; } } else { acc = null; } } if (acc == null) { acc = _hashAccessor;
} } if (acc == null) { acc = (Accessor) _binaryAccessors.get(propName); if ((acc != null) && ((start + 1) <= names.length)) {
public Object getProperty (final Context context, final Object instance, final Object[] names, int start, int end) throws PropertyException { String propName; Object nextPropValue = null; Accessor acc = null; if (names[start] instanceof String) { propName = (String) names[start]; } else if (names[start] instanceof PropertyMethod) { PropertyMethod pm = (PropertyMethod) names[start]; propName = pm.getName(); acc = (Accessor) _directAccessors.get(propName); Object[] args = pm.getArguments(context); if (acc == null) { if (isMethodRestricted(instance.getClass(), propName)) throw new PropertyException.RestrictedMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } try { nextPropValue = acc.get(instance, args); start++; } catch (NoSuchMethodException e) { throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } } else { propName = names[start].toString(); } // unary? if (acc == null) { acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { try { nextPropValue = acc.get(instance); start++; } catch (NoSuchMethodException e) { acc = null; } } } // binary? if (acc == null) { acc = (Accessor) _binaryAccessors.get(propName);// if ((acc != null) && ((start + 1) <= end)) if ((acc != null) && ((start + 1) <= names.length)) { try { nextPropValue = acc.get(instance, (String) names[start + 1]); start += 2; } catch (NoSuchMethodException e) { acc = null; } catch (ClassCastException e) { // names[start + 1] was not a String, just move on // this catch is more efficient than using instanceof // since 90% of the time it really will be a string acc = null; } } else { acc = null; } } // hash? if (acc == null) { acc = _hashAccessor; try { if (acc != null) { nextPropValue = acc.get(instance, propName); start++; } } catch (NoSuchMethodException e) { acc = null; } } if (acc == null) { // user tried to access a property of a property that doesn't exist // ex: $TestObject.FirstName.NotThere // check if object is restricted if (isMethodRestricted(instance.getClass(), "get" + propName) || isMethodRestricted(instance.getClass(), "set" + propName)) throw new PropertyException.RestrictedPropertyException( propName, fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchPropertyException( propName, fillInName(names, start), instance.getClass().getName()); } if ( start <= end) { try { return _cache.getOperator(nextPropValue) .getProperty(context, nextPropValue, names, start, end); } catch (NullPointerException e) { // $Foo.getNull().SomeProperty is what makes this happen throw new PropertyException("$" + fillInName(names, start) + " is null. Cannot access ." + names[end]); } } else { return nextPropValue; } }
if (acc != null) { nextPropValue = acc.get(instance, propName); start++; }
nextPropValue = acc.get(instance, (String) names[start + 1]); start += 2;
public Object getProperty (final Context context, final Object instance, final Object[] names, int start, int end) throws PropertyException { String propName; Object nextPropValue = null; Accessor acc = null; if (names[start] instanceof String) { propName = (String) names[start]; } else if (names[start] instanceof PropertyMethod) { PropertyMethod pm = (PropertyMethod) names[start]; propName = pm.getName(); acc = (Accessor) _directAccessors.get(propName); Object[] args = pm.getArguments(context); if (acc == null) { if (isMethodRestricted(instance.getClass(), propName)) throw new PropertyException.RestrictedMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } try { nextPropValue = acc.get(instance, args); start++; } catch (NoSuchMethodException e) { throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } } else { propName = names[start].toString(); } // unary? if (acc == null) { acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { try { nextPropValue = acc.get(instance); start++; } catch (NoSuchMethodException e) { acc = null; } } } // binary? if (acc == null) { acc = (Accessor) _binaryAccessors.get(propName);// if ((acc != null) && ((start + 1) <= end)) if ((acc != null) && ((start + 1) <= names.length)) { try { nextPropValue = acc.get(instance, (String) names[start + 1]); start += 2; } catch (NoSuchMethodException e) { acc = null; } catch (ClassCastException e) { // names[start + 1] was not a String, just move on // this catch is more efficient than using instanceof // since 90% of the time it really will be a string acc = null; } } else { acc = null; } } // hash? if (acc == null) { acc = _hashAccessor; try { if (acc != null) { nextPropValue = acc.get(instance, propName); start++; } } catch (NoSuchMethodException e) { acc = null; } } if (acc == null) { // user tried to access a property of a property that doesn't exist // ex: $TestObject.FirstName.NotThere // check if object is restricted if (isMethodRestricted(instance.getClass(), "get" + propName) || isMethodRestricted(instance.getClass(), "set" + propName)) throw new PropertyException.RestrictedPropertyException( propName, fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchPropertyException( propName, fillInName(names, start), instance.getClass().getName()); } if ( start <= end) { try { return _cache.getOperator(nextPropValue) .getProperty(context, nextPropValue, names, start, end); } catch (NullPointerException e) { // $Foo.getNull().SomeProperty is what makes this happen throw new PropertyException("$" + fillInName(names, start) + " is null. Cannot access ." + names[end]); } } else { return nextPropValue; } }
} if (acc == null) { if (isMethodRestricted(instance.getClass(), "get" + propName) || isMethodRestricted(instance.getClass(), "set" + propName)) throw new PropertyException.RestrictedPropertyException( propName, fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchPropertyException( propName, fillInName(names, start), instance.getClass().getName()); } if ( start <= end) { try
catch (ClassCastException e)
public Object getProperty (final Context context, final Object instance, final Object[] names, int start, int end) throws PropertyException { String propName; Object nextPropValue = null; Accessor acc = null; if (names[start] instanceof String) { propName = (String) names[start]; } else if (names[start] instanceof PropertyMethod) { PropertyMethod pm = (PropertyMethod) names[start]; propName = pm.getName(); acc = (Accessor) _directAccessors.get(propName); Object[] args = pm.getArguments(context); if (acc == null) { if (isMethodRestricted(instance.getClass(), propName)) throw new PropertyException.RestrictedMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } try { nextPropValue = acc.get(instance, args); start++; } catch (NoSuchMethodException e) { throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } } else { propName = names[start].toString(); } // unary? if (acc == null) { acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { try { nextPropValue = acc.get(instance); start++; } catch (NoSuchMethodException e) { acc = null; } } } // binary? if (acc == null) { acc = (Accessor) _binaryAccessors.get(propName);// if ((acc != null) && ((start + 1) <= end)) if ((acc != null) && ((start + 1) <= names.length)) { try { nextPropValue = acc.get(instance, (String) names[start + 1]); start += 2; } catch (NoSuchMethodException e) { acc = null; } catch (ClassCastException e) { // names[start + 1] was not a String, just move on // this catch is more efficient than using instanceof // since 90% of the time it really will be a string acc = null; } } else { acc = null; } } // hash? if (acc == null) { acc = _hashAccessor; try { if (acc != null) { nextPropValue = acc.get(instance, propName); start++; } } catch (NoSuchMethodException e) { acc = null; } } if (acc == null) { // user tried to access a property of a property that doesn't exist // ex: $TestObject.FirstName.NotThere // check if object is restricted if (isMethodRestricted(instance.getClass(), "get" + propName) || isMethodRestricted(instance.getClass(), "set" + propName)) throw new PropertyException.RestrictedPropertyException( propName, fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchPropertyException( propName, fillInName(names, start), instance.getClass().getName()); } if ( start <= end) { try { return _cache.getOperator(nextPropValue) .getProperty(context, nextPropValue, names, start, end); } catch (NullPointerException e) { // $Foo.getNull().SomeProperty is what makes this happen throw new PropertyException("$" + fillInName(names, start) + " is null. Cannot access ." + names[end]); } } else { return nextPropValue; } }
return _cache.getOperator(nextPropValue) .getProperty(context, nextPropValue, names, start, end);
acc = null;
public Object getProperty (final Context context, final Object instance, final Object[] names, int start, int end) throws PropertyException { String propName; Object nextPropValue = null; Accessor acc = null; if (names[start] instanceof String) { propName = (String) names[start]; } else if (names[start] instanceof PropertyMethod) { PropertyMethod pm = (PropertyMethod) names[start]; propName = pm.getName(); acc = (Accessor) _directAccessors.get(propName); Object[] args = pm.getArguments(context); if (acc == null) { if (isMethodRestricted(instance.getClass(), propName)) throw new PropertyException.RestrictedMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } try { nextPropValue = acc.get(instance, args); start++; } catch (NoSuchMethodException e) { throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } } else { propName = names[start].toString(); } // unary? if (acc == null) { acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { try { nextPropValue = acc.get(instance); start++; } catch (NoSuchMethodException e) { acc = null; } } } // binary? if (acc == null) { acc = (Accessor) _binaryAccessors.get(propName);// if ((acc != null) && ((start + 1) <= end)) if ((acc != null) && ((start + 1) <= names.length)) { try { nextPropValue = acc.get(instance, (String) names[start + 1]); start += 2; } catch (NoSuchMethodException e) { acc = null; } catch (ClassCastException e) { // names[start + 1] was not a String, just move on // this catch is more efficient than using instanceof // since 90% of the time it really will be a string acc = null; } } else { acc = null; } } // hash? if (acc == null) { acc = _hashAccessor; try { if (acc != null) { nextPropValue = acc.get(instance, propName); start++; } } catch (NoSuchMethodException e) { acc = null; } } if (acc == null) { // user tried to access a property of a property that doesn't exist // ex: $TestObject.FirstName.NotThere // check if object is restricted if (isMethodRestricted(instance.getClass(), "get" + propName) || isMethodRestricted(instance.getClass(), "set" + propName)) throw new PropertyException.RestrictedPropertyException( propName, fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchPropertyException( propName, fillInName(names, start), instance.getClass().getName()); } if ( start <= end) { try { return _cache.getOperator(nextPropValue) .getProperty(context, nextPropValue, names, start, end); } catch (NullPointerException e) { // $Foo.getNull().SomeProperty is what makes this happen throw new PropertyException("$" + fillInName(names, start) + " is null. Cannot access ." + names[end]); } } else { return nextPropValue; } }
catch (NullPointerException e)
} else { acc = null; } } if (acc == null) { acc = _hashAccessor; try { if (acc != null)
public Object getProperty (final Context context, final Object instance, final Object[] names, int start, int end) throws PropertyException { String propName; Object nextPropValue = null; Accessor acc = null; if (names[start] instanceof String) { propName = (String) names[start]; } else if (names[start] instanceof PropertyMethod) { PropertyMethod pm = (PropertyMethod) names[start]; propName = pm.getName(); acc = (Accessor) _directAccessors.get(propName); Object[] args = pm.getArguments(context); if (acc == null) { if (isMethodRestricted(instance.getClass(), propName)) throw new PropertyException.RestrictedMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } try { nextPropValue = acc.get(instance, args); start++; } catch (NoSuchMethodException e) { throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } } else { propName = names[start].toString(); } // unary? if (acc == null) { acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { try { nextPropValue = acc.get(instance); start++; } catch (NoSuchMethodException e) { acc = null; } } } // binary? if (acc == null) { acc = (Accessor) _binaryAccessors.get(propName);// if ((acc != null) && ((start + 1) <= end)) if ((acc != null) && ((start + 1) <= names.length)) { try { nextPropValue = acc.get(instance, (String) names[start + 1]); start += 2; } catch (NoSuchMethodException e) { acc = null; } catch (ClassCastException e) { // names[start + 1] was not a String, just move on // this catch is more efficient than using instanceof // since 90% of the time it really will be a string acc = null; } } else { acc = null; } } // hash? if (acc == null) { acc = _hashAccessor; try { if (acc != null) { nextPropValue = acc.get(instance, propName); start++; } } catch (NoSuchMethodException e) { acc = null; } } if (acc == null) { // user tried to access a property of a property that doesn't exist // ex: $TestObject.FirstName.NotThere // check if object is restricted if (isMethodRestricted(instance.getClass(), "get" + propName) || isMethodRestricted(instance.getClass(), "set" + propName)) throw new PropertyException.RestrictedPropertyException( propName, fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchPropertyException( propName, fillInName(names, start), instance.getClass().getName()); } if ( start <= end) { try { return _cache.getOperator(nextPropValue) .getProperty(context, nextPropValue, names, start, end); } catch (NullPointerException e) { // $Foo.getNull().SomeProperty is what makes this happen throw new PropertyException("$" + fillInName(names, start) + " is null. Cannot access ." + names[end]); } } else { return nextPropValue; } }
throw new PropertyException("$" + fillInName(names, start) + " is null. Cannot access ." + names[end]);
nextPropValue = acc.get(instance, propName); start++;
public Object getProperty (final Context context, final Object instance, final Object[] names, int start, int end) throws PropertyException { String propName; Object nextPropValue = null; Accessor acc = null; if (names[start] instanceof String) { propName = (String) names[start]; } else if (names[start] instanceof PropertyMethod) { PropertyMethod pm = (PropertyMethod) names[start]; propName = pm.getName(); acc = (Accessor) _directAccessors.get(propName); Object[] args = pm.getArguments(context); if (acc == null) { if (isMethodRestricted(instance.getClass(), propName)) throw new PropertyException.RestrictedMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } try { nextPropValue = acc.get(instance, args); start++; } catch (NoSuchMethodException e) { throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } } else { propName = names[start].toString(); } // unary? if (acc == null) { acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { try { nextPropValue = acc.get(instance); start++; } catch (NoSuchMethodException e) { acc = null; } } } // binary? if (acc == null) { acc = (Accessor) _binaryAccessors.get(propName);// if ((acc != null) && ((start + 1) <= end)) if ((acc != null) && ((start + 1) <= names.length)) { try { nextPropValue = acc.get(instance, (String) names[start + 1]); start += 2; } catch (NoSuchMethodException e) { acc = null; } catch (ClassCastException e) { // names[start + 1] was not a String, just move on // this catch is more efficient than using instanceof // since 90% of the time it really will be a string acc = null; } } else { acc = null; } } // hash? if (acc == null) { acc = _hashAccessor; try { if (acc != null) { nextPropValue = acc.get(instance, propName); start++; } } catch (NoSuchMethodException e) { acc = null; } } if (acc == null) { // user tried to access a property of a property that doesn't exist // ex: $TestObject.FirstName.NotThere // check if object is restricted if (isMethodRestricted(instance.getClass(), "get" + propName) || isMethodRestricted(instance.getClass(), "set" + propName)) throw new PropertyException.RestrictedPropertyException( propName, fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchPropertyException( propName, fillInName(names, start), instance.getClass().getName()); } if ( start <= end) { try { return _cache.getOperator(nextPropValue) .getProperty(context, nextPropValue, names, start, end); } catch (NullPointerException e) { // $Foo.getNull().SomeProperty is what makes this happen throw new PropertyException("$" + fillInName(names, start) + " is null. Cannot access ." + names[end]); } } else { return nextPropValue; } }
} else { return nextPropValue; } }
} catch (NoSuchMethodException e) { acc = null; } } if (acc == null) { if (isMethodRestricted(instance.getClass(), "get" + propName) || isMethodRestricted(instance.getClass(), "set" + propName)) throw new PropertyException.RestrictedPropertyException( propName, fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchPropertyException( propName, fillInName(names, start), instance.getClass().getName()); } if ( start <= end) { try { return _cache.getOperator(nextPropValue) .getProperty(context, nextPropValue, names, start, end); } catch (NullPointerException e) { throw new PropertyException("$" + fillInName(names, start) + " is null. Cannot access ." + names[end]); } } else { return nextPropValue; } }
public Object getProperty (final Context context, final Object instance, final Object[] names, int start, int end) throws PropertyException { String propName; Object nextPropValue = null; Accessor acc = null; if (names[start] instanceof String) { propName = (String) names[start]; } else if (names[start] instanceof PropertyMethod) { PropertyMethod pm = (PropertyMethod) names[start]; propName = pm.getName(); acc = (Accessor) _directAccessors.get(propName); Object[] args = pm.getArguments(context); if (acc == null) { if (isMethodRestricted(instance.getClass(), propName)) throw new PropertyException.RestrictedMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } try { nextPropValue = acc.get(instance, args); start++; } catch (NoSuchMethodException e) { throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } } else { propName = names[start].toString(); } // unary? if (acc == null) { acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { try { nextPropValue = acc.get(instance); start++; } catch (NoSuchMethodException e) { acc = null; } } } // binary? if (acc == null) { acc = (Accessor) _binaryAccessors.get(propName);// if ((acc != null) && ((start + 1) <= end)) if ((acc != null) && ((start + 1) <= names.length)) { try { nextPropValue = acc.get(instance, (String) names[start + 1]); start += 2; } catch (NoSuchMethodException e) { acc = null; } catch (ClassCastException e) { // names[start + 1] was not a String, just move on // this catch is more efficient than using instanceof // since 90% of the time it really will be a string acc = null; } } else { acc = null; } } // hash? if (acc == null) { acc = _hashAccessor; try { if (acc != null) { nextPropValue = acc.get(instance, propName); start++; } } catch (NoSuchMethodException e) { acc = null; } } if (acc == null) { // user tried to access a property of a property that doesn't exist // ex: $TestObject.FirstName.NotThere // check if object is restricted if (isMethodRestricted(instance.getClass(), "get" + propName) || isMethodRestricted(instance.getClass(), "set" + propName)) throw new PropertyException.RestrictedPropertyException( propName, fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchPropertyException( propName, fillInName(names, start), instance.getClass().getName()); } if ( start <= end) { try { return _cache.getOperator(nextPropValue) .getProperty(context, nextPropValue, names, start, end); } catch (NullPointerException e) { // $Foo.getNull().SomeProperty is what makes this happen throw new PropertyException("$" + fillInName(names, start) + " is null. Cannot access ." + names[end]); } } else { return nextPropValue; } }
boolean isMethodRestricted (Class c, String name) { Map restrictedClassMap = _cache.getRestrictedClassMap(); if (!restrictedClassMap.containsKey(c)) { return false; } else { Method[] meths = c.getMethods(); for (int i = 0; i < meths.length; i++)
boolean isMethodRestricted(Class c, String name) { Map restrictedClassMap = _cache.getRestrictedClassMap(); if (!restrictedClassMap.containsKey(c)) { return false; } else { Method[] meths = c.getMethods(); for (int i = 0; i < meths.length; i++) { if (meths[i].getName().equals(name))
boolean isMethodRestricted (Class c, String name) { // check if object is restricted Map restrictedClassMap = _cache.getRestrictedClassMap(); if (!restrictedClassMap.containsKey(c)) { return false; // there are no restrictions on this class } else { // restricted class, check method Method[] meths = c.getMethods(); for (int i = 0; i < meths.length; i++) { if (meths[i].getName().equals(name)) { // check if method is explicitly allowed List l = (List) restrictedClassMap.get(c); if (l != null) return !l.contains(name); } } } return false; }
if (meths[i].getName().equals(name)) { List l = (List) restrictedClassMap.get(c); if (l != null) return !l.contains(name); }
List l = (List) restrictedClassMap.get(c); if (l != null) return !l.contains(name);
boolean isMethodRestricted (Class c, String name) { // check if object is restricted Map restrictedClassMap = _cache.getRestrictedClassMap(); if (!restrictedClassMap.containsKey(c)) { return false; // there are no restrictions on this class } else { // restricted class, check method Method[] meths = c.getMethods(); for (int i = 0; i < meths.length; i++) { if (meths[i].getName().equals(name)) { // check if method is explicitly allowed List l = (List) restrictedClassMap.get(c); if (l != null) return !l.contains(name); } } } return false; }
} return false; }
} } return false; }
boolean isMethodRestricted (Class c, String name) { // check if object is restricted Map restrictedClassMap = _cache.getRestrictedClassMap(); if (!restrictedClassMap.containsKey(c)) { return false; // there are no restrictions on this class } else { // restricted class, check method Method[] meths = c.getMethods(); for (int i = 0; i < meths.length; i++) { if (meths[i].getName().equals(name)) { // check if method is explicitly allowed List l = (List) restrictedClassMap.get(c); if (l != null) return !l.contains(name); } } } return false; }
private int precedes (Class[] lhs, Class[] rhs) { if (lhs.length == rhs.length) { for (int i = 0; i < lhs.length; i++)
private int precedes(Class[] lhs, Class[] rhs) { if (lhs.length == rhs.length) { for (int i = 0; i < lhs.length; i++) { if (!rhs[i].equals(lhs[i]))
private int precedes (Class[] lhs, Class[] rhs) { if (lhs.length == rhs.length) { for (int i = 0; i < lhs.length; i++) { if (!rhs[i].equals(lhs[i])) { if (lhs[i].isAssignableFrom(rhs[i])) { // rhs is more specific than lhs return 1; } if (rhs[i].isAssignableFrom(lhs[i])) { // lhs is more specific than rhs return -1; } // not related by inheritance, put lhs later on return 1; } } return 0; // all the same } else { return (lhs.length < rhs.length) ? -1 : 1; } }
if (!rhs[i].equals(lhs[i])) { if (lhs[i].isAssignableFrom(rhs[i])) { return 1; } if (rhs[i].isAssignableFrom(lhs[i])) { return -1; } return 1; }
if (lhs[i].isAssignableFrom(rhs[i])) { return 1; } if (rhs[i].isAssignableFrom(lhs[i])) { return -1; } return 1;
private int precedes (Class[] lhs, Class[] rhs) { if (lhs.length == rhs.length) { for (int i = 0; i < lhs.length; i++) { if (!rhs[i].equals(lhs[i])) { if (lhs[i].isAssignableFrom(rhs[i])) { // rhs is more specific than lhs return 1; } if (rhs[i].isAssignableFrom(lhs[i])) { // lhs is more specific than rhs return -1; } // not related by inheritance, put lhs later on return 1; } } return 0; // all the same } else { return (lhs.length < rhs.length) ? -1 : 1; } }
return 0; } else { return (lhs.length < rhs.length) ? -1 : 1; } }
} return 0; } else { return (lhs.length < rhs.length) ? -1 : 1; } }
private int precedes (Class[] lhs, Class[] rhs) { if (lhs.length == rhs.length) { for (int i = 0; i < lhs.length; i++) { if (!rhs[i].equals(lhs[i])) { if (lhs[i].isAssignableFrom(rhs[i])) { // rhs is more specific than lhs return 1; } if (rhs[i].isAssignableFrom(lhs[i])) { // lhs is more specific than rhs return -1; } // not related by inheritance, put lhs later on return 1; } } return 0; // all the same } else { return (lhs.length < rhs.length) ? -1 : 1; } }
public boolean setProperty (Context context, Object instance, Object[] names, Object value, int pos) throws PropertyException, NoSuchMethodException { int binPos = names.length - 2; if (pos < binPos) { Object grandparent = getProperty(context, instance, names, pos, binPos - 1); PropertyOperator po = _cache.getOperator(grandparent); return po.setProperty(context, grandparent, names, value, binPos); } if (pos == binPos) { Object parent = null;
public boolean setProperty(Context context, Object instance, Object[] names, Object value, int pos) throws PropertyException, NoSuchMethodException { int binPos = names.length - 2; if (pos < binPos) { Object grandparent = getProperty(context, instance, names, pos, binPos - 1); PropertyOperator po = _cache.getOperator(grandparent); return po.setProperty(context, grandparent, names, value, binPos); } if (pos == binPos) { Object parent = null; try { parent = getProperty(context, instance, names, pos, pos); if (parent != null) { PropertyOperator po = _cache.getOperator(parent); if (po.setProperty(context, parent, names, value, pos + 1)) { return true; } } } catch (NoSuchMethodException e) { } Accessor binOp = (Accessor) _binaryAccessors.get(names[pos]); if (binOp != null) {
public boolean setProperty (Context context, Object instance, Object[] names, Object value, int pos) throws PropertyException, NoSuchMethodException { // names[pos] is what we could set from here int binPos = names.length - 2; // if we're not yet at the binary-settable parent, go there if (pos < binPos) { Object grandparent = getProperty(context, instance, names, pos, binPos - 1); PropertyOperator po = _cache.getOperator(grandparent); return po.setProperty(context, grandparent, names, value, binPos); } // if we're at the binary-settable parent, try direct first if (pos == binPos) { // try direct -- move to direct parent and try from there Object parent = null; try { parent = getProperty(context, instance, names, pos, pos); if (parent != null) { PropertyOperator po = _cache.getOperator(parent); if (po.setProperty(context, parent, names, value, pos + 1)) { return true; } } } catch (NoSuchMethodException e) { // oh well, keep trying: XXX this makes binOp expensive } // if direct failed, try binary Accessor binOp = (Accessor) _binaryAccessors.get(names[pos]); if (binOp != null) { try { return binOp.set(instance, (String) names[pos + 1], value); } catch (ClassCastException e) { // names[pos+1] was not a string, just move on return false; } catch (NoSuchMethodException e) { return false; } } return false; } // we're the direct parent, use unaryOp or hash method Accessor unaryOp = (Accessor) _unaryAccessors.get(names[pos]); try { if ((unaryOp != null) && unaryOp.set(instance, value)) { return true; } if (_hashAccessor != null) { return _hashAccessor.set(instance, (String) names[pos], value); } } catch (NoSuchMethodException e) { // fall through } catch (ClassCastException e) { // names[pos] was not a string, fall through } return false; }
parent = getProperty(context, instance, names, pos, pos); if (parent != null) { PropertyOperator po = _cache.getOperator(parent); if (po.setProperty(context, parent, names, value, pos + 1)) { return true; } }
return binOp.set(instance, (String) names[pos + 1], value); } catch (ClassCastException e) { return false;
public boolean setProperty (Context context, Object instance, Object[] names, Object value, int pos) throws PropertyException, NoSuchMethodException { // names[pos] is what we could set from here int binPos = names.length - 2; // if we're not yet at the binary-settable parent, go there if (pos < binPos) { Object grandparent = getProperty(context, instance, names, pos, binPos - 1); PropertyOperator po = _cache.getOperator(grandparent); return po.setProperty(context, grandparent, names, value, binPos); } // if we're at the binary-settable parent, try direct first if (pos == binPos) { // try direct -- move to direct parent and try from there Object parent = null; try { parent = getProperty(context, instance, names, pos, pos); if (parent != null) { PropertyOperator po = _cache.getOperator(parent); if (po.setProperty(context, parent, names, value, pos + 1)) { return true; } } } catch (NoSuchMethodException e) { // oh well, keep trying: XXX this makes binOp expensive } // if direct failed, try binary Accessor binOp = (Accessor) _binaryAccessors.get(names[pos]); if (binOp != null) { try { return binOp.set(instance, (String) names[pos + 1], value); } catch (ClassCastException e) { // names[pos+1] was not a string, just move on return false; } catch (NoSuchMethodException e) { return false; } } return false; } // we're the direct parent, use unaryOp or hash method Accessor unaryOp = (Accessor) _unaryAccessors.get(names[pos]); try { if ((unaryOp != null) && unaryOp.set(instance, value)) { return true; } if (_hashAccessor != null) { return _hashAccessor.set(instance, (String) names[pos], value); } } catch (NoSuchMethodException e) { // fall through } catch (ClassCastException e) { // names[pos] was not a string, fall through } return false; }
return false;
public boolean setProperty (Context context, Object instance, Object[] names, Object value, int pos) throws PropertyException, NoSuchMethodException { // names[pos] is what we could set from here int binPos = names.length - 2; // if we're not yet at the binary-settable parent, go there if (pos < binPos) { Object grandparent = getProperty(context, instance, names, pos, binPos - 1); PropertyOperator po = _cache.getOperator(grandparent); return po.setProperty(context, grandparent, names, value, binPos); } // if we're at the binary-settable parent, try direct first if (pos == binPos) { // try direct -- move to direct parent and try from there Object parent = null; try { parent = getProperty(context, instance, names, pos, pos); if (parent != null) { PropertyOperator po = _cache.getOperator(parent); if (po.setProperty(context, parent, names, value, pos + 1)) { return true; } } } catch (NoSuchMethodException e) { // oh well, keep trying: XXX this makes binOp expensive } // if direct failed, try binary Accessor binOp = (Accessor) _binaryAccessors.get(names[pos]); if (binOp != null) { try { return binOp.set(instance, (String) names[pos + 1], value); } catch (ClassCastException e) { // names[pos+1] was not a string, just move on return false; } catch (NoSuchMethodException e) { return false; } } return false; } // we're the direct parent, use unaryOp or hash method Accessor unaryOp = (Accessor) _unaryAccessors.get(names[pos]); try { if ((unaryOp != null) && unaryOp.set(instance, value)) { return true; } if (_hashAccessor != null) { return _hashAccessor.set(instance, (String) names[pos], value); } } catch (NoSuchMethodException e) { // fall through } catch (ClassCastException e) { // names[pos] was not a string, fall through } return false; }
Accessor binOp = (Accessor) _binaryAccessors.get(names[pos]); if (binOp != null) { try { return binOp.set(instance, (String) names[pos + 1], value); } catch (ClassCastException e) { return false; } catch (NoSuchMethodException e) { return false; } } return false; } Accessor unaryOp = (Accessor) _unaryAccessors.get(names[pos]); try { if ((unaryOp != null) && unaryOp.set(instance, value)) { return true; } if (_hashAccessor != null) { return _hashAccessor.set(instance, (String) names[pos], value); } } catch (NoSuchMethodException e) { } catch (ClassCastException e) { } return false; }
} return false; } Accessor unaryOp = (Accessor) _unaryAccessors.get(names[pos]); try { if ((unaryOp != null) && unaryOp.set(instance, value)) { return true; } if (_hashAccessor != null) { return _hashAccessor.set(instance, (String) names[pos], value); } } catch (NoSuchMethodException e) { } catch (ClassCastException e) { } return false; }
public boolean setProperty (Context context, Object instance, Object[] names, Object value, int pos) throws PropertyException, NoSuchMethodException { // names[pos] is what we could set from here int binPos = names.length - 2; // if we're not yet at the binary-settable parent, go there if (pos < binPos) { Object grandparent = getProperty(context, instance, names, pos, binPos - 1); PropertyOperator po = _cache.getOperator(grandparent); return po.setProperty(context, grandparent, names, value, binPos); } // if we're at the binary-settable parent, try direct first if (pos == binPos) { // try direct -- move to direct parent and try from there Object parent = null; try { parent = getProperty(context, instance, names, pos, pos); if (parent != null) { PropertyOperator po = _cache.getOperator(parent); if (po.setProperty(context, parent, names, value, pos + 1)) { return true; } } } catch (NoSuchMethodException e) { // oh well, keep trying: XXX this makes binOp expensive } // if direct failed, try binary Accessor binOp = (Accessor) _binaryAccessors.get(names[pos]); if (binOp != null) { try { return binOp.set(instance, (String) names[pos + 1], value); } catch (ClassCastException e) { // names[pos+1] was not a string, just move on return false; } catch (NoSuchMethodException e) { return false; } } return false; } // we're the direct parent, use unaryOp or hash method Accessor unaryOp = (Accessor) _unaryAccessors.get(names[pos]); try { if ((unaryOp != null) && unaryOp.set(instance, value)) { return true; } if (_hashAccessor != null) { return _hashAccessor.set(instance, (String) names[pos], value); } } catch (NoSuchMethodException e) { // fall through } catch (ClassCastException e) { // names[pos] was not a string, fall through } return false; }
final public void init (Broker b, Settings config) throws InitException { String cacheManager; _log = b.getLog("resource", "Object loading and caching"); cacheManager = b.getSetting("PropertyOperator.CacheManager"); if (cacheManager == null || cacheManager.equals("")) { _log.info("CachingProvider: No cache manager specified for PropertyOperator, using SimpleCacheManager");
final public void init(Broker b, Settings config) throws InitException { String cacheManager; _log = b.getLog("resource", "Object loading and caching"); cacheManager = b.getSetting("PropertyOperator.CacheManager"); if (cacheManager == null || cacheManager.equals("")) { _log.info("CachingProvider: No cache manager specified for PropertyOperator, using SimpleCacheManager"); _cache = new SimpleCacheManager(); } else { try { _cache = (CacheManager) b.classForName(cacheManager).newInstance(); } catch (Exception e) { _log.warning("Unable to load cache manager " + cacheManager + " for PropertyOperator, using SimpleCacheManager. Reason:\n" + e);
final public void init (Broker b, Settings config) throws InitException { String cacheManager; _log = b.getLog("resource", "Object loading and caching"); cacheManager = b.getSetting("PropertyOperator.CacheManager"); if (cacheManager == null || cacheManager.equals("")) { _log.info("CachingProvider: No cache manager specified for PropertyOperator, using SimpleCacheManager"); _cache = new SimpleCacheManager(); } else { try { _cache = (CacheManager) b.classForName(cacheManager).newInstance(); } catch (Exception e) { _log.warning("Unable to load cache manager " + cacheManager + " for PropertyOperator, using SimpleCacheManager. Reason:\n" + e); _cache = new SimpleCacheManager(); } } _cache.init(b, config, "PropertyOperator"); _restrictedClasses = new HashMap(11); String restrictList = b.getSetting("RestrictedClasses"); if (restrictList != null) { StringTokenizer stok = new StringTokenizer(restrictList, ","); while (stok.hasMoreTokens()) { String className = stok.nextToken(); try { Class c = Class.forName(className); String okMethList = b.getSetting("RestrictedClasses.AllowedMethods." + className); ArrayList okMeths = null; if (okMethList != null) { okMeths = new ArrayList(20); StringTokenizer stok2 = new StringTokenizer(okMethList, ","); while (stok2.hasMoreTokens()) { okMeths.add(stok2.nextToken()); } } _restrictedClasses.put(c, okMeths); } catch (Exception e) { _log.error("Configuration error: restricted class " + className + " cannot be loaded", e); } } } }
} else {
} } _cache.init(b, config, "PropertyOperator"); _restrictedClasses = new HashMap(11); String restrictList = b.getSetting("RestrictedClasses"); if (restrictList != null) { StringTokenizer stok = new StringTokenizer(restrictList, ","); while (stok.hasMoreTokens()) { String className = stok.nextToken();
final public void init (Broker b, Settings config) throws InitException { String cacheManager; _log = b.getLog("resource", "Object loading and caching"); cacheManager = b.getSetting("PropertyOperator.CacheManager"); if (cacheManager == null || cacheManager.equals("")) { _log.info("CachingProvider: No cache manager specified for PropertyOperator, using SimpleCacheManager"); _cache = new SimpleCacheManager(); } else { try { _cache = (CacheManager) b.classForName(cacheManager).newInstance(); } catch (Exception e) { _log.warning("Unable to load cache manager " + cacheManager + " for PropertyOperator, using SimpleCacheManager. Reason:\n" + e); _cache = new SimpleCacheManager(); } } _cache.init(b, config, "PropertyOperator"); _restrictedClasses = new HashMap(11); String restrictList = b.getSetting("RestrictedClasses"); if (restrictList != null) { StringTokenizer stok = new StringTokenizer(restrictList, ","); while (stok.hasMoreTokens()) { String className = stok.nextToken(); try { Class c = Class.forName(className); String okMethList = b.getSetting("RestrictedClasses.AllowedMethods." + className); ArrayList okMeths = null; if (okMethList != null) { okMeths = new ArrayList(20); StringTokenizer stok2 = new StringTokenizer(okMethList, ","); while (stok2.hasMoreTokens()) { okMeths.add(stok2.nextToken()); } } _restrictedClasses.put(c, okMeths); } catch (Exception e) { _log.error("Configuration error: restricted class " + className + " cannot be loaded", e); } } } }
_cache = (CacheManager) b.classForName(cacheManager).newInstance();
Class c = Class.forName(className); String okMethList = b.getSetting("RestrictedClasses.AllowedMethods." + className); ArrayList okMeths = null; if (okMethList != null) { okMeths = new ArrayList(20); StringTokenizer stok2 = new StringTokenizer(okMethList, ","); while (stok2.hasMoreTokens()) { okMeths.add(stok2.nextToken()); } } _restrictedClasses.put(c, okMeths);
final public void init (Broker b, Settings config) throws InitException { String cacheManager; _log = b.getLog("resource", "Object loading and caching"); cacheManager = b.getSetting("PropertyOperator.CacheManager"); if (cacheManager == null || cacheManager.equals("")) { _log.info("CachingProvider: No cache manager specified for PropertyOperator, using SimpleCacheManager"); _cache = new SimpleCacheManager(); } else { try { _cache = (CacheManager) b.classForName(cacheManager).newInstance(); } catch (Exception e) { _log.warning("Unable to load cache manager " + cacheManager + " for PropertyOperator, using SimpleCacheManager. Reason:\n" + e); _cache = new SimpleCacheManager(); } } _cache.init(b, config, "PropertyOperator"); _restrictedClasses = new HashMap(11); String restrictList = b.getSetting("RestrictedClasses"); if (restrictList != null) { StringTokenizer stok = new StringTokenizer(restrictList, ","); while (stok.hasMoreTokens()) { String className = stok.nextToken(); try { Class c = Class.forName(className); String okMethList = b.getSetting("RestrictedClasses.AllowedMethods." + className); ArrayList okMeths = null; if (okMethList != null) { okMeths = new ArrayList(20); StringTokenizer stok2 = new StringTokenizer(okMethList, ","); while (stok2.hasMoreTokens()) { okMeths.add(stok2.nextToken()); } } _restrictedClasses.put(c, okMeths); } catch (Exception e) { _log.error("Configuration error: restricted class " + className + " cannot be loaded", e); } } } }
_log.warning("Unable to load cache manager " + cacheManager + " for PropertyOperator, using SimpleCacheManager. Reason:\n" + e); _cache = new SimpleCacheManager();
_log.error("Configuration error: restricted class " + className + " cannot be loaded", e);
final public void init (Broker b, Settings config) throws InitException { String cacheManager; _log = b.getLog("resource", "Object loading and caching"); cacheManager = b.getSetting("PropertyOperator.CacheManager"); if (cacheManager == null || cacheManager.equals("")) { _log.info("CachingProvider: No cache manager specified for PropertyOperator, using SimpleCacheManager"); _cache = new SimpleCacheManager(); } else { try { _cache = (CacheManager) b.classForName(cacheManager).newInstance(); } catch (Exception e) { _log.warning("Unable to load cache manager " + cacheManager + " for PropertyOperator, using SimpleCacheManager. Reason:\n" + e); _cache = new SimpleCacheManager(); } } _cache.init(b, config, "PropertyOperator"); _restrictedClasses = new HashMap(11); String restrictList = b.getSetting("RestrictedClasses"); if (restrictList != null) { StringTokenizer stok = new StringTokenizer(restrictList, ","); while (stok.hasMoreTokens()) { String className = stok.nextToken(); try { Class c = Class.forName(className); String okMethList = b.getSetting("RestrictedClasses.AllowedMethods." + className); ArrayList okMeths = null; if (okMethList != null) { okMeths = new ArrayList(20); StringTokenizer stok2 = new StringTokenizer(okMethList, ","); while (stok2.hasMoreTokens()) { okMeths.add(stok2.nextToken()); } } _restrictedClasses.put(c, okMeths); } catch (Exception e) { _log.error("Configuration error: restricted class " + className + " cannot be loaded", e); } } } }