rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
jjmatchedKind = 34; jjmatchedPos = 0; } return 54; } if ((active0 & 0x100000L) != 0L) { if (jjmatchedPos == 0) { jjmatchedKind = 34;
jjmatchedKind = 36;
private final int jjStopStringLiteralDfa_0(int pos, long active0){ switch (pos) { case 0: if ((active0 & 0x200000000L) != 0L) { jjmatchedKind = 34; return 0; } if ((active0 & 0x100000L) != 0L) { jjmatchedKind = 34; return 14; } if ((active0 & 0x100080000L) != 0L) return 10; if ((active0 & 0x80001000L) != 0L) return 14; return -1; case 1: if ((active0 & 0x100000L) != 0L) { if (jjmatchedPos == 0) { jjmatchedKind = 34; jjmatchedPos = 0; } return 14; } if ((active0 & 0x200000000L) != 0L) { if (jjmatchedPos == 0) { jjmatchedKind = 34; jjmatchedPos = 0; } return 53; } if ((active0 & 0x80000000L) != 0L) return 14; return -1; case 2: if ((active0 & 0x200000000L) != 0L) { if (jjmatchedPos == 0) { jjmatchedKind = 34; jjmatchedPos = 0; } return 54; } if ((active0 & 0x100000L) != 0L) { if (jjmatchedPos == 0) { jjmatchedKind = 34; jjmatchedPos = 0; } return 14; } return -1; case 3: if ((active0 & 0x100000L) != 0L) { if (jjmatchedPos == 0) { jjmatchedKind = 34; jjmatchedPos = 0; } return 14; } if ((active0 & 0x200000000L) != 0L) return 54; return -1; default : return -1; }}
if ((active0 & 0x100000L) != 0L)
if ((active0 & 0x800000000L) != 0L) return 59; if ((active0 & 0x200000L) != 0L)
private final int jjStopStringLiteralDfa_0(int pos, long active0){ switch (pos) { case 0: if ((active0 & 0x200000000L) != 0L) { jjmatchedKind = 34; return 0; } if ((active0 & 0x100000L) != 0L) { jjmatchedKind = 34; return 14; } if ((active0 & 0x100080000L) != 0L) return 10; if ((active0 & 0x80001000L) != 0L) return 14; return -1; case 1: if ((active0 & 0x100000L) != 0L) { if (jjmatchedPos == 0) { jjmatchedKind = 34; jjmatchedPos = 0; } return 14; } if ((active0 & 0x200000000L) != 0L) { if (jjmatchedPos == 0) { jjmatchedKind = 34; jjmatchedPos = 0; } return 53; } if ((active0 & 0x80000000L) != 0L) return 14; return -1; case 2: if ((active0 & 0x200000000L) != 0L) { if (jjmatchedPos == 0) { jjmatchedKind = 34; jjmatchedPos = 0; } return 54; } if ((active0 & 0x100000L) != 0L) { if (jjmatchedPos == 0) { jjmatchedKind = 34; jjmatchedPos = 0; } return 14; } return -1; case 3: if ((active0 & 0x100000L) != 0L) { if (jjmatchedPos == 0) { jjmatchedKind = 34; jjmatchedPos = 0; } return 14; } if ((active0 & 0x200000000L) != 0L) return 54; return -1; default : return -1; }}
if ((active0 & 0x200000000L) != 0L) return 54;
private final int jjStopStringLiteralDfa_0(int pos, long active0){ switch (pos) { case 0: if ((active0 & 0x200000000L) != 0L) { jjmatchedKind = 34; return 0; } if ((active0 & 0x100000L) != 0L) { jjmatchedKind = 34; return 14; } if ((active0 & 0x100080000L) != 0L) return 10; if ((active0 & 0x80001000L) != 0L) return 14; return -1; case 1: if ((active0 & 0x100000L) != 0L) { if (jjmatchedPos == 0) { jjmatchedKind = 34; jjmatchedPos = 0; } return 14; } if ((active0 & 0x200000000L) != 0L) { if (jjmatchedPos == 0) { jjmatchedKind = 34; jjmatchedPos = 0; } return 53; } if ((active0 & 0x80000000L) != 0L) return 14; return -1; case 2: if ((active0 & 0x200000000L) != 0L) { if (jjmatchedPos == 0) { jjmatchedKind = 34; jjmatchedPos = 0; } return 54; } if ((active0 & 0x100000L) != 0L) { if (jjmatchedPos == 0) { jjmatchedKind = 34; jjmatchedPos = 0; } return 14; } return -1; case 3: if ((active0 & 0x100000L) != 0L) { if (jjmatchedPos == 0) { jjmatchedKind = 34; jjmatchedPos = 0; } return 14; } if ((active0 & 0x200000000L) != 0L) return 54; return -1; default : return -1; }}
if (object == null || !(object instanceof Note[])) return;
if (object == null) return; if (!(object instanceof List)) return; if (((List) object).isEmpty()) return; if (!(((List) object).get(0) instanceof Note)) return;
public void javaToNative(Object object, TransferData transferData) { // If null Object or unsupported TransferData, return. if (object == null || !(object instanceof Note[])) return; if (!isSupportedType(transferData)) return; // Write data to a byte[]. List<Note> notes = (List<Note>) object; org.jdom.Document jdomDocument = XMLNoteSerializer.createJDOMDocumentFromNotes(notes); ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat()); try { xmlOut.output(jdomDocument, bytesOut); } catch (IOException ioe) { throw new KoalaException(ERROR_TEXT, ioe); } byte[] buffer = bytesOut.toByteArray(); // Super converts byte[] to native. super.javaToNative(buffer, transferData); }
logger.debug("Moving " + sourceFile.getAbsolutePath() + " to " + destinationFile.getAbsolutePath());
public static void moveFile(File sourceFile, File destinationFile) throws IOException { logger.debug("Moving " + sourceFile.getAbsolutePath() + " to " + destinationFile.getAbsolutePath()); if (destinationFile.exists()) { destinationFile.delete(); } // Move file using File method if possible boolean succesfulMove = sourceFile.renameTo(destinationFile); if (succesfulMove) return; // Copy file from source to destination logger.debug("Using copy and delete method"); InputStream in = null; OutputStream out = null; try { in = new FileInputStream(sourceFile); out = new FileOutputStream(destinationFile); copyStream(in, out); } finally { if (in != null) { try { in.close(); } catch (IOException e) { } } if (out != null) { try { out.close(); } catch (IOException e) { } } } // Remove source file sourceFile.delete(); }
logger.debug("Using copy and delete method");
public static void moveFile(File sourceFile, File destinationFile) throws IOException { logger.debug("Moving " + sourceFile.getAbsolutePath() + " to " + destinationFile.getAbsolutePath()); if (destinationFile.exists()) { destinationFile.delete(); } // Move file using File method if possible boolean succesfulMove = sourceFile.renameTo(destinationFile); if (succesfulMove) return; // Copy file from source to destination logger.debug("Using copy and delete method"); InputStream in = null; OutputStream out = null; try { in = new FileInputStream(sourceFile); out = new FileOutputStream(destinationFile); copyStream(in, out); } finally { if (in != null) { try { in.close(); } catch (IOException e) { } } if (out != null) { try { out.close(); } catch (IOException e) { } } } // Remove source file sourceFile.delete(); }
if (in != null) { try { in.close(); } catch (IOException e) { } } if (out != null) { try { out.close(); } catch (IOException e) { } }
in = closeInputStream(in); out = closeOutputStream(out);
public static void moveFile(File sourceFile, File destinationFile) throws IOException { logger.debug("Moving " + sourceFile.getAbsolutePath() + " to " + destinationFile.getAbsolutePath()); if (destinationFile.exists()) { destinationFile.delete(); } // Move file using File method if possible boolean succesfulMove = sourceFile.renameTo(destinationFile); if (succesfulMove) return; // Copy file from source to destination logger.debug("Using copy and delete method"); InputStream in = null; OutputStream out = null; try { in = new FileInputStream(sourceFile); out = new FileOutputStream(destinationFile); copyStream(in, out); } finally { if (in != null) { try { in.close(); } catch (IOException e) { } } if (out != null) { try { out.close(); } catch (IOException e) { } } } // Remove source file sourceFile.delete(); }
String folder = folderInput.getValue().toString();
public UIComponent getEditContainer() { WFResourceUtil localizer = WFResourceUtil.getResourceUtilArticle(); String ref = ARTICLE_ITEM_BEAN_ID + ".";// String bref = WFPage.CONTENT_BUNDLE + "."; WFContainer mainContainer = new WFContainer(); mainContainer.setId(ARTICLE_EDITOR_ID); WFErrorMessages em = new WFErrorMessages(); em.addErrorMessage(HEADLINE_ID); em.addErrorMessage(TEASER_ID);// em.addErrorMessage(PUBLISHED_FROM_DATE_ID);// em.addErrorMessage(PUBLISHED_TO_DATE_ID); em.addErrorMessage(SAVE_ID); mainContainer.add(em); HtmlPanelGrid p = WFPanelUtil.getPlainFormPanel(2); p.getChildren().add(WFUtil.group(localizer.getTextVB("headline"), WFUtil.getText(":")));// p.getChildren().add(WFUtil.group(WFUtil.getTextVB(bref + "language"), WFUtil.getText(":"))); HtmlInputText headlineInput = WFUtil.getInputText(HEADLINE_ID, ref + "headline"); headlineInput.setSize(40); p.getChildren().add(headlineInput); //HtmlSelectOneMenu localeMenu = WFUtil.getSelectOneMenu(LOCALE_ID, ref + "allLocales", ref + "pendingLocaleId"); //localeMenu.setOnchange("document.forms[0].submit();"); //p.getChildren().add(localeMenu); p.getChildren().add(WFUtil.group(localizer.getTextVB("teaser"), WFUtil.getText(":"))); HtmlInputTextarea teaserArea = WFUtil.getTextArea(TEASER_ID, ref + "teaser", "440px", "30px"); p.getChildren().add(teaserArea); p.getChildren().add(WFUtil.group(localizer.getTextVB("author"), WFUtil.getText(":"))); HtmlInputText authorInput = WFUtil.getInputText(AUTHOR_ID, ref + "author"); authorInput.setSize(22); p.getChildren().add(authorInput); p.getChildren().add(WFUtil.group(localizer.getTextVB("body"), WFUtil.getText(":"))); HTMLArea bodyArea = WFUtil.getHtmlAreaTextArea(BODY_ID, ref + "body", "100%", "400px"); bodyArea.addPlugin(HTMLArea.PLUGIN_TABLE_OPERATIONS); bodyArea.addPlugin(HTMLArea.PLUGIN_DYNAMIC_CSS, "3"); bodyArea.addPlugin(HTMLArea.PLUGIN_CSS, "3"); bodyArea.addPlugin(HTMLArea.PLUGIN_CONTEXT_MENU); bodyArea.addPlugin(HTMLArea.PLUGIN_LIST_TYPE); bodyArea.addPlugin(HTMLArea.PLUGIN_CHARACTER_MAP); bodyArea.setAllowFontSelection(false); HtmlCommandButton editButton = localizer.getButtonVB(EDIT_HTML_ID, "edit", this); editButton.setOnclick("wurl='htmlarea/webface/htmledit.jsp?" + PREVIEW_ARTICLE_ITEM_ID + "='+this.tabindex;window.open(wurl,'Edit','height=450,width=600,resizable=yes,status=no,toolbar=no,menubar=no,location=no,scrollbars=no');return false;"); p.getChildren().add(WFUtil.group(WFUtil.group(bodyArea, WFUtil.getBreak()), editButton));/* WFContainer imageContainer = new WFContainer(); imageContainer.add(WFUtil.getButtonVB(ADD_IMAGE_ID, bref + "add_image", this)); imageContainer.add(WFUtil.getBreak()); imageContainer.add(getImageList()); p.getChildren().add(imageContainer); p.getChildren().add(WFUtil.group(WFUtil.getTextVB(bref + "source"), WFUtil.getText(":"))); p.getChildren().add(WFUtil.group(WFUtil.getTextVB(bref + "main_category"), WFUtil.getText(":"))); HtmlInputTextarea sourceArea = WFUtil.getTextArea(SOURCE_ID, ref + "source", "440px", "30px"); p.getChildren().add(sourceArea); HtmlSelectOneMenu mainCategoryMenu = WFUtil.getSelectOneMenu(MAIN_CATEGORY_ID, ref + "categories", ref + "mainCategoryId"); p.getChildren().add(mainCategoryMenu); */// mainContainer.add(p);// mainContainer.add(WFUtil.getBreak()); p.getChildren().add(WFUtil.getBreak()); p.getChildren().add(WFUtil.getBreak()); // p = WFPanelUtil.getPlainFormPanel(1);/* p.getChildren().add(WFUtil.group(WFUtil.getHeaderTextVB(bref + "created"), WFUtil.getTextVB(ref + "creationDate") ));*/// p.getChildren().add(WFUtil.getText(" "));// UIComponent t = WFUtil.group(localizer.getHeaderTextVB("status"), WFUtil.getText(": "));// t.getChildren().add(WFUtil.getTextVB(ref + "status"));// p.getChildren().add(t); p.getChildren().add(WFUtil.group(localizer.getTextVB("status"), WFUtil.getText(":"))); p.getChildren().add(WFUtil.getTextVB(ref + "status")); p.getChildren().add(WFUtil.group(localizer.getTextVB("current_version"), WFUtil.getText(":"))); p.getChildren().add(WFUtil.getTextVB(ref + "versionId"));// p.getChildren().add(WFUtil.getText(" "));// p.getChildren().add(WFUtil.group(localizer.getHeaderTextVB("current_version"), // WFUtil.getTextVB(ref + "versionId")// )); // mainContainer.add(p); p.getChildren().add(WFUtil.getBreak()); p.getChildren().add(WFUtil.getBreak()); // p = WFPanelUtil.getFormPanel(2); p.getChildren().add(WFUtil.group(localizer.getTextVB("comment"), WFUtil.getText(":")));// p.getChildren().add(WFUtil.group(WFUtil.getTextVB(bref + "attachments"), WFUtil.getText(":"))); HtmlInputTextarea commentArea = WFUtil.getTextArea(COMMENT_ID, ref + "comment", "400px", "60px"); p.getChildren().add(commentArea);// WFContainer attachmentContainer = new WFContainer();// attachmentContainer.add(WFUtil.getButtonVB(ADD_ATTACHMENT_ID, bref + "add_attachment", this));// attachmentContainer.add(WFUtil.getBreak());// attachmentContainer.add(getAttachmentList());// p.getChildren().add(attachmentContainer); // mainContainer.add(p); // p = WFPanelUtil.getFormPanel(1);// p.getChildren().add(WFUtil.group(WFUtil.getTextVB(bref + "related_content_items"), WFUtil.getText(":"))); // WFContainer contentItemContainer = new WFContainer(); // contentItemContainer.add(WFUtil.getButtonVB(ADD_RELATED_CONTENT_ITEM_ID, bref + "add_content_item", this));// contentItemContainer.add(WFUtil.getBreak());// contentItemContainer.add(getRelatedContentItemsList());// p.getChildren().add(contentItemContainer);// p.getChildren().add(WFUtil.group(WFUtil.getTextVB(bref + "publishing_date"), WFUtil.getText(":"))); // WFDateInput publishedFromInput = WFUtil.getDateInput(PUBLISHED_FROM_DATE_ID, ref + "case.publishedFromDate");// publishedFromInput.setShowTime(true);// p.getChildren().add(publishedFromInput);// p.getChildren().add(WFUtil.group(WFUtil.getTextVB(bref + "expiration_date"), WFUtil.getText(":"))); // WFDateInput publishedToInput = WFUtil.getDateInput(PUBLISHED_TO_DATE_ID, ref + "case.publishedToDate");// publishedToInput.setShowTime(true);// p.getChildren().add(publishedToInput); // mainContainer.add(p); p.getChildren().add(WFUtil.getBreak()); p.getChildren().add(WFUtil.getBreak());// mainContainer.add(WFUtil.getBreak());// p = WFPanelUtil.getPlainFormPanel(1);// HtmlCommandButton editCategoriesButton = WFUtil.getButtonVB(EDIT_CATEGORIES_ID, bref + "edit_categories", this);// p.getChildren().add(editCategoriesButton); p.getChildren().add(WFUtil.group(localizer.getTextVB("folder"), WFUtil.getText(":"))); HtmlInputText folderInput = WFUtil.getInputText(FOLDER_ID, ref + "folderLocation"); String folder = folderInput.getValue().toString(); if(null==folderInput.getValue() || "".equals(folderInput.getValue())) { folderInput.setValue(ContentUtil.ARTICLE_PATH); } folderInput.setSize(40); p.getChildren().add(folderInput); p.getChildren().add(WFUtil.getBreak()); p.getChildren().add(WFUtil.getBreak()); p.getChildren().add(WFUtil.getBreak());// WFComponentSelector cs = new WFComponentSelector();// cs.setId(BUTTON_SELECTOR_ID);// cs.setDividerText(" "); HtmlCommandButton saveButton = localizer.getButtonVB(SAVE_ID, "save", this);// HtmlCommandButton saveButton = WFUtil.getButtonVB(SAVE_ID, WFPage.CONTENT_BUNDLE + "save", this);// cs.add(saveButton);// cs.add(WFUtil.getButtonVB(FOR_REVIEW_ID, bref + "for_review", this));// cs.add(WFUtil.getButtonVB(PUBLISH_ID, bref + "publish", this));// cs.add(WFUtil.getButtonVB(REWRITE_ID, bref + "rewrite", this));// cs.add(WFUtil.getButtonVB(REJECT_ID, bref + "reject", this));// cs.add(WFUtil.getButtonVB(DELETE_ID, bref + "delete", this));// cs.add(WFUtil.getButtonVB(CANCEL_ID, bref + "cancel", this));// cs.setSelectedId(CANCEL_ID, true);// p.getChildren().add(cs); p.getChildren().add(saveButton); mainContainer.add(p); WFComponentSelector editorSelector = new WFComponentSelector(); editorSelector.setId(EDITOR_SELECTOR_ID); editorSelector.add(mainContainer); editorSelector.add(getCategoryEditContainer());// FileUploadForm f = new FileUploadForm(this, FILE_UPLOAD_ID, FILE_UPLOAD_CANCEL_ID); FileUploadForm f = new FileUploadForm(); f.setId(FILE_UPLOAD_FORM_ID); editorSelector.add(f); editorSelector.add(getRelatedContentItemsContainer()); editorSelector.setSelectedId(ARTICLE_EDITOR_ID, true); return editorSelector; }
ObjectNameBuilder objectNameBuilder = new ObjectNameBuilder(metadataManager, "domain", "server", "application");
ObjectNameBuilder objectNameBuilder = new ObjectNameBuilder(metadataManager, "domain", "server", "module");
public void testObjectNameCreation() { String beanName = "foobar"; assertTrue(factory.containsBeanDefinition(beanName)); BeanDefinition beanDefinition = factory.getBeanDefinition(beanName); assertNotNull(beanDefinition); assertFalse(beanDefinition.getPropertyValues().contains("gbean-objectName")); // convert properties into named constructor args List metadataProviders = new ArrayList(2); metadataProviders.add(new PropertiesMetadataProvider()); MetadataManager metadataManager = new SimpleMetadataManager(metadataProviders); ObjectNameBuilder objectNameBuilder = new ObjectNameBuilder(metadataManager, "domain", "server", "application"); objectNameBuilder.postProcessBeanFactory(factory); ObjectName objectName = ServiceName.createName("domain:J2EEServer=server,J2EEApplication=application,name=" + beanName); objectNameBuilder.postProcessBeanFactory(factory); assertFalse(beanDefinition.getPropertyValues().contains("gbean-objectName")); assertEquals(objectName, objectNameBuilder.getObjectName(beanName)); }
ObjectName objectName = ServiceName.createName("domain:J2EEServer=server,J2EEApplication=application,name=" + beanName);
ObjectName objectName = ServiceName.createName("domain:J2EEServer=server,J2EEApplication=null,J2EEModule=module,name=" + beanName);
public void testObjectNameCreation() { String beanName = "foobar"; assertTrue(factory.containsBeanDefinition(beanName)); BeanDefinition beanDefinition = factory.getBeanDefinition(beanName); assertNotNull(beanDefinition); assertFalse(beanDefinition.getPropertyValues().contains("gbean-objectName")); // convert properties into named constructor args List metadataProviders = new ArrayList(2); metadataProviders.add(new PropertiesMetadataProvider()); MetadataManager metadataManager = new SimpleMetadataManager(metadataProviders); ObjectNameBuilder objectNameBuilder = new ObjectNameBuilder(metadataManager, "domain", "server", "application"); objectNameBuilder.postProcessBeanFactory(factory); ObjectName objectName = ServiceName.createName("domain:J2EEServer=server,J2EEApplication=application,name=" + beanName); objectNameBuilder.postProcessBeanFactory(factory); assertFalse(beanDefinition.getPropertyValues().contains("gbean-objectName")); assertEquals(objectName, objectNameBuilder.getObjectName(beanName)); }
ignoreRegex = new Ignore();
Ignore ignoreRegex = new Ignore(); ignoreRegexs.add(ignoreRegex);
public Ignore createIgnore() { ignoreRegex = new Ignore(); return ignoreRegex; }
if (ignoreRegex != null)
for (int i = 0; i < ignoreRegexs.size(); i++) { Ignore ignoreRegex = (Ignore)ignoreRegexs.get(i);
public void execute() throws BuildException { CommandLineBuilder builder = null; try { builder = new CommandLineBuilder(); if (dataFile != null) builder.addArg("--datafile", dataFile); if (toDir != null) builder.addArg("--destination", toDir.getAbsolutePath()); // ignoreRegex.setRegex() is never called, but that's ok // because ant sets it somehow, I think if (ignoreRegex != null) builder.addArg("--ignore", ignoreRegex.getRegex()); createArgumentsForFilesets(builder); builder.saveArgs(); } catch (IOException ioe) { getProject().log("Error creating commands file.", Project.MSG_ERR); throw new BuildException("Unable to create the commands file.", ioe); } // Execute GPL licensed code in separate virtual machine getJava().createArg().setValue("--commandsfile"); getJava().createArg().setValue(builder.getCommandLineFile()); if (getJava().executeJava() != 0) { throw new BuildException( "Error instrumenting classes. See messages above."); } builder.dispose(); }
}
public void execute() throws BuildException { CommandLineBuilder builder = null; try { builder = new CommandLineBuilder(); if (dataFile != null) builder.addArg("--datafile", dataFile); if (toDir != null) builder.addArg("--destination", toDir.getAbsolutePath()); // ignoreRegex.setRegex() is never called, but that's ok // because ant sets it somehow, I think if (ignoreRegex != null) builder.addArg("--ignore", ignoreRegex.getRegex()); createArgumentsForFilesets(builder); builder.saveArgs(); } catch (IOException ioe) { getProject().log("Error creating commands file.", Project.MSG_ERR); throw new BuildException("Unable to create the commands file.", ioe); } // Execute GPL licensed code in separate virtual machine getJava().createArg().setValue("--commandsfile"); getJava().createArg().setValue(builder.getCommandLineFile()); if (getJava().executeJava() != 0) { throw new BuildException( "Error instrumenting classes. See messages above."); } builder.dispose(); }
WebDAVMetadata metadataUI = new WebDAVMetadata(path+"/"+fileName+".xml");
WebDAVMetadata metadataUI = new WebDAVMetadata(path+"/"+fileName+ArticleItemBean.ARTICLE_SUFFIX);
private UIComponent getMetadataPanel() { String path = (String)WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "getFolderLocation"); String fileName = (String)WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "getHeadline");// System.out.println("path = "+path+"/"+fileName+".xml"); WebDAVMetadata metadataUI = new WebDAVMetadata(path+"/"+fileName+".xml"); return metadataUI; }
bodyDoc = builder.parse(new ByteArrayInputStream(theArticle.getMethodDataAsString().getBytes()));
bodyDoc = builder.parse(new ByteArrayInputStream(theArticle.getMethodDataAsString().getBytes("UTF-8")));
public boolean load(WebdavExtendedResource webdavResource) throws IOException { XMLParser builder = new XMLParser(); XMLDocument bodyDoc = null; try { WebdavResource theArticle = null; if(webdavResource.isCollection()){ IWContext iwc = IWContext.getInstance(); WebdavResources resources = webdavResource.getChildResources(); String userLanguageArticleName = getArticleName(iwc.getCurrentLocale()); String systemLanguageArticleName = getArticleName(iwc.getIWMainApplication().getDefaultLocale()); if(resources.isThereResourceName(userLanguageArticleName)){ //the language that the user has selected theArticle = resources.getResource(userLanguageArticleName); } else if(resources.isThereResourceName(systemLanguageArticleName)){ //the language that is default for the system theArticle = resources.getResource(systemLanguageArticleName); } else { // take the first language Enumeration en = resources.getResources(); if(en.hasMoreElements()){ theArticle = (WebdavResource)en.nextElement(); } } } else { theArticle = webdavResource; } if(theArticle!=null && !theArticle.isCollection()){ setArticleResourcePath(theArticle.getPath()); bodyDoc = builder.parse(new ByteArrayInputStream(theArticle.getMethodDataAsString().getBytes())); } else { bodyDoc = null; } } catch (XMLException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } if(bodyDoc!=null){ XMLElement rootElement = bodyDoc.getRootElement(); try { XMLElement language = rootElement.getChild(FIELDNAME_CONTENT_LANGUAGE,idegaXMLNameSpace); if(language != null){ setContentLanguage(language.getText()); } else { setContentLanguage(null); } }catch(Exception e) { setContentLanguage(null); } try { XMLElement headline = rootElement.getChild(FIELDNAME_HEADLINE,idegaXMLNameSpace); if(headline != null){ setHeadline(headline.getText()); } else { setHeadline(""); } }catch(Exception e) { //Nullpointer could occur if field isn't used e.printStackTrace(); setHeadline(""); } try { XMLElement teaser = rootElement.getChild(FIELDNAME_TEASER,idegaXMLNameSpace); if(teaser != null){ setTeaser(teaser.getText()); } else { setTeaser(""); } }catch(Exception e) { //Nullpointer could occur if field isn't used e.printStackTrace(); setTeaser(""); } try { XMLElement author = rootElement.getChild(FIELDNAME_AUTHOR,idegaXMLNameSpace); if(author != null){ setAuthor(author.getText()); } else { setAuthor(""); } }catch(Exception e) { //Nullpointer could occur if field isn't used e.printStackTrace(); setAuthor(""); } //Parse out the body try { XMLNamespace htmlNamespace = new XMLNamespace("http://www.w3.org/1999/xhtml"); XMLElement bodyElement = rootElement.getChild(FIELDNAME_BODY,idegaXMLNameSpace); XMLElement htmlElement = bodyElement.getChild("html",htmlNamespace); XMLElement htmlBodyElement = htmlElement.getChild("body",htmlNamespace); String bodyValue = new XMLOutput().outputString(htmlBodyElement); // System.out.println("htmlBody value= "+bodyValue); setBody(bodyValue); }catch(Exception e) { //Nullpointer could occur if field isn't used // e.printStackTrace(); Logger log = Logger.getLogger(this.getClass().toString()); log.warning("Body of article is empty"); setBody(""); } try { XMLElement source = rootElement.getChild(FIELDNAME_SOURCE,idegaXMLNameSpace); if(source != null){ setSource(source.getText()); } else { setSource(""); } }catch(Exception e) { //Nullpointer could occur if field isn't used setSource(""); } try { XMLElement comment = rootElement.getChild(FIELDNAME_ARTICLE_COMMENT,idegaXMLNameSpace); if(comment != null){ setComment(comment.getText()); } else { setComment(""); } }catch(Exception e) { //Nullpointer could occur if field isn't used e.printStackTrace(); setComment(""); } } else { //article not found Logger log = Logger.getLogger(this.getClass().toString()); log.warning("Article xml file was not found"); setRendered(false); return false; } return true;// setFilename();// setFolderLocation(bodyElement.getChild(FIELDNAME_FOLDER_LOCATION,idegans).getText()); }
if(rootResource.putMethod(filePath,article)){
if(rootResource.putMethod(filePath,utf8stream)){
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;// }// } // String filename = getHeadline();// if(null==filename || filename.length()==0) {// filename = "empty";// } if(storeOk){ try { IWUserContext iwuc = IWContext.getInstance(); IWSlideSession session = (IWSlideSession)IBOLookup.getSessionInstance(iwuc,IWSlideSession.class); WebdavRootResource rootResource = session.getWebdavRootResource(); //Setting the path for creating new file/creating localized version/updating existing file String filePath=getResourcePath(); String articleFolderPath=getArticlePath(); if(articleFolderPath!=null) { filePath=articleFolderPath+"/"+getArticleName(); }else { filePath=getArticleResourcePath(); articleFolderPath = getArticlePath(); } boolean hadToCreate = session.createAllFoldersInPath(articleFolderPath); if(hadToCreate){ String fixedFolderURL = session.getURI(articleFolderPath); rootResource.proppatchMethod(fixedFolderURL,PROPERTY_CONTENT_TYPE,"LocalizedFile",true); } else{ rootResource.proppatchMethod(articleFolderPath,PROPERTY_CONTENT_TYPE,"LocalizedFile",true); } String article = getAsXML(); // System.out.println(article); //Conflict fix: uri for creating but path for updating //Note! This is a patch to what seems to be a bug in WebDav //Apparently in verion below works in some cases and the other in other cases. //Seems to be connected to creating files in folders created in same tomcat session or similar //not quite clear... if(rootResource.putMethod(filePath,article)){ rootResource.proppatchMethod(filePath,PROPERTY_CONTENT_TYPE,ARTICLE_FILENAME_SCOPE,true); } else{ String fixedURL = session.getURI(filePath); rootResource.putMethod(fixedURL,article); rootResource.proppatchMethod(fixedURL,PROPERTY_CONTENT_TYPE,ARTICLE_FILENAME_SCOPE,true); } rootResource.close(); try { load(filePath); } catch (Exception e) { e.printStackTrace(); } } catch (IOException e1) { storeOk = false; e1.printStackTrace(); } catch (XMLException e) { storeOk = false; e.printStackTrace(); } } if (storeOk) { if (getRequestedStatus() != null) { setStatus(getRequestedStatus()); setRequestedStatus(null); } }else { throw new ArticleStoreException(); } }
rootResource.putMethod(fixedURL,article);
rootResource.putMethod(fixedURL,utf8stream);
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;// }// } // String filename = getHeadline();// if(null==filename || filename.length()==0) {// filename = "empty";// } if(storeOk){ try { IWUserContext iwuc = IWContext.getInstance(); IWSlideSession session = (IWSlideSession)IBOLookup.getSessionInstance(iwuc,IWSlideSession.class); WebdavRootResource rootResource = session.getWebdavRootResource(); //Setting the path for creating new file/creating localized version/updating existing file String filePath=getResourcePath(); String articleFolderPath=getArticlePath(); if(articleFolderPath!=null) { filePath=articleFolderPath+"/"+getArticleName(); }else { filePath=getArticleResourcePath(); articleFolderPath = getArticlePath(); } boolean hadToCreate = session.createAllFoldersInPath(articleFolderPath); if(hadToCreate){ String fixedFolderURL = session.getURI(articleFolderPath); rootResource.proppatchMethod(fixedFolderURL,PROPERTY_CONTENT_TYPE,"LocalizedFile",true); } else{ rootResource.proppatchMethod(articleFolderPath,PROPERTY_CONTENT_TYPE,"LocalizedFile",true); } String article = getAsXML(); // System.out.println(article); //Conflict fix: uri for creating but path for updating //Note! This is a patch to what seems to be a bug in WebDav //Apparently in verion below works in some cases and the other in other cases. //Seems to be connected to creating files in folders created in same tomcat session or similar //not quite clear... if(rootResource.putMethod(filePath,article)){ rootResource.proppatchMethod(filePath,PROPERTY_CONTENT_TYPE,ARTICLE_FILENAME_SCOPE,true); } else{ String fixedURL = session.getURI(filePath); rootResource.putMethod(fixedURL,article); rootResource.proppatchMethod(fixedURL,PROPERTY_CONTENT_TYPE,ARTICLE_FILENAME_SCOPE,true); } rootResource.close(); try { load(filePath); } catch (Exception e) { e.printStackTrace(); } } catch (IOException e1) { storeOk = false; e1.printStackTrace(); } catch (XMLException e) { storeOk = false; e.printStackTrace(); } } if (storeOk) { if (getRequestedStatus() != null) { setStatus(getRequestedStatus()); setRequestedStatus(null); } }else { throw new ArticleStoreException(); } }
return null;
FlowGraphNode result = (FlowGraphNode)identToAbslocMap.get(ident); if (result == null) { identToAbslocMap.put(ident, result = new AbslocNode(ident.toString(), type)); } return result;
public FlowGraphNode makeAbslocNode(Object ident, Type typ, SootMethod enclosingMethod) { return null; }
SootMethod method) { return null;
SootMethod enclosingMethod) { return base.getField(field);
public FlowGraphNode makeFieldRefNode(FlowGraphNode base, SootField field, SootMethod method) { return null; }
throw new IllegalArgumentException("Could not load property editor: "+propertyEditor, e);
throw (IllegalArgumentException)new IllegalArgumentException("Could not load property editor: "+propertyEditor).initCause(e);
protected PropertyEditor createPropertyEditor(String propertyEditor) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); if( cl==null ) { cl = XBeanXmlBeanDefinitionParser.class.getClassLoader(); } try { return (PropertyEditor)cl.loadClass(propertyEditor).newInstance(); } catch (Throwable e){ throw new IllegalArgumentException("Could not load property editor: "+propertyEditor, e); } }
public Object getObject() { return object;; }
public Object getObject() { return object; }
public Object getObject() { return object;; }
NoteTreeNode parentTreeNode = dd.getTree().getSelectedNode(); Note parentNote = parentTreeNode.getDisplayedNote().getNote();
DisplayedNote parentDisplayed = dd.getTree().getSelectedNote(); Note parentNote = parentDisplayed.getNote();
public void addNote(Event e) { NoteTreeNode parentTreeNode = dd.getTree().getSelectedNode(); Note parentNote = parentTreeNode.getDisplayedNote().getNote(); Note newNote = new Note("new", parentNote, ""); parentTreeNode.addChild(newNote); }
parentTreeNode.addChild(newNote);
new DisplayedNote(parentDisplayed, newNote);
public void addNote(Event e) { NoteTreeNode parentTreeNode = dd.getTree().getSelectedNode(); Note parentNote = parentTreeNode.getDisplayedNote().getNote(); Note newNote = new Note("new", parentNote, ""); parentTreeNode.addChild(newNote); }
for (NoteTreeNode node : dd.getTree().getSelectedNodes()) { node.dispose();
for (DisplayedNote removeMe : dd.getTree().getSelectedNotes()) { removeMe.disposeDisplayedWidgets(); removeMe.getNote().removeFromParent();
public void removeNotes(Event e) { for (NoteTreeNode node : dd.getTree().getSelectedNodes()) { node.dispose(); } }
AndFilter presenceFilter = new AndFilter(new PacketTypeFilter(Presence.class), new FromContainsFilter(this.participantJID));
AndFilter presenceFilter = new AndFilter(new PacketTypeFilter(Presence.class), new BareAddressFilter(participantJID));
public ChatRoomImpl(final String participantJID, String participantNickname, String title) { this.participantJID = participantJID; this.participantNickname = participantNickname; AndFilter presenceFilter = new AndFilter(new PacketTypeFilter(Presence.class), new FromContainsFilter(this.participantJID)); // Register PacketListeners AndFilter messageFilter = new AndFilter(new PacketTypeFilter(Message.class), new FromContainsFilter(participantJID)); SparkManager.getConnection().addPacketListener(this, messageFilter); SparkManager.getConnection().addPacketListener(this, presenceFilter); // The roomname will be the participantJID this.roomname = participantJID; // Use the agents username as the Tab Title this.tabTitle = title; // The name of the room will be the node of the user jid + conversation. final SimpleDateFormat formatter = new SimpleDateFormat("h:mm a"); this.roomTitle = participantNickname; // Add RoomInfo this.getSplitPane().setRightComponent(null); getSplitPane().setDividerSize(0); roster = SparkManager.getConnection().getRoster(); presence = roster.getPresence(participantJID); RosterEntry entry = roster.getEntry(participantJID); tabIcon = SparkManager.getUserManager().getTabIconForPresence(presence); PacketFilter filter = new AndFilter(new PacketTypeFilter(Presence.class), new FromContainsFilter(participantJID)); SparkManager.getConnection().addPacketListener(new PacketListener() { public void processPacket(Packet packet) { presence = (Presence)packet; } }, filter); // Create toolbar buttons. ChatRoomButton infoButton = new ChatRoomButton("", SparkRes.getImageIcon(SparkRes.PROFILE_IMAGE_24x24)); infoButton.setToolTipText(Res.getString("message.view.information.about.this.user")); // Create basic toolbar. getToolBar().addChatRoomButton(infoButton); // If the user is not in the roster, then allow user to add them. if (entry == null && !StringUtils.parseResource(participantJID).equals(participantNickname)) { ChatRoomButton addToRosterButton = new ChatRoomButton("", SparkRes.getImageIcon(SparkRes.ADD_IMAGE_24x24)); addToRosterButton.setToolTipText(Res.getString("message.add.this.user.to.your.roster")); getToolBar().addChatRoomButton(addToRosterButton); addToRosterButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { RosterDialog rosterDialog = new RosterDialog(); rosterDialog.setDefaultJID(participantJID); rosterDialog.setDefaultNickname(getParticipantNickname()); rosterDialog.showRosterDialog(SparkManager.getChatManager().getChatContainer().getChatFrame()); } }); } // Show VCard. infoButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VCardManager vcard = SparkManager.getVCardManager(); vcard.viewProfile(participantJID, SparkManager.getChatManager().getChatContainer()); } }); // If this is a private chat from a group chat room, do not show toolbar. if (StringUtils.parseResource(participantJID).equals(participantNickname)) { getToolBar().setVisible(false); } typingTimer = new Timer(2000, new ActionListener() { public void actionPerformed(ActionEvent e) { if(!sendTypingNotification) { return; } long now = System.currentTimeMillis(); if (now - lastTypedCharTime > 2000) { if (!sendNotification) { // send cancel SparkManager.getMessageEventManager().sendCancelledNotification(getParticipantJID(), threadID); sendNotification = true; } } } }); typingTimer.start(); lastActivity = System.currentTimeMillis(); // Add VCard Panel final VCardPanel vcardPanel = new VCardPanel(participantJID); getToolBar().add(vcardPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); }
AndFilter messageFilter = new AndFilter(new PacketTypeFilter(Message.class), new FromContainsFilter(participantJID));
AndFilter messageFilter = new AndFilter(new PacketTypeFilter(Message.class), new BareAddressFilter(participantJID));
public ChatRoomImpl(final String participantJID, String participantNickname, String title) { this.participantJID = participantJID; this.participantNickname = participantNickname; AndFilter presenceFilter = new AndFilter(new PacketTypeFilter(Presence.class), new FromContainsFilter(this.participantJID)); // Register PacketListeners AndFilter messageFilter = new AndFilter(new PacketTypeFilter(Message.class), new FromContainsFilter(participantJID)); SparkManager.getConnection().addPacketListener(this, messageFilter); SparkManager.getConnection().addPacketListener(this, presenceFilter); // The roomname will be the participantJID this.roomname = participantJID; // Use the agents username as the Tab Title this.tabTitle = title; // The name of the room will be the node of the user jid + conversation. final SimpleDateFormat formatter = new SimpleDateFormat("h:mm a"); this.roomTitle = participantNickname; // Add RoomInfo this.getSplitPane().setRightComponent(null); getSplitPane().setDividerSize(0); roster = SparkManager.getConnection().getRoster(); presence = roster.getPresence(participantJID); RosterEntry entry = roster.getEntry(participantJID); tabIcon = SparkManager.getUserManager().getTabIconForPresence(presence); PacketFilter filter = new AndFilter(new PacketTypeFilter(Presence.class), new FromContainsFilter(participantJID)); SparkManager.getConnection().addPacketListener(new PacketListener() { public void processPacket(Packet packet) { presence = (Presence)packet; } }, filter); // Create toolbar buttons. ChatRoomButton infoButton = new ChatRoomButton("", SparkRes.getImageIcon(SparkRes.PROFILE_IMAGE_24x24)); infoButton.setToolTipText(Res.getString("message.view.information.about.this.user")); // Create basic toolbar. getToolBar().addChatRoomButton(infoButton); // If the user is not in the roster, then allow user to add them. if (entry == null && !StringUtils.parseResource(participantJID).equals(participantNickname)) { ChatRoomButton addToRosterButton = new ChatRoomButton("", SparkRes.getImageIcon(SparkRes.ADD_IMAGE_24x24)); addToRosterButton.setToolTipText(Res.getString("message.add.this.user.to.your.roster")); getToolBar().addChatRoomButton(addToRosterButton); addToRosterButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { RosterDialog rosterDialog = new RosterDialog(); rosterDialog.setDefaultJID(participantJID); rosterDialog.setDefaultNickname(getParticipantNickname()); rosterDialog.showRosterDialog(SparkManager.getChatManager().getChatContainer().getChatFrame()); } }); } // Show VCard. infoButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VCardManager vcard = SparkManager.getVCardManager(); vcard.viewProfile(participantJID, SparkManager.getChatManager().getChatContainer()); } }); // If this is a private chat from a group chat room, do not show toolbar. if (StringUtils.parseResource(participantJID).equals(participantNickname)) { getToolBar().setVisible(false); } typingTimer = new Timer(2000, new ActionListener() { public void actionPerformed(ActionEvent e) { if(!sendTypingNotification) { return; } long now = System.currentTimeMillis(); if (now - lastTypedCharTime > 2000) { if (!sendNotification) { // send cancel SparkManager.getMessageEventManager().sendCancelledNotification(getParticipantJID(), threadID); sendNotification = true; } } } }); typingTimer.start(); lastActivity = System.currentTimeMillis(); // Add VCard Panel final VCardPanel vcardPanel = new VCardPanel(participantJID); getToolBar().add(vcardPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); }
dndList.add(phone);
private void populateDndList() { final ImageIcon availableIcon = SparkRes.getImageIcon(SparkRes.GREEN_BALL); final ImageIcon awayIcon = SparkRes.getImageIcon(SparkRes.IM_AWAY); final ImageIcon dndIcon = SparkRes.getImageIcon(SparkRes.IM_DND); StatusItem online = new StatusItem(new Presence(Presence.Type.available, "Online", -1, Presence.Mode.available), availableIcon); StatusItem freeToChat = new StatusItem(new Presence(Presence.Type.available, "Free To Chat", -1, Presence.Mode.chat), SparkRes.getImageIcon(SparkRes.FREE_TO_CHAT_IMAGE)); StatusItem away = new StatusItem(new Presence(Presence.Type.available, "Away", -1, Presence.Mode.away), awayIcon); StatusItem dnd = new StatusItem(new Presence(Presence.Type.available, "Do Not Disturb", -1, Presence.Mode.dnd), dndIcon); StatusItem extendedAway = new StatusItem(new Presence(Presence.Type.available, "Extended Away", -1, Presence.Mode.xa), awayIcon); dndList.add(freeToChat); dndList.add(online); dndList.add(away); dndList.add(extendedAway); dndList.add(dnd); // Set default presence icon (Avaialble) statusPanel.setIcon(availableIcon); }
return null;
return jid;
public String getUserNicknameFromJID(String jid) { ContactList contactList = SparkManager.getWorkspace().getContactList(); ContactItem item = contactList.getContactItemByJID(jid); if (item != null) { return item.getNickname(); } return null; }
_log = bc.getLog("IncludeDirective");
public final Object build(DirectiveBuilder builder, BuildContext bc) throws BuildException { Broker broker = bc.getBroker(); // build configuration key names, since they're based // on the configured name of this directive _directiveName = builder.getName(); TEMPLATE_EXTENSIONS_NAME = _directiveName + TEMPLATE_EXTENSIONS_NAME; // determine what type of file we need to deal with if (builder.getArg(PARSE_TEXT_K, bc) != null) { _type = TYPE_TEXT; } else if (builder.getArg(PARSE_TEMPLATE_K, bc) != null) { _type = TYPE_TEMPLATE; } else if (builder.getArg(PARSE_MACRO_K, bc) != null) { _type = TYPE_MACRO; } else { _type = TYPE_DYNAMIC; } // if the filename passed to us was a Macro (needs to be evaluated later) // then store it as _macFilename. Otherwise, assume it's a String // and we'll just use that string as the filename Object o = builder.getArg(PARSE_FILENAME, bc); if (o instanceof Macro) { if (_type == TYPE_TEXT || _type == TYPE_MACRO) { broker.getLog("IncludeDirective") .warning("Included a 'static' file type using a dynamic filename." + "File will be included, but any included #macro's will not."); } _macFilename = (Macro) o; } else { _strFilename = o.toString(); if (_strFilename == null || _strFilename.length() == 0) throw makeBuildException("Filename cannot be null or empty"); if (_type == TYPE_TEXT) { // we're a static type, need to // include the file (by returning it) now, // during build time try { return getThingToInclude(broker, _type, _strFilename); } catch (Exception e) { throw makeBuildException("Unable to include as text", e); } } else if (_type == TYPE_MACRO) { // we're a template type. ned to get the template (already parsed) // and merge its macros into our build context. // then we return the template so its contents can also be included Template t = null; try { t = getTemplate(broker, _strFilename); bc.mergeConstants(t); } catch (Exception e) { throw makeBuildException("Unable to include as macro", e); } return t; } else if (_type == TYPE_DYNAMIC) { // being dynamic means we need to guess the // file type based on the file's extension // and take care of finding the file during runtime _type = guessType(broker, _strFilename); } } // we are configured to be lazy, or we couldn't determine the filename // during the build() process (b/c it is a Macro) return this; }
if (context.getCurrentLocation().indexOf(_strFilename) > -1) { String warning = context.getCurrentLocation() + " includes itself."; writeWarning(warning, context, out);
if (_log.loggingDebug() && context.getCurrentLocation().indexOf(_strFilename) > -1) { _log.warning(context.getCurrentLocation() + " includes itself.");
public void write(FastWriter out, Context context) throws PropertyException, IOException { Broker broker = context.getBroker(); // the filename arg passed to us was a Macro, so // evaluate and check it now if (_macFilename != null) { _strFilename = _macFilename.evaluate(context).toString(); if (_strFilename == null || _strFilename.length() == 0) { throw makePropertyException("Filename cannot be null or empty"); } } // make sure we're not trying to include ourself. // maybe there is a better way to handle this? if (context.getCurrentLocation().indexOf(_strFilename) > -1) { String warning = context.getCurrentLocation() + " includes itself."; writeWarning(warning, context, out); } // this should only be true if StrictCompatibility is set to false // and "as <something>" wasn't specified in the arg list if (_type == TYPE_DYNAMIC) _type = guessType(broker, _strFilename); Object toInclude = getThingToInclude(broker, _type, _strFilename); switch (_type) { case TYPE_MACRO: // during runtime evaluation of a template, // a TYPE_MACRO doesn't really work as expected. // we logged a warning above in build(), but // we still need to write it out as a template // so just fall through case TYPE_TEMPLATE: ((Template) toInclude).write(out, context); break; case TYPE_TEXT: // static types are strings out.write(toInclude.toString()); break; default: // should never happen throw makePropertyException("Unrecognized file type: " + _type); } }
if (_log.loggingDebug()) { _log.debug("Including '" + _strFilename + "' as " + (_type == TYPE_MACRO) ? "MACRO" : (_type == TYPE_TEMPLATE) ? "TEMPLATE" : (_type == TYPE_TEXT) ? "TEXT" : "UNKNOWN. Throwing exceptin"); }
public void write(FastWriter out, Context context) throws PropertyException, IOException { Broker broker = context.getBroker(); // the filename arg passed to us was a Macro, so // evaluate and check it now if (_macFilename != null) { _strFilename = _macFilename.evaluate(context).toString(); if (_strFilename == null || _strFilename.length() == 0) { throw makePropertyException("Filename cannot be null or empty"); } } // make sure we're not trying to include ourself. // maybe there is a better way to handle this? if (context.getCurrentLocation().indexOf(_strFilename) > -1) { String warning = context.getCurrentLocation() + " includes itself."; writeWarning(warning, context, out); } // this should only be true if StrictCompatibility is set to false // and "as <something>" wasn't specified in the arg list if (_type == TYPE_DYNAMIC) _type = guessType(broker, _strFilename); Object toInclude = getThingToInclude(broker, _type, _strFilename); switch (_type) { case TYPE_MACRO: // during runtime evaluation of a template, // a TYPE_MACRO doesn't really work as expected. // we logged a warning above in build(), but // we still need to write it out as a template // so just fall through case TYPE_TEMPLATE: ((Template) toInclude).write(out, context); break; case TYPE_TEXT: // static types are strings out.write(toInclude.toString()); break; default: // should never happen throw makePropertyException("Unrecognized file type: " + _type); } }
availableCategories.setConverter(new IntegerConverter());
private UIComponent getCategoryEditContainer() { String ref = ARTICLE_ITEM_BEAN_ID + "."; String bref = WFPage.CONTENT_BUNDLE + "."; HtmlPanelGrid p = WFPanelUtil.getFormPanel(3); p.setId(CATEGORY_EDITOR_ID); p.getChildren().add(WFUtil.group(WFUtil.getTextVB(bref + "available_categories"), WFUtil.getText(":"))); p.getChildren().add(WFUtil.getText(" ")); p.getChildren().add(WFUtil.group(WFUtil.getTextVB(bref + "categories_for_this_article"), WFUtil.getText(":"))); WFContainer c = new WFContainer(); HtmlSelectManyListbox availableCategories = WFUtil.getSelectManyListbox(AVAILABLE_CATEGORIES_ID, ref + "availableCategories", ref + "selectedAvailableCategories"); availableCategories.setStyle("width:200px;height:160px;"); availableCategories.setConverter(new IntegerConverter()); c.add(availableCategories); c.add(WFUtil.getBreak(2)); c.add(WFUtil.getButtonVB(CATEGORY_BACK_ID, bref + "back", this)); p.getChildren().add(c); c = new WFContainer(); c.add(WFUtil.getBreak()); c.add(WFUtil.getButton(ADD_CATEGORIES_ID, ">", this)); c.add(WFUtil.getBreak(2)); c.add(WFUtil.getButton(SUB_CATEGORIES_ID, "<", this)); p.getChildren().add(c); HtmlSelectManyListbox articleCategories = WFUtil.getSelectManyListbox(ARTICLE_CATEGORIES_ID, ref + "categories", ref + "selectedCategories"); articleCategories.setStyle("width:200px;height:160px;"); articleCategories.setConverter(new IntegerConverter()); p.getChildren().add(articleCategories); return p; }
articleCategories.setConverter(new IntegerConverter());
private UIComponent getCategoryEditContainer() { String ref = ARTICLE_ITEM_BEAN_ID + "."; String bref = WFPage.CONTENT_BUNDLE + "."; HtmlPanelGrid p = WFPanelUtil.getFormPanel(3); p.setId(CATEGORY_EDITOR_ID); p.getChildren().add(WFUtil.group(WFUtil.getTextVB(bref + "available_categories"), WFUtil.getText(":"))); p.getChildren().add(WFUtil.getText(" ")); p.getChildren().add(WFUtil.group(WFUtil.getTextVB(bref + "categories_for_this_article"), WFUtil.getText(":"))); WFContainer c = new WFContainer(); HtmlSelectManyListbox availableCategories = WFUtil.getSelectManyListbox(AVAILABLE_CATEGORIES_ID, ref + "availableCategories", ref + "selectedAvailableCategories"); availableCategories.setStyle("width:200px;height:160px;"); availableCategories.setConverter(new IntegerConverter()); c.add(availableCategories); c.add(WFUtil.getBreak(2)); c.add(WFUtil.getButtonVB(CATEGORY_BACK_ID, bref + "back", this)); p.getChildren().add(c); c = new WFContainer(); c.add(WFUtil.getBreak()); c.add(WFUtil.getButton(ADD_CATEGORIES_ID, ">", this)); c.add(WFUtil.getBreak(2)); c.add(WFUtil.getButton(SUB_CATEGORIES_ID, "<", this)); p.getChildren().add(c); HtmlSelectManyListbox articleCategories = WFUtil.getSelectManyListbox(ARTICLE_CATEGORIES_ID, ref + "categories", ref + "selectedCategories"); articleCategories.setStyle("width:200px;height:160px;"); articleCategories.setConverter(new IntegerConverter()); p.getChildren().add(articleCategories); return p; }
Icon icon = room.getTabIcon();
final ChatRoomImpl chatRoomImpl = (ChatRoomImpl)room; Presence presence = chatRoomImpl.getPresence(); Icon icon = SparkManager.getUserManager().getIconFromPresence(presence);
public void useTabDefault(final ChatRoom room) { // Check if room is stale boolean containsRoom = getStaleChatRooms().contains(room); if (containsRoom) { return; } final int index = indexOfComponent(room); if (index != -1) { SparkTab tab = getTabAt(index); Font defaultFont = tab.getDefaultFont(); final JLabel titleLabel = tab.getTitleLabel(); if (room instanceof ChatRoomImpl) { Icon icon = room.getTabIcon(); tab.setIcon(icon); } titleLabel.setForeground(Color.black); titleLabel.setFont(defaultFont); } }
exitStatus |= checkPackageCoverageLevels(packageBranchCoverageRate, packageLineCoverageRate);
public Main(String[] args) throws MalformedPatternException { int exitStatus = 0; Header.print(System.out); File dataFile = CoverageDataFileHandler.getDefaultDataFile(); double branchCoverageRate = 0.0; double lineCoverageRate = 0.0; double totalBranchCoverageRate = 0.0; double totalLineCoverageRate = 0.0; for (int i = 0; i < args.length; i++) { if (args[i].equals("--branch")) { branchCoverageRate = inRangeAndDivideByOneHundred(args[++i]); } else if (args[i].equals("--datafile")) { dataFile = new File(args[++i]); } else if (args[i].equals("--line")) { lineCoverageRate = inRangeAndDivideByOneHundred(args[++i]); } else if (args[i].equals("--regex")) { setMinimumCoverageRate(args[++i]); } else if (args[i].equals("--totalbranch")) { totalBranchCoverageRate = inRangeAndDivideByOneHundred(args[++i]); } else if (args[i].equals("--totalline")) { totalLineCoverageRate = inRangeAndDivideByOneHundred(args[++i]); } } ProjectData projectData = CoverageDataFileHandler .loadCoverageData(dataFile); if (projectData == null) { System.err.println("Error: Unable to read from data file " + dataFile.getAbsolutePath()); System.exit(1); } // If they didn't specify any thresholds, then use some defaults if ((branchCoverageRate == 0) && (lineCoverageRate == 0) && (totalLineCoverageRate == 0) && (totalBranchCoverageRate == 0) && (this.minimumCoverageRates.size() == 0)) { branchCoverageRate = 0.5; lineCoverageRate = 0.5; totalBranchCoverageRate = 0.5; totalLineCoverageRate = 0.5; } this.minimumCoverageRate = new CoverageRate(lineCoverageRate, branchCoverageRate); double totalLines = 0; double totalLinesCovered = 0; double totalBranches = 0; double totalBranchesCovered = 0; Iterator iter = projectData.getClasses().iterator(); while (iter.hasNext()) { ClassData classData = (ClassData)iter.next(); CoverageRate coverageRate = findMinimumCoverageRate(classData .getName()); if (totalBranchCoverageRate > 0.0) { totalBranches += classData.getNumberOfValidBranches(); totalBranchesCovered += classData.getNumberOfCoveredBranches(); } if (totalLineCoverageRate > 0.0) { totalLines += classData.getNumberOfValidLines(); totalLinesCovered += classData.getNumberOfCoveredLines(); } logger.debug("Class " + classData.getName() + ", line coverage rate: " + percentage(classData.getLineCoverageRate()) + "%, branch coverage rate: " + percentage(classData.getBranchCoverageRate()) + "%"); if (classData.getBranchCoverageRate() < coverageRate .getBranchCoverageRate()) { System.err.println(classData.getName() + " failed check. Branch coverage rate of " + percentage(classData.getBranchCoverageRate()) + "% is below " + percentage(coverageRate.getBranchCoverageRate()) + "%"); exitStatus |= 2; } if (classData.getLineCoverageRate() < coverageRate .getLineCoverageRate()) { System.err.println(classData.getName() + " failed check. Line coverage rate of " + percentage(classData.getLineCoverageRate()) + "% is below " + percentage(coverageRate.getLineCoverageRate()) + "%"); exitStatus |= 4; } } // Check the rates for the overal project if ((totalBranches > 0) && (totalBranchCoverageRate > (totalBranchesCovered / totalBranches))) { System.err .println("Project failed check. " + "Total branch coverage rate of " + percentage(totalBranchesCovered / totalBranches) + "% is below " + percentage(totalBranchCoverageRate) + "%"); exitStatus |= 8; } if ((totalLines > 0) && (totalLineCoverageRate > (totalLinesCovered / totalLines))) { System.err.println("Project failed check. " + "Total line coverage rate of " + percentage(totalLinesCovered / totalLines) + "% is below " + percentage(totalLineCoverageRate) + "%"); exitStatus |= 16; } System.exit(exitStatus); }
task.createArg().setValue("test.xml");
task.createArg().setValue(BASEDIR + "/test.xml");
private static void runTestAntScript(String testName, String target) throws IOException { Java task = new Java(); task.setTaskName("java"); task.setProject(new Project()); task.init(); // Call ant launcher. Requires ant-lancher.jar. task.setClassname("org.apache.tools.ant.launch.Launcher"); task.setFork(true); transferCoberturaDataFileProperty(task); task.createArg().setValue("-f"); task.createArg().setValue("test.xml"); task.createArg().setValue(target); task.setFailonerror(true); // Set output to go to a temp file File outputFile = Util.createTemporaryTextFile("cobertura-test"); task.setOutput(outputFile); // Set the classpath to the same classpath as this JVM Path classpath = task.createClasspath(); PathElement pathElement = classpath.createPathElement(); pathElement.setPath(System.getProperty("java.class.path")); try { task.execute(); } catch (Throwable t) { t.printStackTrace(); if (outputFile.exists()) { // Put the contents of the output file in the exception System.out.println("\n\n\nOutput from Ant for " + testName + " test:\n----------------------------------------\n" + Util.getText(outputFile) + "----------------------------------------"); outputFile.delete(); throw new RuntimeException(Util.getText(outputFile)); } } finally { if (outputFile.exists()) { // Put the contents of the output file in the exception System.out.println("\n\n\nOutput from Ant for " + testName + " test:\n----------------------------------------\n" + Util.getText(outputFile) + "----------------------------------------"); outputFile.delete(); } } }
public XMLReport(Map coverageData, File outputDir, File sourceDirectory)
public XMLReport(Coverage coverage, File outputDir, File sourceDirectory)
public XMLReport(Map coverageData, File outputDir, File sourceDirectory) throws IOException { pw = new PrintWriter(new FileWriter(new File(outputDir, "coverage.xml"))); try { println("<?xml version=\"1.0\"?>"); if (sourceDirectory == null) { println("<coverage>"); } else { println("<coverage src=\"" + sourceDirectory + "\">"); } increaseIndentation(); dump(coverageData.entrySet().iterator()); decreaseIndentation(); println("</coverage>"); } finally { pw.close(); } }
dump(coverageData.entrySet().iterator());
dumpPackages(coverage);
public XMLReport(Map coverageData, File outputDir, File sourceDirectory) throws IOException { pw = new PrintWriter(new FileWriter(new File(outputDir, "coverage.xml"))); try { println("<?xml version=\"1.0\"?>"); if (sourceDirectory == null) { println("<coverage>"); } else { println("<coverage src=\"" + sourceDirectory + "\">"); } increaseIndentation(); dump(coverageData.entrySet().iterator()); decreaseIndentation(); println("</coverage>"); } finally { pw.close(); } }
for (DisplayedNote child : displayedNotes) {
while (displayedNotes.size() > 0) { DisplayedNote child = displayedNotes.get(0);
public void deleteSelfAndChildren() { for (DisplayedNote child : displayedNotes) { child.deleteSelfAndChildren(); } treeNode.dispose(); if (tab != null) tab.dispose(); holder.removeDisplayedNote(this); note.getHolder().removeNote(note); }
out.println(pkg == null ? "All Packages" : pkg.getName());
out.println(pkg == null ? "All Packages" : generatePackageName(pkg));
private void generateClassList(Package pkg) throws IOException { String filename; Collection classes; if (pkg == null) { filename = "frame-classes.html"; classes = coverage.getClassesSortedByBasename().values(); } else { filename = "frame-classes-" + pkg.getName() + ".html"; classes = pkg.getClasses(); } 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 Classes</title>"); out .println("<link title=\"Style\" type=\"text/css\" rel=\"stylesheet\" href=\"css/main.css\" />"); out.println("</head>"); out.println("<body>"); out.println("<h5>"); out.println(pkg == null ? "All Packages" : pkg.getName()); out.println("</h5>"); out.println("<h5>Classes</h5>"); out.println("<table width=\"100%\">"); for (Iterator iter = classes.iterator(); iter.hasNext();) { Clazz clazz = (Clazz)iter.next(); out.println("<tr>"); String percentCovered; if (clazz.getNumberOfLines() > 0) percentCovered = getPercentValue(clazz .getLineCoverageRate()); else percentCovered = "N/A"; out .println("<td nowrap=\"nowrap\"><a target=\"summary\" href=\"" + clazz.getLongName() + ".html\">" + clazz.getName() + "</a> <i>(" + percentCovered + ")</i></td>"); out.println("</tr>"); } out.println("</td>"); out.println("</tr>"); out.println("</table>"); out.println("</body>"); out.println("</html>"); } finally { if (out != null) { out.close(); } } }
out.print(pkg == null ? "All Packages" : pkg.getName());
out.print(pkg == null ? "All Packages" : generatePackageName(pkg));
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.getNumberOfClasses() > 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("<div class=\"footer\">"); out .println("Reports generated by <a href=\"http://cobertura.sourceforge.net/\" target=\"_top\">Cobertura</a>."); out.println("</div>"); out.println("</body>"); out.println("</html>"); } finally { if (out != null) { out.close(); } } }
+ url2 + "\"' target=\"summary\">" + pkg.getName()
+ url2 + "\"' target=\"summary\">" + generatePackageName(pkg)
private void generatePackageList() throws IOException { File file = new File(outputDir, "frame-packages.html"); 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("</head>"); out.println("<body>"); out.println("<h5>Packages</h5>"); out.println("<table width=\"100%\">"); out.println("<tr>"); out .println("<td nowrap=\"nowrap\"><a href=\"frame-summary.html\" onClick='parent.classList.location.href=\"frame-classes.html\"' target=\"summary\">All</a></td>"); out.println("</tr>"); Iterator iter = coverage.getPackages().iterator(); while (iter.hasNext()) { Package pkg = (Package)iter.next(); String url1 = "frame-summary-" + pkg.getName() + ".html"; String url2 = "frame-classes-" + pkg.getName() + ".html"; out.println("<tr>"); out.println("<td nowrap=\"nowrap\"><a href=\"" + url1 + "\" onClick='parent.classList.location.href=\"" + url2 + "\"' target=\"summary\">" + pkg.getName() + "</a></td>"); out.println("</tr>"); } out.println("</table>"); out.println("</body>"); out.println("</html>"); } finally { if (out != null) { out.close(); } } }
if (clazz.getPackageName() != null)
String classPackageName = clazz.getPackageName(); if ((classPackageName != null) && classPackageName.length() > 0)
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("<div class=\"footer\">"); out .println("Reports generated by <a href=\"http://cobertura.sourceforge.net/\" target=\"_top\">Cobertura</a>."); out.println("</div>"); out.println("</body>"); out.println("</html>"); } finally { if (out != null) { out.close(); } } }
+ "\"'>" + pkg.getName() + "</a></td>");
+ "\"'>" + generatePackageName(pkg) + "</a></td>");
private String generateTableRowForPackage(Package pkg) { StringBuffer ret = new StringBuffer(); String url1 = "frame-summary-" + pkg.getName() + ".html"; String url2 = "frame-classes-" + pkg.getName() + ".html"; double lineCoverage = pkg.getLineCoverageRate(); double branchCoverage = pkg.getBranchCoverageRate(); double ccn = Util.getCCN(new File(sourceDir, pkg.getFileName()), false); ret.append(" <tr>"); ret.append("<td class=\"text\"><a href=\"" + url1 + "\" onClick='parent.classList.location.href=\"" + url2 + "\"'>" + pkg.getName() + "</a></td>"); ret .append("<td class=\"value\">" + pkg.getClasses().size() + "</td>"); ret.append(generateTableColumnsFromData(lineCoverage, branchCoverage, ccn)); ret.append("</tr>"); return ret.toString(); }
if ((broadcast || message.getType() == Message.Type.NORMAL) && message.getBody() != null) {
if ((broadcast || (message.getType() == Message.Type.NORMAL) || message.getType() == Message.Type.HEADLINE) && message.getBody() != null) {
public void processPacket(final Packet packet) { SwingUtilities.invokeLater(new Runnable() { public void run() { final Message message = (Message)packet; boolean broadcast = message.getProperty("broadcast") != null; if ((broadcast || message.getType() == Message.Type.NORMAL) && message.getBody() != null) { showAlert((Message)packet); } else { String host = SparkManager.getSessionManager().getServerAddress(); String from = packet.getFrom() != null ? packet.getFrom() : ""; if (host.equalsIgnoreCase(from) || !ModelUtil.hasLength(from)) { showAlert((Message)packet); } } } }); }
if ((broadcast || message.getType() == Message.Type.NORMAL) && message.getBody() != null) {
if ((broadcast || (message.getType() == Message.Type.NORMAL) || message.getType() == Message.Type.HEADLINE) && message.getBody() != null) {
public void run() { final Message message = (Message)packet; boolean broadcast = message.getProperty("broadcast") != null; if ((broadcast || message.getType() == Message.Type.NORMAL) && message.getBody() != null) { showAlert((Message)packet); } else { String host = SparkManager.getSessionManager().getServerAddress(); String from = packet.getFrom() != null ? packet.getFrom() : ""; if (host.equalsIgnoreCase(from) || !ModelUtil.hasLength(from)) { showAlert((Message)packet); } } }
pathToTestOutput, "--source", pathToSourceCode };
pathToTestOutput, pathToSourceCode };
public void testXMLReportValidity() throws Exception { String[] args; // Serialize the current coverage data to disk ProjectData.saveGlobalProjectData(); String dataFileName = CoverageDataFileHandler.getDefaultDataFile() .getAbsolutePath(); // Then we need to generate the XML report args = new String[] { "--format", "xml", "--datafile", dataFileName, "--destination", pathToTestOutput, "--source", pathToSourceCode }; net.sourceforge.cobertura.reporting.Main.main(args); // Create a validating XML document parser DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(true); DocumentBuilder documentBuilder = factory.newDocumentBuilder(); documentBuilder.setEntityResolver(new JUnitXMLParserEntityResolver( basedir)); documentBuilder.setErrorHandler(new JUnitXMLParserErrorHandler()); // Parse the XML report InputStream inputStream = null; try { inputStream = new FileInputStream(pathToXMLReport); documentBuilder.parse(inputStream); } finally { if (inputStream != null) inputStream.close(); } }
public SingletonReference(String name, Set patterns, String objectTypeName) { this.name = name; this.patterns = patterns; this.objectTypeName = objectTypeName;
public SingletonReference() {
public SingletonReference(String name, Set patterns, String objectTypeName) { this.name = name; this.patterns = patterns; this.objectTypeName = objectTypeName; }
objectType = ClassLoading.loadClass(objectTypeName, serviceContext.getClassLoader());
objectType = ClassLoading.loadClass(referenceType, serviceContext.getClassLoader());
public synchronized final Object getObject() throws ClassNotFoundException { ServiceContext serviceContext = ServiceContextThreadLocal.get(); if (serviceContext == null) { throw new IllegalStateException("Service context has not been set"); } synchronized (this) { if (objectType == null) { objectType = ClassLoading.loadClass(objectTypeName, serviceContext.getClassLoader()); } } Set targets = ServiceInstanceUtil.getRunningTargets(serviceContext.getKernel(), patterns); if (targets.size() != 1) { throw new IllegalStateException("Invalid reference: name=" + name + ", targetCount=" + targets.size() + ", patterns=" + getPatternsText()); } // add a dependency on our target and create the proxy ObjectName target = (ObjectName) targets.iterator().next(); ProxyManager proxyManager = null; try { proxyManager = ProxyManager.findProxyManager(serviceContext.getKernel()); } catch (ServiceNotFoundException e) { throw new IllegalStateException("ProxyManger has not been loaded"); } try { return proxyManager.createProxy(target, objectType, this); } catch (ServiceNotFoundException e) { throw new IllegalStateException("Referenced object was unregistered before a proxy could be created: name=" + name + ", targetCount=" + targets.size() + ", patterns=" + getPatternsText()); } }
objectType = ClassLoading.loadClass(objectTypeName, serviceContext.getClassLoader());
objectType = ClassLoading.loadClass(referenceType, serviceContext.getClassLoader());
public final Class getObjectType() { ServiceContext serviceContext = ServiceContextThreadLocal.get(); if (serviceContext == null) { throw new IllegalStateException("Service context has not been set"); } synchronized (this) { if (objectType == null) { try { objectType = ClassLoading.loadClass(objectTypeName, serviceContext.getClassLoader()); } catch (ClassNotFoundException e) { throw new IllegalStateException("Could not load singleton reference object type"); } } } return objectType; }
return (l.equals(r)) ? TRUE : FALSE;
return (!l.equals(r)) ? TRUE : FALSE;
public Boolean compare(Object l, Object r) { return (l.equals(r)) ? TRUE : FALSE; }
return ((o instanceof Integer) || o instanceof Long || o instanceof Short || o instanceof Byte);
return (o instanceof Number);
public static boolean isNumber(Object o) { return ((o instanceof Integer) || o instanceof Long || o instanceof Short || o instanceof Byte); }
if (coberturaFile.isClass() && shouldInstrument(coberturaFile.getPathname()))
if (coberturaFile.isClass() && classPattern.matches(coberturaFile.getPathname()))
private void addInstrumentation(CoberturaFile coberturaFile) { if (coberturaFile.isClass() && shouldInstrument(coberturaFile.getPathname())) { addInstrumentationToSingleClass(coberturaFile); } else if (coberturaFile.isDirectory()) { String[] contents = coberturaFile.list(); for (int i = 0; i < contents.length; i++) { File relativeFile = new File(coberturaFile.getPathname(), contents[i]); CoberturaFile relativeCoberturaFile = new CoberturaFile(coberturaFile.getBaseDir(), relativeFile.toString()); //recursion! addInstrumentation(relativeCoberturaFile); } } }
private void addInstrumentationToArchive(ZipInputStream archive, ZipOutputStream output) throws Exception
private boolean addInstrumentationToArchive(CoberturaFile file, InputStream archive, OutputStream output) throws Exception
private void addInstrumentationToArchive(ZipInputStream archive, ZipOutputStream output) throws Exception { ZipEntry entry; while ((entry = archive.getNextEntry()) != null) { try { ZipEntry outputEntry = new ZipEntry(entry.getName()); output.putNextEntry(outputEntry); // Read current entry byte[] entryBytes = IOUtil .createByteArrayFromInputStream(archive); // Check if we have class file if (isClass(entry) && shouldInstrument(entry.getName())) { // Instrument class ClassReader cr = new ClassReader(entryBytes); ClassWriter cw = new ClassWriter(true); ClassInstrumenter cv = new ClassInstrumenter(projectData, cw, ignoreRegexes); cr.accept(cv, CustomAttribute.getExtraAttributes(), false); // If class was instrumented, get bytes that define the // class if (cv.isInstrumented()) { logger.debug("Putting instrumented entry: " + entry.getName()); entryBytes = cw.toByteArray(); } } // Add entry to the output output.write(entryBytes); output.closeEntry(); archive.closeEntry(); } catch (Exception e) { logger.warn("Problems with archive entry: " + entry); throw e; } output.flush(); } }
ZipEntry entry; while ((entry = archive.getNextEntry()) != null)
ZipInputStream zis = null; ZipOutputStream zos = null; try
private void addInstrumentationToArchive(ZipInputStream archive, ZipOutputStream output) throws Exception { ZipEntry entry; while ((entry = archive.getNextEntry()) != null) { try { ZipEntry outputEntry = new ZipEntry(entry.getName()); output.putNextEntry(outputEntry); // Read current entry byte[] entryBytes = IOUtil .createByteArrayFromInputStream(archive); // Check if we have class file if (isClass(entry) && shouldInstrument(entry.getName())) { // Instrument class ClassReader cr = new ClassReader(entryBytes); ClassWriter cw = new ClassWriter(true); ClassInstrumenter cv = new ClassInstrumenter(projectData, cw, ignoreRegexes); cr.accept(cv, CustomAttribute.getExtraAttributes(), false); // If class was instrumented, get bytes that define the // class if (cv.isInstrumented()) { logger.debug("Putting instrumented entry: " + entry.getName()); entryBytes = cw.toByteArray(); } } // Add entry to the output output.write(entryBytes); output.closeEntry(); archive.closeEntry(); } catch (Exception e) { logger.warn("Problems with archive entry: " + entry); throw e; } output.flush(); } }
try { ZipEntry outputEntry = new ZipEntry(entry.getName()); output.putNextEntry(outputEntry); byte[] entryBytes = IOUtil .createByteArrayFromInputStream(archive); if (isClass(entry) && shouldInstrument(entry.getName())) { ClassReader cr = new ClassReader(entryBytes); ClassWriter cw = new ClassWriter(true); ClassInstrumenter cv = new ClassInstrumenter(projectData, cw, ignoreRegexes); cr.accept(cv, CustomAttribute.getExtraAttributes(), false); if (cv.isInstrumented()) { logger.debug("Putting instrumented entry: " + entry.getName()); entryBytes = cw.toByteArray(); } } output.write(entryBytes); output.closeEntry(); archive.closeEntry(); } catch (Exception e) { logger.warn("Problems with archive entry: " + entry); throw e; } output.flush();
zis = new ZipInputStream(archive); zos = new ZipOutputStream(output); return addInstrumentationToArchive(file, zis, zos); } finally { zis = (ZipInputStream)IOUtil.closeInputStream(zis); zos = (ZipOutputStream)IOUtil.closeOutputStream(zos);
private void addInstrumentationToArchive(ZipInputStream archive, ZipOutputStream output) throws Exception { ZipEntry entry; while ((entry = archive.getNextEntry()) != null) { try { ZipEntry outputEntry = new ZipEntry(entry.getName()); output.putNextEntry(outputEntry); // Read current entry byte[] entryBytes = IOUtil .createByteArrayFromInputStream(archive); // Check if we have class file if (isClass(entry) && shouldInstrument(entry.getName())) { // Instrument class ClassReader cr = new ClassReader(entryBytes); ClassWriter cw = new ClassWriter(true); ClassInstrumenter cv = new ClassInstrumenter(projectData, cw, ignoreRegexes); cr.accept(cv, CustomAttribute.getExtraAttributes(), false); // If class was instrumented, get bytes that define the // class if (cv.isInstrumented()) { logger.debug("Putting instrumented entry: " + entry.getName()); entryBytes = cw.toByteArray(); } } // Add entry to the output output.write(entryBytes); output.closeEntry(); archive.closeEntry(); } catch (Exception e) { logger.warn("Problems with archive entry: " + entry); throw e; } output.flush(); } }
if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { } }
inputStream = IOUtil.closeInputStream(inputStream);
private void addInstrumentationToSingleClass(File file) { logger.debug("Instrumenting class " + file.getAbsolutePath()); InputStream inputStream = null; ClassWriter cw; ClassInstrumenter cv; try { inputStream = new FileInputStream(file); ClassReader cr = new ClassReader(inputStream); cw = new ClassWriter(true); cv = new ClassInstrumenter(projectData, cw, ignoreRegexes); cr.accept(cv, CustomAttribute.getExtraAttributes(), false); } catch (Throwable t) { logger.warn("Unable to instrument file " + file.getAbsolutePath(), t); return; } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { } } } OutputStream outputStream = null; try { if (cv.isInstrumented()) { // If destinationDirectory is null, then overwrite // the original, uninstrumented file. File outputFile; if (destinationDirectory == null) outputFile = file; else outputFile = new File(destinationDirectory, cv .getClassName().replace('.', File.separatorChar) + ".class"); File parentFile = outputFile.getParentFile(); if (parentFile != null) { parentFile.mkdirs(); } byte[] instrumentedClass = cw.toByteArray(); outputStream = new FileOutputStream(outputFile); outputStream.write(instrumentedClass); } } catch (Throwable t) { logger.warn("Unable to instrument file " + file.getAbsolutePath(), t); return; } finally { if (outputStream != null) { try { outputStream.close(); } catch (IOException e) { } } } }
if (outputStream != null) { try { outputStream.close(); } catch (IOException e) { } }
outputStream = IOUtil.closeOutputStream(outputStream);
private void addInstrumentationToSingleClass(File file) { logger.debug("Instrumenting class " + file.getAbsolutePath()); InputStream inputStream = null; ClassWriter cw; ClassInstrumenter cv; try { inputStream = new FileInputStream(file); ClassReader cr = new ClassReader(inputStream); cw = new ClassWriter(true); cv = new ClassInstrumenter(projectData, cw, ignoreRegexes); cr.accept(cv, CustomAttribute.getExtraAttributes(), false); } catch (Throwable t) { logger.warn("Unable to instrument file " + file.getAbsolutePath(), t); return; } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { } } } OutputStream outputStream = null; try { if (cv.isInstrumented()) { // If destinationDirectory is null, then overwrite // the original, uninstrumented file. File outputFile; if (destinationDirectory == null) outputFile = file; else outputFile = new File(destinationDirectory, cv .getClassName().replace('.', File.separatorChar) + ".class"); File parentFile = outputFile.getParentFile(); if (parentFile != null) { parentFile.mkdirs(); } byte[] instrumentedClass = cw.toByteArray(); outputStream = new FileOutputStream(outputFile); outputStream.write(instrumentedClass); } } catch (Throwable t) { logger.warn("Unable to instrument file " + file.getAbsolutePath(), t); return; } finally { if (outputStream != null) { try { outputStream.close(); } catch (IOException e) { } } } }
addRegex(ignoreRegexes, args[++i]);
RegexUtil.addRegex(ignoreRegexes, args[++i]);
private void parseArguments(String[] args) { File dataFile = CoverageDataFileHandler.getDefaultDataFile(); // Parse our parameters List filePaths = new ArrayList(); String baseDir = null; for (int i = 0; i < args.length; i++) { if (args[i].equals("--basedir")) baseDir = args[++i]; else if (args[i].equals("--datafile")) dataFile = new File(args[++i]); else if (args[i].equals("--destination")) destinationDirectory = new File(args[++i]); else if (args[i].equals("--ignore")) { addRegex(ignoreRegexes, args[++i]); } else if (args[i].equals("--includeClasses")) { addRegex(includeClassesRegexes, args[++i]); } else if (args[i].equals("--excludeClasses")) { addRegex(excludeClassesRegexes, args[++i]); } else { CoberturaFile coberturaFile = new CoberturaFile(baseDir, args[i]); filePaths.add(coberturaFile); } } // Load coverage data if (dataFile.isFile()) projectData = CoverageDataFileHandler.loadCoverageData(dataFile); if (projectData == null) projectData = new ProjectData(); // Instrument classes System.out.println("Instrumenting " + filePaths.size() + " " + (filePaths.size() == 1 ? "file" : "files") + (destinationDirectory != null ? " to " + destinationDirectory.getAbsoluteFile() : "")); Iterator iter = filePaths.iterator(); while (iter.hasNext()) { CoberturaFile coberturaFile = (CoberturaFile)iter.next(); if (coberturaFile.isArchive()) { addInstrumentationToArchive(coberturaFile); } else { addInstrumentation(coberturaFile); } } // Save coverage data CoverageDataFileHandler.saveCoverageData(projectData, dataFile); }
addRegex(includeClassesRegexes, args[++i]);
classPattern.addIncludeClassesRegex(args[++i]);
private void parseArguments(String[] args) { File dataFile = CoverageDataFileHandler.getDefaultDataFile(); // Parse our parameters List filePaths = new ArrayList(); String baseDir = null; for (int i = 0; i < args.length; i++) { if (args[i].equals("--basedir")) baseDir = args[++i]; else if (args[i].equals("--datafile")) dataFile = new File(args[++i]); else if (args[i].equals("--destination")) destinationDirectory = new File(args[++i]); else if (args[i].equals("--ignore")) { addRegex(ignoreRegexes, args[++i]); } else if (args[i].equals("--includeClasses")) { addRegex(includeClassesRegexes, args[++i]); } else if (args[i].equals("--excludeClasses")) { addRegex(excludeClassesRegexes, args[++i]); } else { CoberturaFile coberturaFile = new CoberturaFile(baseDir, args[i]); filePaths.add(coberturaFile); } } // Load coverage data if (dataFile.isFile()) projectData = CoverageDataFileHandler.loadCoverageData(dataFile); if (projectData == null) projectData = new ProjectData(); // Instrument classes System.out.println("Instrumenting " + filePaths.size() + " " + (filePaths.size() == 1 ? "file" : "files") + (destinationDirectory != null ? " to " + destinationDirectory.getAbsoluteFile() : "")); Iterator iter = filePaths.iterator(); while (iter.hasNext()) { CoberturaFile coberturaFile = (CoberturaFile)iter.next(); if (coberturaFile.isArchive()) { addInstrumentationToArchive(coberturaFile); } else { addInstrumentation(coberturaFile); } } // Save coverage data CoverageDataFileHandler.saveCoverageData(projectData, dataFile); }
addRegex(excludeClassesRegexes, args[++i]);
classPattern.addExcludeClassesRegex(args[++i]);
private void parseArguments(String[] args) { File dataFile = CoverageDataFileHandler.getDefaultDataFile(); // Parse our parameters List filePaths = new ArrayList(); String baseDir = null; for (int i = 0; i < args.length; i++) { if (args[i].equals("--basedir")) baseDir = args[++i]; else if (args[i].equals("--datafile")) dataFile = new File(args[++i]); else if (args[i].equals("--destination")) destinationDirectory = new File(args[++i]); else if (args[i].equals("--ignore")) { addRegex(ignoreRegexes, args[++i]); } else if (args[i].equals("--includeClasses")) { addRegex(includeClassesRegexes, args[++i]); } else if (args[i].equals("--excludeClasses")) { addRegex(excludeClassesRegexes, args[++i]); } else { CoberturaFile coberturaFile = new CoberturaFile(baseDir, args[i]); filePaths.add(coberturaFile); } } // Load coverage data if (dataFile.isFile()) projectData = CoverageDataFileHandler.loadCoverageData(dataFile); if (projectData == null) projectData = new ProjectData(); // Instrument classes System.out.println("Instrumenting " + filePaths.size() + " " + (filePaths.size() == 1 ? "file" : "files") + (destinationDirectory != null ? " to " + destinationDirectory.getAbsoluteFile() : "")); Iterator iter = filePaths.iterator(); while (iter.hasNext()) { CoberturaFile coberturaFile = (CoberturaFile)iter.next(); if (coberturaFile.isArchive()) { addInstrumentationToArchive(coberturaFile); } else { addInstrumentation(coberturaFile); } } // Save coverage data CoverageDataFileHandler.saveCoverageData(projectData, dataFile); }
.println("<script type=\"text/javascript\" src=\"js/percentagesorttype.js\"></script>");
.println("<script type=\"text/javascript\" src=\"js/customsorttypes.js\"></script>");
private void generateOverview(PackageData packageData) throws IOException { Iterator iter; String filename; if (packageData == null) { filename = "frame-summary.html"; } else { filename = "frame-summary-" + packageData.getName() + ".html"; } File file = new File(destinationDir, 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(packageData == null ? "All Packages" : generatePackageName(packageData)); 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>"); Collection packages; if (packageData == null) { // Output a summary line for all packages out.println(generateTableRowForTotal()); // Get packages packages = projectData.getChildren(); } else { // Get subpackages packages = projectData.getSubPackages(packageData.getName()); } // Output a line for each package or subpackage iter = packages.iterator(); while (iter.hasNext()) { PackageData subPackageData = (PackageData)iter.next(); out.println(generateTableRowForPackage(subPackageData)); } 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 Collection classes; if (packageData == null) { classes = new TreeSet(); if (projectData.getNumberOfClasses() > 0) { iter = projectData.getClasses().iterator(); while (iter.hasNext()) { ClassData classData = (ClassData)iter.next(); if (classData.getPackageName() == null) { classes.add(classData); } } } } else { classes = packageData.getChildren(); } // 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>"); iter = classes.iterator(); while (iter.hasNext()) { ClassData classData = (ClassData)iter.next(); out.println(generateTableRowForClass(classData)); } 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("<div class=\"footer\">"); out .println("Report generated by <a href=\"http://cobertura.sourceforge.net/\" target=\"_top\">Cobertura</a>."); out.println("</div>"); out.println("</body>"); out.println("</html>"); } finally { if (out != null) { out.close(); } } }
.println(" [\"String\", \"Number\", \"Percentage\", \"Percentage\", \"Number\", \"Number\", \"Number\"]);");
.println(" [\"String\", \"Number\", \"Percentage\", \"Percentage\", \"LocalizedNumber\"]);");
private void generateOverview(PackageData packageData) throws IOException { Iterator iter; String filename; if (packageData == null) { filename = "frame-summary.html"; } else { filename = "frame-summary-" + packageData.getName() + ".html"; } File file = new File(destinationDir, 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(packageData == null ? "All Packages" : generatePackageName(packageData)); 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>"); Collection packages; if (packageData == null) { // Output a summary line for all packages out.println(generateTableRowForTotal()); // Get packages packages = projectData.getChildren(); } else { // Get subpackages packages = projectData.getSubPackages(packageData.getName()); } // Output a line for each package or subpackage iter = packages.iterator(); while (iter.hasNext()) { PackageData subPackageData = (PackageData)iter.next(); out.println(generateTableRowForPackage(subPackageData)); } 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 Collection classes; if (packageData == null) { classes = new TreeSet(); if (projectData.getNumberOfClasses() > 0) { iter = projectData.getClasses().iterator(); while (iter.hasNext()) { ClassData classData = (ClassData)iter.next(); if (classData.getPackageName() == null) { classes.add(classData); } } } } else { classes = packageData.getChildren(); } // 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>"); iter = classes.iterator(); while (iter.hasNext()) { ClassData classData = (ClassData)iter.next(); out.println(generateTableRowForClass(classData)); } 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("<div class=\"footer\">"); out .println("Report generated by <a href=\"http://cobertura.sourceforge.net/\" target=\"_top\">Cobertura</a>."); out.println("</div>"); out.println("</body>"); out.println("</html>"); } finally { if (out != null) { out.close(); } } }
.println(" [\"String\", \"Percentage\", \"Percentage\", \"Number\", \"Number\", \"Number\"]);");
.println(" [\"String\", \"Percentage\", \"Percentage\", \"LocalizedNumber\"]);");
private void generateOverview(PackageData packageData) throws IOException { Iterator iter; String filename; if (packageData == null) { filename = "frame-summary.html"; } else { filename = "frame-summary-" + packageData.getName() + ".html"; } File file = new File(destinationDir, 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(packageData == null ? "All Packages" : generatePackageName(packageData)); 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>"); Collection packages; if (packageData == null) { // Output a summary line for all packages out.println(generateTableRowForTotal()); // Get packages packages = projectData.getChildren(); } else { // Get subpackages packages = projectData.getSubPackages(packageData.getName()); } // Output a line for each package or subpackage iter = packages.iterator(); while (iter.hasNext()) { PackageData subPackageData = (PackageData)iter.next(); out.println(generateTableRowForPackage(subPackageData)); } 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 Collection classes; if (packageData == null) { classes = new TreeSet(); if (projectData.getNumberOfClasses() > 0) { iter = projectData.getClasses().iterator(); while (iter.hasNext()) { ClassData classData = (ClassData)iter.next(); if (classData.getPackageName() == null) { classes.add(classData); } } } } else { classes = packageData.getChildren(); } // 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>"); iter = classes.iterator(); while (iter.hasNext()) { ClassData classData = (ClassData)iter.next(); out.println(generateTableRowForClass(classData)); } 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("<div class=\"footer\">"); out .println("Report generated by <a href=\"http://cobertura.sourceforge.net/\" target=\"_top\">Cobertura</a>."); out.println("</div>"); out.println("</body>"); out.println("</html>"); } finally { if (out != null) { out.close(); } } }
JOptionPane.showMessageDialog(SparkManager.getMainWindow(), "The message has been broadcasted to the following users:\n" + buf.toString(), "Message Broadcasted", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(SparkManager.getMainWindow(), Res.getString("message.broadcasted.to", buf.toString()), Res.getString("title.notification"), JOptionPane.INFORMATION_MESSAGE);
private void broadcastToGroup(ContactGroup group) { StringBuffer buf = new StringBuffer(); InputDialog dialog = new InputDialog(); final String messageText = dialog.getInput(Res.getString("title.broadcast.message"), Res.getString("message.broadcast.to", group.getGroupName()), SparkRes.getImageIcon(SparkRes.BLANK_IMAGE), SparkManager.getMainWindow()); if (ModelUtil.hasLength(messageText)) { for (ContactItem item : group.getContactItems()) { final Message message = new Message(); message.setTo(item.getFullJID()); message.setProperty("broadcast", true); message.setBody(messageText); buf.append(item.getNickname()).append("\n"); SparkManager.getConnection().sendPacket(message); } JOptionPane.showMessageDialog(SparkManager.getMainWindow(), "The message has been broadcasted to the following users:\n" + buf.toString(), "Message Broadcasted", JOptionPane.INFORMATION_MESSAGE); } }
new XMLReport(coverageData, outputDir, sourceDir);
new XMLReport(coverage, outputDir, sourceDir);
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("instrumentation", LongOpt.REQUIRED_ARGUMENT, null, 'i'); 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:i: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 'i': serializationFile = new File(g.getOptarg()); if (!serializationFile.exists()) { throw new Exception("Error: serialization file " + serializationFile + " does not exist"); } if (serializationFile.isDirectory()) { throw new Exception("Error: serialization file " + serializationFile + " 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("serializationFile is " + serializationFile.getAbsolutePath()); logger.debug("outputDir is " + outputDir.getAbsolutePath()); logger.debug("sourceDir is " + sourceDir.getAbsolutePath()); } InputStream is = null; ObjectInputStream objects = null; try { is = new FileInputStream(serializationFile); objects = new ObjectInputStream(is); Map coverageData = (Map)objects.readObject(); if (format.equalsIgnoreCase("xml")) { new XMLReport(coverageData, outputDir, sourceDir); } else if (format.equalsIgnoreCase("html")) { new HTMLReport(coverageData, outputDir, sourceDir); } } finally { if (is != null) is.close(); if (objects != null) objects.close(); } long stopTime = System.currentTimeMillis(); System.out .println("Reporting time: " + (stopTime - startTime) + "ms"); }
new HTMLReport(coverageData, outputDir, sourceDir);
new HTMLReport(coverage, outputDir, sourceDir);
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("instrumentation", LongOpt.REQUIRED_ARGUMENT, null, 'i'); 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:i: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 'i': serializationFile = new File(g.getOptarg()); if (!serializationFile.exists()) { throw new Exception("Error: serialization file " + serializationFile + " does not exist"); } if (serializationFile.isDirectory()) { throw new Exception("Error: serialization file " + serializationFile + " 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("serializationFile is " + serializationFile.getAbsolutePath()); logger.debug("outputDir is " + outputDir.getAbsolutePath()); logger.debug("sourceDir is " + sourceDir.getAbsolutePath()); } InputStream is = null; ObjectInputStream objects = null; try { is = new FileInputStream(serializationFile); objects = new ObjectInputStream(is); Map coverageData = (Map)objects.readObject(); if (format.equalsIgnoreCase("xml")) { new XMLReport(coverageData, outputDir, sourceDir); } else if (format.equalsIgnoreCase("html")) { new HTMLReport(coverageData, outputDir, sourceDir); } } finally { if (is != null) is.close(); if (objects != null) objects.close(); } long stopTime = System.currentTimeMillis(); System.out .println("Reporting time: " + (stopTime - startTime) + "ms"); }
public static List loadAllArticlesInFolder(File folder) throws XmlException, IOException{
public static List loadAllArticlesInFolder(String folder) throws XmlException, IOException{
public static List loadAllArticlesInFolder(File folder) throws XmlException, IOException{ List list = new ArrayList(); File[] articleFile = folder.listFiles(); if(articleFile!=null){ for(int i=0;i<articleFile.length;i++){ System.out.println("Attempting to load "+articleFile[i].toString()); ArticleItemBean article = new ArticleItemBean(); article.load(articleFile[i]); list.add(article); } } return list; }
File[] articleFile = folder.listFiles();
public static List loadAllArticlesInFolder(File folder) throws XmlException, IOException{ List list = new ArrayList(); File[] articleFile = folder.listFiles(); if(articleFile!=null){ for(int i=0;i<articleFile.length;i++){ System.out.println("Attempting to load "+articleFile[i].toString()); ArticleItemBean article = new ArticleItemBean(); article.load(articleFile[i]); list.add(article); } } return list; }
if(articleFile!=null){ for(int i=0;i<articleFile.length;i++){ System.out.println("Attempting to load "+articleFile[i].toString()); ArticleItemBean article = new ArticleItemBean(); article.load(articleFile[i]); list.add(article); }
IWUserContext iwuc = IWContext.getInstance(); IWApplicationContext iwac = iwuc.getApplicationContext(); IWSlideSession session = (IWSlideSession)IBOLookup.getSessionInstance(iwuc,IWSlideSession.class); IWSlideService service = (IWSlideService)IBOLookup.getServiceInstance(iwac,IWSlideService.class); HttpURL root = new HttpURL(service.getWebdavServerURL()+folder); root.setUserinfo("root","root"); WebdavResource webdavResource = new WebdavResource(root); String[] file = webdavResource.list(); for(int i=0;i<file.length;i++){ System.out.println("Attempting to load "+file[i].toString()); ArticleItemBean article = new ArticleItemBean(); article.load(folder+"/"+file[i]); list.add(article);
public static List loadAllArticlesInFolder(File folder) throws XmlException, IOException{ List list = new ArrayList(); File[] articleFile = folder.listFiles(); if(articleFile!=null){ for(int i=0;i<articleFile.length;i++){ System.out.println("Attempting to load "+articleFile[i].toString()); ArticleItemBean article = new ArticleItemBean(); article.load(articleFile[i]); list.add(article); } } return list; }
articleItemBean = (ArticleItemBean[])loadAllArticlesInFolder(new File("/Test/article/")).toArray(new ArticleItemBean[0]);
articleItemBean = (ArticleItemBean[])loadAllArticlesInFolder("/files/content").toArray(new ArticleItemBean[0]);
public void updateDataModel(Integer start, Integer rows) { if (_dataModel == null) { _dataModel = new WFDataModel(); } int availableRows = 0; ArticleItemBean[] articleItemBean; try { articleItemBean = (ArticleItemBean[])loadAllArticlesInFolder(new File("/Test/article/")).toArray(new ArticleItemBean[0]); 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++) { ArticleListBean a = new ArticleListBean(String.valueOf(i), articleItemBean[i].getHeadline(), articleItemBean[i].getItemType(), articleItemBean[i].getAuthor(), articleItemBean[i].getStatus()); _dataModel.set(a, i); } } catch (XmlException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } _dataModel.setRowCount(availableRows); }
ArticleListBean a = new ArticleListBean(String.valueOf(i), articleItemBean[i].getHeadline(), articleItemBean[i].getItemType(), articleItemBean[i].getAuthor(), articleItemBean[i].getStatus());
ArticleListBean a = new ArticleListBean(articleItemBean[i].getMainCategory()+"/"+articleItemBean[i].getHeadline()+".xml", articleItemBean[i].getHeadline(), articleItemBean[i].getItemType(), articleItemBean[i].getAuthor(), articleItemBean[i].getStatus());
public void updateDataModel(Integer start, Integer rows) { if (_dataModel == null) { _dataModel = new WFDataModel(); } int availableRows = 0; ArticleItemBean[] articleItemBean; try { articleItemBean = (ArticleItemBean[])loadAllArticlesInFolder(new File("/Test/article/")).toArray(new ArticleItemBean[0]); 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++) { ArticleListBean a = new ArticleListBean(String.valueOf(i), articleItemBean[i].getHeadline(), articleItemBean[i].getItemType(), articleItemBean[i].getAuthor(), articleItemBean[i].getStatus()); _dataModel.set(a, i); } } catch (XmlException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } _dataModel.setRowCount(availableRows); }
if(presence == null){ return null; }
private void registerPresences() { SparkManager.getConnection().addPacketListener(new PacketListener() { public void processPacket(Packet packet) { Presence presence = (Presence)packet; Transport transport = TransportManager.getTransport(packet.getFrom()); if (transport != null) { boolean registered = presence != null && presence.getMode() != null; if (presence.getType() == Presence.Type.UNAVAILABLE) { registered = false; } RolloverButton button = uiMap.get(transport); if (!registered) { button.setIcon(transport.getInactiveIcon()); } else { button.setIcon(transport.getIcon()); } } } }, new PacketTypeFilter(Presence.class)); ChatManager chatManager = SparkManager.getChatManager(); chatManager.addContactItemHandler(new ContactItemHandler() { public boolean handlePresence(ContactItem item, Presence presence) { if (presence != null) { String domain = StringUtils.parseServer(presence.getFrom()); Transport transport = TransportManager.getTransport(domain); if (transport != null) { if (presence.getType() == Presence.Type.AVAILABLE) { item.setIcon(transport.getIcon()); } else { item.setIcon(transport.getInactiveIcon()); } item.updatePresenceStatus(presence); return true; } } return false; } public boolean handleDoubleClick(ContactItem item) { return false; } public Icon useIcon(Presence presence) { String domain = StringUtils.parseServer(presence.getFrom()); Transport transport = TransportManager.getTransport(domain); if (transport != null) { if (presence.getType() == Presence.Type.AVAILABLE) { return transport.getIcon(); } else { return transport.getInactiveIcon(); } } return null; } }); }
if(presence == null){ return null; }
public Icon useIcon(Presence presence) { String domain = StringUtils.parseServer(presence.getFrom()); Transport transport = TransportManager.getTransport(domain); if (transport != null) { if (presence.getType() == Presence.Type.AVAILABLE) { return transport.getIcon(); } else { return transport.getInactiveIcon(); } } return null; }
DisplayedNote parentDisplayed = dd.getTree().getSelectedNote();
DisplayedNote parentDisplayed = tree.getSelectedNote();
public void addNote(Event e) { DisplayedNote parentDisplayed = dd.getTree().getSelectedNote(); Note parentNote = parentDisplayed.getNote(); Note newNote = new Note("new", parentNote, ""); new DisplayedNote(parentDisplayed, newNote); }
for (DisplayedNote removeMe : dd.getTree().getSelectedNotes()) {
for (DisplayedNote removeMe : tree.getSelectedNotes()) {
public void removeNotes(Event e) { for (DisplayedNote removeMe : dd.getTree().getSelectedNotes()) { removeMe.deleteSelfAndChildren(); } }
dd.getTree().initialiseTreeEditor();
tree.initialiseTreeEditor();
public void renameNote(Event e) { dd.getTree().initialiseTreeEditor(); }
ret = myBlock.evaluate(context); if (timing) context.stopTiming();
try { ret = myBlock.evaluate(context); } finally { if (timing) context.stopTiming(); }
public Object evaluate(Context context) throws PropertyException { Object ret; boolean timing = context.isTiming(); if (timing) context.startTiming(myName); ret = myBlock.evaluate(context); if (timing) context.stopTiming(); return ret; }
System.out.println(parent);
public String getPassword(String title, String description, Icon icon, Component parent) { passwordField = new JPasswordField(); TitlePanel titlePanel = new TitlePanel(title, description, icon, true); // Construct main panel w/ layout. final JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); mainPanel.add(titlePanel, BorderLayout.NORTH); final JPanel passwordPanel = new JPanel(new GridBagLayout()); JLabel passwordLabel = new JLabel("Enter Password:"); passwordPanel.add(passwordLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); passwordPanel.add(passwordField, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); // The user should only be able to close this dialog. final Object[] options = {Res.getString("ok"), Res.getString("cancel")}; optionPane = new JOptionPane(passwordPanel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]); mainPanel.add(optionPane, BorderLayout.CENTER); // Lets make sure that the dialog is modal. Cannot risk people // losing this dialog. JOptionPane p = new JOptionPane(); dialog = p.createDialog(parent, title); dialog.setModal(true); dialog.pack(); dialog.setSize(width, height); dialog.setContentPane(mainPanel); dialog.setLocationRelativeTo(parent); optionPane.addPropertyChangeListener(this); // Add Key Listener to Send Field passwordField.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyChar() == KeyEvent.VK_TAB) { optionPane.requestFocus(); } else if (e.getKeyChar() == KeyEvent.VK_ESCAPE) { dialog.dispose(); } } }); passwordField.requestFocus(); dialog.setVisible(true); return stringValue; }
redirectURI.append(subjectParameterName); redirectURI.append("="); redirectURI.append(uri.getPathPart()); redirectURI.append("&");
String pathPart = uri.getPathPart(); if(pathPart!=null && !pathPart.equals("")){ redirectURI.append(subjectParameterName); redirectURI.append("="); redirectURI.append(pathPart); redirectURI.append("&"); }
public String getRedirectURI(IWActionURI uri) { //todo set to previewer or editor depending on action //todo register actions as subnodes of article String action = uri.getActionPart(); String subjectParameterName = ContentViewer.PARAMETER_CONTENT_RESOURCE; StringBuffer redirectURI = new StringBuffer(); redirectURI.append(uri.getContextURI()); redirectURI.append("workspace/content/article/"); redirectURI.append(action); redirectURI.append("/?"); redirectURI.append(subjectParameterName); redirectURI.append("="); redirectURI.append(uri.getPathPart()); redirectURI.append("&"); redirectURI.append(ContentViewer.PARAMETER_ACTION); redirectURI.append("="); redirectURI.append(action); String queryString = uri.getQueryString(); if(queryString!=null){ /*StringTokenizer tokenizer = new StringTokenizer(queryString,"&"); while(tokenizer.hasMoreTokens()){ String token = tokenizer.nextToken(); if(token.startsWith("?")){ token = token.substring(1,token.length()); } redirectURI.append("&"); redirectURI.append(token); }*/ if(!queryString.startsWith("&")){ if(queryString.startsWith("?")){ queryString = queryString.substring(1,queryString.length()); } redirectURI.append("&"); } redirectURI.append(queryString); } return redirectURI.toString(); }
resourcePath=null; avilableInRequestedLanguage=false;
public void clear() { // TODO Auto-generated method stub getLocalizedArticle().clear(); }
private String getArticleDefaultLocalizedFileName(){ return getArticleDefaultLocalizedFileName(getLanguage());
private String getArticleDefaultLocalizedFileName(String language){ return language+ARTICLE_FILE_SUFFIX;
private String getArticleDefaultLocalizedFileName(){ return getArticleDefaultLocalizedFileName(getLanguage()); }
System.out.println(parent);
public String getPassword(String title, String description, Icon icon, Component parent) { System.out.println(parent); passwordField = new JPasswordField(); TitlePanel titlePanel = new TitlePanel(title, description, icon, true); // Construct main panel w/ layout. final JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); mainPanel.add(titlePanel, BorderLayout.NORTH); final JPanel passwordPanel = new JPanel(new GridBagLayout()); JLabel passwordLabel = new JLabel("Enter Password:"); passwordPanel.add(passwordLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); passwordPanel.add(passwordField, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); // The user should only be able to close this dialog. final Object[] options = {Res.getString("ok"), Res.getString("cancel")}; optionPane = new JOptionPane(passwordPanel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]); mainPanel.add(optionPane, BorderLayout.CENTER); // Lets make sure that the dialog is modal. Cannot risk people // losing this dialog. JOptionPane p = new JOptionPane(); dialog = p.createDialog(parent, title); dialog.setModal(true); dialog.pack(); dialog.setSize(width, height); dialog.setContentPane(mainPanel); dialog.setLocationRelativeTo(parent); optionPane.addPropertyChangeListener(this); // Add Key Listener to Send Field passwordField.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyChar() == KeyEvent.VK_TAB) { optionPane.requestFocus(); } else if (e.getKeyChar() == KeyEvent.VK_ESCAPE) { dialog.dispose(); } } }); passwordField.requestFocus(); dialog.setVisible(true); return stringValue; }
tokenBegin = -1;
tokenBeginPos = -1;
public final char BeginToken() throws java.io.IOException { tokenBegin = -1; char c = readChar(); tokenBuf = curBuf; tokenBegin = curBuf.curPos; return c; }
tokenBuf = curBuf; tokenBegin = curBuf.curPos;
tokenBeginBuf = curBuf; tokenBeginPos = curBuf.curPos;
public final char BeginToken() throws java.io.IOException { tokenBegin = -1; char c = readChar(); tokenBuf = curBuf; tokenBegin = curBuf.curPos; return c; }
if (tokenBegin >= 0 && ((tokenBuf == curBuf && tokenBegin < 2048) || tokenBuf != curBuf)) {
if (tokenBeginPos >= 0 && ((tokenBeginBuf == curBuf && tokenBeginPos < 2048) || tokenBeginBuf != curBuf)) {
private final void FillBuff() throws java.io.IOException { // Buffer fill logic: // If there is at least 2K left in this buffer, just read some more // Otherwise, if we're processing a token and it either // (a) starts in the other buffer (meaning it's filled both part of // the other buffer and some of this one, or // (b) starts in the first 2K of this buffer (meaning its taken up // most of this buffer // we expand this buffer. Otherwise, we swap buffers. // This guarantees we will be able to back up at least 2K characters. if (curBuf.size - curBuf.dataLen < 2048) { if (tokenBegin >= 0 && ((tokenBuf == curBuf && tokenBegin < 2048) || tokenBuf != curBuf)) { curBuf.expand(2048); } else { swapBuf(); curBuf.curPos = curBuf.dataLen = 0; } } try { int i = inputStream.read(curBuf.buffer, curBuf.dataLen, curBuf.size - curBuf.dataLen); if (i == -1) { inputStream.close(); throw new java.io.IOException(); } else curBuf.dataLen += i; return; } catch(java.io.IOException e) { --curBuf.curPos; if (tokenBegin == -1) { tokenBegin = curBuf.curPos; tokenBuf = curBuf; throw e; } } }
--curBuf.curPos; if (tokenBegin == -1) { tokenBegin = curBuf.curPos; tokenBuf = curBuf;
if (curBuf.curPos > 0) --curBuf.curPos; if (tokenBeginPos == -1) { tokenBeginPos = curBuf.curPos; tokenBeginBuf = curBuf; }
private final void FillBuff() throws java.io.IOException { // Buffer fill logic: // If there is at least 2K left in this buffer, just read some more // Otherwise, if we're processing a token and it either // (a) starts in the other buffer (meaning it's filled both part of // the other buffer and some of this one, or // (b) starts in the first 2K of this buffer (meaning its taken up // most of this buffer // we expand this buffer. Otherwise, we swap buffers. // This guarantees we will be able to back up at least 2K characters. if (curBuf.size - curBuf.dataLen < 2048) { if (tokenBegin >= 0 && ((tokenBuf == curBuf && tokenBegin < 2048) || tokenBuf != curBuf)) { curBuf.expand(2048); } else { swapBuf(); curBuf.curPos = curBuf.dataLen = 0; } } try { int i = inputStream.read(curBuf.buffer, curBuf.dataLen, curBuf.size - curBuf.dataLen); if (i == -1) { inputStream.close(); throw new java.io.IOException(); } else curBuf.dataLen += i; return; } catch(java.io.IOException e) { --curBuf.curPos; if (tokenBegin == -1) { tokenBegin = curBuf.curPos; tokenBuf = curBuf; throw e; } } }
}
private final void FillBuff() throws java.io.IOException { // Buffer fill logic: // If there is at least 2K left in this buffer, just read some more // Otherwise, if we're processing a token and it either // (a) starts in the other buffer (meaning it's filled both part of // the other buffer and some of this one, or // (b) starts in the first 2K of this buffer (meaning its taken up // most of this buffer // we expand this buffer. Otherwise, we swap buffers. // This guarantees we will be able to back up at least 2K characters. if (curBuf.size - curBuf.dataLen < 2048) { if (tokenBegin >= 0 && ((tokenBuf == curBuf && tokenBegin < 2048) || tokenBuf != curBuf)) { curBuf.expand(2048); } else { swapBuf(); curBuf.curPos = curBuf.dataLen = 0; } } try { int i = inputStream.read(curBuf.buffer, curBuf.dataLen, curBuf.size - curBuf.dataLen); if (i == -1) { inputStream.close(); throw new java.io.IOException(); } else curBuf.dataLen += i; return; } catch(java.io.IOException e) { --curBuf.curPos; if (tokenBegin == -1) { tokenBegin = curBuf.curPos; tokenBuf = curBuf; throw e; } } }
if (tokenBuf == curBuf) return new String(curBuf.buffer, tokenBegin, curBuf.curPos - tokenBegin + 1);
if (tokenBeginBuf == curBuf) return new String(curBuf.buffer, tokenBeginPos, curBuf.curPos - tokenBeginPos + 1);
public final String GetImage() { if (tokenBuf == curBuf) return new String(curBuf.buffer, tokenBegin, curBuf.curPos - tokenBegin + 1); else return new String(otherBuf.buffer, tokenBegin, otherBuf.dataLen - tokenBegin) + new String(curBuf.buffer, 0, curBuf.curPos + 1); }
return new String(otherBuf.buffer, tokenBegin, otherBuf.dataLen - tokenBegin)
return new String(otherBuf.buffer, tokenBeginPos, otherBuf.dataLen - tokenBeginPos)
public final String GetImage() { if (tokenBuf == curBuf) return new String(curBuf.buffer, tokenBegin, curBuf.curPos - tokenBegin + 1); else return new String(otherBuf.buffer, tokenBegin, otherBuf.dataLen - tokenBegin) + new String(curBuf.buffer, 0, curBuf.curPos + 1); }
if (otherBuf != null)
if (otherBuf.dataLen >= len - curBuf.curPos - 1)
public final char[] GetSuffix(int len) { char[] ret = new char[len]; if ((curBuf.curPos + 1) >= len) System.arraycopy(curBuf.buffer, curBuf.curPos - len + 1, ret, 0, len); else { if (otherBuf != null) System.arraycopy(otherBuf.buffer, otherBuf.dataLen - (len - curBuf.curPos - 1), ret, 0, len - curBuf.curPos - 1); System.arraycopy(curBuf.buffer, 0, ret, len - curBuf.curPos - 1, curBuf.curPos + 1); } return null; }
if (curBuf.curPos - amount < -1) {
if (curBuf.curPos - amount < 0) {
public final void backup(int amount) { backupChars += amount; if (curBuf.curPos - amount < -1) { int addlChars = amount - 1 - curBuf.curPos; curBuf.curPos = 0; swapBuf(); curBuf.curPos = curBuf.dataLen - addlChars - 1; if (curBuf.curPos < -1) { // Throw something // System.out.println("ASCII_CharStream: Attempt to back up too far"); } } else { curBuf.curPos -= amount; } }
if (curBuf.curPos < -1) { }
public final void backup(int amount) { backupChars += amount; if (curBuf.curPos - amount < -1) { int addlChars = amount - 1 - curBuf.curPos; curBuf.curPos = 0; swapBuf(); curBuf.curPos = curBuf.dataLen - addlChars - 1; if (curBuf.curPos < -1) { // Throw something // System.out.println("ASCII_CharStream: Attempt to back up too far"); } } else { curBuf.curPos -= amount; } }
return tokenBuf.bufcolumn[tokenBegin];
return tokenBeginBuf.bufcolumn[tokenBeginPos];
public final int getBeginColumn() { return tokenBuf.bufcolumn[tokenBegin]; }
return tokenBuf.bufline[tokenBegin];
return tokenBeginBuf.bufline[tokenBeginPos];
public final int getBeginLine() { return tokenBuf.bufline[tokenBegin]; }
if (++curBuf.curPos >= curBuf.dataLen) { if (backupChars > 0) swapBuf(); else FillBuff(); };
if (++curBuf.curPos >= curBuf.dataLen) { if (backupChars > 0) { --curBuf.curPos; swapBuf(); } else FillBuff(); };
public final char readChar() throws java.io.IOException { if (++curBuf.curPos >= curBuf.dataLen) { if (backupChars > 0) swapBuf(); else FillBuff(); }; char c = (char)((char)0xff & curBuf.buffer[curBuf.curPos]); // No need to update line numbers if we've already processed this char if (backupChars > 0) --backupChars; else UpdateLineColumn(c); return (c); }
private void swapBuf() { if (otherBuf == null) { curBuf = bufB; otherBuf = bufA; } else { Buffer tmp = curBuf; curBuf = otherBuf; otherBuf = tmp; }
private final void swapBuf() { Buffer tmp = curBuf; curBuf = otherBuf; otherBuf = tmp;
private void swapBuf() { if (otherBuf == null) { curBuf = bufB; otherBuf = bufA; } else { Buffer tmp = curBuf; curBuf = otherBuf; otherBuf = tmp; } }
if ((level >= LogSource.WARNING) && hasTargets()) {
if ((level >= LogSource.NOTICE) && !hasTargets()) {
protected void log(int level, String msg, Exception e) { super.log(level,msg,e); if ((level >= LogSource.WARNING) && hasTargets()) { _err.log("sys", LEVELS[level],msg,e); } }
tec._lineNo = iter.getLineNo(); tec._columnNo = iter.getColNo();
tec._lineNo = ln[pos]; tec._columnNo = cn[pos++];
final public Object build(BuildContext bc) throws BuildException { ArrayList strings = new ArrayList((elements.size())); ArrayList macros = new ArrayList((elements.size())); int[] ln = new int[elements.size()]; int[] cn = new int[elements.size()]; Stack iterStack = new Stack(); StringBuffer s = new StringBuffer(); Context.TemplateEvaluationContext tec = bc.getTemplateEvaluationContext(); // flatten everything and view the content as being: // string (macro string)* string // store that as an array of strings and an array of // Macro objects and create a block. BlockIterator iter = new BBIterator(); tec._templateName = name; while (iter.hasNext()) { Object o = iter.next(); // track line/column numbers in the build context // so that bc.getCurrentLocation() stays current tec._lineNo = iter.getLineNo(); tec._columnNo = iter.getColNo(); if (o instanceof Builder) o = ((Builder) o).build(bc); if (o instanceof Block) { iterStack.push(iter); iter = ((Block) o).getBlockIterator(); } else { if (o instanceof Macro) { strings.add(s.toString()); s = new StringBuffer(); // do not reuse StringBuffer, // otherwise all strings will contain char[] of max length!! macros.add(o); // Now deal with the line numbers int size = macros.size(); if (ln.length < size) { ln = resizeIntArray(ln, ln.length * 2); cn = resizeIntArray(cn, cn.length * 2); } ln[size - 1] = iter.getLineNo(); cn[size - 1] = iter.getColNo(); } else if (o != null) { s.append(o.toString()); } } while (!iter.hasNext() && !iterStack.empty()) iter = (BlockIterator) iterStack.pop(); } strings.add(s.toString()); Macro finalMacros[] = (Macro[]) macros.toArray(mArray); String finalStrings[] = (String[]) strings.toArray(sArray); int finalLines[] = resizeIntArray(ln, macros.size()); int finalCols[] = resizeIntArray(cn, macros.size()); return new Block(name, finalStrings, finalMacros, finalLines, finalCols); }
throws InvalidContextException
throws ContextException
final Object getValue(Context context) throws InvalidContextException { try { return context.getTool(_names); } catch (Exception e) { Engine.log.exception(e); String warning = "Variable: unable to access " + this + ";"; throw new InvalidContextException(warning); } }