id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
152,000
jbundle/jbundle
app/program/script/src/main/java/org/jbundle/app/program/script/db/Script.java
Script.getProperty
public String getProperty(String strKey) { return ((PropertiesField)this.getField(Script.PROPERTIES)).getProperty(strKey); }
java
public String getProperty(String strKey) { return ((PropertiesField)this.getField(Script.PROPERTIES)).getProperty(strKey); }
[ "public", "String", "getProperty", "(", "String", "strKey", ")", "{", "return", "(", "(", "PropertiesField", ")", "this", ".", "getField", "(", "Script", ".", "PROPERTIES", ")", ")", ".", "getProperty", "(", "strKey", ")", ";", "}" ]
GetProperty Method.
[ "GetProperty", "Method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/script/src/main/java/org/jbundle/app/program/script/db/Script.java#L261-L264
152,001
jbundle/jbundle
app/program/script/src/main/java/org/jbundle/app/program/script/db/Script.java
Script.getSubScript
public Script getSubScript() { if (m_recSubScript == null) { RecordOwner recordOwner = this.findRecordOwner(); m_recSubScript = new Script(recordOwner); recordOwner.removeRecord(m_recSubScript); m_recSubScript.addListener(new SubFileFilter(this)); } return m_recSubScript; }
java
public Script getSubScript() { if (m_recSubScript == null) { RecordOwner recordOwner = this.findRecordOwner(); m_recSubScript = new Script(recordOwner); recordOwner.removeRecord(m_recSubScript); m_recSubScript.addListener(new SubFileFilter(this)); } return m_recSubScript; }
[ "public", "Script", "getSubScript", "(", ")", "{", "if", "(", "m_recSubScript", "==", "null", ")", "{", "RecordOwner", "recordOwner", "=", "this", ".", "findRecordOwner", "(", ")", ";", "m_recSubScript", "=", "new", "Script", "(", "recordOwner", ")", ";", "recordOwner", ".", "removeRecord", "(", "m_recSubScript", ")", ";", "m_recSubScript", ".", "addListener", "(", "new", "SubFileFilter", "(", "this", ")", ")", ";", "}", "return", "m_recSubScript", ";", "}" ]
Create a record to read through this script's children.
[ "Create", "a", "record", "to", "read", "through", "this", "script", "s", "children", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/script/src/main/java/org/jbundle/app/program/script/db/Script.java#L268-L278
152,002
huangp/entityunit
src/main/java/com/github/huangp/entityunit/maker/RangeValuesMaker.java
RangeValuesMaker.cycle
public static <T> Maker<T> cycle(T first, T... rest) { ImmutableList<T> values = ImmutableList.<T>builder().add(first).add(rest).build(); return new RangeValuesMaker<T>(Iterables.cycle(values).iterator()); }
java
public static <T> Maker<T> cycle(T first, T... rest) { ImmutableList<T> values = ImmutableList.<T>builder().add(first).add(rest).build(); return new RangeValuesMaker<T>(Iterables.cycle(values).iterator()); }
[ "public", "static", "<", "T", ">", "Maker", "<", "T", ">", "cycle", "(", "T", "first", ",", "T", "...", "rest", ")", "{", "ImmutableList", "<", "T", ">", "values", "=", "ImmutableList", ".", "<", "T", ">", "builder", "(", ")", ".", "add", "(", "first", ")", ".", "add", "(", "rest", ")", ".", "build", "(", ")", ";", "return", "new", "RangeValuesMaker", "<", "T", ">", "(", "Iterables", ".", "cycle", "(", "values", ")", ".", "iterator", "(", ")", ")", ";", "}" ]
Factory method. Given a list of values and the produced maker will cycle them infinitely. @param first first value @param rest rest of the values @param <T> value type @return a RangeValuesMaker
[ "Factory", "method", ".", "Given", "a", "list", "of", "values", "and", "the", "produced", "maker", "will", "cycle", "them", "infinitely", "." ]
1a09b530149d707dbff7ff46f5428d9db709a4b4
https://github.com/huangp/entityunit/blob/1a09b530149d707dbff7ff46f5428d9db709a4b4/src/main/java/com/github/huangp/entityunit/maker/RangeValuesMaker.java#L36-L39
152,003
huangp/entityunit
src/main/java/com/github/huangp/entityunit/maker/RangeValuesMaker.java
RangeValuesMaker.errorOnEnd
public static <T> Maker<T> errorOnEnd(T first, T... rest) { ImmutableList<T> values = ImmutableList.<T>builder().add(first).add(rest).build(); return new RangeValuesMaker<T>(values.iterator()); }
java
public static <T> Maker<T> errorOnEnd(T first, T... rest) { ImmutableList<T> values = ImmutableList.<T>builder().add(first).add(rest).build(); return new RangeValuesMaker<T>(values.iterator()); }
[ "public", "static", "<", "T", ">", "Maker", "<", "T", ">", "errorOnEnd", "(", "T", "first", ",", "T", "...", "rest", ")", "{", "ImmutableList", "<", "T", ">", "values", "=", "ImmutableList", ".", "<", "T", ">", "builder", "(", ")", ".", "add", "(", "first", ")", ".", "add", "(", "rest", ")", ".", "build", "(", ")", ";", "return", "new", "RangeValuesMaker", "<", "T", ">", "(", "values", ".", "iterator", "(", ")", ")", ";", "}" ]
Factory method. Given a list of values and the produced maker will exhaust them before throwing an exception. @param first first value @param rest rest of the values @param <T> value type @return a RangeValuesMaker
[ "Factory", "method", ".", "Given", "a", "list", "of", "values", "and", "the", "produced", "maker", "will", "exhaust", "them", "before", "throwing", "an", "exception", "." ]
1a09b530149d707dbff7ff46f5428d9db709a4b4
https://github.com/huangp/entityunit/blob/1a09b530149d707dbff7ff46f5428d9db709a4b4/src/main/java/com/github/huangp/entityunit/maker/RangeValuesMaker.java#L52-L55
152,004
drewwills/cernunnos
cernunnos-core/src/main/java/org/danann/cernunnos/runtime/web/CernunnosServlet.java
CernunnosServlet.init
@SuppressWarnings("unchecked") @Override public void init() throws ServletException { ServletConfig config = getServletConfig(); // Load the context, if present... try { // Bootstrap the servlet Grammar instance... final Grammar root = XmlGrammar.getMainGrammar(); final InputStream inpt = CernunnosServlet.class.getResourceAsStream("servlet.grammar"); // Can't rely on classpath:// protocol handler... final Document doc = new SAXReader().read(inpt); final Task k = new ScriptRunner(root).compileTask(doc.getRootElement()); final RuntimeRequestResponse req = new RuntimeRequestResponse(); final ReturnValueImpl rslt = new ReturnValueImpl(); req.setAttribute(Attributes.RETURN_VALUE, rslt); k.perform(req, new RuntimeRequestResponse()); Grammar g = (Grammar) rslt.getValue(); runner = new ScriptRunner(g); // Choose a context location & load it if it exists... String defaultLoc = "/WEB-INF/" + config.getServletName() + "-portlet.xml"; URL defaultUrl = getServletConfig().getServletContext().getResource(defaultLoc); URL u = Settings.locateContextConfig( getServletConfig().getServletContext().getResource("/").toExternalForm(), config.getInitParameter(CONFIG_LOCATION_PARAM), defaultUrl); if (u != null) { // There *is* a resource mapped to this path name... spring_context = new FileSystemXmlApplicationContext(u.toExternalForm()); } if (log.isDebugEnabled()) { log.debug("Location of spring context (null means none): " + u); } // Load the Settings... Map<String,String> settingsMap = new HashMap<String,String>(); // default... if (spring_context != null && spring_context.containsBean("settings")) { settingsMap = (Map<String,String>) spring_context.getBean("settings"); } settings = Settings.load(settingsMap); } catch (Throwable t) { String msg = "Failure in CernunnosServlet.init()"; throw new ServletException(msg, t); } }
java
@SuppressWarnings("unchecked") @Override public void init() throws ServletException { ServletConfig config = getServletConfig(); // Load the context, if present... try { // Bootstrap the servlet Grammar instance... final Grammar root = XmlGrammar.getMainGrammar(); final InputStream inpt = CernunnosServlet.class.getResourceAsStream("servlet.grammar"); // Can't rely on classpath:// protocol handler... final Document doc = new SAXReader().read(inpt); final Task k = new ScriptRunner(root).compileTask(doc.getRootElement()); final RuntimeRequestResponse req = new RuntimeRequestResponse(); final ReturnValueImpl rslt = new ReturnValueImpl(); req.setAttribute(Attributes.RETURN_VALUE, rslt); k.perform(req, new RuntimeRequestResponse()); Grammar g = (Grammar) rslt.getValue(); runner = new ScriptRunner(g); // Choose a context location & load it if it exists... String defaultLoc = "/WEB-INF/" + config.getServletName() + "-portlet.xml"; URL defaultUrl = getServletConfig().getServletContext().getResource(defaultLoc); URL u = Settings.locateContextConfig( getServletConfig().getServletContext().getResource("/").toExternalForm(), config.getInitParameter(CONFIG_LOCATION_PARAM), defaultUrl); if (u != null) { // There *is* a resource mapped to this path name... spring_context = new FileSystemXmlApplicationContext(u.toExternalForm()); } if (log.isDebugEnabled()) { log.debug("Location of spring context (null means none): " + u); } // Load the Settings... Map<String,String> settingsMap = new HashMap<String,String>(); // default... if (spring_context != null && spring_context.containsBean("settings")) { settingsMap = (Map<String,String>) spring_context.getBean("settings"); } settings = Settings.load(settingsMap); } catch (Throwable t) { String msg = "Failure in CernunnosServlet.init()"; throw new ServletException(msg, t); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "Override", "public", "void", "init", "(", ")", "throws", "ServletException", "{", "ServletConfig", "config", "=", "getServletConfig", "(", ")", ";", "// Load the context, if present...", "try", "{", "// Bootstrap the servlet Grammar instance...", "final", "Grammar", "root", "=", "XmlGrammar", ".", "getMainGrammar", "(", ")", ";", "final", "InputStream", "inpt", "=", "CernunnosServlet", ".", "class", ".", "getResourceAsStream", "(", "\"servlet.grammar\"", ")", ";", "// Can't rely on classpath:// protocol handler...", "final", "Document", "doc", "=", "new", "SAXReader", "(", ")", ".", "read", "(", "inpt", ")", ";", "final", "Task", "k", "=", "new", "ScriptRunner", "(", "root", ")", ".", "compileTask", "(", "doc", ".", "getRootElement", "(", ")", ")", ";", "final", "RuntimeRequestResponse", "req", "=", "new", "RuntimeRequestResponse", "(", ")", ";", "final", "ReturnValueImpl", "rslt", "=", "new", "ReturnValueImpl", "(", ")", ";", "req", ".", "setAttribute", "(", "Attributes", ".", "RETURN_VALUE", ",", "rslt", ")", ";", "k", ".", "perform", "(", "req", ",", "new", "RuntimeRequestResponse", "(", ")", ")", ";", "Grammar", "g", "=", "(", "Grammar", ")", "rslt", ".", "getValue", "(", ")", ";", "runner", "=", "new", "ScriptRunner", "(", "g", ")", ";", "// Choose a context location & load it if it exists...", "String", "defaultLoc", "=", "\"/WEB-INF/\"", "+", "config", ".", "getServletName", "(", ")", "+", "\"-portlet.xml\"", ";", "URL", "defaultUrl", "=", "getServletConfig", "(", ")", ".", "getServletContext", "(", ")", ".", "getResource", "(", "defaultLoc", ")", ";", "URL", "u", "=", "Settings", ".", "locateContextConfig", "(", "getServletConfig", "(", ")", ".", "getServletContext", "(", ")", ".", "getResource", "(", "\"/\"", ")", ".", "toExternalForm", "(", ")", ",", "config", ".", "getInitParameter", "(", "CONFIG_LOCATION_PARAM", ")", ",", "defaultUrl", ")", ";", "if", "(", "u", "!=", "null", ")", "{", "// There *is* a resource mapped to this path name...", "spring_context", "=", "new", "FileSystemXmlApplicationContext", "(", "u", ".", "toExternalForm", "(", ")", ")", ";", "}", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Location of spring context (null means none): \"", "+", "u", ")", ";", "}", "// Load the Settings...", "Map", "<", "String", ",", "String", ">", "settingsMap", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "// default...", "if", "(", "spring_context", "!=", "null", "&&", "spring_context", ".", "containsBean", "(", "\"settings\"", ")", ")", "{", "settingsMap", "=", "(", "Map", "<", "String", ",", "String", ">", ")", "spring_context", ".", "getBean", "(", "\"settings\"", ")", ";", "}", "settings", "=", "Settings", ".", "load", "(", "settingsMap", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "String", "msg", "=", "\"Failure in CernunnosServlet.init()\"", ";", "throw", "new", "ServletException", "(", "msg", ",", "t", ")", ";", "}", "}" ]
Don't declare as static in general libraries
[ "Don", "t", "declare", "as", "static", "in", "general", "libraries" ]
dc6848e0253775e22b6c869fd06506d4ddb6d728
https://github.com/drewwills/cernunnos/blob/dc6848e0253775e22b6c869fd06506d4ddb6d728/cernunnos-core/src/main/java/org/danann/cernunnos/runtime/web/CernunnosServlet.java#L74-L123
152,005
BeholderTAF/beholder-selenium
src/main/java/br/ufmg/dcc/saotome/beholder/selenium/SeleniumController.java
SeleniumController.startSelenium
@BeforeSuite(alwaysRun=true) @Parameters(value={"parameters"}) public static void startSelenium(String parameters) { parametersMap = parameterScanner(parameters); parametersInfo(); String browserName = parametersMap.get("browser"), profile = parametersMap.get("profile"), chromeDriverBin = parametersMap.get("chromeDriverBin"), ieDriverBin = parametersMap.get("ieDriverBin"), chromeBin = parametersMap.get("chromeBin"), languages = parametersMap.get("languages"); if(browserName == null){ throw new IllegalArgumentException(String.format(ErrorMessages.ERROR_TEMPLATE_VARIABLE_NULL,"browser")); } if(driver == null) { if(BrowsersList.FIREFOX.equalsString(browserName)){ FirefoxProfile fp = new FirefoxProfile(); fp.setPreference("dom.max_script_run_time", 0); fp.setPreference("dom.max_chrome_script_run_time", 0); if(profile != null && !profile.isEmpty()){ fp.setPreference("webdriver.firefox.profile", profile); } if(languages != null && !languages.isEmpty()){ fp.setPreference("intl.accept_languages", languages); } driver = new WebDriverAdapter(new FirefoxDriver(fp)); } else if(BrowsersList.CHROME.equalsString(browserName)) { if(chromeBin == null){ throw new IllegalArgumentException(String.format(ErrorMessages.ERROR_TEMPLATE_VARIABLE_NULL,"chromeBin")); } // Optional, if not specified, WebDriver will search your path for chromedriver // in the system environment. (OBS: To evade problems, webdriver.chrome.driver MUST have a value. if(System.getProperty("webdriver.chrome.driver") == null || System.getProperty("webdriver.chrome.driver").isEmpty()){ if(chromeDriverBin == null){ throw new IllegalArgumentException(String.format(ErrorMessages.ERROR_TEMPLATE_VARIABLE_NULL,"chromeDriverBin")); } System.setProperty("webdriver.chrome.driver", chromeDriverBin); } ChromeOptions co = new ChromeOptions(); // Get the chrome binary directory path from System Envionment. co.setBinary(new File(chromeBin)); driver = new WebDriverAdapter(new ChromeDriver(co)); } else if(BrowsersList.IE.equalsString(browserName)) { if(ieDriverBin == null){ throw new IllegalArgumentException(String.format(ErrorMessages.ERROR_TEMPLATE_VARIABLE_NULL,"ieDriverBin")); } System.setProperty("webdriver.ie.driver", ieDriverBin); driver = new WebDriverAdapter(new InternetExplorerDriver()); } else if(BrowsersList.HTML_UNIT.equalsString(browserName)){ driver = new HtmlUnitDriver(true); } else { throw new IllegalArgumentException(ErrorMessages.ERROR_BROWSER_INVALID); } } /* Sets to all driver methods the global timeout of 1 second. * To tests, Timeouts must be specified on the components. */ SeleniumController.driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS); SeleniumController.builder = new SeleniumBuilder(driver); SeleniumController.browser = new SeleniumBrowser(); ListenerGateway.setWebDriver(driver); ListenerGateway.setParameters(parametersMap); }
java
@BeforeSuite(alwaysRun=true) @Parameters(value={"parameters"}) public static void startSelenium(String parameters) { parametersMap = parameterScanner(parameters); parametersInfo(); String browserName = parametersMap.get("browser"), profile = parametersMap.get("profile"), chromeDriverBin = parametersMap.get("chromeDriverBin"), ieDriverBin = parametersMap.get("ieDriverBin"), chromeBin = parametersMap.get("chromeBin"), languages = parametersMap.get("languages"); if(browserName == null){ throw new IllegalArgumentException(String.format(ErrorMessages.ERROR_TEMPLATE_VARIABLE_NULL,"browser")); } if(driver == null) { if(BrowsersList.FIREFOX.equalsString(browserName)){ FirefoxProfile fp = new FirefoxProfile(); fp.setPreference("dom.max_script_run_time", 0); fp.setPreference("dom.max_chrome_script_run_time", 0); if(profile != null && !profile.isEmpty()){ fp.setPreference("webdriver.firefox.profile", profile); } if(languages != null && !languages.isEmpty()){ fp.setPreference("intl.accept_languages", languages); } driver = new WebDriverAdapter(new FirefoxDriver(fp)); } else if(BrowsersList.CHROME.equalsString(browserName)) { if(chromeBin == null){ throw new IllegalArgumentException(String.format(ErrorMessages.ERROR_TEMPLATE_VARIABLE_NULL,"chromeBin")); } // Optional, if not specified, WebDriver will search your path for chromedriver // in the system environment. (OBS: To evade problems, webdriver.chrome.driver MUST have a value. if(System.getProperty("webdriver.chrome.driver") == null || System.getProperty("webdriver.chrome.driver").isEmpty()){ if(chromeDriverBin == null){ throw new IllegalArgumentException(String.format(ErrorMessages.ERROR_TEMPLATE_VARIABLE_NULL,"chromeDriverBin")); } System.setProperty("webdriver.chrome.driver", chromeDriverBin); } ChromeOptions co = new ChromeOptions(); // Get the chrome binary directory path from System Envionment. co.setBinary(new File(chromeBin)); driver = new WebDriverAdapter(new ChromeDriver(co)); } else if(BrowsersList.IE.equalsString(browserName)) { if(ieDriverBin == null){ throw new IllegalArgumentException(String.format(ErrorMessages.ERROR_TEMPLATE_VARIABLE_NULL,"ieDriverBin")); } System.setProperty("webdriver.ie.driver", ieDriverBin); driver = new WebDriverAdapter(new InternetExplorerDriver()); } else if(BrowsersList.HTML_UNIT.equalsString(browserName)){ driver = new HtmlUnitDriver(true); } else { throw new IllegalArgumentException(ErrorMessages.ERROR_BROWSER_INVALID); } } /* Sets to all driver methods the global timeout of 1 second. * To tests, Timeouts must be specified on the components. */ SeleniumController.driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS); SeleniumController.builder = new SeleniumBuilder(driver); SeleniumController.browser = new SeleniumBrowser(); ListenerGateway.setWebDriver(driver); ListenerGateway.setParameters(parametersMap); }
[ "@", "BeforeSuite", "(", "alwaysRun", "=", "true", ")", "@", "Parameters", "(", "value", "=", "{", "\"parameters\"", "}", ")", "public", "static", "void", "startSelenium", "(", "String", "parameters", ")", "{", "parametersMap", "=", "parameterScanner", "(", "parameters", ")", ";", "parametersInfo", "(", ")", ";", "String", "browserName", "=", "parametersMap", ".", "get", "(", "\"browser\"", ")", ",", "profile", "=", "parametersMap", ".", "get", "(", "\"profile\"", ")", ",", "chromeDriverBin", "=", "parametersMap", ".", "get", "(", "\"chromeDriverBin\"", ")", ",", "ieDriverBin", "=", "parametersMap", ".", "get", "(", "\"ieDriverBin\"", ")", ",", "chromeBin", "=", "parametersMap", ".", "get", "(", "\"chromeBin\"", ")", ",", "languages", "=", "parametersMap", ".", "get", "(", "\"languages\"", ")", ";", "if", "(", "browserName", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "ErrorMessages", ".", "ERROR_TEMPLATE_VARIABLE_NULL", ",", "\"browser\"", ")", ")", ";", "}", "if", "(", "driver", "==", "null", ")", "{", "if", "(", "BrowsersList", ".", "FIREFOX", ".", "equalsString", "(", "browserName", ")", ")", "{", "FirefoxProfile", "fp", "=", "new", "FirefoxProfile", "(", ")", ";", "fp", ".", "setPreference", "(", "\"dom.max_script_run_time\"", ",", "0", ")", ";", "fp", ".", "setPreference", "(", "\"dom.max_chrome_script_run_time\"", ",", "0", ")", ";", "if", "(", "profile", "!=", "null", "&&", "!", "profile", ".", "isEmpty", "(", ")", ")", "{", "fp", ".", "setPreference", "(", "\"webdriver.firefox.profile\"", ",", "profile", ")", ";", "}", "if", "(", "languages", "!=", "null", "&&", "!", "languages", ".", "isEmpty", "(", ")", ")", "{", "fp", ".", "setPreference", "(", "\"intl.accept_languages\"", ",", "languages", ")", ";", "}", "driver", "=", "new", "WebDriverAdapter", "(", "new", "FirefoxDriver", "(", "fp", ")", ")", ";", "}", "else", "if", "(", "BrowsersList", ".", "CHROME", ".", "equalsString", "(", "browserName", ")", ")", "{", "if", "(", "chromeBin", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "ErrorMessages", ".", "ERROR_TEMPLATE_VARIABLE_NULL", ",", "\"chromeBin\"", ")", ")", ";", "}", "// Optional, if not specified, WebDriver will search your path for chromedriver ", "// in the system environment. (OBS: To evade problems, webdriver.chrome.driver MUST have a value.", "if", "(", "System", ".", "getProperty", "(", "\"webdriver.chrome.driver\"", ")", "==", "null", "||", "System", ".", "getProperty", "(", "\"webdriver.chrome.driver\"", ")", ".", "isEmpty", "(", ")", ")", "{", "if", "(", "chromeDriverBin", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "ErrorMessages", ".", "ERROR_TEMPLATE_VARIABLE_NULL", ",", "\"chromeDriverBin\"", ")", ")", ";", "}", "System", ".", "setProperty", "(", "\"webdriver.chrome.driver\"", ",", "chromeDriverBin", ")", ";", "}", "ChromeOptions", "co", "=", "new", "ChromeOptions", "(", ")", ";", "// Get the chrome binary directory path from System Envionment.", "co", ".", "setBinary", "(", "new", "File", "(", "chromeBin", ")", ")", ";", "driver", "=", "new", "WebDriverAdapter", "(", "new", "ChromeDriver", "(", "co", ")", ")", ";", "}", "else", "if", "(", "BrowsersList", ".", "IE", ".", "equalsString", "(", "browserName", ")", ")", "{", "if", "(", "ieDriverBin", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "ErrorMessages", ".", "ERROR_TEMPLATE_VARIABLE_NULL", ",", "\"ieDriverBin\"", ")", ")", ";", "}", "System", ".", "setProperty", "(", "\"webdriver.ie.driver\"", ",", "ieDriverBin", ")", ";", "driver", "=", "new", "WebDriverAdapter", "(", "new", "InternetExplorerDriver", "(", ")", ")", ";", "}", "else", "if", "(", "BrowsersList", ".", "HTML_UNIT", ".", "equalsString", "(", "browserName", ")", ")", "{", "driver", "=", "new", "HtmlUnitDriver", "(", "true", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "ErrorMessages", ".", "ERROR_BROWSER_INVALID", ")", ";", "}", "}", "/* Sets to all driver methods the global timeout of 1 second. \n\t\t * To tests, Timeouts must be specified on the components.\n\t\t */", "SeleniumController", ".", "driver", ".", "manage", "(", ")", ".", "timeouts", "(", ")", ".", "implicitlyWait", "(", "1", ",", "TimeUnit", ".", "SECONDS", ")", ";", "SeleniumController", ".", "builder", "=", "new", "SeleniumBuilder", "(", "driver", ")", ";", "SeleniumController", ".", "browser", "=", "new", "SeleniumBrowser", "(", ")", ";", "ListenerGateway", ".", "setWebDriver", "(", "driver", ")", ";", "ListenerGateway", ".", "setParameters", "(", "parametersMap", ")", ";", "}" ]
This method starts the selenium remote control using the parameters informed by testng.xml file @param parameters @throws Exception
[ "This", "method", "starts", "the", "selenium", "remote", "control", "using", "the", "parameters", "informed", "by", "testng", ".", "xml", "file" ]
8dc999e74a9c3f5c09e4e68ea0ef5634cdb760ee
https://github.com/BeholderTAF/beholder-selenium/blob/8dc999e74a9c3f5c09e4e68ea0ef5634cdb760ee/src/main/java/br/ufmg/dcc/saotome/beholder/selenium/SeleniumController.java#L90-L166
152,006
BeholderTAF/beholder-selenium
src/main/java/br/ufmg/dcc/saotome/beholder/selenium/SeleniumController.java
SeleniumController.closeSelenium
@AfterSuite(alwaysRun=true) public static void closeSelenium() { if(driver != null) { driver.quit(); driver = null; } }
java
@AfterSuite(alwaysRun=true) public static void closeSelenium() { if(driver != null) { driver.quit(); driver = null; } }
[ "@", "AfterSuite", "(", "alwaysRun", "=", "true", ")", "public", "static", "void", "closeSelenium", "(", ")", "{", "if", "(", "driver", "!=", "null", ")", "{", "driver", ".", "quit", "(", ")", ";", "driver", "=", "null", ";", "}", "}" ]
Close the driver. It'll close the browsers window and stop the selenium RC.
[ "Close", "the", "driver", ".", "It", "ll", "close", "the", "browsers", "window", "and", "stop", "the", "selenium", "RC", "." ]
8dc999e74a9c3f5c09e4e68ea0ef5634cdb760ee
https://github.com/BeholderTAF/beholder-selenium/blob/8dc999e74a9c3f5c09e4e68ea0ef5634cdb760ee/src/main/java/br/ufmg/dcc/saotome/beholder/selenium/SeleniumController.java#L169-L176
152,007
Stratio/stratio-connector-commons
connector-commons/src/main/java/com/stratio/connector/commons/util/PropertyValueRecovered.java
PropertyValueRecovered.recoveredValueASArray
public static <T> T[] recoveredValueASArray(Class<T> type, String properties) throws ExecutionException { LOGGER.info(String.format("Recovered propeties [%s] as [%s]", properties, type)); String[] stringParseProperties = properties.replaceAll("\\s+", "").replaceAll("\\[", "").replaceAll("]", "").split(","); T[] returnValue = null; if (isString(type)) { returnValue = (T[]) stringParseProperties; } else if (isBoolean(type)) { Boolean[] tempReturnValue = new Boolean[stringParseProperties.length]; for (int i = 0; i < stringParseProperties.length; i++) { tempReturnValue[i] = Boolean.parseBoolean(stringParseProperties[i]); } returnValue = (T[]) tempReturnValue; } else { String message = String.format("The type %s is not supported for conversion.", type); LOGGER.error(message); throw new ExecutionException(String.format(message)); } if (LOGGER.isDebugEnabled()) { LOGGER.debug(String.format("The property as converted to %s", Arrays.deepToString(returnValue))); } return returnValue; }
java
public static <T> T[] recoveredValueASArray(Class<T> type, String properties) throws ExecutionException { LOGGER.info(String.format("Recovered propeties [%s] as [%s]", properties, type)); String[] stringParseProperties = properties.replaceAll("\\s+", "").replaceAll("\\[", "").replaceAll("]", "").split(","); T[] returnValue = null; if (isString(type)) { returnValue = (T[]) stringParseProperties; } else if (isBoolean(type)) { Boolean[] tempReturnValue = new Boolean[stringParseProperties.length]; for (int i = 0; i < stringParseProperties.length; i++) { tempReturnValue[i] = Boolean.parseBoolean(stringParseProperties[i]); } returnValue = (T[]) tempReturnValue; } else { String message = String.format("The type %s is not supported for conversion.", type); LOGGER.error(message); throw new ExecutionException(String.format(message)); } if (LOGGER.isDebugEnabled()) { LOGGER.debug(String.format("The property as converted to %s", Arrays.deepToString(returnValue))); } return returnValue; }
[ "public", "static", "<", "T", ">", "T", "[", "]", "recoveredValueASArray", "(", "Class", "<", "T", ">", "type", ",", "String", "properties", ")", "throws", "ExecutionException", "{", "LOGGER", ".", "info", "(", "String", ".", "format", "(", "\"Recovered propeties [%s] as [%s]\"", ",", "properties", ",", "type", ")", ")", ";", "String", "[", "]", "stringParseProperties", "=", "properties", ".", "replaceAll", "(", "\"\\\\s+\"", ",", "\"\"", ")", ".", "replaceAll", "(", "\"\\\\[\"", ",", "\"\"", ")", ".", "replaceAll", "(", "\"]\"", ",", "\"\"", ")", ".", "split", "(", "\",\"", ")", ";", "T", "[", "]", "returnValue", "=", "null", ";", "if", "(", "isString", "(", "type", ")", ")", "{", "returnValue", "=", "(", "T", "[", "]", ")", "stringParseProperties", ";", "}", "else", "if", "(", "isBoolean", "(", "type", ")", ")", "{", "Boolean", "[", "]", "tempReturnValue", "=", "new", "Boolean", "[", "stringParseProperties", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "stringParseProperties", ".", "length", ";", "i", "++", ")", "{", "tempReturnValue", "[", "i", "]", "=", "Boolean", ".", "parseBoolean", "(", "stringParseProperties", "[", "i", "]", ")", ";", "}", "returnValue", "=", "(", "T", "[", "]", ")", "tempReturnValue", ";", "}", "else", "{", "String", "message", "=", "String", ".", "format", "(", "\"The type %s is not supported for conversion.\"", ",", "type", ")", ";", "LOGGER", ".", "error", "(", "message", ")", ";", "throw", "new", "ExecutionException", "(", "String", ".", "format", "(", "message", ")", ")", ";", "}", "if", "(", "LOGGER", ".", "isDebugEnabled", "(", ")", ")", "{", "LOGGER", ".", "debug", "(", "String", ".", "format", "(", "\"The property as converted to %s\"", ",", "Arrays", ".", "deepToString", "(", "returnValue", ")", ")", ")", ";", "}", "return", "returnValue", ";", "}" ]
This method recovered the array of properties. @param properties the string which represents the properties to recovered. @param type the type to recovered. @return the properties. @throws ExecutionException if an error happens.
[ "This", "method", "recovered", "the", "array", "of", "properties", "." ]
d7cc66cb9591344a13055962e87a91f01c3707d1
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/util/PropertyValueRecovered.java#L57-L80
152,008
Stratio/stratio-connector-commons
connector-commons/src/main/java/com/stratio/connector/commons/util/PropertyValueRecovered.java
PropertyValueRecovered.recoveredValue
public static <T> T recoveredValue(Class<T> type, String properties) throws ExecutionException { return recoveredValueASArray(type, properties)[0]; }
java
public static <T> T recoveredValue(Class<T> type, String properties) throws ExecutionException { return recoveredValueASArray(type, properties)[0]; }
[ "public", "static", "<", "T", ">", "T", "recoveredValue", "(", "Class", "<", "T", ">", "type", ",", "String", "properties", ")", "throws", "ExecutionException", "{", "return", "recoveredValueASArray", "(", "type", ",", "properties", ")", "[", "0", "]", ";", "}" ]
This method recovered the property. @param properties the string which represents the properties to recovered. @param type the type to recovered. @return the properties. @Throws ExecutionException if an error happens.
[ "This", "method", "recovered", "the", "property", "." ]
d7cc66cb9591344a13055962e87a91f01c3707d1
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/util/PropertyValueRecovered.java#L91-L93
152,009
pahakia/lib
settings/src/main/java/pahakia/settings/Settings.java
Settings.init
public static final void init() { String settingDir = System.getProperty(SETTINGS_DIR); if (settingDir == null) { settingDir = System.getenv(SETTINGS_DIR); } if (settingDir == null) { throw Fault.create(SettingsFaultCodes.SettingsDirNotSpecified, SETTINGS_DIR); } init(settingDir); }
java
public static final void init() { String settingDir = System.getProperty(SETTINGS_DIR); if (settingDir == null) { settingDir = System.getenv(SETTINGS_DIR); } if (settingDir == null) { throw Fault.create(SettingsFaultCodes.SettingsDirNotSpecified, SETTINGS_DIR); } init(settingDir); }
[ "public", "static", "final", "void", "init", "(", ")", "{", "String", "settingDir", "=", "System", ".", "getProperty", "(", "SETTINGS_DIR", ")", ";", "if", "(", "settingDir", "==", "null", ")", "{", "settingDir", "=", "System", ".", "getenv", "(", "SETTINGS_DIR", ")", ";", "}", "if", "(", "settingDir", "==", "null", ")", "{", "throw", "Fault", ".", "create", "(", "SettingsFaultCodes", ".", "SettingsDirNotSpecified", ",", "SETTINGS_DIR", ")", ";", "}", "init", "(", "settingDir", ")", ";", "}" ]
load the files from -Dcom.pahakia.settings.dir=directory
[ "load", "the", "files", "from", "-", "Dcom", ".", "pahakia", ".", "settings", ".", "dir", "=", "directory" ]
f78402d176371837a5c33fcd540475bcb81f4086
https://github.com/pahakia/lib/blob/f78402d176371837a5c33fcd540475bcb81f4086/settings/src/main/java/pahakia/settings/Settings.java#L53-L62
152,010
jbundle/jbundle
main/db/src/main/java/org/jbundle/main/user/db/UpdateGroupPermissionHandler.java
UpdateGroupPermissionHandler.updateGroupPermission
public void updateGroupPermission(int iGroupID) { if (m_recUserPermission == null) m_recUserPermission = new UserPermission(this.getOwner().findRecordOwner()); Record m_recUserGroup = ((ReferenceField)m_recUserPermission.getField(UserPermission.USER_GROUP_ID)).getReferenceRecord(); m_recUserGroup.setOpenMode(m_recUserGroup.getOpenMode() & ~DBConstants.OPEN_READ_ONLY); // Read and write if (m_recUserPermission.getListener(SubFileFilter.class) == null) m_recUserPermission.addListener(new SubFileFilter(m_recUserGroup)); try { m_recUserGroup.addNew(); m_recUserGroup.getCounterField().setValue(iGroupID); if (m_recUserGroup.seek(null)) { m_recUserGroup.edit(); StringBuffer sb = new StringBuffer(); m_recUserPermission.close(); while (m_recUserPermission.hasNext()) { m_recUserPermission.next(); Record recUserResource = ((ReferenceField)m_recUserPermission.getField(UserPermission.USER_RESOURCE_ID)).getReference(); String strResource = recUserResource.getField(UserResource.RESOURCE_CLASS).toString(); StringTokenizer tokenizer = new StringTokenizer(strResource, "\n\t ,"); while (tokenizer.hasMoreTokens()) { String strClass = tokenizer.nextToken(); int startThin = strClass.indexOf(Constants.THIN_SUBPACKAGE, 0); if (startThin != -1) // Remove the ".thin" reference strClass = strClass.substring(0, startThin) + strClass.substring(startThin + Constants.THIN_SUBPACKAGE.length()); if (strClass.length() > 0) { sb.append(strClass).append('\t'); sb.append(m_recUserPermission.getField(UserPermission.ACCESS_LEVEL).toString()).append('\t'); sb.append(m_recUserPermission.getField(UserPermission.LOGIN_LEVEL).toString()).append("\t\n"); } } } m_recUserGroup.getField(UserGroup.ACCESS_MAP).setString(sb.toString()); m_recUserGroup.set(); } } catch (DBException e) { e.printStackTrace(); } }
java
public void updateGroupPermission(int iGroupID) { if (m_recUserPermission == null) m_recUserPermission = new UserPermission(this.getOwner().findRecordOwner()); Record m_recUserGroup = ((ReferenceField)m_recUserPermission.getField(UserPermission.USER_GROUP_ID)).getReferenceRecord(); m_recUserGroup.setOpenMode(m_recUserGroup.getOpenMode() & ~DBConstants.OPEN_READ_ONLY); // Read and write if (m_recUserPermission.getListener(SubFileFilter.class) == null) m_recUserPermission.addListener(new SubFileFilter(m_recUserGroup)); try { m_recUserGroup.addNew(); m_recUserGroup.getCounterField().setValue(iGroupID); if (m_recUserGroup.seek(null)) { m_recUserGroup.edit(); StringBuffer sb = new StringBuffer(); m_recUserPermission.close(); while (m_recUserPermission.hasNext()) { m_recUserPermission.next(); Record recUserResource = ((ReferenceField)m_recUserPermission.getField(UserPermission.USER_RESOURCE_ID)).getReference(); String strResource = recUserResource.getField(UserResource.RESOURCE_CLASS).toString(); StringTokenizer tokenizer = new StringTokenizer(strResource, "\n\t ,"); while (tokenizer.hasMoreTokens()) { String strClass = tokenizer.nextToken(); int startThin = strClass.indexOf(Constants.THIN_SUBPACKAGE, 0); if (startThin != -1) // Remove the ".thin" reference strClass = strClass.substring(0, startThin) + strClass.substring(startThin + Constants.THIN_SUBPACKAGE.length()); if (strClass.length() > 0) { sb.append(strClass).append('\t'); sb.append(m_recUserPermission.getField(UserPermission.ACCESS_LEVEL).toString()).append('\t'); sb.append(m_recUserPermission.getField(UserPermission.LOGIN_LEVEL).toString()).append("\t\n"); } } } m_recUserGroup.getField(UserGroup.ACCESS_MAP).setString(sb.toString()); m_recUserGroup.set(); } } catch (DBException e) { e.printStackTrace(); } }
[ "public", "void", "updateGroupPermission", "(", "int", "iGroupID", ")", "{", "if", "(", "m_recUserPermission", "==", "null", ")", "m_recUserPermission", "=", "new", "UserPermission", "(", "this", ".", "getOwner", "(", ")", ".", "findRecordOwner", "(", ")", ")", ";", "Record", "m_recUserGroup", "=", "(", "(", "ReferenceField", ")", "m_recUserPermission", ".", "getField", "(", "UserPermission", ".", "USER_GROUP_ID", ")", ")", ".", "getReferenceRecord", "(", ")", ";", "m_recUserGroup", ".", "setOpenMode", "(", "m_recUserGroup", ".", "getOpenMode", "(", ")", "&", "~", "DBConstants", ".", "OPEN_READ_ONLY", ")", ";", "// Read and write", "if", "(", "m_recUserPermission", ".", "getListener", "(", "SubFileFilter", ".", "class", ")", "==", "null", ")", "m_recUserPermission", ".", "addListener", "(", "new", "SubFileFilter", "(", "m_recUserGroup", ")", ")", ";", "try", "{", "m_recUserGroup", ".", "addNew", "(", ")", ";", "m_recUserGroup", ".", "getCounterField", "(", ")", ".", "setValue", "(", "iGroupID", ")", ";", "if", "(", "m_recUserGroup", ".", "seek", "(", "null", ")", ")", "{", "m_recUserGroup", ".", "edit", "(", ")", ";", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "m_recUserPermission", ".", "close", "(", ")", ";", "while", "(", "m_recUserPermission", ".", "hasNext", "(", ")", ")", "{", "m_recUserPermission", ".", "next", "(", ")", ";", "Record", "recUserResource", "=", "(", "(", "ReferenceField", ")", "m_recUserPermission", ".", "getField", "(", "UserPermission", ".", "USER_RESOURCE_ID", ")", ")", ".", "getReference", "(", ")", ";", "String", "strResource", "=", "recUserResource", ".", "getField", "(", "UserResource", ".", "RESOURCE_CLASS", ")", ".", "toString", "(", ")", ";", "StringTokenizer", "tokenizer", "=", "new", "StringTokenizer", "(", "strResource", ",", "\"\\n\\t ,\"", ")", ";", "while", "(", "tokenizer", ".", "hasMoreTokens", "(", ")", ")", "{", "String", "strClass", "=", "tokenizer", ".", "nextToken", "(", ")", ";", "int", "startThin", "=", "strClass", ".", "indexOf", "(", "Constants", ".", "THIN_SUBPACKAGE", ",", "0", ")", ";", "if", "(", "startThin", "!=", "-", "1", ")", "// Remove the \".thin\" reference", "strClass", "=", "strClass", ".", "substring", "(", "0", ",", "startThin", ")", "+", "strClass", ".", "substring", "(", "startThin", "+", "Constants", ".", "THIN_SUBPACKAGE", ".", "length", "(", ")", ")", ";", "if", "(", "strClass", ".", "length", "(", ")", ">", "0", ")", "{", "sb", ".", "append", "(", "strClass", ")", ".", "append", "(", "'", "'", ")", ";", "sb", ".", "append", "(", "m_recUserPermission", ".", "getField", "(", "UserPermission", ".", "ACCESS_LEVEL", ")", ".", "toString", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "sb", ".", "append", "(", "m_recUserPermission", ".", "getField", "(", "UserPermission", ".", "LOGIN_LEVEL", ")", ".", "toString", "(", ")", ")", ".", "append", "(", "\"\\t\\n\"", ")", ";", "}", "}", "}", "m_recUserGroup", ".", "getField", "(", "UserGroup", ".", "ACCESS_MAP", ")", ".", "setString", "(", "sb", ".", "toString", "(", ")", ")", ";", "m_recUserGroup", ".", "set", "(", ")", ";", "}", "}", "catch", "(", "DBException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
UpdateGroupPermission Method.
[ "UpdateGroupPermission", "Method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/db/src/main/java/org/jbundle/main/user/db/UpdateGroupPermissionHandler.java#L116-L161
152,011
tvesalainen/util
ham/src/main/java/org/vesalainen/ham/HfFax.java
HfFax.inMap
public boolean inMap(Location location) { for (String map : schedule.getMap()) { if (station.inMap(map, location)) { return true; } } return false; }
java
public boolean inMap(Location location) { for (String map : schedule.getMap()) { if (station.inMap(map, location)) { return true; } } return false; }
[ "public", "boolean", "inMap", "(", "Location", "location", ")", "{", "for", "(", "String", "map", ":", "schedule", ".", "getMap", "(", ")", ")", "{", "if", "(", "station", ".", "inMap", "(", "map", ",", "location", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns true if location is inside map. @param location @return
[ "Returns", "true", "if", "location", "is", "inside", "map", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/ham/src/main/java/org/vesalainen/ham/HfFax.java#L44-L54
152,012
jbundle/jbundle
base/screen/control/servlet/src/main/java/org/jbundle/base/screen/control/servlet/ServletApplication.java
ServletApplication.init
public void init(Object env, Map<String,Object> properties, Object applet) { super.init(env, properties, applet); }
java
public void init(Object env, Map<String,Object> properties, Object applet) { super.init(env, properties, applet); }
[ "public", "void", "init", "(", "Object", "env", ",", "Map", "<", "String", ",", "Object", ">", "properties", ",", "Object", "applet", ")", "{", "super", ".", "init", "(", "env", ",", "properties", ",", "applet", ")", ";", "}" ]
Initializes the ServletApplication. Usually you pass the object that wants to use this session. For example, the applet or ServletApplication. @param env The Environment. @param strURL The application parameters as a URL. @param args The application parameters as an initial arg list. @param applet The application parameters coming from an applet.
[ "Initializes", "the", "ServletApplication", ".", "Usually", "you", "pass", "the", "object", "that", "wants", "to", "use", "this", "session", ".", "For", "example", "the", "applet", "or", "ServletApplication", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/control/servlet/src/main/java/org/jbundle/base/screen/control/servlet/ServletApplication.java#L51-L54
152,013
jbundle/jbundle
base/screen/control/servlet/src/main/java/org/jbundle/base/screen/control/servlet/ServletApplication.java
ServletApplication.valueUnbound
public void valueUnbound(HttpSessionBindingEvent event) { Utility.getLogger().info("Session Unbound"); if (this.getMainTask() == null) this.free(); else // Never - This would mean the session was released before the http response was sent (memory leak) Utility.getLogger().severe("Unbound error ServletApplication.valueUnbound"); }
java
public void valueUnbound(HttpSessionBindingEvent event) { Utility.getLogger().info("Session Unbound"); if (this.getMainTask() == null) this.free(); else // Never - This would mean the session was released before the http response was sent (memory leak) Utility.getLogger().severe("Unbound error ServletApplication.valueUnbound"); }
[ "public", "void", "valueUnbound", "(", "HttpSessionBindingEvent", "event", ")", "{", "Utility", ".", "getLogger", "(", ")", ".", "info", "(", "\"Session Unbound\"", ")", ";", "if", "(", "this", ".", "getMainTask", "(", ")", "==", "null", ")", "this", ".", "free", "(", ")", ";", "else", "// Never - This would mean the session was released before the http response was sent (memory leak)", "Utility", ".", "getLogger", "(", ")", ".", "severe", "(", "\"Unbound error ServletApplication.valueUnbound\"", ")", ";", "}" ]
Notifies the object that is being unbound from a session and identifies the session.
[ "Notifies", "the", "object", "that", "is", "being", "unbound", "from", "a", "session", "and", "identifies", "the", "session", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/control/servlet/src/main/java/org/jbundle/base/screen/control/servlet/ServletApplication.java#L73-L80
152,014
jeremiehuchet/acrachilisync
acrachilisync-core/src/main/java/fr/dudie/acrachilisync/utils/ChiliprojectUtils.java
ChiliprojectUtils.isSynchronized
public static boolean isSynchronized(final AcraReport pReport, final Issue pIssue) throws IssueParseException { final IssueDescriptionReader reader = new IssueDescriptionReader(pIssue); return CollectionUtils.exists(reader.getOccurrences(), new ReportPredicate(pReport)); }
java
public static boolean isSynchronized(final AcraReport pReport, final Issue pIssue) throws IssueParseException { final IssueDescriptionReader reader = new IssueDescriptionReader(pIssue); return CollectionUtils.exists(reader.getOccurrences(), new ReportPredicate(pReport)); }
[ "public", "static", "boolean", "isSynchronized", "(", "final", "AcraReport", "pReport", ",", "final", "Issue", "pIssue", ")", "throws", "IssueParseException", "{", "final", "IssueDescriptionReader", "reader", "=", "new", "IssueDescriptionReader", "(", "pIssue", ")", ";", "return", "CollectionUtils", ".", "exists", "(", "reader", ".", "getOccurrences", "(", ")", ",", "new", "ReportPredicate", "(", "pReport", ")", ")", ";", "}" ]
Gets wheter or not the given report has already been synchronized with the given issue. @param pReport an ACRA report @param pIssue a Chiliproject issue @return true if the given report has already been synchronized with the given issue @throws IssueParseException the Date of one of the synchronized issue is unreadable
[ "Gets", "wheter", "or", "not", "the", "given", "report", "has", "already", "been", "synchronized", "with", "the", "given", "issue", "." ]
4eadb0218623e77e0d92b5a08515eea2db51e988
https://github.com/jeremiehuchet/acrachilisync/blob/4eadb0218623e77e0d92b5a08515eea2db51e988/acrachilisync-core/src/main/java/fr/dudie/acrachilisync/utils/ChiliprojectUtils.java#L55-L60
152,015
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.getNumWarnings
public int getNumWarnings() { int numWarnings = 0; if (getBuildData().getErrorDatabase() != null && getBuildData().getErrorDatabase().getErrors( getBuildData().getBuildLocale()) != null) { for (final TopicErrorData errorData : getBuildData().getErrorDatabase().getErrors(getBuildData().getBuildLocale())) { numWarnings += errorData.getItemsOfType(ErrorLevel.WARNING).size(); } } return numWarnings; }
java
public int getNumWarnings() { int numWarnings = 0; if (getBuildData().getErrorDatabase() != null && getBuildData().getErrorDatabase().getErrors( getBuildData().getBuildLocale()) != null) { for (final TopicErrorData errorData : getBuildData().getErrorDatabase().getErrors(getBuildData().getBuildLocale())) { numWarnings += errorData.getItemsOfType(ErrorLevel.WARNING).size(); } } return numWarnings; }
[ "public", "int", "getNumWarnings", "(", ")", "{", "int", "numWarnings", "=", "0", ";", "if", "(", "getBuildData", "(", ")", ".", "getErrorDatabase", "(", ")", "!=", "null", "&&", "getBuildData", "(", ")", ".", "getErrorDatabase", "(", ")", ".", "getErrors", "(", "getBuildData", "(", ")", ".", "getBuildLocale", "(", ")", ")", "!=", "null", ")", "{", "for", "(", "final", "TopicErrorData", "errorData", ":", "getBuildData", "(", ")", ".", "getErrorDatabase", "(", ")", ".", "getErrors", "(", "getBuildData", "(", ")", ".", "getBuildLocale", "(", ")", ")", ")", "{", "numWarnings", "+=", "errorData", ".", "getItemsOfType", "(", "ErrorLevel", ".", "WARNING", ")", ".", "size", "(", ")", ";", "}", "}", "return", "numWarnings", ";", "}" ]
Gets the number of warnings that occurred during the last build. @return The number of warnings that occurred.
[ "Gets", "the", "number", "of", "warnings", "that", "occurred", "during", "the", "last", "build", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L342-L351
152,016
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.getNumErrors
public int getNumErrors() { int numErrors = 0; if (getBuildData().getErrorDatabase() != null && getBuildData().getErrorDatabase().getErrors( getBuildData().getBuildLocale()) != null) { for (final TopicErrorData errorData : getBuildData().getErrorDatabase().getErrors(getBuildData().getBuildLocale())) { numErrors += errorData.getItemsOfType(ErrorLevel.ERROR).size(); } } return numErrors; }
java
public int getNumErrors() { int numErrors = 0; if (getBuildData().getErrorDatabase() != null && getBuildData().getErrorDatabase().getErrors( getBuildData().getBuildLocale()) != null) { for (final TopicErrorData errorData : getBuildData().getErrorDatabase().getErrors(getBuildData().getBuildLocale())) { numErrors += errorData.getItemsOfType(ErrorLevel.ERROR).size(); } } return numErrors; }
[ "public", "int", "getNumErrors", "(", ")", "{", "int", "numErrors", "=", "0", ";", "if", "(", "getBuildData", "(", ")", ".", "getErrorDatabase", "(", ")", "!=", "null", "&&", "getBuildData", "(", ")", ".", "getErrorDatabase", "(", ")", ".", "getErrors", "(", "getBuildData", "(", ")", ".", "getBuildLocale", "(", ")", ")", "!=", "null", ")", "{", "for", "(", "final", "TopicErrorData", "errorData", ":", "getBuildData", "(", ")", ".", "getErrorDatabase", "(", ")", ".", "getErrors", "(", "getBuildData", "(", ")", ".", "getBuildLocale", "(", ")", ")", ")", "{", "numErrors", "+=", "errorData", ".", "getItemsOfType", "(", "ErrorLevel", ".", "ERROR", ")", ".", "size", "(", ")", ";", "}", "}", "return", "numErrors", ";", "}" ]
Gets the number of errors that occurred during the last build. @return The number of errors that occurred.
[ "Gets", "the", "number", "of", "errors", "that", "occurred", "during", "the", "last", "build", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L358-L367
152,017
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.pullTranslations
protected void pullTranslations(final ContentSpec contentSpec, final String locale) throws BuildProcessingException { final CollectionWrapper<TranslatedContentSpecWrapper> translatedContentSpecs = providerFactory.getProvider( TranslatedContentSpecProvider.class).getTranslatedContentSpecsWithQuery("query;" + CommonFilterConstants.ZANATA_IDS_FILTER_VAR + "=CS" + contentSpec.getId() + "-" + contentSpec.getRevision()); // Ensure that the passed content spec has a translation if (translatedContentSpecs == null || translatedContentSpecs.isEmpty()) { throw new BuildProcessingException( "Unable to find any translations for Content Spec " + contentSpec.getId() + (contentSpec.getRevision() == null ? "" : (", Revision " + contentSpec.getRevision()))); } final TranslatedContentSpecWrapper translatedContentSpec = translatedContentSpecs.getItems().get(0); if (translatedContentSpec.getTranslatedNodes() != null) { final Map<String, String> translations = new HashMap<String, String>(); // Iterate over each translated node and build up the list of translated strings for the content spec. final List<TranslatedCSNodeWrapper> translatedCSNodes = translatedContentSpec.getTranslatedNodes().getItems(); for (final TranslatedCSNodeWrapper translatedCSNode : translatedCSNodes) { // Only process nodes that have content pushed to Zanata if (!isNullOrEmpty(translatedCSNode.getOriginalString())) { if (translatedCSNode.getTranslatedStrings() != null) { final List<TranslatedCSNodeStringWrapper> translatedCSNodeStrings = translatedCSNode.getTranslatedStrings() .getItems(); for (final TranslatedCSNodeStringWrapper translatedCSNodeString : translatedCSNodeStrings) { if (translatedCSNodeString.getLocale().getValue().equals(locale)) { translations.put(translatedCSNode.getOriginalString(), translatedCSNodeString.getTranslatedString()); } } } } } // Resolve any entities to make sure that the source string match final List<Entity> entities = XMLUtilities.parseEntitiesFromString(contentSpec.getEntities()); TranslationUtilities.resolveCustomContentSpecEntities(entities, translatedContentSpec.getContentSpec()); // Replace all the translated strings TranslationUtilities.replaceTranslatedStrings(translatedContentSpec.getContentSpec(), contentSpec, translations); // Set the Unique Ids so that they can be used later setTranslationUniqueIds(contentSpec, translatedContentSpec); } }
java
protected void pullTranslations(final ContentSpec contentSpec, final String locale) throws BuildProcessingException { final CollectionWrapper<TranslatedContentSpecWrapper> translatedContentSpecs = providerFactory.getProvider( TranslatedContentSpecProvider.class).getTranslatedContentSpecsWithQuery("query;" + CommonFilterConstants.ZANATA_IDS_FILTER_VAR + "=CS" + contentSpec.getId() + "-" + contentSpec.getRevision()); // Ensure that the passed content spec has a translation if (translatedContentSpecs == null || translatedContentSpecs.isEmpty()) { throw new BuildProcessingException( "Unable to find any translations for Content Spec " + contentSpec.getId() + (contentSpec.getRevision() == null ? "" : (", Revision " + contentSpec.getRevision()))); } final TranslatedContentSpecWrapper translatedContentSpec = translatedContentSpecs.getItems().get(0); if (translatedContentSpec.getTranslatedNodes() != null) { final Map<String, String> translations = new HashMap<String, String>(); // Iterate over each translated node and build up the list of translated strings for the content spec. final List<TranslatedCSNodeWrapper> translatedCSNodes = translatedContentSpec.getTranslatedNodes().getItems(); for (final TranslatedCSNodeWrapper translatedCSNode : translatedCSNodes) { // Only process nodes that have content pushed to Zanata if (!isNullOrEmpty(translatedCSNode.getOriginalString())) { if (translatedCSNode.getTranslatedStrings() != null) { final List<TranslatedCSNodeStringWrapper> translatedCSNodeStrings = translatedCSNode.getTranslatedStrings() .getItems(); for (final TranslatedCSNodeStringWrapper translatedCSNodeString : translatedCSNodeStrings) { if (translatedCSNodeString.getLocale().getValue().equals(locale)) { translations.put(translatedCSNode.getOriginalString(), translatedCSNodeString.getTranslatedString()); } } } } } // Resolve any entities to make sure that the source string match final List<Entity> entities = XMLUtilities.parseEntitiesFromString(contentSpec.getEntities()); TranslationUtilities.resolveCustomContentSpecEntities(entities, translatedContentSpec.getContentSpec()); // Replace all the translated strings TranslationUtilities.replaceTranslatedStrings(translatedContentSpec.getContentSpec(), contentSpec, translations); // Set the Unique Ids so that they can be used later setTranslationUniqueIds(contentSpec, translatedContentSpec); } }
[ "protected", "void", "pullTranslations", "(", "final", "ContentSpec", "contentSpec", ",", "final", "String", "locale", ")", "throws", "BuildProcessingException", "{", "final", "CollectionWrapper", "<", "TranslatedContentSpecWrapper", ">", "translatedContentSpecs", "=", "providerFactory", ".", "getProvider", "(", "TranslatedContentSpecProvider", ".", "class", ")", ".", "getTranslatedContentSpecsWithQuery", "(", "\"query;\"", "+", "CommonFilterConstants", ".", "ZANATA_IDS_FILTER_VAR", "+", "\"=CS\"", "+", "contentSpec", ".", "getId", "(", ")", "+", "\"-\"", "+", "contentSpec", ".", "getRevision", "(", ")", ")", ";", "// Ensure that the passed content spec has a translation", "if", "(", "translatedContentSpecs", "==", "null", "||", "translatedContentSpecs", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "BuildProcessingException", "(", "\"Unable to find any translations for Content Spec \"", "+", "contentSpec", ".", "getId", "(", ")", "+", "(", "contentSpec", ".", "getRevision", "(", ")", "==", "null", "?", "\"\"", ":", "(", "\", Revision \"", "+", "contentSpec", ".", "getRevision", "(", ")", ")", ")", ")", ";", "}", "final", "TranslatedContentSpecWrapper", "translatedContentSpec", "=", "translatedContentSpecs", ".", "getItems", "(", ")", ".", "get", "(", "0", ")", ";", "if", "(", "translatedContentSpec", ".", "getTranslatedNodes", "(", ")", "!=", "null", ")", "{", "final", "Map", "<", "String", ",", "String", ">", "translations", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "// Iterate over each translated node and build up the list of translated strings for the content spec.", "final", "List", "<", "TranslatedCSNodeWrapper", ">", "translatedCSNodes", "=", "translatedContentSpec", ".", "getTranslatedNodes", "(", ")", ".", "getItems", "(", ")", ";", "for", "(", "final", "TranslatedCSNodeWrapper", "translatedCSNode", ":", "translatedCSNodes", ")", "{", "// Only process nodes that have content pushed to Zanata", "if", "(", "!", "isNullOrEmpty", "(", "translatedCSNode", ".", "getOriginalString", "(", ")", ")", ")", "{", "if", "(", "translatedCSNode", ".", "getTranslatedStrings", "(", ")", "!=", "null", ")", "{", "final", "List", "<", "TranslatedCSNodeStringWrapper", ">", "translatedCSNodeStrings", "=", "translatedCSNode", ".", "getTranslatedStrings", "(", ")", ".", "getItems", "(", ")", ";", "for", "(", "final", "TranslatedCSNodeStringWrapper", "translatedCSNodeString", ":", "translatedCSNodeStrings", ")", "{", "if", "(", "translatedCSNodeString", ".", "getLocale", "(", ")", ".", "getValue", "(", ")", ".", "equals", "(", "locale", ")", ")", "{", "translations", ".", "put", "(", "translatedCSNode", ".", "getOriginalString", "(", ")", ",", "translatedCSNodeString", ".", "getTranslatedString", "(", ")", ")", ";", "}", "}", "}", "}", "}", "// Resolve any entities to make sure that the source string match", "final", "List", "<", "Entity", ">", "entities", "=", "XMLUtilities", ".", "parseEntitiesFromString", "(", "contentSpec", ".", "getEntities", "(", ")", ")", ";", "TranslationUtilities", ".", "resolveCustomContentSpecEntities", "(", "entities", ",", "translatedContentSpec", ".", "getContentSpec", "(", ")", ")", ";", "// Replace all the translated strings", "TranslationUtilities", ".", "replaceTranslatedStrings", "(", "translatedContentSpec", ".", "getContentSpec", "(", ")", ",", "contentSpec", ",", "translations", ")", ";", "// Set the Unique Ids so that they can be used later", "setTranslationUniqueIds", "(", "contentSpec", ",", "translatedContentSpec", ")", ";", "}", "}" ]
Get the translations from the REST API and replace the original strings with the values downloaded. @param contentSpec The Content Spec to get and replace the translations for. @param locale The locale to pull the translations for. @throws BuildProcessingException Thrown if an unexpected error occurs during building.
[ "Get", "the", "translations", "from", "the", "REST", "API", "and", "replace", "the", "original", "strings", "with", "the", "values", "downloaded", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L580-L623
152,018
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.setTranslationUniqueIds
protected void setTranslationUniqueIds(final ContentSpec contentSpec, final TranslatedContentSpecWrapper translatedContentSpec) throws BuildProcessingException { final List<TranslatedCSNodeWrapper> translatedCSNodes = translatedContentSpec.getTranslatedNodes().getItems(); for (final TranslatedCSNodeWrapper translatedCSNode : translatedCSNodes) { final org.jboss.pressgang.ccms.contentspec.Node node = ContentSpecUtilities.findMatchingContentSpecNode(contentSpec, translatedCSNode.getNodeId()); if (node != null) { node.setTranslationUniqueId(translatedCSNode.getId().toString()); if (node instanceof KeyValueNode && ((KeyValueNode) node).getValue() instanceof SpecTopic) { ((SpecTopic) ((KeyValueNode) node).getValue()).setTranslationUniqueId(translatedCSNode.getId().toString()); } } else { // This shouldn't happen, but take care of it incase it does due to another bug throw new BuildProcessingException( "Unable to find a matching Content Spec Node object for Translated Node " + translatedCSNode.getId()); } } }
java
protected void setTranslationUniqueIds(final ContentSpec contentSpec, final TranslatedContentSpecWrapper translatedContentSpec) throws BuildProcessingException { final List<TranslatedCSNodeWrapper> translatedCSNodes = translatedContentSpec.getTranslatedNodes().getItems(); for (final TranslatedCSNodeWrapper translatedCSNode : translatedCSNodes) { final org.jboss.pressgang.ccms.contentspec.Node node = ContentSpecUtilities.findMatchingContentSpecNode(contentSpec, translatedCSNode.getNodeId()); if (node != null) { node.setTranslationUniqueId(translatedCSNode.getId().toString()); if (node instanceof KeyValueNode && ((KeyValueNode) node).getValue() instanceof SpecTopic) { ((SpecTopic) ((KeyValueNode) node).getValue()).setTranslationUniqueId(translatedCSNode.getId().toString()); } } else { // This shouldn't happen, but take care of it incase it does due to another bug throw new BuildProcessingException( "Unable to find a matching Content Spec Node object for Translated Node " + translatedCSNode.getId()); } } }
[ "protected", "void", "setTranslationUniqueIds", "(", "final", "ContentSpec", "contentSpec", ",", "final", "TranslatedContentSpecWrapper", "translatedContentSpec", ")", "throws", "BuildProcessingException", "{", "final", "List", "<", "TranslatedCSNodeWrapper", ">", "translatedCSNodes", "=", "translatedContentSpec", ".", "getTranslatedNodes", "(", ")", ".", "getItems", "(", ")", ";", "for", "(", "final", "TranslatedCSNodeWrapper", "translatedCSNode", ":", "translatedCSNodes", ")", "{", "final", "org", ".", "jboss", ".", "pressgang", ".", "ccms", ".", "contentspec", ".", "Node", "node", "=", "ContentSpecUtilities", ".", "findMatchingContentSpecNode", "(", "contentSpec", ",", "translatedCSNode", ".", "getNodeId", "(", ")", ")", ";", "if", "(", "node", "!=", "null", ")", "{", "node", ".", "setTranslationUniqueId", "(", "translatedCSNode", ".", "getId", "(", ")", ".", "toString", "(", ")", ")", ";", "if", "(", "node", "instanceof", "KeyValueNode", "&&", "(", "(", "KeyValueNode", ")", "node", ")", ".", "getValue", "(", ")", "instanceof", "SpecTopic", ")", "{", "(", "(", "SpecTopic", ")", "(", "(", "KeyValueNode", ")", "node", ")", ".", "getValue", "(", ")", ")", ".", "setTranslationUniqueId", "(", "translatedCSNode", ".", "getId", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "}", "else", "{", "// This shouldn't happen, but take care of it incase it does due to another bug", "throw", "new", "BuildProcessingException", "(", "\"Unable to find a matching Content Spec Node object for Translated Node \"", "+", "translatedCSNode", ".", "getId", "(", ")", ")", ";", "}", "}", "}" ]
Sets the Translation Unique Ids on all the content spec nodes, that have a matching translated node. @param contentSpec The content spec that contains all the nodes to set the translation unique ids for. @param translatedContentSpec The Translated Content Spec object, that holds details on the translated nodes.
[ "Sets", "the", "Translation", "Unique", "Ids", "on", "all", "the", "content", "spec", "nodes", "that", "have", "a", "matching", "translated", "node", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L631-L648
152,019
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.validateTopicLinks
@SuppressWarnings("unchecked") protected void validateTopicLinks(final BuildData buildData, final Set<String> bookIdAttributes) throws BuildProcessingException { final List<SpecTopic> topics = buildData.getBuildDatabase().getAllSpecTopics(); final Set<Integer> processedTopics = new HashSet<Integer>(); for (final SpecTopic specTopic : topics) { final BaseTopicWrapper<?> topic = specTopic.getTopic(); final Document doc = specTopic.getXMLDocument(); /* * We only to to process topics at this point and not spec topics. So check to see if the topic has all ready been * processed. */ if (!processedTopics.contains(topic.getId())) { processedTopics.add(topic.getId()); // Get the XRef links in the topic document final Set<String> linkIds = new HashSet<String>(); DocBookBuildUtilities.getTopicLinkIds(doc, linkIds); final List<String> invalidLinks = new ArrayList<String>(); for (final String linkId : linkIds) { /* * Check if the xref linkend id exists in the book. If the Tag Starts with our error syntax then we can * ignore it */ if (!bookIdAttributes.contains(linkId) && !linkId.startsWith(CommonConstants.ERROR_XREF_ID_PREFIX)) { invalidLinks.add("\"" + linkId + "\""); } } // If there were any invalid links then replace the XML with an error template and add an error message. if (!invalidLinks.isEmpty()) { final String xmlStringInCDATA = DocBookBuildUtilities.convertDocumentToCDATAFormattedString(doc, getXMLFormatProperties()); buildData.getErrorDatabase().addError(topic, ErrorType.INVALID_CONTENT, "The following link(s) " + CollectionUtilities.toSeperatedString(invalidLinks, ", ") + " don't exist. The processed XML is <programlisting>" + xmlStringInCDATA + "</programlisting>"); // Find the Topic ID final Integer topicId = topic.getTopicId(); final List<ITopicNode> buildTopics = buildData.getBuildDatabase().getTopicNodesForTopicID(topicId); for (final ITopicNode topicNode : buildTopics) { DocBookBuildUtilities.setTopicNodeXMLForError(buildData, topicNode, getErrorInvalidValidationTopicTemplate().getValue()); } } } } }
java
@SuppressWarnings("unchecked") protected void validateTopicLinks(final BuildData buildData, final Set<String> bookIdAttributes) throws BuildProcessingException { final List<SpecTopic> topics = buildData.getBuildDatabase().getAllSpecTopics(); final Set<Integer> processedTopics = new HashSet<Integer>(); for (final SpecTopic specTopic : topics) { final BaseTopicWrapper<?> topic = specTopic.getTopic(); final Document doc = specTopic.getXMLDocument(); /* * We only to to process topics at this point and not spec topics. So check to see if the topic has all ready been * processed. */ if (!processedTopics.contains(topic.getId())) { processedTopics.add(topic.getId()); // Get the XRef links in the topic document final Set<String> linkIds = new HashSet<String>(); DocBookBuildUtilities.getTopicLinkIds(doc, linkIds); final List<String> invalidLinks = new ArrayList<String>(); for (final String linkId : linkIds) { /* * Check if the xref linkend id exists in the book. If the Tag Starts with our error syntax then we can * ignore it */ if (!bookIdAttributes.contains(linkId) && !linkId.startsWith(CommonConstants.ERROR_XREF_ID_PREFIX)) { invalidLinks.add("\"" + linkId + "\""); } } // If there were any invalid links then replace the XML with an error template and add an error message. if (!invalidLinks.isEmpty()) { final String xmlStringInCDATA = DocBookBuildUtilities.convertDocumentToCDATAFormattedString(doc, getXMLFormatProperties()); buildData.getErrorDatabase().addError(topic, ErrorType.INVALID_CONTENT, "The following link(s) " + CollectionUtilities.toSeperatedString(invalidLinks, ", ") + " don't exist. The processed XML is <programlisting>" + xmlStringInCDATA + "</programlisting>"); // Find the Topic ID final Integer topicId = topic.getTopicId(); final List<ITopicNode> buildTopics = buildData.getBuildDatabase().getTopicNodesForTopicID(topicId); for (final ITopicNode topicNode : buildTopics) { DocBookBuildUtilities.setTopicNodeXMLForError(buildData, topicNode, getErrorInvalidValidationTopicTemplate().getValue()); } } } } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "void", "validateTopicLinks", "(", "final", "BuildData", "buildData", ",", "final", "Set", "<", "String", ">", "bookIdAttributes", ")", "throws", "BuildProcessingException", "{", "final", "List", "<", "SpecTopic", ">", "topics", "=", "buildData", ".", "getBuildDatabase", "(", ")", ".", "getAllSpecTopics", "(", ")", ";", "final", "Set", "<", "Integer", ">", "processedTopics", "=", "new", "HashSet", "<", "Integer", ">", "(", ")", ";", "for", "(", "final", "SpecTopic", "specTopic", ":", "topics", ")", "{", "final", "BaseTopicWrapper", "<", "?", ">", "topic", "=", "specTopic", ".", "getTopic", "(", ")", ";", "final", "Document", "doc", "=", "specTopic", ".", "getXMLDocument", "(", ")", ";", "/*\n * We only to to process topics at this point and not spec topics. So check to see if the topic has all ready been\n * processed.\n */", "if", "(", "!", "processedTopics", ".", "contains", "(", "topic", ".", "getId", "(", ")", ")", ")", "{", "processedTopics", ".", "add", "(", "topic", ".", "getId", "(", ")", ")", ";", "// Get the XRef links in the topic document", "final", "Set", "<", "String", ">", "linkIds", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "DocBookBuildUtilities", ".", "getTopicLinkIds", "(", "doc", ",", "linkIds", ")", ";", "final", "List", "<", "String", ">", "invalidLinks", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "final", "String", "linkId", ":", "linkIds", ")", "{", "/*\n * Check if the xref linkend id exists in the book. If the Tag Starts with our error syntax then we can\n * ignore it\n */", "if", "(", "!", "bookIdAttributes", ".", "contains", "(", "linkId", ")", "&&", "!", "linkId", ".", "startsWith", "(", "CommonConstants", ".", "ERROR_XREF_ID_PREFIX", ")", ")", "{", "invalidLinks", ".", "add", "(", "\"\\\"\"", "+", "linkId", "+", "\"\\\"\"", ")", ";", "}", "}", "// If there were any invalid links then replace the XML with an error template and add an error message.", "if", "(", "!", "invalidLinks", ".", "isEmpty", "(", ")", ")", "{", "final", "String", "xmlStringInCDATA", "=", "DocBookBuildUtilities", ".", "convertDocumentToCDATAFormattedString", "(", "doc", ",", "getXMLFormatProperties", "(", ")", ")", ";", "buildData", ".", "getErrorDatabase", "(", ")", ".", "addError", "(", "topic", ",", "ErrorType", ".", "INVALID_CONTENT", ",", "\"The following link(s) \"", "+", "CollectionUtilities", ".", "toSeperatedString", "(", "invalidLinks", ",", "\", \"", ")", "+", "\" don't exist. The processed XML is <programlisting>\"", "+", "xmlStringInCDATA", "+", "\"</programlisting>\"", ")", ";", "// Find the Topic ID", "final", "Integer", "topicId", "=", "topic", ".", "getTopicId", "(", ")", ";", "final", "List", "<", "ITopicNode", ">", "buildTopics", "=", "buildData", ".", "getBuildDatabase", "(", ")", ".", "getTopicNodesForTopicID", "(", "topicId", ")", ";", "for", "(", "final", "ITopicNode", "topicNode", ":", "buildTopics", ")", "{", "DocBookBuildUtilities", ".", "setTopicNodeXMLForError", "(", "buildData", ",", "topicNode", ",", "getErrorInvalidValidationTopicTemplate", "(", ")", ".", "getValue", "(", ")", ")", ";", "}", "}", "}", "}", "}" ]
Validate all the book links in the each topic to ensure that they exist somewhere in the book. If they don't then the topic XML is replaced with a generic error template. @param buildData Information and data structures for the build. @param bookIdAttributes A set of all the id's that exist in the book. @throws BuildProcessingException Thrown if an unexpected error occurs during building.
[ "Validate", "all", "the", "book", "links", "in", "the", "each", "topic", "to", "ensure", "that", "they", "exist", "somewhere", "in", "the", "book", ".", "If", "they", "don", "t", "then", "the", "topic", "XML", "is", "replaced", "with", "a", "generic", "error", "template", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L658-L708
152,020
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.doPopulateDatabasePass
@SuppressWarnings("unchecked") private void doPopulateDatabasePass(final BuildData buildData) throws BuildProcessingException { log.info("Doing " + buildData.getBuildLocale() + " Populate Database Pass"); final ContentSpec contentSpec = buildData.getContentSpec(); final Map<String, BaseTopicWrapper<?>> topics = new HashMap<String, BaseTopicWrapper<?>>(); if (buildData.isTranslationBuild()) { //Translations should reference an existing historical topic with the fixed urls set, so we assume this to be the case populateTranslatedTopicDatabase(buildData, topics); } else { populateDatabaseTopics(buildData, topics); } // Check if the app should be shutdown if (isShuttingDown.get()) { return; } // Add all the levels to the database DocBookBuildUtilities.addLevelsToDatabase(buildData.getBuildDatabase(), contentSpec.getBaseLevel()); // Check if the app should be shutdown if (isShuttingDown.get()) { return; } // Process the topics to make sure they are valid doTopicPass(buildData, topics); }
java
@SuppressWarnings("unchecked") private void doPopulateDatabasePass(final BuildData buildData) throws BuildProcessingException { log.info("Doing " + buildData.getBuildLocale() + " Populate Database Pass"); final ContentSpec contentSpec = buildData.getContentSpec(); final Map<String, BaseTopicWrapper<?>> topics = new HashMap<String, BaseTopicWrapper<?>>(); if (buildData.isTranslationBuild()) { //Translations should reference an existing historical topic with the fixed urls set, so we assume this to be the case populateTranslatedTopicDatabase(buildData, topics); } else { populateDatabaseTopics(buildData, topics); } // Check if the app should be shutdown if (isShuttingDown.get()) { return; } // Add all the levels to the database DocBookBuildUtilities.addLevelsToDatabase(buildData.getBuildDatabase(), contentSpec.getBaseLevel()); // Check if the app should be shutdown if (isShuttingDown.get()) { return; } // Process the topics to make sure they are valid doTopicPass(buildData, topics); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "doPopulateDatabasePass", "(", "final", "BuildData", "buildData", ")", "throws", "BuildProcessingException", "{", "log", ".", "info", "(", "\"Doing \"", "+", "buildData", ".", "getBuildLocale", "(", ")", "+", "\" Populate Database Pass\"", ")", ";", "final", "ContentSpec", "contentSpec", "=", "buildData", ".", "getContentSpec", "(", ")", ";", "final", "Map", "<", "String", ",", "BaseTopicWrapper", "<", "?", ">", ">", "topics", "=", "new", "HashMap", "<", "String", ",", "BaseTopicWrapper", "<", "?", ">", ">", "(", ")", ";", "if", "(", "buildData", ".", "isTranslationBuild", "(", ")", ")", "{", "//Translations should reference an existing historical topic with the fixed urls set, so we assume this to be the case", "populateTranslatedTopicDatabase", "(", "buildData", ",", "topics", ")", ";", "}", "else", "{", "populateDatabaseTopics", "(", "buildData", ",", "topics", ")", ";", "}", "// Check if the app should be shutdown", "if", "(", "isShuttingDown", ".", "get", "(", ")", ")", "{", "return", ";", "}", "// Add all the levels to the database", "DocBookBuildUtilities", ".", "addLevelsToDatabase", "(", "buildData", ".", "getBuildDatabase", "(", ")", ",", "contentSpec", ".", "getBaseLevel", "(", ")", ")", ";", "// Check if the app should be shutdown", "if", "(", "isShuttingDown", ".", "get", "(", ")", ")", "{", "return", ";", "}", "// Process the topics to make sure they are valid", "doTopicPass", "(", "buildData", ",", "topics", ")", ";", "}" ]
Populates the SpecTopicDatabase with the SpecTopics inside the content specification. It also adds the equivalent real topics to each SpecTopic. @param buildData Information and data structures for the build. @return True if the database was populated successfully otherwise false. @throws BuildProcessingException Thrown if an unexpected error occurs during building.
[ "Populates", "the", "SpecTopicDatabase", "with", "the", "SpecTopics", "inside", "the", "content", "specification", ".", "It", "also", "adds", "the", "equivalent", "real", "topics", "to", "each", "SpecTopic", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L718-L746
152,021
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.populateTranslatedTopicDatabase
private void populateTranslatedTopicDatabase(final BuildData buildData, final Map<String, BaseTopicWrapper<?>> translatedTopics) throws BuildProcessingException { final List<ITopicNode> topicNodes = buildData.getContentSpec().getAllTopicNodes(); final int showPercent = 10; final float total = topicNodes.size(); float current = 0; int lastPercent = 0; // Loop over each Topic Node in the content spec and get it's translated topic for (final ITopicNode topicNode : topicNodes) { getTranslatedTopicForTopicNode(buildData, topicNode, translatedTopics); ++current; final int percent = Math.round(current / total * 100); if (percent - lastPercent >= showPercent) { lastPercent = percent; log.info("\tPopulate " + buildData.getBuildLocale() + " Database Pass " + percent + "% Done"); } } }
java
private void populateTranslatedTopicDatabase(final BuildData buildData, final Map<String, BaseTopicWrapper<?>> translatedTopics) throws BuildProcessingException { final List<ITopicNode> topicNodes = buildData.getContentSpec().getAllTopicNodes(); final int showPercent = 10; final float total = topicNodes.size(); float current = 0; int lastPercent = 0; // Loop over each Topic Node in the content spec and get it's translated topic for (final ITopicNode topicNode : topicNodes) { getTranslatedTopicForTopicNode(buildData, topicNode, translatedTopics); ++current; final int percent = Math.round(current / total * 100); if (percent - lastPercent >= showPercent) { lastPercent = percent; log.info("\tPopulate " + buildData.getBuildLocale() + " Database Pass " + percent + "% Done"); } } }
[ "private", "void", "populateTranslatedTopicDatabase", "(", "final", "BuildData", "buildData", ",", "final", "Map", "<", "String", ",", "BaseTopicWrapper", "<", "?", ">", ">", "translatedTopics", ")", "throws", "BuildProcessingException", "{", "final", "List", "<", "ITopicNode", ">", "topicNodes", "=", "buildData", ".", "getContentSpec", "(", ")", ".", "getAllTopicNodes", "(", ")", ";", "final", "int", "showPercent", "=", "10", ";", "final", "float", "total", "=", "topicNodes", ".", "size", "(", ")", ";", "float", "current", "=", "0", ";", "int", "lastPercent", "=", "0", ";", "// Loop over each Topic Node in the content spec and get it's translated topic", "for", "(", "final", "ITopicNode", "topicNode", ":", "topicNodes", ")", "{", "getTranslatedTopicForTopicNode", "(", "buildData", ",", "topicNode", ",", "translatedTopics", ")", ";", "++", "current", ";", "final", "int", "percent", "=", "Math", ".", "round", "(", "current", "/", "total", "*", "100", ")", ";", "if", "(", "percent", "-", "lastPercent", ">=", "showPercent", ")", "{", "lastPercent", "=", "percent", ";", "log", ".", "info", "(", "\"\\tPopulate \"", "+", "buildData", ".", "getBuildLocale", "(", ")", "+", "\" Database Pass \"", "+", "percent", "+", "\"% Done\"", ")", ";", "}", "}", "}" ]
Gets the translated topics from the REST Interface and also creates any dummy translations for topics that have yet to be translated. @param buildData Information and data structures for the build. @param translatedTopics The translated topic collection to add translated topics to.
[ "Gets", "the", "translated", "topics", "from", "the", "REST", "Interface", "and", "also", "creates", "any", "dummy", "translations", "for", "topics", "that", "have", "yet", "to", "be", "translated", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L794-L814
152,022
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.createDummyTranslatedTopicFromExisting
private TranslatedTopicWrapper createDummyTranslatedTopicFromExisting(final TranslatedTopicWrapper translatedTopic, final LocaleWrapper locale) { // Make sure some collections are loaded, so the clone works properly translatedTopic.getTags(); translatedTopic.getProperties(); // Clone the existing version final TranslatedTopicWrapper defaultLocaleTranslatedTopic = translatedTopic.clone(false); // Negate the ID to show it isn't a proper translated topic defaultLocaleTranslatedTopic.setId(translatedTopic.getTopicId() * -1); // Change the locale since the default locale translation is being transformed into a dummy translation defaultLocaleTranslatedTopic.setLocale(locale); return defaultLocaleTranslatedTopic; }
java
private TranslatedTopicWrapper createDummyTranslatedTopicFromExisting(final TranslatedTopicWrapper translatedTopic, final LocaleWrapper locale) { // Make sure some collections are loaded, so the clone works properly translatedTopic.getTags(); translatedTopic.getProperties(); // Clone the existing version final TranslatedTopicWrapper defaultLocaleTranslatedTopic = translatedTopic.clone(false); // Negate the ID to show it isn't a proper translated topic defaultLocaleTranslatedTopic.setId(translatedTopic.getTopicId() * -1); // Change the locale since the default locale translation is being transformed into a dummy translation defaultLocaleTranslatedTopic.setLocale(locale); return defaultLocaleTranslatedTopic; }
[ "private", "TranslatedTopicWrapper", "createDummyTranslatedTopicFromExisting", "(", "final", "TranslatedTopicWrapper", "translatedTopic", ",", "final", "LocaleWrapper", "locale", ")", "{", "// Make sure some collections are loaded, so the clone works properly", "translatedTopic", ".", "getTags", "(", ")", ";", "translatedTopic", ".", "getProperties", "(", ")", ";", "// Clone the existing version", "final", "TranslatedTopicWrapper", "defaultLocaleTranslatedTopic", "=", "translatedTopic", ".", "clone", "(", "false", ")", ";", "// Negate the ID to show it isn't a proper translated topic", "defaultLocaleTranslatedTopic", ".", "setId", "(", "translatedTopic", ".", "getTopicId", "(", ")", "*", "-", "1", ")", ";", "// Change the locale since the default locale translation is being transformed into a dummy translation", "defaultLocaleTranslatedTopic", ".", "setLocale", "(", "locale", ")", ";", "return", "defaultLocaleTranslatedTopic", ";", "}" ]
Creates a dummy translated topic from an existing translated topic so that a book can be built using the same relationships as a normal build. @param translatedTopic The translated topic to create the dummy translated topic from. @param locale The locale to build the dummy translations for. @return The dummy translated topic.
[ "Creates", "a", "dummy", "translated", "topic", "from", "an", "existing", "translated", "topic", "so", "that", "a", "book", "can", "be", "built", "using", "the", "same", "relationships", "as", "a", "normal", "build", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L1029-L1045
152,023
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.mergeAdditionalTranslatedXML
private Document mergeAdditionalTranslatedXML(BuildData buildData, final Document topicDoc, final TranslatedTopicWrapper translatedTopic, final TopicType topicType) throws BuildProcessingException { Document retValue = topicDoc; if (!isNullOrEmpty(translatedTopic.getTranslatedAdditionalXML())) { Document additionalXMLDoc = null; try { additionalXMLDoc = XMLUtilities.convertStringToDocument(translatedTopic.getTranslatedAdditionalXML()); } catch (Exception ex) { buildData.getErrorDatabase().addError(translatedTopic, ErrorType.INVALID_CONTENT, BuilderConstants.ERROR_INVALID_TOPIC_XML + " " + StringUtilities.escapeForXML(ex.getMessage())); retValue = DocBookBuildUtilities.setTopicXMLForError(buildData, translatedTopic, getErrorInvalidValidationTopicTemplate().getValue()); } if (additionalXMLDoc != null) { // Merge the two together try { if (TopicType.AUTHOR_GROUP.equals(topicType)) { DocBookBuildUtilities.mergeAuthorGroups(topicDoc, additionalXMLDoc); } else if (TopicType.REVISION_HISTORY.equals(topicType)) { DocBookBuildUtilities.mergeRevisionHistories(topicDoc, additionalXMLDoc); } } catch (BuildProcessingException ex) { final String xmlStringInCDATA = XMLUtilities.wrapStringInCDATA(translatedTopic.getTranslatedAdditionalXML()); buildData.getErrorDatabase().addError(translatedTopic, ErrorType.INVALID_CONTENT, BuilderConstants.ERROR_BAD_XML_STRUCTURE + " " + StringUtilities.escapeForXML( ex.getMessage()) + " The processed XML is <programlisting>" + xmlStringInCDATA + "</programlisting>"); retValue = DocBookBuildUtilities.setTopicXMLForError(buildData, translatedTopic, getErrorInvalidValidationTopicTemplate().getValue()); } } else { final String xmlStringInCDATA = XMLUtilities.wrapStringInCDATA(translatedTopic.getTranslatedAdditionalXML()); buildData.getErrorDatabase().addError(translatedTopic, ErrorType.INVALID_CONTENT, BuilderConstants.ERROR_INVALID_XML_CONTENT + " The processed XML is <programlisting>" + xmlStringInCDATA + "</programlisting>"); retValue = DocBookBuildUtilities.setTopicXMLForError(buildData, translatedTopic, getErrorInvalidValidationTopicTemplate().getValue()); } } return retValue; }
java
private Document mergeAdditionalTranslatedXML(BuildData buildData, final Document topicDoc, final TranslatedTopicWrapper translatedTopic, final TopicType topicType) throws BuildProcessingException { Document retValue = topicDoc; if (!isNullOrEmpty(translatedTopic.getTranslatedAdditionalXML())) { Document additionalXMLDoc = null; try { additionalXMLDoc = XMLUtilities.convertStringToDocument(translatedTopic.getTranslatedAdditionalXML()); } catch (Exception ex) { buildData.getErrorDatabase().addError(translatedTopic, ErrorType.INVALID_CONTENT, BuilderConstants.ERROR_INVALID_TOPIC_XML + " " + StringUtilities.escapeForXML(ex.getMessage())); retValue = DocBookBuildUtilities.setTopicXMLForError(buildData, translatedTopic, getErrorInvalidValidationTopicTemplate().getValue()); } if (additionalXMLDoc != null) { // Merge the two together try { if (TopicType.AUTHOR_GROUP.equals(topicType)) { DocBookBuildUtilities.mergeAuthorGroups(topicDoc, additionalXMLDoc); } else if (TopicType.REVISION_HISTORY.equals(topicType)) { DocBookBuildUtilities.mergeRevisionHistories(topicDoc, additionalXMLDoc); } } catch (BuildProcessingException ex) { final String xmlStringInCDATA = XMLUtilities.wrapStringInCDATA(translatedTopic.getTranslatedAdditionalXML()); buildData.getErrorDatabase().addError(translatedTopic, ErrorType.INVALID_CONTENT, BuilderConstants.ERROR_BAD_XML_STRUCTURE + " " + StringUtilities.escapeForXML( ex.getMessage()) + " The processed XML is <programlisting>" + xmlStringInCDATA + "</programlisting>"); retValue = DocBookBuildUtilities.setTopicXMLForError(buildData, translatedTopic, getErrorInvalidValidationTopicTemplate().getValue()); } } else { final String xmlStringInCDATA = XMLUtilities.wrapStringInCDATA(translatedTopic.getTranslatedAdditionalXML()); buildData.getErrorDatabase().addError(translatedTopic, ErrorType.INVALID_CONTENT, BuilderConstants.ERROR_INVALID_XML_CONTENT + " The processed XML is <programlisting>" + xmlStringInCDATA + "</programlisting>"); retValue = DocBookBuildUtilities.setTopicXMLForError(buildData, translatedTopic, getErrorInvalidValidationTopicTemplate().getValue()); } } return retValue; }
[ "private", "Document", "mergeAdditionalTranslatedXML", "(", "BuildData", "buildData", ",", "final", "Document", "topicDoc", ",", "final", "TranslatedTopicWrapper", "translatedTopic", ",", "final", "TopicType", "topicType", ")", "throws", "BuildProcessingException", "{", "Document", "retValue", "=", "topicDoc", ";", "if", "(", "!", "isNullOrEmpty", "(", "translatedTopic", ".", "getTranslatedAdditionalXML", "(", ")", ")", ")", "{", "Document", "additionalXMLDoc", "=", "null", ";", "try", "{", "additionalXMLDoc", "=", "XMLUtilities", ".", "convertStringToDocument", "(", "translatedTopic", ".", "getTranslatedAdditionalXML", "(", ")", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "buildData", ".", "getErrorDatabase", "(", ")", ".", "addError", "(", "translatedTopic", ",", "ErrorType", ".", "INVALID_CONTENT", ",", "BuilderConstants", ".", "ERROR_INVALID_TOPIC_XML", "+", "\" \"", "+", "StringUtilities", ".", "escapeForXML", "(", "ex", ".", "getMessage", "(", ")", ")", ")", ";", "retValue", "=", "DocBookBuildUtilities", ".", "setTopicXMLForError", "(", "buildData", ",", "translatedTopic", ",", "getErrorInvalidValidationTopicTemplate", "(", ")", ".", "getValue", "(", ")", ")", ";", "}", "if", "(", "additionalXMLDoc", "!=", "null", ")", "{", "// Merge the two together", "try", "{", "if", "(", "TopicType", ".", "AUTHOR_GROUP", ".", "equals", "(", "topicType", ")", ")", "{", "DocBookBuildUtilities", ".", "mergeAuthorGroups", "(", "topicDoc", ",", "additionalXMLDoc", ")", ";", "}", "else", "if", "(", "TopicType", ".", "REVISION_HISTORY", ".", "equals", "(", "topicType", ")", ")", "{", "DocBookBuildUtilities", ".", "mergeRevisionHistories", "(", "topicDoc", ",", "additionalXMLDoc", ")", ";", "}", "}", "catch", "(", "BuildProcessingException", "ex", ")", "{", "final", "String", "xmlStringInCDATA", "=", "XMLUtilities", ".", "wrapStringInCDATA", "(", "translatedTopic", ".", "getTranslatedAdditionalXML", "(", ")", ")", ";", "buildData", ".", "getErrorDatabase", "(", ")", ".", "addError", "(", "translatedTopic", ",", "ErrorType", ".", "INVALID_CONTENT", ",", "BuilderConstants", ".", "ERROR_BAD_XML_STRUCTURE", "+", "\" \"", "+", "StringUtilities", ".", "escapeForXML", "(", "ex", ".", "getMessage", "(", ")", ")", "+", "\" The processed XML is <programlisting>\"", "+", "xmlStringInCDATA", "+", "\"</programlisting>\"", ")", ";", "retValue", "=", "DocBookBuildUtilities", ".", "setTopicXMLForError", "(", "buildData", ",", "translatedTopic", ",", "getErrorInvalidValidationTopicTemplate", "(", ")", ".", "getValue", "(", ")", ")", ";", "}", "}", "else", "{", "final", "String", "xmlStringInCDATA", "=", "XMLUtilities", ".", "wrapStringInCDATA", "(", "translatedTopic", ".", "getTranslatedAdditionalXML", "(", ")", ")", ";", "buildData", ".", "getErrorDatabase", "(", ")", ".", "addError", "(", "translatedTopic", ",", "ErrorType", ".", "INVALID_CONTENT", ",", "BuilderConstants", ".", "ERROR_INVALID_XML_CONTENT", "+", "\" The processed XML is <programlisting>\"", "+", "xmlStringInCDATA", "+", "\"</programlisting>\"", ")", ";", "retValue", "=", "DocBookBuildUtilities", ".", "setTopicXMLForError", "(", "buildData", ",", "translatedTopic", ",", "getErrorInvalidValidationTopicTemplate", "(", ")", ".", "getValue", "(", ")", ")", ";", "}", "}", "return", "retValue", ";", "}" ]
Merges the Additional Translated XML of a Translated Topic into the original Topic XML content. @param buildData @param topicDoc The transformed original XML content. @param translatedTopic The Translated Topic that is being merged. @param topicType The type of topic being merged. @return The merged DOM document. @throws BuildProcessingException
[ "Merges", "the", "Additional", "Translated", "XML", "of", "a", "Translated", "Topic", "into", "the", "original", "Topic", "XML", "content", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L1217-L1259
152,024
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.processConditions
protected void processConditions(final BuildData buildData, final SpecTopic specTopic, final Document doc) { final String condition = specTopic.getConditionStatement(true); DocBookUtilities.processConditions(condition, doc, BuilderConstants.DEFAULT_CONDITION); }
java
protected void processConditions(final BuildData buildData, final SpecTopic specTopic, final Document doc) { final String condition = specTopic.getConditionStatement(true); DocBookUtilities.processConditions(condition, doc, BuilderConstants.DEFAULT_CONDITION); }
[ "protected", "void", "processConditions", "(", "final", "BuildData", "buildData", ",", "final", "SpecTopic", "specTopic", ",", "final", "Document", "doc", ")", "{", "final", "String", "condition", "=", "specTopic", ".", "getConditionStatement", "(", "true", ")", ";", "DocBookUtilities", ".", "processConditions", "(", "condition", ",", "doc", ",", "BuilderConstants", ".", "DEFAULT_CONDITION", ")", ";", "}" ]
Checks if the conditional pass should be performed. @param buildData Information and data structures for the build. @param specTopic The spec topic the conditions should be processed for, @param doc The DOM Document to process the conditions against.
[ "Checks", "if", "the", "conditional", "pass", "should", "be", "performed", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L1368-L1371
152,025
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.doLinkSecondPass
protected void doLinkSecondPass(final BuildData buildData, final Map<SpecTopic, Set<String>> usedIdAttributes) throws BuildProcessingException { final List<SpecTopic> topics = buildData.getBuildDatabase().getAllSpecTopics(); for (final SpecTopic specTopic : topics) { final Document doc = specTopic.getXMLDocument(); // Get the XRef links in the topic document final Set<String> linkIds = new HashSet<String>(); DocBookBuildUtilities.getTopicLinkIds(doc, linkIds); final Map<String, SpecTopic> invalidLinks = new HashMap<String, SpecTopic>(); for (final String linkId : linkIds) { // Ignore error links if (linkId.startsWith(CommonConstants.ERROR_XREF_ID_PREFIX)) continue; // Find the linked topic SpecTopic linkedTopic = null; for (final Map.Entry<SpecTopic, Set<String>> usedIdEntry : usedIdAttributes.entrySet()) { if (usedIdEntry.getValue().contains(linkId)) { linkedTopic = usedIdEntry.getKey(); break; } } // If the linked topic has been set as an error, than update the links to point to the topic id if (linkedTopic != null && buildData.getErrorDatabase().hasErrorData(linkedTopic.getTopic())) { final TopicErrorData errorData = buildData.getErrorDatabase().getErrorData(linkedTopic.getTopic()); if (errorData.hasFatalErrors()) { invalidLinks.put(linkId, linkedTopic); } } } // Go through and fix any invalid links if (!invalidLinks.isEmpty()) { final List<Node> linkNodes = XMLUtilities.getChildNodes(doc, "xref", "link"); for (final Node linkNode : linkNodes) { final String linkId = ((Element) linkNode).getAttribute("linkend"); if (invalidLinks.containsKey(linkId)) { final SpecTopic linkedTopic = invalidLinks.get(linkId); ((Element) linkNode).setAttribute("linkend", linkedTopic.getUniqueLinkId(buildData.isUseFixedUrls())); } } } } }
java
protected void doLinkSecondPass(final BuildData buildData, final Map<SpecTopic, Set<String>> usedIdAttributes) throws BuildProcessingException { final List<SpecTopic> topics = buildData.getBuildDatabase().getAllSpecTopics(); for (final SpecTopic specTopic : topics) { final Document doc = specTopic.getXMLDocument(); // Get the XRef links in the topic document final Set<String> linkIds = new HashSet<String>(); DocBookBuildUtilities.getTopicLinkIds(doc, linkIds); final Map<String, SpecTopic> invalidLinks = new HashMap<String, SpecTopic>(); for (final String linkId : linkIds) { // Ignore error links if (linkId.startsWith(CommonConstants.ERROR_XREF_ID_PREFIX)) continue; // Find the linked topic SpecTopic linkedTopic = null; for (final Map.Entry<SpecTopic, Set<String>> usedIdEntry : usedIdAttributes.entrySet()) { if (usedIdEntry.getValue().contains(linkId)) { linkedTopic = usedIdEntry.getKey(); break; } } // If the linked topic has been set as an error, than update the links to point to the topic id if (linkedTopic != null && buildData.getErrorDatabase().hasErrorData(linkedTopic.getTopic())) { final TopicErrorData errorData = buildData.getErrorDatabase().getErrorData(linkedTopic.getTopic()); if (errorData.hasFatalErrors()) { invalidLinks.put(linkId, linkedTopic); } } } // Go through and fix any invalid links if (!invalidLinks.isEmpty()) { final List<Node> linkNodes = XMLUtilities.getChildNodes(doc, "xref", "link"); for (final Node linkNode : linkNodes) { final String linkId = ((Element) linkNode).getAttribute("linkend"); if (invalidLinks.containsKey(linkId)) { final SpecTopic linkedTopic = invalidLinks.get(linkId); ((Element) linkNode).setAttribute("linkend", linkedTopic.getUniqueLinkId(buildData.isUseFixedUrls())); } } } } }
[ "protected", "void", "doLinkSecondPass", "(", "final", "BuildData", "buildData", ",", "final", "Map", "<", "SpecTopic", ",", "Set", "<", "String", ">", ">", "usedIdAttributes", ")", "throws", "BuildProcessingException", "{", "final", "List", "<", "SpecTopic", ">", "topics", "=", "buildData", ".", "getBuildDatabase", "(", ")", ".", "getAllSpecTopics", "(", ")", ";", "for", "(", "final", "SpecTopic", "specTopic", ":", "topics", ")", "{", "final", "Document", "doc", "=", "specTopic", ".", "getXMLDocument", "(", ")", ";", "// Get the XRef links in the topic document", "final", "Set", "<", "String", ">", "linkIds", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "DocBookBuildUtilities", ".", "getTopicLinkIds", "(", "doc", ",", "linkIds", ")", ";", "final", "Map", "<", "String", ",", "SpecTopic", ">", "invalidLinks", "=", "new", "HashMap", "<", "String", ",", "SpecTopic", ">", "(", ")", ";", "for", "(", "final", "String", "linkId", ":", "linkIds", ")", "{", "// Ignore error links", "if", "(", "linkId", ".", "startsWith", "(", "CommonConstants", ".", "ERROR_XREF_ID_PREFIX", ")", ")", "continue", ";", "// Find the linked topic", "SpecTopic", "linkedTopic", "=", "null", ";", "for", "(", "final", "Map", ".", "Entry", "<", "SpecTopic", ",", "Set", "<", "String", ">", ">", "usedIdEntry", ":", "usedIdAttributes", ".", "entrySet", "(", ")", ")", "{", "if", "(", "usedIdEntry", ".", "getValue", "(", ")", ".", "contains", "(", "linkId", ")", ")", "{", "linkedTopic", "=", "usedIdEntry", ".", "getKey", "(", ")", ";", "break", ";", "}", "}", "// If the linked topic has been set as an error, than update the links to point to the topic id", "if", "(", "linkedTopic", "!=", "null", "&&", "buildData", ".", "getErrorDatabase", "(", ")", ".", "hasErrorData", "(", "linkedTopic", ".", "getTopic", "(", ")", ")", ")", "{", "final", "TopicErrorData", "errorData", "=", "buildData", ".", "getErrorDatabase", "(", ")", ".", "getErrorData", "(", "linkedTopic", ".", "getTopic", "(", ")", ")", ";", "if", "(", "errorData", ".", "hasFatalErrors", "(", ")", ")", "{", "invalidLinks", ".", "put", "(", "linkId", ",", "linkedTopic", ")", ";", "}", "}", "}", "// Go through and fix any invalid links", "if", "(", "!", "invalidLinks", ".", "isEmpty", "(", ")", ")", "{", "final", "List", "<", "Node", ">", "linkNodes", "=", "XMLUtilities", ".", "getChildNodes", "(", "doc", ",", "\"xref\"", ",", "\"link\"", ")", ";", "for", "(", "final", "Node", "linkNode", ":", "linkNodes", ")", "{", "final", "String", "linkId", "=", "(", "(", "Element", ")", "linkNode", ")", ".", "getAttribute", "(", "\"linkend\"", ")", ";", "if", "(", "invalidLinks", ".", "containsKey", "(", "linkId", ")", ")", "{", "final", "SpecTopic", "linkedTopic", "=", "invalidLinks", ".", "get", "(", "linkId", ")", ";", "(", "(", "Element", ")", "linkNode", ")", ".", "setAttribute", "(", "\"linkend\"", ",", "linkedTopic", ".", "getUniqueLinkId", "(", "buildData", ".", "isUseFixedUrls", "(", ")", ")", ")", ";", "}", "}", "}", "}", "}" ]
Fixes any topics links that have been broken due to the linked topics XML being invalid. @param buildData Information and data structures for the build. @param usedIdAttributes The set of ids that have been used in the set of topics in the content spec. @throws BuildProcessingException
[ "Fixes", "any", "topics", "links", "that", "have", "been", "broken", "due", "to", "the", "linked", "topics", "XML", "being", "invalid", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L1492-L1539
152,026
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.processSpecTopicInjectionErrors
protected boolean processSpecTopicInjectionErrors(final BuildData buildData, final BaseTopicWrapper<?> topic, final List<String> customInjectionErrors) { boolean valid = true; if (!customInjectionErrors.isEmpty()) { final String message = "Topic has referenced Topic/Level(s) " + CollectionUtilities.toSeperatedString( customInjectionErrors) + " in a custom injection point that was not included this book."; if (buildData.getBuildOptions().getIgnoreMissingCustomInjections()) { buildData.getErrorDatabase().addWarning(topic, ErrorType.INVALID_INJECTION, message); } else { buildData.getErrorDatabase().addError(topic, ErrorType.INVALID_INJECTION, message); valid = false; } } return valid; }
java
protected boolean processSpecTopicInjectionErrors(final BuildData buildData, final BaseTopicWrapper<?> topic, final List<String> customInjectionErrors) { boolean valid = true; if (!customInjectionErrors.isEmpty()) { final String message = "Topic has referenced Topic/Level(s) " + CollectionUtilities.toSeperatedString( customInjectionErrors) + " in a custom injection point that was not included this book."; if (buildData.getBuildOptions().getIgnoreMissingCustomInjections()) { buildData.getErrorDatabase().addWarning(topic, ErrorType.INVALID_INJECTION, message); } else { buildData.getErrorDatabase().addError(topic, ErrorType.INVALID_INJECTION, message); valid = false; } } return valid; }
[ "protected", "boolean", "processSpecTopicInjectionErrors", "(", "final", "BuildData", "buildData", ",", "final", "BaseTopicWrapper", "<", "?", ">", "topic", ",", "final", "List", "<", "String", ">", "customInjectionErrors", ")", "{", "boolean", "valid", "=", "true", ";", "if", "(", "!", "customInjectionErrors", ".", "isEmpty", "(", ")", ")", "{", "final", "String", "message", "=", "\"Topic has referenced Topic/Level(s) \"", "+", "CollectionUtilities", ".", "toSeperatedString", "(", "customInjectionErrors", ")", "+", "\" in a custom injection point that was not included this book.\"", ";", "if", "(", "buildData", ".", "getBuildOptions", "(", ")", ".", "getIgnoreMissingCustomInjections", "(", ")", ")", "{", "buildData", ".", "getErrorDatabase", "(", ")", ".", "addWarning", "(", "topic", ",", "ErrorType", ".", "INVALID_INJECTION", ",", "message", ")", ";", "}", "else", "{", "buildData", ".", "getErrorDatabase", "(", ")", ".", "addError", "(", "topic", ",", "ErrorType", ".", "INVALID_INJECTION", ",", "message", ")", ";", "valid", "=", "false", ";", "}", "}", "return", "valid", ";", "}" ]
Process the Injection Errors and add them to the Error Database. @param buildData Information and data structures for the build. @param topic The topic that the errors occurred for. @param customInjectionErrors The List of Custom Injection Errors. @return True if no errors were processed or if the build is set to ignore missing injections, otherwise false.
[ "Process", "the", "Injection", "Errors", "and", "add", "them", "to", "the", "Error", "Database", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L1619-L1635
152,027
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.addBookBaseFilesAndImages
protected void addBookBaseFilesAndImages(final BuildData buildData) throws BuildProcessingException { final String pressgangWebsiteJS = buildPressGangWebsiteJS(buildData); addToZip(buildData.getBookImagesFolder() + "icon.svg", ResourceUtilities.resourceFileToByteArray("/", "icon.svg"), buildData); addToZip(buildData.getBookFilesFolder() + "pressgang_website.js", pressgangWebsiteJS, buildData); }
java
protected void addBookBaseFilesAndImages(final BuildData buildData) throws BuildProcessingException { final String pressgangWebsiteJS = buildPressGangWebsiteJS(buildData); addToZip(buildData.getBookImagesFolder() + "icon.svg", ResourceUtilities.resourceFileToByteArray("/", "icon.svg"), buildData); addToZip(buildData.getBookFilesFolder() + "pressgang_website.js", pressgangWebsiteJS, buildData); }
[ "protected", "void", "addBookBaseFilesAndImages", "(", "final", "BuildData", "buildData", ")", "throws", "BuildProcessingException", "{", "final", "String", "pressgangWebsiteJS", "=", "buildPressGangWebsiteJS", "(", "buildData", ")", ";", "addToZip", "(", "buildData", ".", "getBookImagesFolder", "(", ")", "+", "\"icon.svg\"", ",", "ResourceUtilities", ".", "resourceFileToByteArray", "(", "\"/\"", ",", "\"icon.svg\"", ")", ",", "buildData", ")", ";", "addToZip", "(", "buildData", ".", "getBookFilesFolder", "(", ")", "+", "\"pressgang_website.js\"", ",", "pressgangWebsiteJS", ",", "buildData", ")", ";", "}" ]
Adds the basic Images and Files to the book that are the minimum requirements to build it. @param buildData Information and data structures for the build.
[ "Adds", "the", "basic", "Images", "and", "Files", "to", "the", "book", "that", "are", "the", "minimum", "requirements", "to", "build", "it", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L1916-L1921
152,028
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.buildBookPreface
protected void buildBookPreface(final BuildData buildData) throws BuildProcessingException { final ContentSpec contentSpec = buildData.getContentSpec(); // Check that should actually use the preface if (contentSpec.getUseDefaultPreface()) { final Map<String, String> overrides = buildData.getBuildOptions().getOverrides(); final Map<String, byte[]> overrideFiles = buildData.getOverrideFiles(); final Document prefaceDoc; try { prefaceDoc = XMLUtilities.convertStringToDocument("<preface></preface>"); } catch (Exception e) { throw new BuildProcessingException(e); } // Add the title final String prefaceTitleTranslation = buildData.getConstants().getString("PREFACE"); final Element titleEle = prefaceDoc.createElement("title"); titleEle.setTextContent(prefaceTitleTranslation); prefaceDoc.getDocumentElement().appendChild(titleEle); // Add the Conventions.xml final Element conventions = XMLUtilities.createXIInclude(prefaceDoc, "Common_Content/Conventions.xml"); prefaceDoc.getDocumentElement().appendChild(conventions); // Add the Feedback.xml if (overrides.containsKey(CSConstants.FEEDBACK_OVERRIDE) && overrideFiles.containsKey( CSConstants.FEEDBACK_OVERRIDE) || contentSpec.getFeedback() != null) { final Element xinclude = XMLUtilities.createXIInclude(prefaceDoc, "Feedback.xml"); prefaceDoc.getDocumentElement().appendChild(xinclude); } else { final Element xinclude = XMLUtilities.createXIInclude(prefaceDoc, "Common_Content/Feedback.xml"); prefaceDoc.getDocumentElement().appendChild(xinclude); } final String prefaceXml = DocBookBuildUtilities.convertDocumentToDocBookFormattedString(buildData.getDocBookVersion(), prefaceDoc, "preface", buildData.getEntityFileName(), getXMLFormatProperties()); addToZip(buildData.getBookLocaleFolder() + PREFACE_FILE_NAME, prefaceXml, buildData); } }
java
protected void buildBookPreface(final BuildData buildData) throws BuildProcessingException { final ContentSpec contentSpec = buildData.getContentSpec(); // Check that should actually use the preface if (contentSpec.getUseDefaultPreface()) { final Map<String, String> overrides = buildData.getBuildOptions().getOverrides(); final Map<String, byte[]> overrideFiles = buildData.getOverrideFiles(); final Document prefaceDoc; try { prefaceDoc = XMLUtilities.convertStringToDocument("<preface></preface>"); } catch (Exception e) { throw new BuildProcessingException(e); } // Add the title final String prefaceTitleTranslation = buildData.getConstants().getString("PREFACE"); final Element titleEle = prefaceDoc.createElement("title"); titleEle.setTextContent(prefaceTitleTranslation); prefaceDoc.getDocumentElement().appendChild(titleEle); // Add the Conventions.xml final Element conventions = XMLUtilities.createXIInclude(prefaceDoc, "Common_Content/Conventions.xml"); prefaceDoc.getDocumentElement().appendChild(conventions); // Add the Feedback.xml if (overrides.containsKey(CSConstants.FEEDBACK_OVERRIDE) && overrideFiles.containsKey( CSConstants.FEEDBACK_OVERRIDE) || contentSpec.getFeedback() != null) { final Element xinclude = XMLUtilities.createXIInclude(prefaceDoc, "Feedback.xml"); prefaceDoc.getDocumentElement().appendChild(xinclude); } else { final Element xinclude = XMLUtilities.createXIInclude(prefaceDoc, "Common_Content/Feedback.xml"); prefaceDoc.getDocumentElement().appendChild(xinclude); } final String prefaceXml = DocBookBuildUtilities.convertDocumentToDocBookFormattedString(buildData.getDocBookVersion(), prefaceDoc, "preface", buildData.getEntityFileName(), getXMLFormatProperties()); addToZip(buildData.getBookLocaleFolder() + PREFACE_FILE_NAME, prefaceXml, buildData); } }
[ "protected", "void", "buildBookPreface", "(", "final", "BuildData", "buildData", ")", "throws", "BuildProcessingException", "{", "final", "ContentSpec", "contentSpec", "=", "buildData", ".", "getContentSpec", "(", ")", ";", "// Check that should actually use the preface", "if", "(", "contentSpec", ".", "getUseDefaultPreface", "(", ")", ")", "{", "final", "Map", "<", "String", ",", "String", ">", "overrides", "=", "buildData", ".", "getBuildOptions", "(", ")", ".", "getOverrides", "(", ")", ";", "final", "Map", "<", "String", ",", "byte", "[", "]", ">", "overrideFiles", "=", "buildData", ".", "getOverrideFiles", "(", ")", ";", "final", "Document", "prefaceDoc", ";", "try", "{", "prefaceDoc", "=", "XMLUtilities", ".", "convertStringToDocument", "(", "\"<preface></preface>\"", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "BuildProcessingException", "(", "e", ")", ";", "}", "// Add the title", "final", "String", "prefaceTitleTranslation", "=", "buildData", ".", "getConstants", "(", ")", ".", "getString", "(", "\"PREFACE\"", ")", ";", "final", "Element", "titleEle", "=", "prefaceDoc", ".", "createElement", "(", "\"title\"", ")", ";", "titleEle", ".", "setTextContent", "(", "prefaceTitleTranslation", ")", ";", "prefaceDoc", ".", "getDocumentElement", "(", ")", ".", "appendChild", "(", "titleEle", ")", ";", "// Add the Conventions.xml", "final", "Element", "conventions", "=", "XMLUtilities", ".", "createXIInclude", "(", "prefaceDoc", ",", "\"Common_Content/Conventions.xml\"", ")", ";", "prefaceDoc", ".", "getDocumentElement", "(", ")", ".", "appendChild", "(", "conventions", ")", ";", "// Add the Feedback.xml", "if", "(", "overrides", ".", "containsKey", "(", "CSConstants", ".", "FEEDBACK_OVERRIDE", ")", "&&", "overrideFiles", ".", "containsKey", "(", "CSConstants", ".", "FEEDBACK_OVERRIDE", ")", "||", "contentSpec", ".", "getFeedback", "(", ")", "!=", "null", ")", "{", "final", "Element", "xinclude", "=", "XMLUtilities", ".", "createXIInclude", "(", "prefaceDoc", ",", "\"Feedback.xml\"", ")", ";", "prefaceDoc", ".", "getDocumentElement", "(", ")", ".", "appendChild", "(", "xinclude", ")", ";", "}", "else", "{", "final", "Element", "xinclude", "=", "XMLUtilities", ".", "createXIInclude", "(", "prefaceDoc", ",", "\"Common_Content/Feedback.xml\"", ")", ";", "prefaceDoc", ".", "getDocumentElement", "(", ")", ".", "appendChild", "(", "xinclude", ")", ";", "}", "final", "String", "prefaceXml", "=", "DocBookBuildUtilities", ".", "convertDocumentToDocBookFormattedString", "(", "buildData", ".", "getDocBookVersion", "(", ")", ",", "prefaceDoc", ",", "\"preface\"", ",", "buildData", ".", "getEntityFileName", "(", ")", ",", "getXMLFormatProperties", "(", ")", ")", ";", "addToZip", "(", "buildData", ".", "getBookLocaleFolder", "(", ")", "+", "PREFACE_FILE_NAME", ",", "prefaceXml", ",", "buildData", ")", ";", "}", "}" ]
Builds the Preface.xml file for the book. @param buildData @throws BuildProcessingException
[ "Builds", "the", "Preface", ".", "xml", "file", "for", "the", "book", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L2158-L2197
152,029
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.buildBookEntityFile
protected String buildBookEntityFile(final BuildData buildData) throws BuildProcessingException { final ContentSpec contentSpec = buildData.getContentSpec(); final StringBuilder retValue = new StringBuilder(); if (!buildData.getBuildOptions().getUseOldBugLinks() && buildData.getBuildOptions().getInsertBugLinks()) { // Add the bug link entities retValue.append("<!-- BUG LINK ENTITIES -->\n"); try { final BaseBugLinkStrategy bugLinkStrategy = buildData.getBugLinkStrategy(); final BugLinkOptions bugLinkOptions = buildData.getBugLinkOptions(); retValue.append(bugLinkStrategy.generateEntities(bugLinkOptions, buildData.getBuildName(), buildData.getBuildDate())); } catch (UnsupportedEncodingException e) { throw new BuildProcessingException(e); } catch (BugLinkException e) { throw new BuildProcessingException(e); } catch (final Exception ex) { throw new BuildProcessingException("Failed to insert Bug Links into the DOM Document", ex); } } retValue.append("<!-- CS ENTITIES -->\n"); final String entities = ContentSpecUtilities.generateEntitiesForContentSpec(contentSpec, buildData.getDocBookVersion(), buildData.getEscapedBookTitle(), buildData.getOriginalBookTitle(), buildData.getOriginalBookProduct()); retValue.append(entities); // Add the docbook.ent file for DocBook 5 builds if (buildData.getDocBookVersion() == DocBookVersion.DOCBOOK_50) { retValue.append("<!-- START DOCBOOK ENTITIES -->\n"); retValue.append(docbook45Entities); } return retValue.toString(); }
java
protected String buildBookEntityFile(final BuildData buildData) throws BuildProcessingException { final ContentSpec contentSpec = buildData.getContentSpec(); final StringBuilder retValue = new StringBuilder(); if (!buildData.getBuildOptions().getUseOldBugLinks() && buildData.getBuildOptions().getInsertBugLinks()) { // Add the bug link entities retValue.append("<!-- BUG LINK ENTITIES -->\n"); try { final BaseBugLinkStrategy bugLinkStrategy = buildData.getBugLinkStrategy(); final BugLinkOptions bugLinkOptions = buildData.getBugLinkOptions(); retValue.append(bugLinkStrategy.generateEntities(bugLinkOptions, buildData.getBuildName(), buildData.getBuildDate())); } catch (UnsupportedEncodingException e) { throw new BuildProcessingException(e); } catch (BugLinkException e) { throw new BuildProcessingException(e); } catch (final Exception ex) { throw new BuildProcessingException("Failed to insert Bug Links into the DOM Document", ex); } } retValue.append("<!-- CS ENTITIES -->\n"); final String entities = ContentSpecUtilities.generateEntitiesForContentSpec(contentSpec, buildData.getDocBookVersion(), buildData.getEscapedBookTitle(), buildData.getOriginalBookTitle(), buildData.getOriginalBookProduct()); retValue.append(entities); // Add the docbook.ent file for DocBook 5 builds if (buildData.getDocBookVersion() == DocBookVersion.DOCBOOK_50) { retValue.append("<!-- START DOCBOOK ENTITIES -->\n"); retValue.append(docbook45Entities); } return retValue.toString(); }
[ "protected", "String", "buildBookEntityFile", "(", "final", "BuildData", "buildData", ")", "throws", "BuildProcessingException", "{", "final", "ContentSpec", "contentSpec", "=", "buildData", ".", "getContentSpec", "(", ")", ";", "final", "StringBuilder", "retValue", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "!", "buildData", ".", "getBuildOptions", "(", ")", ".", "getUseOldBugLinks", "(", ")", "&&", "buildData", ".", "getBuildOptions", "(", ")", ".", "getInsertBugLinks", "(", ")", ")", "{", "// Add the bug link entities", "retValue", ".", "append", "(", "\"<!-- BUG LINK ENTITIES -->\\n\"", ")", ";", "try", "{", "final", "BaseBugLinkStrategy", "bugLinkStrategy", "=", "buildData", ".", "getBugLinkStrategy", "(", ")", ";", "final", "BugLinkOptions", "bugLinkOptions", "=", "buildData", ".", "getBugLinkOptions", "(", ")", ";", "retValue", ".", "append", "(", "bugLinkStrategy", ".", "generateEntities", "(", "bugLinkOptions", ",", "buildData", ".", "getBuildName", "(", ")", ",", "buildData", ".", "getBuildDate", "(", ")", ")", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "throw", "new", "BuildProcessingException", "(", "e", ")", ";", "}", "catch", "(", "BugLinkException", "e", ")", "{", "throw", "new", "BuildProcessingException", "(", "e", ")", ";", "}", "catch", "(", "final", "Exception", "ex", ")", "{", "throw", "new", "BuildProcessingException", "(", "\"Failed to insert Bug Links into the DOM Document\"", ",", "ex", ")", ";", "}", "}", "retValue", ".", "append", "(", "\"<!-- CS ENTITIES -->\\n\"", ")", ";", "final", "String", "entities", "=", "ContentSpecUtilities", ".", "generateEntitiesForContentSpec", "(", "contentSpec", ",", "buildData", ".", "getDocBookVersion", "(", ")", ",", "buildData", ".", "getEscapedBookTitle", "(", ")", ",", "buildData", ".", "getOriginalBookTitle", "(", ")", ",", "buildData", ".", "getOriginalBookProduct", "(", ")", ")", ";", "retValue", ".", "append", "(", "entities", ")", ";", "// Add the docbook.ent file for DocBook 5 builds", "if", "(", "buildData", ".", "getDocBookVersion", "(", ")", "==", "DocBookVersion", ".", "DOCBOOK_50", ")", "{", "retValue", ".", "append", "(", "\"<!-- START DOCBOOK ENTITIES -->\\n\"", ")", ";", "retValue", ".", "append", "(", "docbook45Entities", ")", ";", "}", "return", "retValue", ".", "toString", "(", ")", ";", "}" ]
Builds the book .ent file that is a basic requirement to build the book. @param buildData Information and data structures for the build. @return The book .ent file filled with content from the Content Spec.
[ "Builds", "the", "book", ".", "ent", "file", "that", "is", "a", "basic", "requirement", "to", "build", "the", "book", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L2205-L2238
152,030
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.setUpRootElement
protected void setUpRootElement(final BuildData buildData, final Level level, final Document doc, Element ele) { final Element titleNode = doc.createElement("title"); if (buildData.isTranslationBuild() && !isNullOrEmpty(level.getTranslatedTitle())) { titleNode.setTextContent(DocBookUtilities.escapeForXML(level.getTranslatedTitle())); } else { titleNode.setTextContent(DocBookUtilities.escapeForXML(level.getTitle())); } // Add the info if the container has one final Element infoElement; if (level.getInfoTopic() != null) { final InfoTopic infoTopic = level.getInfoTopic(); final Node info = doc.importNode(infoTopic.getXMLDocument().getDocumentElement(), true); // Generate the info node final String elementInfoName; if (buildData.getDocBookVersion() == DocBookVersion.DOCBOOK_50) { elementInfoName = "info"; } else { elementInfoName = ele.getNodeName() + "info"; } infoElement = doc.createElement(elementInfoName); // Move the contents of the info to the chapter/level final NodeList infoChildren = info.getChildNodes(); while (infoChildren.getLength() > 0) { infoElement.appendChild(infoChildren.item(0)); } } else { infoElement = null; } if (buildData.getDocBookVersion() == DocBookVersion.DOCBOOK_50) { ele.appendChild(titleNode); if (infoElement != null) { ele.appendChild(infoElement); } } else { if (infoElement != null) { ele.appendChild(infoElement); } ele.appendChild(titleNode); } DocBookBuildUtilities.setDOMElementId(buildData.getDocBookVersion(), ele, level.getUniqueLinkId(buildData.isUseFixedUrls())); }
java
protected void setUpRootElement(final BuildData buildData, final Level level, final Document doc, Element ele) { final Element titleNode = doc.createElement("title"); if (buildData.isTranslationBuild() && !isNullOrEmpty(level.getTranslatedTitle())) { titleNode.setTextContent(DocBookUtilities.escapeForXML(level.getTranslatedTitle())); } else { titleNode.setTextContent(DocBookUtilities.escapeForXML(level.getTitle())); } // Add the info if the container has one final Element infoElement; if (level.getInfoTopic() != null) { final InfoTopic infoTopic = level.getInfoTopic(); final Node info = doc.importNode(infoTopic.getXMLDocument().getDocumentElement(), true); // Generate the info node final String elementInfoName; if (buildData.getDocBookVersion() == DocBookVersion.DOCBOOK_50) { elementInfoName = "info"; } else { elementInfoName = ele.getNodeName() + "info"; } infoElement = doc.createElement(elementInfoName); // Move the contents of the info to the chapter/level final NodeList infoChildren = info.getChildNodes(); while (infoChildren.getLength() > 0) { infoElement.appendChild(infoChildren.item(0)); } } else { infoElement = null; } if (buildData.getDocBookVersion() == DocBookVersion.DOCBOOK_50) { ele.appendChild(titleNode); if (infoElement != null) { ele.appendChild(infoElement); } } else { if (infoElement != null) { ele.appendChild(infoElement); } ele.appendChild(titleNode); } DocBookBuildUtilities.setDOMElementId(buildData.getDocBookVersion(), ele, level.getUniqueLinkId(buildData.isUseFixedUrls())); }
[ "protected", "void", "setUpRootElement", "(", "final", "BuildData", "buildData", ",", "final", "Level", "level", ",", "final", "Document", "doc", ",", "Element", "ele", ")", "{", "final", "Element", "titleNode", "=", "doc", ".", "createElement", "(", "\"title\"", ")", ";", "if", "(", "buildData", ".", "isTranslationBuild", "(", ")", "&&", "!", "isNullOrEmpty", "(", "level", ".", "getTranslatedTitle", "(", ")", ")", ")", "{", "titleNode", ".", "setTextContent", "(", "DocBookUtilities", ".", "escapeForXML", "(", "level", ".", "getTranslatedTitle", "(", ")", ")", ")", ";", "}", "else", "{", "titleNode", ".", "setTextContent", "(", "DocBookUtilities", ".", "escapeForXML", "(", "level", ".", "getTitle", "(", ")", ")", ")", ";", "}", "// Add the info if the container has one", "final", "Element", "infoElement", ";", "if", "(", "level", ".", "getInfoTopic", "(", ")", "!=", "null", ")", "{", "final", "InfoTopic", "infoTopic", "=", "level", ".", "getInfoTopic", "(", ")", ";", "final", "Node", "info", "=", "doc", ".", "importNode", "(", "infoTopic", ".", "getXMLDocument", "(", ")", ".", "getDocumentElement", "(", ")", ",", "true", ")", ";", "// Generate the info node", "final", "String", "elementInfoName", ";", "if", "(", "buildData", ".", "getDocBookVersion", "(", ")", "==", "DocBookVersion", ".", "DOCBOOK_50", ")", "{", "elementInfoName", "=", "\"info\"", ";", "}", "else", "{", "elementInfoName", "=", "ele", ".", "getNodeName", "(", ")", "+", "\"info\"", ";", "}", "infoElement", "=", "doc", ".", "createElement", "(", "elementInfoName", ")", ";", "// Move the contents of the info to the chapter/level", "final", "NodeList", "infoChildren", "=", "info", ".", "getChildNodes", "(", ")", ";", "while", "(", "infoChildren", ".", "getLength", "(", ")", ">", "0", ")", "{", "infoElement", ".", "appendChild", "(", "infoChildren", ".", "item", "(", "0", ")", ")", ";", "}", "}", "else", "{", "infoElement", "=", "null", ";", "}", "if", "(", "buildData", ".", "getDocBookVersion", "(", ")", "==", "DocBookVersion", ".", "DOCBOOK_50", ")", "{", "ele", ".", "appendChild", "(", "titleNode", ")", ";", "if", "(", "infoElement", "!=", "null", ")", "{", "ele", ".", "appendChild", "(", "infoElement", ")", ";", "}", "}", "else", "{", "if", "(", "infoElement", "!=", "null", ")", "{", "ele", ".", "appendChild", "(", "infoElement", ")", ";", "}", "ele", ".", "appendChild", "(", "titleNode", ")", ";", "}", "DocBookBuildUtilities", ".", "setDOMElementId", "(", "buildData", ".", "getDocBookVersion", "(", ")", ",", "ele", ",", "level", ".", "getUniqueLinkId", "(", "buildData", ".", "isUseFixedUrls", "(", ")", ")", ")", ";", "}" ]
Sets up an elements title, info and id based on the passed level. @param buildData Information and data structures for the build. @param level The level to build the root element is being built for. @param doc The document object the content is being added to. @param ele
[ "Sets", "up", "an", "elements", "title", "info", "and", "id", "based", "on", "the", "passed", "level", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L2354-L2399
152,031
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.createTopicXMLFile
protected String createTopicXMLFile(final BuildData buildData, final SpecTopic specTopic, final String parentFileLocation) throws BuildProcessingException { String topicFileName; final BaseTopicWrapper<?> topic = specTopic.getTopic(); if (topic != null) { topicFileName = specTopic.getUniqueLinkId(buildData.isUseFixedUrls()) + ".xml"; final String fixedParentFileLocation = buildData.getBuildOptions().getFlattenTopics() ? buildData.getBookTopicsFolder() : parentFileLocation; final String fixedEntityPath = fixedParentFileLocation.replace(buildData.getBookLocaleFolder(), "").replaceAll( ".*?" + File.separator + "", "../"); final String topicXML = DocBookBuildUtilities.convertDocumentToDocBookFormattedString(buildData.getDocBookVersion(), specTopic.getXMLDocument(), DocBookUtilities.TOPIC_ROOT_NODE_NAME, fixedEntityPath + buildData.getEntityFileName(), getXMLFormatProperties()); addToZip(fixedParentFileLocation + topicFileName, topicXML, buildData); return topicFileName; } return null; }
java
protected String createTopicXMLFile(final BuildData buildData, final SpecTopic specTopic, final String parentFileLocation) throws BuildProcessingException { String topicFileName; final BaseTopicWrapper<?> topic = specTopic.getTopic(); if (topic != null) { topicFileName = specTopic.getUniqueLinkId(buildData.isUseFixedUrls()) + ".xml"; final String fixedParentFileLocation = buildData.getBuildOptions().getFlattenTopics() ? buildData.getBookTopicsFolder() : parentFileLocation; final String fixedEntityPath = fixedParentFileLocation.replace(buildData.getBookLocaleFolder(), "").replaceAll( ".*?" + File.separator + "", "../"); final String topicXML = DocBookBuildUtilities.convertDocumentToDocBookFormattedString(buildData.getDocBookVersion(), specTopic.getXMLDocument(), DocBookUtilities.TOPIC_ROOT_NODE_NAME, fixedEntityPath + buildData.getEntityFileName(), getXMLFormatProperties()); addToZip(fixedParentFileLocation + topicFileName, topicXML, buildData); return topicFileName; } return null; }
[ "protected", "String", "createTopicXMLFile", "(", "final", "BuildData", "buildData", ",", "final", "SpecTopic", "specTopic", ",", "final", "String", "parentFileLocation", ")", "throws", "BuildProcessingException", "{", "String", "topicFileName", ";", "final", "BaseTopicWrapper", "<", "?", ">", "topic", "=", "specTopic", ".", "getTopic", "(", ")", ";", "if", "(", "topic", "!=", "null", ")", "{", "topicFileName", "=", "specTopic", ".", "getUniqueLinkId", "(", "buildData", ".", "isUseFixedUrls", "(", ")", ")", "+", "\".xml\"", ";", "final", "String", "fixedParentFileLocation", "=", "buildData", ".", "getBuildOptions", "(", ")", ".", "getFlattenTopics", "(", ")", "?", "buildData", ".", "getBookTopicsFolder", "(", ")", ":", "parentFileLocation", ";", "final", "String", "fixedEntityPath", "=", "fixedParentFileLocation", ".", "replace", "(", "buildData", ".", "getBookLocaleFolder", "(", ")", ",", "\"\"", ")", ".", "replaceAll", "(", "\".*?\"", "+", "File", ".", "separator", "+", "\"\"", ",", "\"../\"", ")", ";", "final", "String", "topicXML", "=", "DocBookBuildUtilities", ".", "convertDocumentToDocBookFormattedString", "(", "buildData", ".", "getDocBookVersion", "(", ")", ",", "specTopic", ".", "getXMLDocument", "(", ")", ",", "DocBookUtilities", ".", "TOPIC_ROOT_NODE_NAME", ",", "fixedEntityPath", "+", "buildData", ".", "getEntityFileName", "(", ")", ",", "getXMLFormatProperties", "(", ")", ")", ";", "addToZip", "(", "fixedParentFileLocation", "+", "topicFileName", ",", "topicXML", ",", "buildData", ")", ";", "return", "topicFileName", ";", "}", "return", "null", ";", "}" ]
Creates the Topic component of a chapter.xml for a specific SpecTopic. @param buildData Information and data structures for the build. @param specTopic The build topic object to get content from. @param parentFileLocation The topics parent file location, so the topic can be saved in a subdirectory. @return The Topics filename.
[ "Creates", "the", "Topic", "component", "of", "a", "chapter", ".", "xml", "for", "a", "specific", "SpecTopic", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L2650-L2673
152,032
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.buildRevisionHistoryFromTemplate
protected void buildRevisionHistoryFromTemplate(final BuildData buildData, final String revisionHistoryXml) throws BuildProcessingException { log.info("\tBuilding " + REVISION_HISTORY_FILE_NAME); Document revHistoryDoc; try { revHistoryDoc = XMLUtilities.convertStringToDocument(revisionHistoryXml); } catch (Exception ex) { // Exit since we shouldn't fail at converting the basic revision history log.debug("", ex); throw new BuildProcessingException( String.format(getMessages().getString("FAILED_CONVERTING_TEMPLATE"), REVISION_HISTORY_FILE_NAME)); } if (revHistoryDoc == null) { throw new BuildProcessingException( String.format(getMessages().getString("FAILED_CONVERTING_TEMPLATE"), REVISION_HISTORY_FILE_NAME)); } final String reportHistoryTitleTranslation = buildData.getConstants().getString("REVISION_HISTORY"); if (reportHistoryTitleTranslation != null) { DocBookUtilities.setRootElementTitle(reportHistoryTitleTranslation, revHistoryDoc); } // Find the revhistory node final Element revHistory; final NodeList revHistories = revHistoryDoc.getElementsByTagName("revhistory"); if (revHistories.getLength() > 0) { revHistory = (Element) revHistories.item(0); } else { revHistory = revHistoryDoc.createElement("revhistory"); // <revhistory> should be a direct child of <appendix> in docbook 5 if (buildData.getDocBookVersion() == DocBookVersion.DOCBOOK_50) { revHistoryDoc.getDocumentElement().appendChild(revHistory); } else { final Element simpara = revHistoryDoc.createElement("simpara"); simpara.appendChild(revHistory); revHistoryDoc.getDocumentElement().appendChild(simpara); } } final TagWrapper author = buildData.getRequester() == null ? null : tagProvider.getTagByName(buildData.getRequester()); // Check if the app should be shutdown if (isShuttingDown.get()) { return; } // An assigned writer tag exists for the User so check if there is an AuthorInformation tuple for that writer if (author != null) { AuthorInformation authorInfo = EntityUtilities.getAuthorInformation(providerFactory, buildData.getServerEntities(), author.getId(), author.getRevision()); if (authorInfo != null) { final Element revision = generateRevision(buildData, revHistoryDoc, authorInfo); addRevisionToRevHistory(revHistory, revision); } else { // No AuthorInformation so Use the default value authorInfo = new AuthorInformation(-1, BuilderConstants.DEFAULT_AUTHOR_FIRSTNAME, BuilderConstants.DEFAULT_AUTHOR_LASTNAME, BuilderConstants.DEFAULT_EMAIL); final Element revision = generateRevision(buildData, revHistoryDoc, authorInfo); addRevisionToRevHistory(revHistory, revision); } } // No assigned writer exists for the uploader so use default values else { final AuthorInformation authorInfo = new AuthorInformation(-1, BuilderConstants.DEFAULT_AUTHOR_FIRSTNAME, BuilderConstants.DEFAULT_AUTHOR_LASTNAME, BuilderConstants.DEFAULT_EMAIL); final Element revision = generateRevision(buildData, revHistoryDoc, authorInfo); addRevisionToRevHistory(revHistory, revision); } // Add the revision history to the book final String fixedRevisionHistoryXml = DocBookBuildUtilities.convertDocumentToDocBookFormattedString(buildData.getDocBookVersion(), revHistoryDoc, "appendix", buildData.getEntityFileName(), getXMLFormatProperties()); addToZip(buildData.getBookLocaleFolder() + REVISION_HISTORY_FILE_NAME, fixedRevisionHistoryXml, buildData); }
java
protected void buildRevisionHistoryFromTemplate(final BuildData buildData, final String revisionHistoryXml) throws BuildProcessingException { log.info("\tBuilding " + REVISION_HISTORY_FILE_NAME); Document revHistoryDoc; try { revHistoryDoc = XMLUtilities.convertStringToDocument(revisionHistoryXml); } catch (Exception ex) { // Exit since we shouldn't fail at converting the basic revision history log.debug("", ex); throw new BuildProcessingException( String.format(getMessages().getString("FAILED_CONVERTING_TEMPLATE"), REVISION_HISTORY_FILE_NAME)); } if (revHistoryDoc == null) { throw new BuildProcessingException( String.format(getMessages().getString("FAILED_CONVERTING_TEMPLATE"), REVISION_HISTORY_FILE_NAME)); } final String reportHistoryTitleTranslation = buildData.getConstants().getString("REVISION_HISTORY"); if (reportHistoryTitleTranslation != null) { DocBookUtilities.setRootElementTitle(reportHistoryTitleTranslation, revHistoryDoc); } // Find the revhistory node final Element revHistory; final NodeList revHistories = revHistoryDoc.getElementsByTagName("revhistory"); if (revHistories.getLength() > 0) { revHistory = (Element) revHistories.item(0); } else { revHistory = revHistoryDoc.createElement("revhistory"); // <revhistory> should be a direct child of <appendix> in docbook 5 if (buildData.getDocBookVersion() == DocBookVersion.DOCBOOK_50) { revHistoryDoc.getDocumentElement().appendChild(revHistory); } else { final Element simpara = revHistoryDoc.createElement("simpara"); simpara.appendChild(revHistory); revHistoryDoc.getDocumentElement().appendChild(simpara); } } final TagWrapper author = buildData.getRequester() == null ? null : tagProvider.getTagByName(buildData.getRequester()); // Check if the app should be shutdown if (isShuttingDown.get()) { return; } // An assigned writer tag exists for the User so check if there is an AuthorInformation tuple for that writer if (author != null) { AuthorInformation authorInfo = EntityUtilities.getAuthorInformation(providerFactory, buildData.getServerEntities(), author.getId(), author.getRevision()); if (authorInfo != null) { final Element revision = generateRevision(buildData, revHistoryDoc, authorInfo); addRevisionToRevHistory(revHistory, revision); } else { // No AuthorInformation so Use the default value authorInfo = new AuthorInformation(-1, BuilderConstants.DEFAULT_AUTHOR_FIRSTNAME, BuilderConstants.DEFAULT_AUTHOR_LASTNAME, BuilderConstants.DEFAULT_EMAIL); final Element revision = generateRevision(buildData, revHistoryDoc, authorInfo); addRevisionToRevHistory(revHistory, revision); } } // No assigned writer exists for the uploader so use default values else { final AuthorInformation authorInfo = new AuthorInformation(-1, BuilderConstants.DEFAULT_AUTHOR_FIRSTNAME, BuilderConstants.DEFAULT_AUTHOR_LASTNAME, BuilderConstants.DEFAULT_EMAIL); final Element revision = generateRevision(buildData, revHistoryDoc, authorInfo); addRevisionToRevHistory(revHistory, revision); } // Add the revision history to the book final String fixedRevisionHistoryXml = DocBookBuildUtilities.convertDocumentToDocBookFormattedString(buildData.getDocBookVersion(), revHistoryDoc, "appendix", buildData.getEntityFileName(), getXMLFormatProperties()); addToZip(buildData.getBookLocaleFolder() + REVISION_HISTORY_FILE_NAME, fixedRevisionHistoryXml, buildData); }
[ "protected", "void", "buildRevisionHistoryFromTemplate", "(", "final", "BuildData", "buildData", ",", "final", "String", "revisionHistoryXml", ")", "throws", "BuildProcessingException", "{", "log", ".", "info", "(", "\"\\tBuilding \"", "+", "REVISION_HISTORY_FILE_NAME", ")", ";", "Document", "revHistoryDoc", ";", "try", "{", "revHistoryDoc", "=", "XMLUtilities", ".", "convertStringToDocument", "(", "revisionHistoryXml", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "// Exit since we shouldn't fail at converting the basic revision history", "log", ".", "debug", "(", "\"\"", ",", "ex", ")", ";", "throw", "new", "BuildProcessingException", "(", "String", ".", "format", "(", "getMessages", "(", ")", ".", "getString", "(", "\"FAILED_CONVERTING_TEMPLATE\"", ")", ",", "REVISION_HISTORY_FILE_NAME", ")", ")", ";", "}", "if", "(", "revHistoryDoc", "==", "null", ")", "{", "throw", "new", "BuildProcessingException", "(", "String", ".", "format", "(", "getMessages", "(", ")", ".", "getString", "(", "\"FAILED_CONVERTING_TEMPLATE\"", ")", ",", "REVISION_HISTORY_FILE_NAME", ")", ")", ";", "}", "final", "String", "reportHistoryTitleTranslation", "=", "buildData", ".", "getConstants", "(", ")", ".", "getString", "(", "\"REVISION_HISTORY\"", ")", ";", "if", "(", "reportHistoryTitleTranslation", "!=", "null", ")", "{", "DocBookUtilities", ".", "setRootElementTitle", "(", "reportHistoryTitleTranslation", ",", "revHistoryDoc", ")", ";", "}", "// Find the revhistory node", "final", "Element", "revHistory", ";", "final", "NodeList", "revHistories", "=", "revHistoryDoc", ".", "getElementsByTagName", "(", "\"revhistory\"", ")", ";", "if", "(", "revHistories", ".", "getLength", "(", ")", ">", "0", ")", "{", "revHistory", "=", "(", "Element", ")", "revHistories", ".", "item", "(", "0", ")", ";", "}", "else", "{", "revHistory", "=", "revHistoryDoc", ".", "createElement", "(", "\"revhistory\"", ")", ";", "// <revhistory> should be a direct child of <appendix> in docbook 5", "if", "(", "buildData", ".", "getDocBookVersion", "(", ")", "==", "DocBookVersion", ".", "DOCBOOK_50", ")", "{", "revHistoryDoc", ".", "getDocumentElement", "(", ")", ".", "appendChild", "(", "revHistory", ")", ";", "}", "else", "{", "final", "Element", "simpara", "=", "revHistoryDoc", ".", "createElement", "(", "\"simpara\"", ")", ";", "simpara", ".", "appendChild", "(", "revHistory", ")", ";", "revHistoryDoc", ".", "getDocumentElement", "(", ")", ".", "appendChild", "(", "simpara", ")", ";", "}", "}", "final", "TagWrapper", "author", "=", "buildData", ".", "getRequester", "(", ")", "==", "null", "?", "null", ":", "tagProvider", ".", "getTagByName", "(", "buildData", ".", "getRequester", "(", ")", ")", ";", "// Check if the app should be shutdown", "if", "(", "isShuttingDown", ".", "get", "(", ")", ")", "{", "return", ";", "}", "// An assigned writer tag exists for the User so check if there is an AuthorInformation tuple for that writer", "if", "(", "author", "!=", "null", ")", "{", "AuthorInformation", "authorInfo", "=", "EntityUtilities", ".", "getAuthorInformation", "(", "providerFactory", ",", "buildData", ".", "getServerEntities", "(", ")", ",", "author", ".", "getId", "(", ")", ",", "author", ".", "getRevision", "(", ")", ")", ";", "if", "(", "authorInfo", "!=", "null", ")", "{", "final", "Element", "revision", "=", "generateRevision", "(", "buildData", ",", "revHistoryDoc", ",", "authorInfo", ")", ";", "addRevisionToRevHistory", "(", "revHistory", ",", "revision", ")", ";", "}", "else", "{", "// No AuthorInformation so Use the default value", "authorInfo", "=", "new", "AuthorInformation", "(", "-", "1", ",", "BuilderConstants", ".", "DEFAULT_AUTHOR_FIRSTNAME", ",", "BuilderConstants", ".", "DEFAULT_AUTHOR_LASTNAME", ",", "BuilderConstants", ".", "DEFAULT_EMAIL", ")", ";", "final", "Element", "revision", "=", "generateRevision", "(", "buildData", ",", "revHistoryDoc", ",", "authorInfo", ")", ";", "addRevisionToRevHistory", "(", "revHistory", ",", "revision", ")", ";", "}", "}", "// No assigned writer exists for the uploader so use default values", "else", "{", "final", "AuthorInformation", "authorInfo", "=", "new", "AuthorInformation", "(", "-", "1", ",", "BuilderConstants", ".", "DEFAULT_AUTHOR_FIRSTNAME", ",", "BuilderConstants", ".", "DEFAULT_AUTHOR_LASTNAME", ",", "BuilderConstants", ".", "DEFAULT_EMAIL", ")", ";", "final", "Element", "revision", "=", "generateRevision", "(", "buildData", ",", "revHistoryDoc", ",", "authorInfo", ")", ";", "addRevisionToRevHistory", "(", "revHistory", ",", "revision", ")", ";", "}", "// Add the revision history to the book", "final", "String", "fixedRevisionHistoryXml", "=", "DocBookBuildUtilities", ".", "convertDocumentToDocBookFormattedString", "(", "buildData", ".", "getDocBookVersion", "(", ")", ",", "revHistoryDoc", ",", "\"appendix\"", ",", "buildData", ".", "getEntityFileName", "(", ")", ",", "getXMLFormatProperties", "(", ")", ")", ";", "addToZip", "(", "buildData", ".", "getBookLocaleFolder", "(", ")", "+", "REVISION_HISTORY_FILE_NAME", ",", "fixedRevisionHistoryXml", ",", "buildData", ")", ";", "}" ]
Builds the revision history using the requester of the build. @param buildData Information and data structures for the build. @param revisionHistoryXml The Revision_History.xml file/template to add revision information to. @throws BuildProcessingException Thrown if an unexpected error occurs during building.
[ "Builds", "the", "revision", "history", "using", "the", "requester", "of", "the", "build", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L3061-L3139
152,033
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.addRevisionToRevHistory
private void addRevisionToRevHistory(final Node revHistory, final Node revision) { if (revHistory.hasChildNodes()) { revHistory.insertBefore(revision, revHistory.getFirstChild()); } else { revHistory.appendChild(revision); } }
java
private void addRevisionToRevHistory(final Node revHistory, final Node revision) { if (revHistory.hasChildNodes()) { revHistory.insertBefore(revision, revHistory.getFirstChild()); } else { revHistory.appendChild(revision); } }
[ "private", "void", "addRevisionToRevHistory", "(", "final", "Node", "revHistory", ",", "final", "Node", "revision", ")", "{", "if", "(", "revHistory", ".", "hasChildNodes", "(", ")", ")", "{", "revHistory", ".", "insertBefore", "(", "revision", ",", "revHistory", ".", "getFirstChild", "(", ")", ")", ";", "}", "else", "{", "revHistory", ".", "appendChild", "(", "revision", ")", ";", "}", "}" ]
Adds a revision element to the list of revisions in a revhistory element. This method ensures that the new revision is at the top of the revhistory list. @param revHistory The revhistory element to add the revision to. @param revision The revision element to be added into the revisionhistory element.
[ "Adds", "a", "revision", "element", "to", "the", "list", "of", "revisions", "in", "a", "revhistory", "element", ".", "This", "method", "ensures", "that", "the", "new", "revision", "is", "at", "the", "top", "of", "the", "revhistory", "list", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L3148-L3154
152,034
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.buildTranslateCSChapter
private String buildTranslateCSChapter(final BuildData buildData) { final ContentSpec contentSpec = buildData.getContentSpec(); final TranslatedContentSpecWrapper translatedContentSpec = EntityUtilities.getClosestTranslatedContentSpecById(providerFactory, contentSpec.getId(), contentSpec.getRevision()); final String para; if (translatedContentSpec != null) { final String url = translatedContentSpec.getEditorURL(buildData.getZanataDetails(), buildData.getBuildLocale()); if (url != null) { para = DocBookUtilities.wrapInPara(DocBookUtilities.buildULink(url, "Translate this Content Spec")); } else { para = DocBookUtilities.wrapInPara( "No editor link available as this Content Specification hasn't been pushed for Translation."); } } else { para = DocBookUtilities.wrapInPara( "No editor link available as this Content Specification hasn't been pushed for Translation."); } if (contentSpec.getBookType() == BookType.ARTICLE || contentSpec.getBookType() == BookType.ARTICLE_DRAFT) { return DocBookUtilities.buildSection(para, "Content Specification"); } else { return DocBookUtilities.buildChapter(para, "Content Specification"); } }
java
private String buildTranslateCSChapter(final BuildData buildData) { final ContentSpec contentSpec = buildData.getContentSpec(); final TranslatedContentSpecWrapper translatedContentSpec = EntityUtilities.getClosestTranslatedContentSpecById(providerFactory, contentSpec.getId(), contentSpec.getRevision()); final String para; if (translatedContentSpec != null) { final String url = translatedContentSpec.getEditorURL(buildData.getZanataDetails(), buildData.getBuildLocale()); if (url != null) { para = DocBookUtilities.wrapInPara(DocBookUtilities.buildULink(url, "Translate this Content Spec")); } else { para = DocBookUtilities.wrapInPara( "No editor link available as this Content Specification hasn't been pushed for Translation."); } } else { para = DocBookUtilities.wrapInPara( "No editor link available as this Content Specification hasn't been pushed for Translation."); } if (contentSpec.getBookType() == BookType.ARTICLE || contentSpec.getBookType() == BookType.ARTICLE_DRAFT) { return DocBookUtilities.buildSection(para, "Content Specification"); } else { return DocBookUtilities.buildChapter(para, "Content Specification"); } }
[ "private", "String", "buildTranslateCSChapter", "(", "final", "BuildData", "buildData", ")", "{", "final", "ContentSpec", "contentSpec", "=", "buildData", ".", "getContentSpec", "(", ")", ";", "final", "TranslatedContentSpecWrapper", "translatedContentSpec", "=", "EntityUtilities", ".", "getClosestTranslatedContentSpecById", "(", "providerFactory", ",", "contentSpec", ".", "getId", "(", ")", ",", "contentSpec", ".", "getRevision", "(", ")", ")", ";", "final", "String", "para", ";", "if", "(", "translatedContentSpec", "!=", "null", ")", "{", "final", "String", "url", "=", "translatedContentSpec", ".", "getEditorURL", "(", "buildData", ".", "getZanataDetails", "(", ")", ",", "buildData", ".", "getBuildLocale", "(", ")", ")", ";", "if", "(", "url", "!=", "null", ")", "{", "para", "=", "DocBookUtilities", ".", "wrapInPara", "(", "DocBookUtilities", ".", "buildULink", "(", "url", ",", "\"Translate this Content Spec\"", ")", ")", ";", "}", "else", "{", "para", "=", "DocBookUtilities", ".", "wrapInPara", "(", "\"No editor link available as this Content Specification hasn't been pushed for Translation.\"", ")", ";", "}", "}", "else", "{", "para", "=", "DocBookUtilities", ".", "wrapInPara", "(", "\"No editor link available as this Content Specification hasn't been pushed for Translation.\"", ")", ";", "}", "if", "(", "contentSpec", ".", "getBookType", "(", ")", "==", "BookType", ".", "ARTICLE", "||", "contentSpec", ".", "getBookType", "(", ")", "==", "BookType", ".", "ARTICLE_DRAFT", ")", "{", "return", "DocBookUtilities", ".", "buildSection", "(", "para", ",", "\"Content Specification\"", ")", ";", "}", "else", "{", "return", "DocBookUtilities", ".", "buildChapter", "(", "para", ",", "\"Content Specification\"", ")", ";", "}", "}" ]
Builds a Chapter with a single paragraph, that contains a link to translate the Content Specification. @param buildData Information and data structures for the build.@return The Chapter represented as Docbook markup.
[ "Builds", "a", "Chapter", "with", "a", "single", "paragraph", "that", "contains", "a", "link", "to", "translate", "the", "Content", "Specification", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L3270-L3295
152,035
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.buildErrorChapterGlossary
private String buildErrorChapterGlossary(final BuildData buildData, final String title) { final StringBuilder glossary = new StringBuilder("<glossary>"); // Add the title of the glossary glossary.append("<title>"); if (title != null) { glossary.append(title); } glossary.append("</title>"); // Add generic error messages // No Content Warning glossary.append( DocBookUtilities.wrapInGlossEntry(DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.WARNING_EMPTY_TOPIC_XML + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.WARNING_NO_CONTENT_TOPIC_DEFINITION))); // Invalid XML entity or element glossary.append(DocBookUtilities.wrapInGlossEntry( DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.ERROR_INVALID_XML_CONTENT + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.ERROR_INVALID_XML_CONTENT_DEFINITION))); // No Content Error glossary.append( DocBookUtilities.wrapInGlossEntry(DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.ERROR_BAD_XML_STRUCTURE + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.ERROR_BAD_XML_STRUCTURE_DEFINITION))); // Invalid Docbook XML Error glossary.append( DocBookUtilities.wrapInGlossEntry(DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.ERROR_INVALID_TOPIC_XML + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.ERROR_INVALID_TOPIC_XML_DEFINITION))); // Invalid Injections Error glossary.append( DocBookUtilities.wrapInGlossEntry(DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.ERROR_INVALID_INJECTIONS + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.ERROR_INVALID_INJECTIONS_DEFINITION))); // Possible Invalid Injections Warning glossary.append(DocBookUtilities.wrapInGlossEntry( DocBookUtilities.wrapInGlossTerm("\"... " + BuilderConstants.WARNING_POSSIBLE_INVALID_INJECTIONS + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.WARNING_POSSIBLE_INVALID_INJECTIONS_DEFINITION))); // Add the glossary terms and definitions if (buildData.isTranslationBuild()) { // Incomplete translation warning glossary.append(DocBookUtilities.wrapInGlossEntry( DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.WARNING_INCOMPLETE_TRANSLATION + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.WARNING_INCOMPLETE_TRANSLATED_TOPIC_DEFINITION))); // Fuzzy translation warning glossary.append(DocBookUtilities.wrapInGlossEntry( DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.WARNING_FUZZY_TRANSLATION + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.WARNING_FUZZY_TRANSLATED_TOPIC_DEFINITION))); // Untranslated Content warning glossary.append(DocBookUtilities.wrapInGlossEntry( DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.WARNING_UNTRANSLATED_TOPIC + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.WARNING_UNTRANSLATED_TOPIC_DEFINITION))); // Non Pushed Translation Content warning glossary.append(DocBookUtilities.wrapInGlossEntry( DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.WARNING_NONPUSHED_TOPIC + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.WARNING_NONPUSHED_TOPIC_DEFINITION))); // Old Translation Content warning glossary.append(DocBookUtilities.wrapInGlossEntry( DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.WARNING_OLD_TRANSLATED_TOPIC + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.WARNING_OLD_TRANSLATED_TOPIC_DEFINITION))); // Old Untranslated Content warning glossary.append(DocBookUtilities.wrapInGlossEntry( DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.WARNING_OLD_UNTRANSLATED_TOPIC + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.WARNING_OLD_UNTRANSLATED_TOPIC_DEFINITION))); } glossary.append("</glossary>"); return glossary.toString(); }
java
private String buildErrorChapterGlossary(final BuildData buildData, final String title) { final StringBuilder glossary = new StringBuilder("<glossary>"); // Add the title of the glossary glossary.append("<title>"); if (title != null) { glossary.append(title); } glossary.append("</title>"); // Add generic error messages // No Content Warning glossary.append( DocBookUtilities.wrapInGlossEntry(DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.WARNING_EMPTY_TOPIC_XML + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.WARNING_NO_CONTENT_TOPIC_DEFINITION))); // Invalid XML entity or element glossary.append(DocBookUtilities.wrapInGlossEntry( DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.ERROR_INVALID_XML_CONTENT + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.ERROR_INVALID_XML_CONTENT_DEFINITION))); // No Content Error glossary.append( DocBookUtilities.wrapInGlossEntry(DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.ERROR_BAD_XML_STRUCTURE + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.ERROR_BAD_XML_STRUCTURE_DEFINITION))); // Invalid Docbook XML Error glossary.append( DocBookUtilities.wrapInGlossEntry(DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.ERROR_INVALID_TOPIC_XML + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.ERROR_INVALID_TOPIC_XML_DEFINITION))); // Invalid Injections Error glossary.append( DocBookUtilities.wrapInGlossEntry(DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.ERROR_INVALID_INJECTIONS + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.ERROR_INVALID_INJECTIONS_DEFINITION))); // Possible Invalid Injections Warning glossary.append(DocBookUtilities.wrapInGlossEntry( DocBookUtilities.wrapInGlossTerm("\"... " + BuilderConstants.WARNING_POSSIBLE_INVALID_INJECTIONS + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.WARNING_POSSIBLE_INVALID_INJECTIONS_DEFINITION))); // Add the glossary terms and definitions if (buildData.isTranslationBuild()) { // Incomplete translation warning glossary.append(DocBookUtilities.wrapInGlossEntry( DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.WARNING_INCOMPLETE_TRANSLATION + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.WARNING_INCOMPLETE_TRANSLATED_TOPIC_DEFINITION))); // Fuzzy translation warning glossary.append(DocBookUtilities.wrapInGlossEntry( DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.WARNING_FUZZY_TRANSLATION + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.WARNING_FUZZY_TRANSLATED_TOPIC_DEFINITION))); // Untranslated Content warning glossary.append(DocBookUtilities.wrapInGlossEntry( DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.WARNING_UNTRANSLATED_TOPIC + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.WARNING_UNTRANSLATED_TOPIC_DEFINITION))); // Non Pushed Translation Content warning glossary.append(DocBookUtilities.wrapInGlossEntry( DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.WARNING_NONPUSHED_TOPIC + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.WARNING_NONPUSHED_TOPIC_DEFINITION))); // Old Translation Content warning glossary.append(DocBookUtilities.wrapInGlossEntry( DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.WARNING_OLD_TRANSLATED_TOPIC + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.WARNING_OLD_TRANSLATED_TOPIC_DEFINITION))); // Old Untranslated Content warning glossary.append(DocBookUtilities.wrapInGlossEntry( DocBookUtilities.wrapInGlossTerm("\"" + BuilderConstants.WARNING_OLD_UNTRANSLATED_TOPIC + "\""), DocBookUtilities.wrapInItemizedGlossDef(null, BuilderConstants.WARNING_OLD_UNTRANSLATED_TOPIC_DEFINITION))); } glossary.append("</glossary>"); return glossary.toString(); }
[ "private", "String", "buildErrorChapterGlossary", "(", "final", "BuildData", "buildData", ",", "final", "String", "title", ")", "{", "final", "StringBuilder", "glossary", "=", "new", "StringBuilder", "(", "\"<glossary>\"", ")", ";", "// Add the title of the glossary", "glossary", ".", "append", "(", "\"<title>\"", ")", ";", "if", "(", "title", "!=", "null", ")", "{", "glossary", ".", "append", "(", "title", ")", ";", "}", "glossary", ".", "append", "(", "\"</title>\"", ")", ";", "// Add generic error messages", "// No Content Warning", "glossary", ".", "append", "(", "DocBookUtilities", ".", "wrapInGlossEntry", "(", "DocBookUtilities", ".", "wrapInGlossTerm", "(", "\"\\\"\"", "+", "BuilderConstants", ".", "WARNING_EMPTY_TOPIC_XML", "+", "\"\\\"\"", ")", ",", "DocBookUtilities", ".", "wrapInItemizedGlossDef", "(", "null", ",", "BuilderConstants", ".", "WARNING_NO_CONTENT_TOPIC_DEFINITION", ")", ")", ")", ";", "// Invalid XML entity or element", "glossary", ".", "append", "(", "DocBookUtilities", ".", "wrapInGlossEntry", "(", "DocBookUtilities", ".", "wrapInGlossTerm", "(", "\"\\\"\"", "+", "BuilderConstants", ".", "ERROR_INVALID_XML_CONTENT", "+", "\"\\\"\"", ")", ",", "DocBookUtilities", ".", "wrapInItemizedGlossDef", "(", "null", ",", "BuilderConstants", ".", "ERROR_INVALID_XML_CONTENT_DEFINITION", ")", ")", ")", ";", "// No Content Error", "glossary", ".", "append", "(", "DocBookUtilities", ".", "wrapInGlossEntry", "(", "DocBookUtilities", ".", "wrapInGlossTerm", "(", "\"\\\"\"", "+", "BuilderConstants", ".", "ERROR_BAD_XML_STRUCTURE", "+", "\"\\\"\"", ")", ",", "DocBookUtilities", ".", "wrapInItemizedGlossDef", "(", "null", ",", "BuilderConstants", ".", "ERROR_BAD_XML_STRUCTURE_DEFINITION", ")", ")", ")", ";", "// Invalid Docbook XML Error", "glossary", ".", "append", "(", "DocBookUtilities", ".", "wrapInGlossEntry", "(", "DocBookUtilities", ".", "wrapInGlossTerm", "(", "\"\\\"\"", "+", "BuilderConstants", ".", "ERROR_INVALID_TOPIC_XML", "+", "\"\\\"\"", ")", ",", "DocBookUtilities", ".", "wrapInItemizedGlossDef", "(", "null", ",", "BuilderConstants", ".", "ERROR_INVALID_TOPIC_XML_DEFINITION", ")", ")", ")", ";", "// Invalid Injections Error", "glossary", ".", "append", "(", "DocBookUtilities", ".", "wrapInGlossEntry", "(", "DocBookUtilities", ".", "wrapInGlossTerm", "(", "\"\\\"\"", "+", "BuilderConstants", ".", "ERROR_INVALID_INJECTIONS", "+", "\"\\\"\"", ")", ",", "DocBookUtilities", ".", "wrapInItemizedGlossDef", "(", "null", ",", "BuilderConstants", ".", "ERROR_INVALID_INJECTIONS_DEFINITION", ")", ")", ")", ";", "// Possible Invalid Injections Warning", "glossary", ".", "append", "(", "DocBookUtilities", ".", "wrapInGlossEntry", "(", "DocBookUtilities", ".", "wrapInGlossTerm", "(", "\"\\\"... \"", "+", "BuilderConstants", ".", "WARNING_POSSIBLE_INVALID_INJECTIONS", "+", "\"\\\"\"", ")", ",", "DocBookUtilities", ".", "wrapInItemizedGlossDef", "(", "null", ",", "BuilderConstants", ".", "WARNING_POSSIBLE_INVALID_INJECTIONS_DEFINITION", ")", ")", ")", ";", "// Add the glossary terms and definitions", "if", "(", "buildData", ".", "isTranslationBuild", "(", ")", ")", "{", "// Incomplete translation warning", "glossary", ".", "append", "(", "DocBookUtilities", ".", "wrapInGlossEntry", "(", "DocBookUtilities", ".", "wrapInGlossTerm", "(", "\"\\\"\"", "+", "BuilderConstants", ".", "WARNING_INCOMPLETE_TRANSLATION", "+", "\"\\\"\"", ")", ",", "DocBookUtilities", ".", "wrapInItemizedGlossDef", "(", "null", ",", "BuilderConstants", ".", "WARNING_INCOMPLETE_TRANSLATED_TOPIC_DEFINITION", ")", ")", ")", ";", "// Fuzzy translation warning", "glossary", ".", "append", "(", "DocBookUtilities", ".", "wrapInGlossEntry", "(", "DocBookUtilities", ".", "wrapInGlossTerm", "(", "\"\\\"\"", "+", "BuilderConstants", ".", "WARNING_FUZZY_TRANSLATION", "+", "\"\\\"\"", ")", ",", "DocBookUtilities", ".", "wrapInItemizedGlossDef", "(", "null", ",", "BuilderConstants", ".", "WARNING_FUZZY_TRANSLATED_TOPIC_DEFINITION", ")", ")", ")", ";", "// Untranslated Content warning", "glossary", ".", "append", "(", "DocBookUtilities", ".", "wrapInGlossEntry", "(", "DocBookUtilities", ".", "wrapInGlossTerm", "(", "\"\\\"\"", "+", "BuilderConstants", ".", "WARNING_UNTRANSLATED_TOPIC", "+", "\"\\\"\"", ")", ",", "DocBookUtilities", ".", "wrapInItemizedGlossDef", "(", "null", ",", "BuilderConstants", ".", "WARNING_UNTRANSLATED_TOPIC_DEFINITION", ")", ")", ")", ";", "// Non Pushed Translation Content warning", "glossary", ".", "append", "(", "DocBookUtilities", ".", "wrapInGlossEntry", "(", "DocBookUtilities", ".", "wrapInGlossTerm", "(", "\"\\\"\"", "+", "BuilderConstants", ".", "WARNING_NONPUSHED_TOPIC", "+", "\"\\\"\"", ")", ",", "DocBookUtilities", ".", "wrapInItemizedGlossDef", "(", "null", ",", "BuilderConstants", ".", "WARNING_NONPUSHED_TOPIC_DEFINITION", ")", ")", ")", ";", "// Old Translation Content warning", "glossary", ".", "append", "(", "DocBookUtilities", ".", "wrapInGlossEntry", "(", "DocBookUtilities", ".", "wrapInGlossTerm", "(", "\"\\\"\"", "+", "BuilderConstants", ".", "WARNING_OLD_TRANSLATED_TOPIC", "+", "\"\\\"\"", ")", ",", "DocBookUtilities", ".", "wrapInItemizedGlossDef", "(", "null", ",", "BuilderConstants", ".", "WARNING_OLD_TRANSLATED_TOPIC_DEFINITION", ")", ")", ")", ";", "// Old Untranslated Content warning", "glossary", ".", "append", "(", "DocBookUtilities", ".", "wrapInGlossEntry", "(", "DocBookUtilities", ".", "wrapInGlossTerm", "(", "\"\\\"\"", "+", "BuilderConstants", ".", "WARNING_OLD_UNTRANSLATED_TOPIC", "+", "\"\\\"\"", ")", ",", "DocBookUtilities", ".", "wrapInItemizedGlossDef", "(", "null", ",", "BuilderConstants", ".", "WARNING_OLD_UNTRANSLATED_TOPIC_DEFINITION", ")", ")", ")", ";", "}", "glossary", ".", "append", "(", "\"</glossary>\"", ")", ";", "return", "glossary", ".", "toString", "(", ")", ";", "}" ]
Builds the Glossary used in the Error Chapter. @param buildData Information and data structures for the build. @param title The title for the glossary. @return A docbook formatted string representation of the glossary.
[ "Builds", "the", "Glossary", "used", "in", "the", "Error", "Chapter", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L3386-L3464
152,036
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.processImageLocations
@SuppressWarnings("unchecked") private void processImageLocations(final BuildData buildData) { final List<Integer> topicIds = buildData.getBuildDatabase().getTopicIds(); for (final Integer topicId : topicIds) { final ITopicNode topicNode = buildData.getBuildDatabase().getTopicNodesForTopicID(topicId).get(0); final BaseTopicWrapper<?> topic = topicNode.getTopic(); if (log.isDebugEnabled()) log.debug("\tProcessing SpecTopic " + topicNode.getId() + (topicNode.getRevision() != null ? (", " + "Revision " + topicNode.getRevision()) : "")); /* * Images have to be in the image folder in Publican. Here we loop through all the imagedata elements and fix up any * reference to an image that is not in the images folder. */ final List<Node> images = XMLUtilities.getChildNodes(topicNode.getXMLDocument(), "imagedata", "inlinegraphic"); for (final Node imageNode : images) { final NamedNodeMap attributes = imageNode.getAttributes(); if (attributes != null) { final Node fileRefAttribute = attributes.getNamedItem("fileref"); if (fileRefAttribute != null && (fileRefAttribute.getNodeValue() == null || fileRefAttribute.getNodeValue().isEmpty() )) { fileRefAttribute.setNodeValue("images/" + BuilderConstants.FAILPENGUIN_PNG_NAME + ".jpg"); buildData.getImageLocations().add(new TopicImageData(topic, fileRefAttribute.getNodeValue())); } else if (fileRefAttribute != null && fileRefAttribute.getNodeValue() != null) { final String fileRefValue = fileRefAttribute.getNodeValue(); if (BuilderConstants.IMAGE_FILE_REF_PATTERN.matcher(fileRefValue).matches()) { if (fileRefValue.startsWith("./images/")) { fileRefAttribute.setNodeValue(fileRefValue.substring(2)); } else if (!fileRefValue.startsWith("images/")) { fileRefAttribute.setNodeValue("images/" + fileRefValue); } buildData.getImageLocations().add(new TopicImageData(topic, fileRefAttribute.getNodeValue())); } else if (!BuilderConstants.COMMON_CONTENT_FILE_REF_PATTERN.matcher(fileRefValue).matches()) { // The file isn't common content or a pressgang image so mark it as a missing image. fileRefAttribute.setNodeValue("images/" + BuilderConstants.FAILPENGUIN_PNG_NAME + ".jpg"); buildData.getImageLocations().add(new TopicImageData(topic, fileRefAttribute.getNodeValue())); } } } } } }
java
@SuppressWarnings("unchecked") private void processImageLocations(final BuildData buildData) { final List<Integer> topicIds = buildData.getBuildDatabase().getTopicIds(); for (final Integer topicId : topicIds) { final ITopicNode topicNode = buildData.getBuildDatabase().getTopicNodesForTopicID(topicId).get(0); final BaseTopicWrapper<?> topic = topicNode.getTopic(); if (log.isDebugEnabled()) log.debug("\tProcessing SpecTopic " + topicNode.getId() + (topicNode.getRevision() != null ? (", " + "Revision " + topicNode.getRevision()) : "")); /* * Images have to be in the image folder in Publican. Here we loop through all the imagedata elements and fix up any * reference to an image that is not in the images folder. */ final List<Node> images = XMLUtilities.getChildNodes(topicNode.getXMLDocument(), "imagedata", "inlinegraphic"); for (final Node imageNode : images) { final NamedNodeMap attributes = imageNode.getAttributes(); if (attributes != null) { final Node fileRefAttribute = attributes.getNamedItem("fileref"); if (fileRefAttribute != null && (fileRefAttribute.getNodeValue() == null || fileRefAttribute.getNodeValue().isEmpty() )) { fileRefAttribute.setNodeValue("images/" + BuilderConstants.FAILPENGUIN_PNG_NAME + ".jpg"); buildData.getImageLocations().add(new TopicImageData(topic, fileRefAttribute.getNodeValue())); } else if (fileRefAttribute != null && fileRefAttribute.getNodeValue() != null) { final String fileRefValue = fileRefAttribute.getNodeValue(); if (BuilderConstants.IMAGE_FILE_REF_PATTERN.matcher(fileRefValue).matches()) { if (fileRefValue.startsWith("./images/")) { fileRefAttribute.setNodeValue(fileRefValue.substring(2)); } else if (!fileRefValue.startsWith("images/")) { fileRefAttribute.setNodeValue("images/" + fileRefValue); } buildData.getImageLocations().add(new TopicImageData(topic, fileRefAttribute.getNodeValue())); } else if (!BuilderConstants.COMMON_CONTENT_FILE_REF_PATTERN.matcher(fileRefValue).matches()) { // The file isn't common content or a pressgang image so mark it as a missing image. fileRefAttribute.setNodeValue("images/" + BuilderConstants.FAILPENGUIN_PNG_NAME + ".jpg"); buildData.getImageLocations().add(new TopicImageData(topic, fileRefAttribute.getNodeValue())); } } } } } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "processImageLocations", "(", "final", "BuildData", "buildData", ")", "{", "final", "List", "<", "Integer", ">", "topicIds", "=", "buildData", ".", "getBuildDatabase", "(", ")", ".", "getTopicIds", "(", ")", ";", "for", "(", "final", "Integer", "topicId", ":", "topicIds", ")", "{", "final", "ITopicNode", "topicNode", "=", "buildData", ".", "getBuildDatabase", "(", ")", ".", "getTopicNodesForTopicID", "(", "topicId", ")", ".", "get", "(", "0", ")", ";", "final", "BaseTopicWrapper", "<", "?", ">", "topic", "=", "topicNode", ".", "getTopic", "(", ")", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "log", ".", "debug", "(", "\"\\tProcessing SpecTopic \"", "+", "topicNode", ".", "getId", "(", ")", "+", "(", "topicNode", ".", "getRevision", "(", ")", "!=", "null", "?", "(", "\", \"", "+", "\"Revision \"", "+", "topicNode", ".", "getRevision", "(", ")", ")", ":", "\"\"", ")", ")", ";", "/*\n * Images have to be in the image folder in Publican. Here we loop through all the imagedata elements and fix up any\n * reference to an image that is not in the images folder.\n */", "final", "List", "<", "Node", ">", "images", "=", "XMLUtilities", ".", "getChildNodes", "(", "topicNode", ".", "getXMLDocument", "(", ")", ",", "\"imagedata\"", ",", "\"inlinegraphic\"", ")", ";", "for", "(", "final", "Node", "imageNode", ":", "images", ")", "{", "final", "NamedNodeMap", "attributes", "=", "imageNode", ".", "getAttributes", "(", ")", ";", "if", "(", "attributes", "!=", "null", ")", "{", "final", "Node", "fileRefAttribute", "=", "attributes", ".", "getNamedItem", "(", "\"fileref\"", ")", ";", "if", "(", "fileRefAttribute", "!=", "null", "&&", "(", "fileRefAttribute", ".", "getNodeValue", "(", ")", "==", "null", "||", "fileRefAttribute", ".", "getNodeValue", "(", ")", ".", "isEmpty", "(", ")", ")", ")", "{", "fileRefAttribute", ".", "setNodeValue", "(", "\"images/\"", "+", "BuilderConstants", ".", "FAILPENGUIN_PNG_NAME", "+", "\".jpg\"", ")", ";", "buildData", ".", "getImageLocations", "(", ")", ".", "add", "(", "new", "TopicImageData", "(", "topic", ",", "fileRefAttribute", ".", "getNodeValue", "(", ")", ")", ")", ";", "}", "else", "if", "(", "fileRefAttribute", "!=", "null", "&&", "fileRefAttribute", ".", "getNodeValue", "(", ")", "!=", "null", ")", "{", "final", "String", "fileRefValue", "=", "fileRefAttribute", ".", "getNodeValue", "(", ")", ";", "if", "(", "BuilderConstants", ".", "IMAGE_FILE_REF_PATTERN", ".", "matcher", "(", "fileRefValue", ")", ".", "matches", "(", ")", ")", "{", "if", "(", "fileRefValue", ".", "startsWith", "(", "\"./images/\"", ")", ")", "{", "fileRefAttribute", ".", "setNodeValue", "(", "fileRefValue", ".", "substring", "(", "2", ")", ")", ";", "}", "else", "if", "(", "!", "fileRefValue", ".", "startsWith", "(", "\"images/\"", ")", ")", "{", "fileRefAttribute", ".", "setNodeValue", "(", "\"images/\"", "+", "fileRefValue", ")", ";", "}", "buildData", ".", "getImageLocations", "(", ")", ".", "add", "(", "new", "TopicImageData", "(", "topic", ",", "fileRefAttribute", ".", "getNodeValue", "(", ")", ")", ")", ";", "}", "else", "if", "(", "!", "BuilderConstants", ".", "COMMON_CONTENT_FILE_REF_PATTERN", ".", "matcher", "(", "fileRefValue", ")", ".", "matches", "(", ")", ")", "{", "// The file isn't common content or a pressgang image so mark it as a missing image.", "fileRefAttribute", ".", "setNodeValue", "(", "\"images/\"", "+", "BuilderConstants", ".", "FAILPENGUIN_PNG_NAME", "+", "\".jpg\"", ")", ";", "buildData", ".", "getImageLocations", "(", ")", ".", "add", "(", "new", "TopicImageData", "(", "topic", ",", "fileRefAttribute", ".", "getNodeValue", "(", ")", ")", ")", ";", "}", "}", "}", "}", "}", "}" ]
Processes the Topics in the BuildDatabase and builds up the images found within the topics XML. If the image reference is blank or invalid it is replaced by the fail penguin image. @param buildData Information and data structures for the build.
[ "Processes", "the", "Topics", "in", "the", "BuildDatabase", "and", "builds", "up", "the", "images", "found", "within", "the", "topics", "XML", ".", "If", "the", "image", "reference", "is", "blank", "or", "invalid", "it", "is", "replaced", "by", "the", "fail", "penguin", "image", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L3650-L3694
152,037
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.processTopicSectionInfo
protected void processTopicSectionInfo(final BuildData buildData, final BaseTopicWrapper<?> topic, final Document doc) { if (doc == null || topic == null) return; final String infoName; if (buildData.getDocBookVersion() == DocBookVersion.DOCBOOK_50) { infoName = "info"; } else { infoName = DocBookUtilities.TOPIC_ROOT_SECTIONINFO_NODE_NAME; } final CollectionWrapper<TagWrapper> tags = topic.getTags(); final List<Integer> seoCategoryIds = buildData.getServerSettings().getSEOCategoryIds(); if (seoCategoryIds != null && !seoCategoryIds.isEmpty() && tags != null && tags.getItems() != null && tags.getItems().size() > 0) { // Find the sectioninfo node in the document, or create one if it doesn't exist final Element sectionInfo; final List<Node> sectionInfoNodes = XMLUtilities.getDirectChildNodes(doc.getDocumentElement(), infoName); if (sectionInfoNodes.size() == 1) { sectionInfo = (Element) sectionInfoNodes.get(0); } else { sectionInfo = doc.createElement(infoName); } // Build up the keywordset final Element keywordSet = doc.createElement("keywordset"); final List<TagWrapper> tagItems = tags.getItems(); for (final TagWrapper tag : tagItems) { if (tag.getName() == null || tag.getName().isEmpty()) continue; if (tag.containedInCategories(seoCategoryIds)) { final Element keyword = doc.createElement("keyword"); keyword.setTextContent(tag.getName()); keywordSet.appendChild(keyword); } } // Only update the section info if we've added data if (keywordSet.hasChildNodes()) { sectionInfo.appendChild(keywordSet); DocBookUtilities.setInfo(buildData.getDocBookVersion(), sectionInfo, doc.getDocumentElement()); } } }
java
protected void processTopicSectionInfo(final BuildData buildData, final BaseTopicWrapper<?> topic, final Document doc) { if (doc == null || topic == null) return; final String infoName; if (buildData.getDocBookVersion() == DocBookVersion.DOCBOOK_50) { infoName = "info"; } else { infoName = DocBookUtilities.TOPIC_ROOT_SECTIONINFO_NODE_NAME; } final CollectionWrapper<TagWrapper> tags = topic.getTags(); final List<Integer> seoCategoryIds = buildData.getServerSettings().getSEOCategoryIds(); if (seoCategoryIds != null && !seoCategoryIds.isEmpty() && tags != null && tags.getItems() != null && tags.getItems().size() > 0) { // Find the sectioninfo node in the document, or create one if it doesn't exist final Element sectionInfo; final List<Node> sectionInfoNodes = XMLUtilities.getDirectChildNodes(doc.getDocumentElement(), infoName); if (sectionInfoNodes.size() == 1) { sectionInfo = (Element) sectionInfoNodes.get(0); } else { sectionInfo = doc.createElement(infoName); } // Build up the keywordset final Element keywordSet = doc.createElement("keywordset"); final List<TagWrapper> tagItems = tags.getItems(); for (final TagWrapper tag : tagItems) { if (tag.getName() == null || tag.getName().isEmpty()) continue; if (tag.containedInCategories(seoCategoryIds)) { final Element keyword = doc.createElement("keyword"); keyword.setTextContent(tag.getName()); keywordSet.appendChild(keyword); } } // Only update the section info if we've added data if (keywordSet.hasChildNodes()) { sectionInfo.appendChild(keywordSet); DocBookUtilities.setInfo(buildData.getDocBookVersion(), sectionInfo, doc.getDocumentElement()); } } }
[ "protected", "void", "processTopicSectionInfo", "(", "final", "BuildData", "buildData", ",", "final", "BaseTopicWrapper", "<", "?", ">", "topic", ",", "final", "Document", "doc", ")", "{", "if", "(", "doc", "==", "null", "||", "topic", "==", "null", ")", "return", ";", "final", "String", "infoName", ";", "if", "(", "buildData", ".", "getDocBookVersion", "(", ")", "==", "DocBookVersion", ".", "DOCBOOK_50", ")", "{", "infoName", "=", "\"info\"", ";", "}", "else", "{", "infoName", "=", "DocBookUtilities", ".", "TOPIC_ROOT_SECTIONINFO_NODE_NAME", ";", "}", "final", "CollectionWrapper", "<", "TagWrapper", ">", "tags", "=", "topic", ".", "getTags", "(", ")", ";", "final", "List", "<", "Integer", ">", "seoCategoryIds", "=", "buildData", ".", "getServerSettings", "(", ")", ".", "getSEOCategoryIds", "(", ")", ";", "if", "(", "seoCategoryIds", "!=", "null", "&&", "!", "seoCategoryIds", ".", "isEmpty", "(", ")", "&&", "tags", "!=", "null", "&&", "tags", ".", "getItems", "(", ")", "!=", "null", "&&", "tags", ".", "getItems", "(", ")", ".", "size", "(", ")", ">", "0", ")", "{", "// Find the sectioninfo node in the document, or create one if it doesn't exist", "final", "Element", "sectionInfo", ";", "final", "List", "<", "Node", ">", "sectionInfoNodes", "=", "XMLUtilities", ".", "getDirectChildNodes", "(", "doc", ".", "getDocumentElement", "(", ")", ",", "infoName", ")", ";", "if", "(", "sectionInfoNodes", ".", "size", "(", ")", "==", "1", ")", "{", "sectionInfo", "=", "(", "Element", ")", "sectionInfoNodes", ".", "get", "(", "0", ")", ";", "}", "else", "{", "sectionInfo", "=", "doc", ".", "createElement", "(", "infoName", ")", ";", "}", "// Build up the keywordset", "final", "Element", "keywordSet", "=", "doc", ".", "createElement", "(", "\"keywordset\"", ")", ";", "final", "List", "<", "TagWrapper", ">", "tagItems", "=", "tags", ".", "getItems", "(", ")", ";", "for", "(", "final", "TagWrapper", "tag", ":", "tagItems", ")", "{", "if", "(", "tag", ".", "getName", "(", ")", "==", "null", "||", "tag", ".", "getName", "(", ")", ".", "isEmpty", "(", ")", ")", "continue", ";", "if", "(", "tag", ".", "containedInCategories", "(", "seoCategoryIds", ")", ")", "{", "final", "Element", "keyword", "=", "doc", ".", "createElement", "(", "\"keyword\"", ")", ";", "keyword", ".", "setTextContent", "(", "tag", ".", "getName", "(", ")", ")", ";", "keywordSet", ".", "appendChild", "(", "keyword", ")", ";", "}", "}", "// Only update the section info if we've added data", "if", "(", "keywordSet", ".", "hasChildNodes", "(", ")", ")", "{", "sectionInfo", ".", "appendChild", "(", "keywordSet", ")", ";", "DocBookUtilities", ".", "setInfo", "(", "buildData", ".", "getDocBookVersion", "(", ")", ",", "sectionInfo", ",", "doc", ".", "getDocumentElement", "(", ")", ")", ";", "}", "}", "}" ]
Process a topic and add the section info information. This information consists of the keywordset information. The keywords are populated using the tags assigned to the topic. @param buildData Information and data structures for the build. @param topic The Topic to create the sectioninfo for. @param doc The XML Document DOM object for the topics XML.
[ "Process", "a", "topic", "and", "add", "the", "section", "info", "information", ".", "This", "information", "consists", "of", "the", "keywordset", "information", ".", "The", "keywords", "are", "populated", "using", "the", "tags", "assigned", "to", "the", "topic", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L3806-L3851
152,038
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.doFixedURLsPass
protected boolean doFixedURLsPass(final BuildData buildData) throws BuildProcessingException { log.info("Doing Fixed URL Pass"); final Set<String> processedFileNames = new HashSet<String>(); final Set<SpecNode> nodesWithoutFixedUrls = new HashSet<SpecNode>(); boolean success = true; try { // Collect any current fixed urls or nodes that need configuring FixedURLGenerator.collectFixedUrlInformation(buildData.getBuildDatabase().getAllSpecNodes(), nodesWithoutFixedUrls, processedFileNames); // Warn the user about using temporary fixed urls if (!nodesWithoutFixedUrls.isEmpty()) { log.info("\tUsing " + nodesWithoutFixedUrls.size() + " temporary Fixed URLs"); } // Generate the fixed urls for the missing nodes FixedURLGenerator.generateFixedUrlForNodes(nodesWithoutFixedUrls, processedFileNames, buildData.getServerEntities().getFixedUrlPropertyTagId()); } catch (Exception e) { success = false; log.debug("", e); throw new BuildProcessingException( "Failed to update the Fixed URLs. Please try again and if the issue persists please log a bug."); } return success; }
java
protected boolean doFixedURLsPass(final BuildData buildData) throws BuildProcessingException { log.info("Doing Fixed URL Pass"); final Set<String> processedFileNames = new HashSet<String>(); final Set<SpecNode> nodesWithoutFixedUrls = new HashSet<SpecNode>(); boolean success = true; try { // Collect any current fixed urls or nodes that need configuring FixedURLGenerator.collectFixedUrlInformation(buildData.getBuildDatabase().getAllSpecNodes(), nodesWithoutFixedUrls, processedFileNames); // Warn the user about using temporary fixed urls if (!nodesWithoutFixedUrls.isEmpty()) { log.info("\tUsing " + nodesWithoutFixedUrls.size() + " temporary Fixed URLs"); } // Generate the fixed urls for the missing nodes FixedURLGenerator.generateFixedUrlForNodes(nodesWithoutFixedUrls, processedFileNames, buildData.getServerEntities().getFixedUrlPropertyTagId()); } catch (Exception e) { success = false; log.debug("", e); throw new BuildProcessingException( "Failed to update the Fixed URLs. Please try again and if the issue persists please log a bug."); } return success; }
[ "protected", "boolean", "doFixedURLsPass", "(", "final", "BuildData", "buildData", ")", "throws", "BuildProcessingException", "{", "log", ".", "info", "(", "\"Doing Fixed URL Pass\"", ")", ";", "final", "Set", "<", "String", ">", "processedFileNames", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "final", "Set", "<", "SpecNode", ">", "nodesWithoutFixedUrls", "=", "new", "HashSet", "<", "SpecNode", ">", "(", ")", ";", "boolean", "success", "=", "true", ";", "try", "{", "// Collect any current fixed urls or nodes that need configuring", "FixedURLGenerator", ".", "collectFixedUrlInformation", "(", "buildData", ".", "getBuildDatabase", "(", ")", ".", "getAllSpecNodes", "(", ")", ",", "nodesWithoutFixedUrls", ",", "processedFileNames", ")", ";", "// Warn the user about using temporary fixed urls", "if", "(", "!", "nodesWithoutFixedUrls", ".", "isEmpty", "(", ")", ")", "{", "log", ".", "info", "(", "\"\\tUsing \"", "+", "nodesWithoutFixedUrls", ".", "size", "(", ")", "+", "\" temporary Fixed URLs\"", ")", ";", "}", "// Generate the fixed urls for the missing nodes", "FixedURLGenerator", ".", "generateFixedUrlForNodes", "(", "nodesWithoutFixedUrls", ",", "processedFileNames", ",", "buildData", ".", "getServerEntities", "(", ")", ".", "getFixedUrlPropertyTagId", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "success", "=", "false", ";", "log", ".", "debug", "(", "\"\"", ",", "e", ")", ";", "throw", "new", "BuildProcessingException", "(", "\"Failed to update the Fixed URLs. Please try again and if the issue persists please log a bug.\"", ")", ";", "}", "return", "success", ";", "}" ]
This method does a pass over all the spec nodes and attempts to create unique Fixed URL if one does not already exist. @param buildData Information and data structures for the build. @return True if the fixed url property tags were able to be created, and false otherwise.
[ "This", "method", "does", "a", "pass", "over", "all", "the", "spec", "nodes", "and", "attempts", "to", "create", "unique", "Fixed", "URL", "if", "one", "does", "not", "already", "exist", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L3860-L3888
152,039
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java
DocBookBuilder.addAdditionalFilesToBook
protected void addAdditionalFilesToBook(final BuildData buildData) throws BuildProcessingException { final FileProvider fileProvider = providerFactory.getProvider(FileProvider.class); final ContentSpec contentSpec = buildData.getContentSpec(); if (contentSpec.getFiles() != null) { log.info("\tDownloading Additional Files"); for (final org.jboss.pressgang.ccms.contentspec.File file : contentSpec.getFiles()) { try { final FileWrapper fileEntity = fileProvider.getFile(file.getId(), file.getRevision()); // Find the file that matches this locale. If the locale isn't found then use the default locale LanguageFileWrapper languageFileFile = null; if (fileEntity.getLanguageFiles() != null && fileEntity.getLanguageFiles().getItems() != null) { final List<LanguageFileWrapper> languageFiles = fileEntity.getLanguageFiles().getItems(); for (final LanguageFileWrapper languageFile : languageFiles) { if (languageFile.getLocale().getValue().equals(buildData.getBuildLocale())) { languageFileFile = languageFile; } else if (languageFile.getLocale().getValue().equals(buildData.getDefaultLocale()) && languageFileFile == null) { languageFileFile = languageFile; } } } if (languageFileFile != null && languageFileFile.getFileData() != null) { // Determine the file path final String filePath; if (!isNullOrEmpty(fileEntity.getFilePath())) { if (fileEntity.getFilePath().endsWith("/") || fileEntity.getFilePath().endsWith("\\")) { filePath = fileEntity.getFilePath(); } else { filePath = fileEntity.getFilePath() + "/"; } } else { filePath = ""; } // Explode the ZIP archive if requested if (fileEntity.isExplodeArchive()) { try { final Map<String, byte[]> files = ZipUtilities.unzipFile(languageFileFile.getFileData(), false); for (final Entry<String, byte[]> entry : files.entrySet()) { addToZip(buildData.getBookFilesFolder() + filePath + entry.getKey(), entry.getValue(), buildData); } } catch (IOException e) { throw new BuildProcessingException(e); } } else { addToZip(buildData.getBookFilesFolder() + filePath + fileEntity.getFilename(), languageFileFile.getFileData(), buildData); } } else { throw new BuildProcessingException("File ID " + fileEntity.getId() + " has no language files!"); } } catch (NotFoundException e) { throw new BuildProcessingException("File ID " + file.getId() + " could not be found!"); } } } }
java
protected void addAdditionalFilesToBook(final BuildData buildData) throws BuildProcessingException { final FileProvider fileProvider = providerFactory.getProvider(FileProvider.class); final ContentSpec contentSpec = buildData.getContentSpec(); if (contentSpec.getFiles() != null) { log.info("\tDownloading Additional Files"); for (final org.jboss.pressgang.ccms.contentspec.File file : contentSpec.getFiles()) { try { final FileWrapper fileEntity = fileProvider.getFile(file.getId(), file.getRevision()); // Find the file that matches this locale. If the locale isn't found then use the default locale LanguageFileWrapper languageFileFile = null; if (fileEntity.getLanguageFiles() != null && fileEntity.getLanguageFiles().getItems() != null) { final List<LanguageFileWrapper> languageFiles = fileEntity.getLanguageFiles().getItems(); for (final LanguageFileWrapper languageFile : languageFiles) { if (languageFile.getLocale().getValue().equals(buildData.getBuildLocale())) { languageFileFile = languageFile; } else if (languageFile.getLocale().getValue().equals(buildData.getDefaultLocale()) && languageFileFile == null) { languageFileFile = languageFile; } } } if (languageFileFile != null && languageFileFile.getFileData() != null) { // Determine the file path final String filePath; if (!isNullOrEmpty(fileEntity.getFilePath())) { if (fileEntity.getFilePath().endsWith("/") || fileEntity.getFilePath().endsWith("\\")) { filePath = fileEntity.getFilePath(); } else { filePath = fileEntity.getFilePath() + "/"; } } else { filePath = ""; } // Explode the ZIP archive if requested if (fileEntity.isExplodeArchive()) { try { final Map<String, byte[]> files = ZipUtilities.unzipFile(languageFileFile.getFileData(), false); for (final Entry<String, byte[]> entry : files.entrySet()) { addToZip(buildData.getBookFilesFolder() + filePath + entry.getKey(), entry.getValue(), buildData); } } catch (IOException e) { throw new BuildProcessingException(e); } } else { addToZip(buildData.getBookFilesFolder() + filePath + fileEntity.getFilename(), languageFileFile.getFileData(), buildData); } } else { throw new BuildProcessingException("File ID " + fileEntity.getId() + " has no language files!"); } } catch (NotFoundException e) { throw new BuildProcessingException("File ID " + file.getId() + " could not be found!"); } } } }
[ "protected", "void", "addAdditionalFilesToBook", "(", "final", "BuildData", "buildData", ")", "throws", "BuildProcessingException", "{", "final", "FileProvider", "fileProvider", "=", "providerFactory", ".", "getProvider", "(", "FileProvider", ".", "class", ")", ";", "final", "ContentSpec", "contentSpec", "=", "buildData", ".", "getContentSpec", "(", ")", ";", "if", "(", "contentSpec", ".", "getFiles", "(", ")", "!=", "null", ")", "{", "log", ".", "info", "(", "\"\\tDownloading Additional Files\"", ")", ";", "for", "(", "final", "org", ".", "jboss", ".", "pressgang", ".", "ccms", ".", "contentspec", ".", "File", "file", ":", "contentSpec", ".", "getFiles", "(", ")", ")", "{", "try", "{", "final", "FileWrapper", "fileEntity", "=", "fileProvider", ".", "getFile", "(", "file", ".", "getId", "(", ")", ",", "file", ".", "getRevision", "(", ")", ")", ";", "// Find the file that matches this locale. If the locale isn't found then use the default locale", "LanguageFileWrapper", "languageFileFile", "=", "null", ";", "if", "(", "fileEntity", ".", "getLanguageFiles", "(", ")", "!=", "null", "&&", "fileEntity", ".", "getLanguageFiles", "(", ")", ".", "getItems", "(", ")", "!=", "null", ")", "{", "final", "List", "<", "LanguageFileWrapper", ">", "languageFiles", "=", "fileEntity", ".", "getLanguageFiles", "(", ")", ".", "getItems", "(", ")", ";", "for", "(", "final", "LanguageFileWrapper", "languageFile", ":", "languageFiles", ")", "{", "if", "(", "languageFile", ".", "getLocale", "(", ")", ".", "getValue", "(", ")", ".", "equals", "(", "buildData", ".", "getBuildLocale", "(", ")", ")", ")", "{", "languageFileFile", "=", "languageFile", ";", "}", "else", "if", "(", "languageFile", ".", "getLocale", "(", ")", ".", "getValue", "(", ")", ".", "equals", "(", "buildData", ".", "getDefaultLocale", "(", ")", ")", "&&", "languageFileFile", "==", "null", ")", "{", "languageFileFile", "=", "languageFile", ";", "}", "}", "}", "if", "(", "languageFileFile", "!=", "null", "&&", "languageFileFile", ".", "getFileData", "(", ")", "!=", "null", ")", "{", "// Determine the file path", "final", "String", "filePath", ";", "if", "(", "!", "isNullOrEmpty", "(", "fileEntity", ".", "getFilePath", "(", ")", ")", ")", "{", "if", "(", "fileEntity", ".", "getFilePath", "(", ")", ".", "endsWith", "(", "\"/\"", ")", "||", "fileEntity", ".", "getFilePath", "(", ")", ".", "endsWith", "(", "\"\\\\\"", ")", ")", "{", "filePath", "=", "fileEntity", ".", "getFilePath", "(", ")", ";", "}", "else", "{", "filePath", "=", "fileEntity", ".", "getFilePath", "(", ")", "+", "\"/\"", ";", "}", "}", "else", "{", "filePath", "=", "\"\"", ";", "}", "// Explode the ZIP archive if requested", "if", "(", "fileEntity", ".", "isExplodeArchive", "(", ")", ")", "{", "try", "{", "final", "Map", "<", "String", ",", "byte", "[", "]", ">", "files", "=", "ZipUtilities", ".", "unzipFile", "(", "languageFileFile", ".", "getFileData", "(", ")", ",", "false", ")", ";", "for", "(", "final", "Entry", "<", "String", ",", "byte", "[", "]", ">", "entry", ":", "files", ".", "entrySet", "(", ")", ")", "{", "addToZip", "(", "buildData", ".", "getBookFilesFolder", "(", ")", "+", "filePath", "+", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ",", "buildData", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "BuildProcessingException", "(", "e", ")", ";", "}", "}", "else", "{", "addToZip", "(", "buildData", ".", "getBookFilesFolder", "(", ")", "+", "filePath", "+", "fileEntity", ".", "getFilename", "(", ")", ",", "languageFileFile", ".", "getFileData", "(", ")", ",", "buildData", ")", ";", "}", "}", "else", "{", "throw", "new", "BuildProcessingException", "(", "\"File ID \"", "+", "fileEntity", ".", "getId", "(", ")", "+", "\" has no language files!\"", ")", ";", "}", "}", "catch", "(", "NotFoundException", "e", ")", "{", "throw", "new", "BuildProcessingException", "(", "\"File ID \"", "+", "file", ".", "getId", "(", ")", "+", "\" could not be found!\"", ")", ";", "}", "}", "}", "}" ]
Adds the additional files defined in a content spec to the book. @param buildData Information and data structures for the build.
[ "Adds", "the", "additional", "files", "defined", "in", "a", "content", "spec", "to", "the", "book", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookBuilder.java#L3922-L3981
152,040
FitLayout/tools
src/main/java/org/fit/layout/tools/BlockBrowser.java
BlockBrowser.segmentPage
private void segmentPage() { DefaultContentRect.resetId(); //reset the default ID generator to obtain the same IDs for every segmentation if (segmentatorCombo.getSelectedIndex() != -1) { AreaTreeProvider provider = segmentatorCombo.getItemAt(segmentatorCombo.getSelectedIndex()); proc.segmentPage(provider, null); //the parametres should have been set through the GUI setAreaTree(proc.getAreaTree()); } }
java
private void segmentPage() { DefaultContentRect.resetId(); //reset the default ID generator to obtain the same IDs for every segmentation if (segmentatorCombo.getSelectedIndex() != -1) { AreaTreeProvider provider = segmentatorCombo.getItemAt(segmentatorCombo.getSelectedIndex()); proc.segmentPage(provider, null); //the parametres should have been set through the GUI setAreaTree(proc.getAreaTree()); } }
[ "private", "void", "segmentPage", "(", ")", "{", "DefaultContentRect", ".", "resetId", "(", ")", ";", "//reset the default ID generator to obtain the same IDs for every segmentation", "if", "(", "segmentatorCombo", ".", "getSelectedIndex", "(", ")", "!=", "-", "1", ")", "{", "AreaTreeProvider", "provider", "=", "segmentatorCombo", ".", "getItemAt", "(", "segmentatorCombo", ".", "getSelectedIndex", "(", ")", ")", ";", "proc", ".", "segmentPage", "(", "provider", ",", "null", ")", ";", "//the parametres should have been set through the GUI", "setAreaTree", "(", "proc", ".", "getAreaTree", "(", ")", ")", ";", "}", "}" ]
Segments the page using the chosen provider and parametres.
[ "Segments", "the", "page", "using", "the", "chosen", "provider", "and", "parametres", "." ]
43a8e3f4ddf21a031d3ab7247b8d37310bda4856
https://github.com/FitLayout/tools/blob/43a8e3f4ddf21a031d3ab7247b8d37310bda4856/src/main/java/org/fit/layout/tools/BlockBrowser.java#L530-L539
152,041
FitLayout/tools
src/main/java/org/fit/layout/tools/BlockBrowser.java
BlockBrowser.buildLogicalTree
private void buildLogicalTree() { if (logicalCombo.getSelectedIndex() != -1) { LogicalTreeProvider provider = logicalCombo.getItemAt(logicalCombo.getSelectedIndex()); proc.buildLogicalTree(provider, null); //the parametres should have been set through the GUI setLogicalTree(proc.getLogicalAreaTree()); } }
java
private void buildLogicalTree() { if (logicalCombo.getSelectedIndex() != -1) { LogicalTreeProvider provider = logicalCombo.getItemAt(logicalCombo.getSelectedIndex()); proc.buildLogicalTree(provider, null); //the parametres should have been set through the GUI setLogicalTree(proc.getLogicalAreaTree()); } }
[ "private", "void", "buildLogicalTree", "(", ")", "{", "if", "(", "logicalCombo", ".", "getSelectedIndex", "(", ")", "!=", "-", "1", ")", "{", "LogicalTreeProvider", "provider", "=", "logicalCombo", ".", "getItemAt", "(", "logicalCombo", ".", "getSelectedIndex", "(", ")", ")", ";", "proc", ".", "buildLogicalTree", "(", "provider", ",", "null", ")", ";", "//the parametres should have been set through the GUI", "setLogicalTree", "(", "proc", ".", "getLogicalAreaTree", "(", ")", ")", ";", "}", "}" ]
Builds the logical tree the chosen provider and parametres.
[ "Builds", "the", "logical", "tree", "the", "chosen", "provider", "and", "parametres", "." ]
43a8e3f4ddf21a031d3ab7247b8d37310bda4856
https://github.com/FitLayout/tools/blob/43a8e3f4ddf21a031d3ab7247b8d37310bda4856/src/main/java/org/fit/layout/tools/BlockBrowser.java#L544-L552
152,042
FitLayout/tools
src/main/java/org/fit/layout/tools/BlockBrowser.java
BlockBrowser.createContentCanvas
private JPanel createContentCanvas() { if (contentCanvas != null) { contentCanvas = new BrowserPanel(proc.getPage()); contentCanvas.setLayout(null); selection = new Selection(); contentCanvas.add(selection); selection.setVisible(false); selection.setLocation(0, 0); } return contentCanvas; }
java
private JPanel createContentCanvas() { if (contentCanvas != null) { contentCanvas = new BrowserPanel(proc.getPage()); contentCanvas.setLayout(null); selection = new Selection(); contentCanvas.add(selection); selection.setVisible(false); selection.setLocation(0, 0); } return contentCanvas; }
[ "private", "JPanel", "createContentCanvas", "(", ")", "{", "if", "(", "contentCanvas", "!=", "null", ")", "{", "contentCanvas", "=", "new", "BrowserPanel", "(", "proc", ".", "getPage", "(", ")", ")", ";", "contentCanvas", ".", "setLayout", "(", "null", ")", ";", "selection", "=", "new", "Selection", "(", ")", ";", "contentCanvas", ".", "add", "(", "selection", ")", ";", "selection", ".", "setVisible", "(", "false", ")", ";", "selection", ".", "setLocation", "(", "0", ",", "0", ")", ";", "}", "return", "contentCanvas", ";", "}" ]
Creates the appropriate canvas based on the file type
[ "Creates", "the", "appropriate", "canvas", "based", "on", "the", "file", "type" ]
43a8e3f4ddf21a031d3ab7247b8d37310bda4856
https://github.com/FitLayout/tools/blob/43a8e3f4ddf21a031d3ab7247b8d37310bda4856/src/main/java/org/fit/layout/tools/BlockBrowser.java#L556-L568
152,043
FitLayout/tools
src/main/java/org/fit/layout/tools/BlockBrowser.java
BlockBrowser.canvasClick
private void canvasClick(int x, int y) { //always called listeners for (CanvasClickListener listener : canvasClickAlwaysListeners) listener.canvasClicked(x, y); //selected listener by toggle buttons for (JToggleButton button : canvasClickToggleListeners.keySet()) { if (button.isSelected()) canvasClickToggleListeners.get(button).canvasClicked(x, y); } /*if (lookupButton.isSelected()) { if (proc.getAreaTree() != null) { Area node = proc.getAreaTree().getAreaAt(x, y); if (node != null) { showAreaInTree(node); showAreaInLogicalTree(node); } } //lookupButton.setSelected(false); } if (boxLookupButton.isSelected()) { Box node = proc.getPage().getBoxAt(x, y); if (node != null) showBoxInTree(node); //boxLookupButton.setSelected(false); } if (sepLookupButton.isSelected()) { showSeparatorAt(x, y); } if (extractButton.isSelected()) { AreaNode node = proc.getAreaTree().getAreaAt(x, y); if (node != null) { proc.getExtractor().findArticleBounds(node); try { PrintStream exs = new PrintStream(new FileOutputStream("test/extract.html")); proc.getExtractor().dumpTo(exs); exs.close(); } catch (java.io.IOException e) { System.err.println("Output failed: " + e.getMessage()); } //String s = ex.getDescriptionX(node, 2); //System.out.println("Extracted: " + s); } extractButton.setSelected(false); }*/ }
java
private void canvasClick(int x, int y) { //always called listeners for (CanvasClickListener listener : canvasClickAlwaysListeners) listener.canvasClicked(x, y); //selected listener by toggle buttons for (JToggleButton button : canvasClickToggleListeners.keySet()) { if (button.isSelected()) canvasClickToggleListeners.get(button).canvasClicked(x, y); } /*if (lookupButton.isSelected()) { if (proc.getAreaTree() != null) { Area node = proc.getAreaTree().getAreaAt(x, y); if (node != null) { showAreaInTree(node); showAreaInLogicalTree(node); } } //lookupButton.setSelected(false); } if (boxLookupButton.isSelected()) { Box node = proc.getPage().getBoxAt(x, y); if (node != null) showBoxInTree(node); //boxLookupButton.setSelected(false); } if (sepLookupButton.isSelected()) { showSeparatorAt(x, y); } if (extractButton.isSelected()) { AreaNode node = proc.getAreaTree().getAreaAt(x, y); if (node != null) { proc.getExtractor().findArticleBounds(node); try { PrintStream exs = new PrintStream(new FileOutputStream("test/extract.html")); proc.getExtractor().dumpTo(exs); exs.close(); } catch (java.io.IOException e) { System.err.println("Output failed: " + e.getMessage()); } //String s = ex.getDescriptionX(node, 2); //System.out.println("Extracted: " + s); } extractButton.setSelected(false); }*/ }
[ "private", "void", "canvasClick", "(", "int", "x", ",", "int", "y", ")", "{", "//always called listeners", "for", "(", "CanvasClickListener", "listener", ":", "canvasClickAlwaysListeners", ")", "listener", ".", "canvasClicked", "(", "x", ",", "y", ")", ";", "//selected listener by toggle buttons", "for", "(", "JToggleButton", "button", ":", "canvasClickToggleListeners", ".", "keySet", "(", ")", ")", "{", "if", "(", "button", ".", "isSelected", "(", ")", ")", "canvasClickToggleListeners", ".", "get", "(", "button", ")", ".", "canvasClicked", "(", "x", ",", "y", ")", ";", "}", "/*if (lookupButton.isSelected())\n {\n if (proc.getAreaTree() != null)\n {\n Area node = proc.getAreaTree().getAreaAt(x, y);\n if (node != null)\n {\n showAreaInTree(node);\n showAreaInLogicalTree(node);\n }\n }\n //lookupButton.setSelected(false);\n }\n if (boxLookupButton.isSelected())\n {\n Box node = proc.getPage().getBoxAt(x, y);\n if (node != null)\n showBoxInTree(node);\n //boxLookupButton.setSelected(false);\n }\n if (sepLookupButton.isSelected())\n {\n showSeparatorAt(x, y);\n }\n if (extractButton.isSelected())\n {\n AreaNode node = proc.getAreaTree().getAreaAt(x, y);\n if (node != null)\n {\n proc.getExtractor().findArticleBounds(node);\n try {\n PrintStream exs = new PrintStream(new FileOutputStream(\"test/extract.html\"));\n proc.getExtractor().dumpTo(exs);\n exs.close();\n } catch (java.io.IOException e) {\n System.err.println(\"Output failed: \" + e.getMessage());\n }\n \n //String s = ex.getDescriptionX(node, 2);\n //System.out.println(\"Extracted: \" + s);\n }\n extractButton.setSelected(false);\n }*/", "}" ]
This is called when the browser canvas is clicked
[ "This", "is", "called", "when", "the", "browser", "canvas", "is", "clicked" ]
43a8e3f4ddf21a031d3ab7247b8d37310bda4856
https://github.com/FitLayout/tools/blob/43a8e3f4ddf21a031d3ab7247b8d37310bda4856/src/main/java/org/fit/layout/tools/BlockBrowser.java#L593-L648
152,044
sworisbreathing/sfmf4j
sfmf4j-jpathwatch/src/main/java/com/github/sworisbreathing/sfmf4j/jpathwatch/WatchServiceFileMonitorServiceImpl.java
WatchServiceFileMonitorServiceImpl.cleanup
@SuppressWarnings("PMD.EmptyCatchBlock") private synchronized void cleanup(final WatchKey key) { logger.trace("cleanUp {}", key); try { key.cancel(); }catch(Exception ex) { //trap } Collection<SFMF4JWatchListener> listeners = listenersByWatchKey.remove(key); if (listeners != null && !listeners.isEmpty()) { logger.warn("Cleaning up key but listeners are still registered."); } String path = pathsByWatchKey.remove(key); if (path != null) { watchKeysByPath.remove(path); } }
java
@SuppressWarnings("PMD.EmptyCatchBlock") private synchronized void cleanup(final WatchKey key) { logger.trace("cleanUp {}", key); try { key.cancel(); }catch(Exception ex) { //trap } Collection<SFMF4JWatchListener> listeners = listenersByWatchKey.remove(key); if (listeners != null && !listeners.isEmpty()) { logger.warn("Cleaning up key but listeners are still registered."); } String path = pathsByWatchKey.remove(key); if (path != null) { watchKeysByPath.remove(path); } }
[ "@", "SuppressWarnings", "(", "\"PMD.EmptyCatchBlock\"", ")", "private", "synchronized", "void", "cleanup", "(", "final", "WatchKey", "key", ")", "{", "logger", ".", "trace", "(", "\"cleanUp {}\"", ",", "key", ")", ";", "try", "{", "key", ".", "cancel", "(", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "//trap", "}", "Collection", "<", "SFMF4JWatchListener", ">", "listeners", "=", "listenersByWatchKey", ".", "remove", "(", "key", ")", ";", "if", "(", "listeners", "!=", "null", "&&", "!", "listeners", ".", "isEmpty", "(", ")", ")", "{", "logger", ".", "warn", "(", "\"Cleaning up key but listeners are still registered.\"", ")", ";", "}", "String", "path", "=", "pathsByWatchKey", ".", "remove", "(", "key", ")", ";", "if", "(", "path", "!=", "null", ")", "{", "watchKeysByPath", ".", "remove", "(", "path", ")", ";", "}", "}" ]
Properly unregisters and removes a watch key. @param key the watch key
[ "Properly", "unregisters", "and", "removes", "a", "watch", "key", "." ]
826c2c02af69d55f98e64fbcfae23d0c7bac3f19
https://github.com/sworisbreathing/sfmf4j/blob/826c2c02af69d55f98e64fbcfae23d0c7bac3f19/sfmf4j-jpathwatch/src/main/java/com/github/sworisbreathing/sfmf4j/jpathwatch/WatchServiceFileMonitorServiceImpl.java#L210-L226
152,045
jkyamog/DeDS
sample_clients/java/src/main/java/nz/net/catalyst/mobile/dds/sample/DDSClient.java
DDSClient.getCapabilities
public static Map<String, String> getCapabilities(HttpServletRequest request, String ddsUrl) throws IOException { URL url; try { url = new URL(ddsUrl + "/get_capabilities?capability=resolution_width&capability=model_name&capability=xhtml_support_level&" + "headers=" + URLEncoder.encode(jsonEncode(getHeadersAsHashMap(request)), "UTF-8")); } catch (MalformedURLException e) { throw new IOException(e); } String httpResponse = fetchHttpResponse(url); return jsonDecode(httpResponse, new TypeReference<Map<String, String>>() { }); }
java
public static Map<String, String> getCapabilities(HttpServletRequest request, String ddsUrl) throws IOException { URL url; try { url = new URL(ddsUrl + "/get_capabilities?capability=resolution_width&capability=model_name&capability=xhtml_support_level&" + "headers=" + URLEncoder.encode(jsonEncode(getHeadersAsHashMap(request)), "UTF-8")); } catch (MalformedURLException e) { throw new IOException(e); } String httpResponse = fetchHttpResponse(url); return jsonDecode(httpResponse, new TypeReference<Map<String, String>>() { }); }
[ "public", "static", "Map", "<", "String", ",", "String", ">", "getCapabilities", "(", "HttpServletRequest", "request", ",", "String", "ddsUrl", ")", "throws", "IOException", "{", "URL", "url", ";", "try", "{", "url", "=", "new", "URL", "(", "ddsUrl", "+", "\"/get_capabilities?capability=resolution_width&capability=model_name&capability=xhtml_support_level&\"", "+", "\"headers=\"", "+", "URLEncoder", ".", "encode", "(", "jsonEncode", "(", "getHeadersAsHashMap", "(", "request", ")", ")", ",", "\"UTF-8\"", ")", ")", ";", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "throw", "new", "IOException", "(", "e", ")", ";", "}", "String", "httpResponse", "=", "fetchHttpResponse", "(", "url", ")", ";", "return", "jsonDecode", "(", "httpResponse", ",", "new", "TypeReference", "<", "Map", "<", "String", ",", "String", ">", ">", "(", ")", "{", "}", ")", ";", "}" ]
Get the capabilities as a map of capabilities. There are times that a strict data type is not desirable. Getting it as map provides some flexibility. This does not require any knowledge of what capabilities will be returned by the service. @param request @param ddsUrl @return @throws IOException
[ "Get", "the", "capabilities", "as", "a", "map", "of", "capabilities", ".", "There", "are", "times", "that", "a", "strict", "data", "type", "is", "not", "desirable", ".", "Getting", "it", "as", "map", "provides", "some", "flexibility", ".", "This", "does", "not", "require", "any", "knowledge", "of", "what", "capabilities", "will", "be", "returned", "by", "the", "service", "." ]
d8cf6a294a23daa8e8a92073827c73b1befe3fa1
https://github.com/jkyamog/DeDS/blob/d8cf6a294a23daa8e8a92073827c73b1befe3fa1/sample_clients/java/src/main/java/nz/net/catalyst/mobile/dds/sample/DDSClient.java#L50-L63
152,046
jkyamog/DeDS
sample_clients/java/src/main/java/nz/net/catalyst/mobile/dds/sample/DDSClient.java
DDSClient.fetchHttpResponse
private static String fetchHttpResponse(URL url) throws IOException { HttpURLConnection conn = null; try { logger.info("fetching from url = " + url); conn = (HttpURLConnection) url.openConnection(); int response = conn.getResponseCode(); if (response != HttpURLConnection.HTTP_ACCEPTED) { String responseContent = IOUtils.toString(conn.getInputStream()); logger.info("responseContent = " + responseContent); return responseContent; } throw new IOException("response from service not valid"); } catch (IOException e) { logger.severe("unable to do proper http request url = " + url.toString()); throw e; } finally { conn.disconnect(); } }
java
private static String fetchHttpResponse(URL url) throws IOException { HttpURLConnection conn = null; try { logger.info("fetching from url = " + url); conn = (HttpURLConnection) url.openConnection(); int response = conn.getResponseCode(); if (response != HttpURLConnection.HTTP_ACCEPTED) { String responseContent = IOUtils.toString(conn.getInputStream()); logger.info("responseContent = " + responseContent); return responseContent; } throw new IOException("response from service not valid"); } catch (IOException e) { logger.severe("unable to do proper http request url = " + url.toString()); throw e; } finally { conn.disconnect(); } }
[ "private", "static", "String", "fetchHttpResponse", "(", "URL", "url", ")", "throws", "IOException", "{", "HttpURLConnection", "conn", "=", "null", ";", "try", "{", "logger", ".", "info", "(", "\"fetching from url = \"", "+", "url", ")", ";", "conn", "=", "(", "HttpURLConnection", ")", "url", ".", "openConnection", "(", ")", ";", "int", "response", "=", "conn", ".", "getResponseCode", "(", ")", ";", "if", "(", "response", "!=", "HttpURLConnection", ".", "HTTP_ACCEPTED", ")", "{", "String", "responseContent", "=", "IOUtils", ".", "toString", "(", "conn", ".", "getInputStream", "(", ")", ")", ";", "logger", ".", "info", "(", "\"responseContent = \"", "+", "responseContent", ")", ";", "return", "responseContent", ";", "}", "throw", "new", "IOException", "(", "\"response from service not valid\"", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "logger", ".", "severe", "(", "\"unable to do proper http request url = \"", "+", "url", ".", "toString", "(", ")", ")", ";", "throw", "e", ";", "}", "finally", "{", "conn", ".", "disconnect", "(", ")", ";", "}", "}" ]
convenience method to do a http request on url, and return result as a string @param url @return @throws IOException
[ "convenience", "method", "to", "do", "a", "http", "request", "on", "url", "and", "return", "result", "as", "a", "string" ]
d8cf6a294a23daa8e8a92073827c73b1befe3fa1
https://github.com/jkyamog/DeDS/blob/d8cf6a294a23daa8e8a92073827c73b1befe3fa1/sample_clients/java/src/main/java/nz/net/catalyst/mobile/dds/sample/DDSClient.java#L72-L92
152,047
jkyamog/DeDS
sample_clients/java/src/main/java/nz/net/catalyst/mobile/dds/sample/DDSClient.java
DDSClient.jsonDecode
private static <T> T jsonDecode(String responseContent, TypeReference<T> valueTypeRef) throws IOException { ObjectMapper mapper = new ObjectMapper(); try { return mapper.<T>readValue(responseContent, valueTypeRef); } catch (JsonGenerationException e) { logger.severe("unable decode"); throw new IOException(e); } catch (JsonMappingException e) { logger.severe("unable decode"); throw new IOException(e.getMessage()); } }
java
private static <T> T jsonDecode(String responseContent, TypeReference<T> valueTypeRef) throws IOException { ObjectMapper mapper = new ObjectMapper(); try { return mapper.<T>readValue(responseContent, valueTypeRef); } catch (JsonGenerationException e) { logger.severe("unable decode"); throw new IOException(e); } catch (JsonMappingException e) { logger.severe("unable decode"); throw new IOException(e.getMessage()); } }
[ "private", "static", "<", "T", ">", "T", "jsonDecode", "(", "String", "responseContent", ",", "TypeReference", "<", "T", ">", "valueTypeRef", ")", "throws", "IOException", "{", "ObjectMapper", "mapper", "=", "new", "ObjectMapper", "(", ")", ";", "try", "{", "return", "mapper", ".", "<", "T", ">", "readValue", "(", "responseContent", ",", "valueTypeRef", ")", ";", "}", "catch", "(", "JsonGenerationException", "e", ")", "{", "logger", ".", "severe", "(", "\"unable decode\"", ")", ";", "throw", "new", "IOException", "(", "e", ")", ";", "}", "catch", "(", "JsonMappingException", "e", ")", "{", "logger", ".", "severe", "(", "\"unable decode\"", ")", ";", "throw", "new", "IOException", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}" ]
Given a string and a type ref. Decode the string and return the values. @param <T> @param responseContent @param valueTypeRef @return @throws IOException
[ "Given", "a", "string", "and", "a", "type", "ref", ".", "Decode", "the", "string", "and", "return", "the", "values", "." ]
d8cf6a294a23daa8e8a92073827c73b1befe3fa1
https://github.com/jkyamog/DeDS/blob/d8cf6a294a23daa8e8a92073827c73b1befe3fa1/sample_clients/java/src/main/java/nz/net/catalyst/mobile/dds/sample/DDSClient.java#L103-L116
152,048
jkyamog/DeDS
sample_clients/java/src/main/java/nz/net/catalyst/mobile/dds/sample/DDSClient.java
DDSClient.jsonEncode
private static String jsonEncode(Object object) throws IOException { ObjectMapper mapper = new ObjectMapper(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); try { mapper.writeValue(outputStream, object); return new String(outputStream.toByteArray()); } catch (JsonGenerationException e) { logger.severe("unable encode"); throw new IOException(e); } catch (JsonMappingException e) { logger.severe("unable encode"); throw new IOException(e.getMessage()); } }
java
private static String jsonEncode(Object object) throws IOException { ObjectMapper mapper = new ObjectMapper(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); try { mapper.writeValue(outputStream, object); return new String(outputStream.toByteArray()); } catch (JsonGenerationException e) { logger.severe("unable encode"); throw new IOException(e); } catch (JsonMappingException e) { logger.severe("unable encode"); throw new IOException(e.getMessage()); } }
[ "private", "static", "String", "jsonEncode", "(", "Object", "object", ")", "throws", "IOException", "{", "ObjectMapper", "mapper", "=", "new", "ObjectMapper", "(", ")", ";", "ByteArrayOutputStream", "outputStream", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "try", "{", "mapper", ".", "writeValue", "(", "outputStream", ",", "object", ")", ";", "return", "new", "String", "(", "outputStream", ".", "toByteArray", "(", ")", ")", ";", "}", "catch", "(", "JsonGenerationException", "e", ")", "{", "logger", ".", "severe", "(", "\"unable encode\"", ")", ";", "throw", "new", "IOException", "(", "e", ")", ";", "}", "catch", "(", "JsonMappingException", "e", ")", "{", "logger", ".", "severe", "(", "\"unable encode\"", ")", ";", "throw", "new", "IOException", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}" ]
Encode a java object into a json which is returned as a string @param object @return @throws IOException
[ "Encode", "a", "java", "object", "into", "a", "json", "which", "is", "returned", "as", "a", "string" ]
d8cf6a294a23daa8e8a92073827c73b1befe3fa1
https://github.com/jkyamog/DeDS/blob/d8cf6a294a23daa8e8a92073827c73b1befe3fa1/sample_clients/java/src/main/java/nz/net/catalyst/mobile/dds/sample/DDSClient.java#L126-L141
152,049
jkyamog/DeDS
sample_clients/java/src/main/java/nz/net/catalyst/mobile/dds/sample/DDSClient.java
DDSClient.getHeadersAsHashMap
private static Map<String, String> getHeadersAsHashMap(HttpServletRequest request) { Map<String, String> headers = new HashMap<String, String>(); for (Enumeration<?> h=request.getHeaderNames(); h.hasMoreElements();) { String headerName = (String) h.nextElement(); String headerValue = request.getHeader(headerName); headers.put(headerName.toLowerCase(), headerValue); } return headers; }
java
private static Map<String, String> getHeadersAsHashMap(HttpServletRequest request) { Map<String, String> headers = new HashMap<String, String>(); for (Enumeration<?> h=request.getHeaderNames(); h.hasMoreElements();) { String headerName = (String) h.nextElement(); String headerValue = request.getHeader(headerName); headers.put(headerName.toLowerCase(), headerValue); } return headers; }
[ "private", "static", "Map", "<", "String", ",", "String", ">", "getHeadersAsHashMap", "(", "HttpServletRequest", "request", ")", "{", "Map", "<", "String", ",", "String", ">", "headers", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "for", "(", "Enumeration", "<", "?", ">", "h", "=", "request", ".", "getHeaderNames", "(", ")", ";", "h", ".", "hasMoreElements", "(", ")", ";", ")", "{", "String", "headerName", "=", "(", "String", ")", "h", ".", "nextElement", "(", ")", ";", "String", "headerValue", "=", "request", ".", "getHeader", "(", "headerName", ")", ";", "headers", ".", "put", "(", "headerName", ".", "toLowerCase", "(", ")", ",", "headerValue", ")", ";", "}", "return", "headers", ";", "}" ]
convenience method turn http headers into a hash map @param request @return
[ "convenience", "method", "turn", "http", "headers", "into", "a", "hash", "map" ]
d8cf6a294a23daa8e8a92073827c73b1befe3fa1
https://github.com/jkyamog/DeDS/blob/d8cf6a294a23daa8e8a92073827c73b1befe3fa1/sample_clients/java/src/main/java/nz/net/catalyst/mobile/dds/sample/DDSClient.java#L149-L160
152,050
jbundle/jbundle
base/screen/control/servlet/src/main/java/org/jbundle/base/screen/control/servlet/html/HTMLServlet.java
HTMLServlet.addBrowserProperties
public void addBrowserProperties(HttpServletRequest req, PropertyOwner servletTask) { String strBrowser = this.getBrowser(req); String strOS = this.getOS(req); servletTask.setProperty(DBParams.BROWSER, strBrowser); servletTask.setProperty(DBParams.OS, strOS); }
java
public void addBrowserProperties(HttpServletRequest req, PropertyOwner servletTask) { String strBrowser = this.getBrowser(req); String strOS = this.getOS(req); servletTask.setProperty(DBParams.BROWSER, strBrowser); servletTask.setProperty(DBParams.OS, strOS); }
[ "public", "void", "addBrowserProperties", "(", "HttpServletRequest", "req", ",", "PropertyOwner", "servletTask", ")", "{", "String", "strBrowser", "=", "this", ".", "getBrowser", "(", "req", ")", ";", "String", "strOS", "=", "this", ".", "getOS", "(", "req", ")", ";", "servletTask", ".", "setProperty", "(", "DBParams", ".", "BROWSER", ",", "strBrowser", ")", ";", "servletTask", ".", "setProperty", "(", "DBParams", ".", "OS", ",", "strOS", ")", ";", "}" ]
Add the browser properties to this servlet task. @param req @param servletTask
[ "Add", "the", "browser", "properties", "to", "this", "servlet", "task", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/control/servlet/src/main/java/org/jbundle/base/screen/control/servlet/html/HTMLServlet.java#L154-L160
152,051
isisaddons-legacy/isis-module-settings
dom/src/main/java/org/isisaddons/module/settings/dom/UserSettingRepository.java
UserSettingRepository.newLocalDate
@Programmatic public UserSettingJdo newLocalDate( final String user, final String key, final String description, final LocalDate value) { return newSetting(user, key, description, SettingType.LOCAL_DATE, value.toString(SettingAbstract.DATE_FORMATTER)); }
java
@Programmatic public UserSettingJdo newLocalDate( final String user, final String key, final String description, final LocalDate value) { return newSetting(user, key, description, SettingType.LOCAL_DATE, value.toString(SettingAbstract.DATE_FORMATTER)); }
[ "@", "Programmatic", "public", "UserSettingJdo", "newLocalDate", "(", "final", "String", "user", ",", "final", "String", "key", ",", "final", "String", "description", ",", "final", "LocalDate", "value", ")", "{", "return", "newSetting", "(", "user", ",", "key", ",", "description", ",", "SettingType", ".", "LOCAL_DATE", ",", "value", ".", "toString", "(", "SettingAbstract", ".", "DATE_FORMATTER", ")", ")", ";", "}" ]
region > newLocalDate
[ "region", ">", "newLocalDate" ]
e56c4e4a828b37381e7af7426c1cf1b26739f23e
https://github.com/isisaddons-legacy/isis-module-settings/blob/e56c4e4a828b37381e7af7426c1cf1b26739f23e/dom/src/main/java/org/isisaddons/module/settings/dom/UserSettingRepository.java#L131-L138
152,052
rometools/rome-certiorem
src/main/java/com/rometools/certiorem/hub/notify/standard/UnthreadedNotifier.java
UnthreadedNotifier.enqueueNotification
@Override protected void enqueueNotification(final Notification not) { not.lastRun = System.currentTimeMillis(); final SubscriptionSummary summary = postNotification(not.subscriber, not.mimeType, not.payload); not.callback.onSummaryInfo(summary); }
java
@Override protected void enqueueNotification(final Notification not) { not.lastRun = System.currentTimeMillis(); final SubscriptionSummary summary = postNotification(not.subscriber, not.mimeType, not.payload); not.callback.onSummaryInfo(summary); }
[ "@", "Override", "protected", "void", "enqueueNotification", "(", "final", "Notification", "not", ")", "{", "not", ".", "lastRun", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "final", "SubscriptionSummary", "summary", "=", "postNotification", "(", "not", ".", "subscriber", ",", "not", ".", "mimeType", ",", "not", ".", "payload", ")", ";", "not", ".", "callback", ".", "onSummaryInfo", "(", "summary", ")", ";", "}" ]
A blocking call that performs a notification. If there are pending retries that are older than two minutes old, they will be retried before the method returns. @param not
[ "A", "blocking", "call", "that", "performs", "a", "notification", ".", "If", "there", "are", "pending", "retries", "that", "are", "older", "than", "two", "minutes", "old", "they", "will", "be", "retried", "before", "the", "method", "returns", "." ]
e5a003193dd2abd748e77961c0f216a7f5690712
https://github.com/rometools/rome-certiorem/blob/e5a003193dd2abd748e77961c0f216a7f5690712/src/main/java/com/rometools/certiorem/hub/notify/standard/UnthreadedNotifier.java#L36-L41
152,053
jbundle/jbundle
base/screen/view/xml/src/main/java/org/jbundle/base/screen/view/xml/report/XTechHelpScreen.java
XTechHelpScreen.printHtmlHeaderArea
public void printHtmlHeaderArea(PrintWriter out) { ClassInfoModel classInfo = ((HelpScreen)this.getScreenField()).getClassInfo(); if (classInfo != null) if (classInfo.isValidRecord()) { String strHeader = " <title>Technical Help Screen - " + Utility.encodeXML(classInfo.getClassDesc()) + " </title>" + //+" <meta-keywords>" + Utility.encodeXML(m_classInfo.getField(ClassInfo.KEYWORDS).toString()) + "</meta-keywords>" + " <meta-description>" + Utility.encodeXML(classInfo.getClassExplain()) + "</meta-description>"; out.println(strHeader); } }
java
public void printHtmlHeaderArea(PrintWriter out) { ClassInfoModel classInfo = ((HelpScreen)this.getScreenField()).getClassInfo(); if (classInfo != null) if (classInfo.isValidRecord()) { String strHeader = " <title>Technical Help Screen - " + Utility.encodeXML(classInfo.getClassDesc()) + " </title>" + //+" <meta-keywords>" + Utility.encodeXML(m_classInfo.getField(ClassInfo.KEYWORDS).toString()) + "</meta-keywords>" + " <meta-description>" + Utility.encodeXML(classInfo.getClassExplain()) + "</meta-description>"; out.println(strHeader); } }
[ "public", "void", "printHtmlHeaderArea", "(", "PrintWriter", "out", ")", "{", "ClassInfoModel", "classInfo", "=", "(", "(", "HelpScreen", ")", "this", ".", "getScreenField", "(", ")", ")", ".", "getClassInfo", "(", ")", ";", "if", "(", "classInfo", "!=", "null", ")", "if", "(", "classInfo", ".", "isValidRecord", "(", ")", ")", "{", "String", "strHeader", "=", "\" <title>Technical Help Screen - \"", "+", "Utility", ".", "encodeXML", "(", "classInfo", ".", "getClassDesc", "(", ")", ")", "+", "\" </title>\"", "+", "//+\" <meta-keywords>\" + Utility.encodeXML(m_classInfo.getField(ClassInfo.KEYWORDS).toString()) + \"</meta-keywords>\" +", "\" <meta-description>\"", "+", "Utility", ".", "encodeXML", "(", "classInfo", ".", "getClassExplain", "(", ")", ")", "+", "\"</meta-description>\"", ";", "out", ".", "println", "(", "strHeader", ")", ";", "}", "}" ]
Get the top menu.
[ "Get", "the", "top", "menu", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/view/xml/src/main/java/org/jbundle/base/screen/view/xml/report/XTechHelpScreen.java#L69-L82
152,054
jbundle/jbundle
app/program/demo/src/main/java/org/jbundle/app/program/demo/BaseSetupSiteProcess.java
BaseSetupSiteProcess.processMessage
public BaseMessage processMessage(BaseMessage message) { RunRemoteProcessMessageData runRemoteProcessMessageData = (RunRemoteProcessMessageData)message.getMessageDataDesc(null); if (runRemoteProcessMessageData == null) message.addMessageDataDesc(runRemoteProcessMessageData = new RunRemoteProcessMessageData(null, null)); CreateSiteMessageData siteMessageData = (CreateSiteMessageData)runRemoteProcessMessageData.getMessageDataDesc(CreateSiteMessageData.CREATE_SITE); if (siteMessageData == null) runRemoteProcessMessageData.addMessageDataDesc(siteMessageData = new CreateSiteMessageData(runRemoteProcessMessageData, null)); StandardMessageResponseData reply = this.setupUserInfo(siteMessageData); if (reply == null) return null; return reply.getMessage(); }
java
public BaseMessage processMessage(BaseMessage message) { RunRemoteProcessMessageData runRemoteProcessMessageData = (RunRemoteProcessMessageData)message.getMessageDataDesc(null); if (runRemoteProcessMessageData == null) message.addMessageDataDesc(runRemoteProcessMessageData = new RunRemoteProcessMessageData(null, null)); CreateSiteMessageData siteMessageData = (CreateSiteMessageData)runRemoteProcessMessageData.getMessageDataDesc(CreateSiteMessageData.CREATE_SITE); if (siteMessageData == null) runRemoteProcessMessageData.addMessageDataDesc(siteMessageData = new CreateSiteMessageData(runRemoteProcessMessageData, null)); StandardMessageResponseData reply = this.setupUserInfo(siteMessageData); if (reply == null) return null; return reply.getMessage(); }
[ "public", "BaseMessage", "processMessage", "(", "BaseMessage", "message", ")", "{", "RunRemoteProcessMessageData", "runRemoteProcessMessageData", "=", "(", "RunRemoteProcessMessageData", ")", "message", ".", "getMessageDataDesc", "(", "null", ")", ";", "if", "(", "runRemoteProcessMessageData", "==", "null", ")", "message", ".", "addMessageDataDesc", "(", "runRemoteProcessMessageData", "=", "new", "RunRemoteProcessMessageData", "(", "null", ",", "null", ")", ")", ";", "CreateSiteMessageData", "siteMessageData", "=", "(", "CreateSiteMessageData", ")", "runRemoteProcessMessageData", ".", "getMessageDataDesc", "(", "CreateSiteMessageData", ".", "CREATE_SITE", ")", ";", "if", "(", "siteMessageData", "==", "null", ")", "runRemoteProcessMessageData", ".", "addMessageDataDesc", "(", "siteMessageData", "=", "new", "CreateSiteMessageData", "(", "runRemoteProcessMessageData", ",", "null", ")", ")", ";", "StandardMessageResponseData", "reply", "=", "this", ".", "setupUserInfo", "(", "siteMessageData", ")", ";", "if", "(", "reply", "==", "null", ")", "return", "null", ";", "return", "reply", ".", "getMessage", "(", ")", ";", "}" ]
Process this message and return a reply.
[ "Process", "this", "message", "and", "return", "a", "reply", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/demo/src/main/java/org/jbundle/app/program/demo/BaseSetupSiteProcess.java#L87-L99
152,055
jbundle/jbundle
app/program/demo/src/main/java/org/jbundle/app/program/demo/BaseSetupSiteProcess.java
BaseSetupSiteProcess.createCustomArchive
public void createCustomArchive(String destArchivePath, String homePath, String templateArchivePath, String templateFilename) { Record recUser = this.getMainRecord(); Map<String,String> map = new HashMap<String,String>(); map.put("${email}", recUser.getField(UserInfo.USER_NAME).toString()); Date date = new Date(); // Today DateField dateField = new DateField(null, null, -1, null, null); dateField.setDate(date, DBConstants.DISPLAY, DBConstants.INIT_MOVE); map.put("${today}", dateField.toString()); dateField.free(); URL url = this.getTask().getApplication().getResourceURL(templateFilename, null); StringBuilder sb = new StringBuilder(Utility.transferURLStream(url.toString(), null)); sb = Utility.replace(sb, map); String templateFile = Utility.addToPath(destArchivePath, "fixdemo.xsl"); PrintWriter out = null; try { File file = new File(templateFile); file.getParentFile().getParentFile().mkdirs(); // .tourgeek file.getParentFile().mkdirs(); // Folder file.createNewFile(); out = new PrintWriter(file); } catch (FileNotFoundException e) {} catch (IOException e) { e.printStackTrace(); } if (out != null) { out.print(sb); out.close(); // First, make sure the base demo files exist in the file system String workDir = templateArchivePath; if (workDir.lastIndexOf(File.separator) != -1) // Always workDir = workDir.substring(workDir.lastIndexOf(File.separator) + 1); String workDirPath = Utility.addToPath(homePath, workDir); this.populateSourceDir(templateArchivePath, workDirPath); // Run the xslt against the base demo files. Map<String, Object> properties = new HashMap<String, Object>(); properties.put("sourceDir", workDirPath); properties.put("destDir", destArchivePath); properties.put("extension", "xml"); properties.put("filter", ".*"); // Hack (filter is a bad name since it it used in many places) properties.put("listenerClass", XMLScanListener.class.getName()); properties.put("converterPath", templateFile); BaseProcess process = new ConvertCode(this.getTask(), null, properties); process.run(); process.free(); } }
java
public void createCustomArchive(String destArchivePath, String homePath, String templateArchivePath, String templateFilename) { Record recUser = this.getMainRecord(); Map<String,String> map = new HashMap<String,String>(); map.put("${email}", recUser.getField(UserInfo.USER_NAME).toString()); Date date = new Date(); // Today DateField dateField = new DateField(null, null, -1, null, null); dateField.setDate(date, DBConstants.DISPLAY, DBConstants.INIT_MOVE); map.put("${today}", dateField.toString()); dateField.free(); URL url = this.getTask().getApplication().getResourceURL(templateFilename, null); StringBuilder sb = new StringBuilder(Utility.transferURLStream(url.toString(), null)); sb = Utility.replace(sb, map); String templateFile = Utility.addToPath(destArchivePath, "fixdemo.xsl"); PrintWriter out = null; try { File file = new File(templateFile); file.getParentFile().getParentFile().mkdirs(); // .tourgeek file.getParentFile().mkdirs(); // Folder file.createNewFile(); out = new PrintWriter(file); } catch (FileNotFoundException e) {} catch (IOException e) { e.printStackTrace(); } if (out != null) { out.print(sb); out.close(); // First, make sure the base demo files exist in the file system String workDir = templateArchivePath; if (workDir.lastIndexOf(File.separator) != -1) // Always workDir = workDir.substring(workDir.lastIndexOf(File.separator) + 1); String workDirPath = Utility.addToPath(homePath, workDir); this.populateSourceDir(templateArchivePath, workDirPath); // Run the xslt against the base demo files. Map<String, Object> properties = new HashMap<String, Object>(); properties.put("sourceDir", workDirPath); properties.put("destDir", destArchivePath); properties.put("extension", "xml"); properties.put("filter", ".*"); // Hack (filter is a bad name since it it used in many places) properties.put("listenerClass", XMLScanListener.class.getName()); properties.put("converterPath", templateFile); BaseProcess process = new ConvertCode(this.getTask(), null, properties); process.run(); process.free(); } }
[ "public", "void", "createCustomArchive", "(", "String", "destArchivePath", ",", "String", "homePath", ",", "String", "templateArchivePath", ",", "String", "templateFilename", ")", "{", "Record", "recUser", "=", "this", ".", "getMainRecord", "(", ")", ";", "Map", "<", "String", ",", "String", ">", "map", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "map", ".", "put", "(", "\"${email}\"", ",", "recUser", ".", "getField", "(", "UserInfo", ".", "USER_NAME", ")", ".", "toString", "(", ")", ")", ";", "Date", "date", "=", "new", "Date", "(", ")", ";", "// Today", "DateField", "dateField", "=", "new", "DateField", "(", "null", ",", "null", ",", "-", "1", ",", "null", ",", "null", ")", ";", "dateField", ".", "setDate", "(", "date", ",", "DBConstants", ".", "DISPLAY", ",", "DBConstants", ".", "INIT_MOVE", ")", ";", "map", ".", "put", "(", "\"${today}\"", ",", "dateField", ".", "toString", "(", ")", ")", ";", "dateField", ".", "free", "(", ")", ";", "URL", "url", "=", "this", ".", "getTask", "(", ")", ".", "getApplication", "(", ")", ".", "getResourceURL", "(", "templateFilename", ",", "null", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "Utility", ".", "transferURLStream", "(", "url", ".", "toString", "(", ")", ",", "null", ")", ")", ";", "sb", "=", "Utility", ".", "replace", "(", "sb", ",", "map", ")", ";", "String", "templateFile", "=", "Utility", ".", "addToPath", "(", "destArchivePath", ",", "\"fixdemo.xsl\"", ")", ";", "PrintWriter", "out", "=", "null", ";", "try", "{", "File", "file", "=", "new", "File", "(", "templateFile", ")", ";", "file", ".", "getParentFile", "(", ")", ".", "getParentFile", "(", ")", ".", "mkdirs", "(", ")", ";", "// .tourgeek", "file", ".", "getParentFile", "(", ")", ".", "mkdirs", "(", ")", ";", "// Folder", "file", ".", "createNewFile", "(", ")", ";", "out", "=", "new", "PrintWriter", "(", "file", ")", ";", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "if", "(", "out", "!=", "null", ")", "{", "out", ".", "print", "(", "sb", ")", ";", "out", ".", "close", "(", ")", ";", "// First, make sure the base demo files exist in the file system", "String", "workDir", "=", "templateArchivePath", ";", "if", "(", "workDir", ".", "lastIndexOf", "(", "File", ".", "separator", ")", "!=", "-", "1", ")", "// Always", "workDir", "=", "workDir", ".", "substring", "(", "workDir", ".", "lastIndexOf", "(", "File", ".", "separator", ")", "+", "1", ")", ";", "String", "workDirPath", "=", "Utility", ".", "addToPath", "(", "homePath", ",", "workDir", ")", ";", "this", ".", "populateSourceDir", "(", "templateArchivePath", ",", "workDirPath", ")", ";", "// Run the xslt against the base demo files.", "Map", "<", "String", ",", "Object", ">", "properties", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "properties", ".", "put", "(", "\"sourceDir\"", ",", "workDirPath", ")", ";", "properties", ".", "put", "(", "\"destDir\"", ",", "destArchivePath", ")", ";", "properties", ".", "put", "(", "\"extension\"", ",", "\"xml\"", ")", ";", "properties", ".", "put", "(", "\"filter\"", ",", "\".*\"", ")", ";", "// Hack (filter is a bad name since it it used in many places)", "properties", ".", "put", "(", "\"listenerClass\"", ",", "XMLScanListener", ".", "class", ".", "getName", "(", ")", ")", ";", "properties", ".", "put", "(", "\"converterPath\"", ",", "templateFile", ")", ";", "BaseProcess", "process", "=", "new", "ConvertCode", "(", "this", ".", "getTask", "(", ")", ",", "null", ",", "properties", ")", ";", "process", ".", "run", "(", ")", ";", "process", ".", "free", "(", ")", ";", "}", "}" ]
CreateCustomArchive Method.
[ "CreateCustomArchive", "Method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/demo/src/main/java/org/jbundle/app/program/demo/BaseSetupSiteProcess.java#L254-L303
152,056
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/db/filter/StringSubFileFilter.java
StringSubFileFilter.setMainKey
public boolean setMainKey(boolean bDisplayOption, Boolean boolSetModified, boolean bSetIfModified) { super.setMainKey(bDisplayOption, boolSetModified, bSetIfModified); boolean bNonNulls = false; // Default to yes, all keys are null. if (m_fldThisFile != null) { m_fldThisFile.setString(m_strFirst, bDisplayOption, DBConstants.READ_MOVE); // Set the booking number in pax file if (!m_fldThisFile.isNull()) bNonNulls = true; // Non null. } if (m_fldThisFile2 != null) { m_fldThisFile2.setString(m_strSecond, bDisplayOption, DBConstants.READ_MOVE); if (!m_fldThisFile2.isNull()) bNonNulls = true; // Non null. } if (m_fldThisFile3 != null) { m_fldThisFile3.setString(m_strThird, bDisplayOption, DBConstants.READ_MOVE); if (!m_fldThisFile3.isNull()) bNonNulls = true; // Non null. } return bNonNulls; }
java
public boolean setMainKey(boolean bDisplayOption, Boolean boolSetModified, boolean bSetIfModified) { super.setMainKey(bDisplayOption, boolSetModified, bSetIfModified); boolean bNonNulls = false; // Default to yes, all keys are null. if (m_fldThisFile != null) { m_fldThisFile.setString(m_strFirst, bDisplayOption, DBConstants.READ_MOVE); // Set the booking number in pax file if (!m_fldThisFile.isNull()) bNonNulls = true; // Non null. } if (m_fldThisFile2 != null) { m_fldThisFile2.setString(m_strSecond, bDisplayOption, DBConstants.READ_MOVE); if (!m_fldThisFile2.isNull()) bNonNulls = true; // Non null. } if (m_fldThisFile3 != null) { m_fldThisFile3.setString(m_strThird, bDisplayOption, DBConstants.READ_MOVE); if (!m_fldThisFile3.isNull()) bNonNulls = true; // Non null. } return bNonNulls; }
[ "public", "boolean", "setMainKey", "(", "boolean", "bDisplayOption", ",", "Boolean", "boolSetModified", ",", "boolean", "bSetIfModified", ")", "{", "super", ".", "setMainKey", "(", "bDisplayOption", ",", "boolSetModified", ",", "bSetIfModified", ")", ";", "boolean", "bNonNulls", "=", "false", ";", "// Default to yes, all keys are null.", "if", "(", "m_fldThisFile", "!=", "null", ")", "{", "m_fldThisFile", ".", "setString", "(", "m_strFirst", ",", "bDisplayOption", ",", "DBConstants", ".", "READ_MOVE", ")", ";", "// Set the booking number in pax file", "if", "(", "!", "m_fldThisFile", ".", "isNull", "(", ")", ")", "bNonNulls", "=", "true", ";", "// Non null.", "}", "if", "(", "m_fldThisFile2", "!=", "null", ")", "{", "m_fldThisFile2", ".", "setString", "(", "m_strSecond", ",", "bDisplayOption", ",", "DBConstants", ".", "READ_MOVE", ")", ";", "if", "(", "!", "m_fldThisFile2", ".", "isNull", "(", ")", ")", "bNonNulls", "=", "true", ";", "// Non null.", "}", "if", "(", "m_fldThisFile3", "!=", "null", ")", "{", "m_fldThisFile3", ".", "setString", "(", "m_strThird", ",", "bDisplayOption", ",", "DBConstants", ".", "READ_MOVE", ")", ";", "if", "(", "!", "m_fldThisFile3", ".", "isNull", "(", ")", ")", "bNonNulls", "=", "true", ";", "// Non null.", "}", "return", "bNonNulls", ";", "}" ]
Setup the target key field to the initial string values. @oaram bDisplayOption If true, display changes. @param boolSetModified - If not null, set this field's modified flag to this value @return false If this key was set to all nulls.
[ "Setup", "the", "target", "key", "field", "to", "the", "initial", "string", "values", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/filter/StringSubFileFilter.java#L110-L133
152,057
tvesalainen/util
util/src/main/java/org/vesalainen/navi/cpa/Vessel.java
Vessel.update
public void update(long time, double latitude, double longitude, double rateOfTurn) { if (strat == Strategy.LONG) { throw new IllegalStateException("mixing short/long update"); } strat = Strategy.SHORT; lock.lock(); try { if (prevTime > 0) { this.time = time; this.latitude = latitude; this.longitude = longitude; this.speed = speed(prevTime, prevLatitude, prevLongitude, time, latitude, longitude); this.bearing = bearing(prevLatitude, prevLongitude, latitude, longitude); this.rateOfTurn = rateOfTurn; calculated = false; } prevTime = time; prevLatitude = latitude; prevLongitude = longitude; } finally { lock.unlock(); } }
java
public void update(long time, double latitude, double longitude, double rateOfTurn) { if (strat == Strategy.LONG) { throw new IllegalStateException("mixing short/long update"); } strat = Strategy.SHORT; lock.lock(); try { if (prevTime > 0) { this.time = time; this.latitude = latitude; this.longitude = longitude; this.speed = speed(prevTime, prevLatitude, prevLongitude, time, latitude, longitude); this.bearing = bearing(prevLatitude, prevLongitude, latitude, longitude); this.rateOfTurn = rateOfTurn; calculated = false; } prevTime = time; prevLatitude = latitude; prevLongitude = longitude; } finally { lock.unlock(); } }
[ "public", "void", "update", "(", "long", "time", ",", "double", "latitude", ",", "double", "longitude", ",", "double", "rateOfTurn", ")", "{", "if", "(", "strat", "==", "Strategy", ".", "LONG", ")", "{", "throw", "new", "IllegalStateException", "(", "\"mixing short/long update\"", ")", ";", "}", "strat", "=", "Strategy", ".", "SHORT", ";", "lock", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "prevTime", ">", "0", ")", "{", "this", ".", "time", "=", "time", ";", "this", ".", "latitude", "=", "latitude", ";", "this", ".", "longitude", "=", "longitude", ";", "this", ".", "speed", "=", "speed", "(", "prevTime", ",", "prevLatitude", ",", "prevLongitude", ",", "time", ",", "latitude", ",", "longitude", ")", ";", "this", ".", "bearing", "=", "bearing", "(", "prevLatitude", ",", "prevLongitude", ",", "latitude", ",", "longitude", ")", ";", "this", ".", "rateOfTurn", "=", "rateOfTurn", ";", "calculated", "=", "false", ";", "}", "prevTime", "=", "time", ";", "prevLatitude", "=", "latitude", ";", "prevLongitude", "=", "longitude", ";", "}", "finally", "{", "lock", ".", "unlock", "(", ")", ";", "}", "}" ]
Updates values and calculates speed and bearing. <p>Don't mix short and long update method usage in same instance! @param time @param latitude @param longitude @param rateOfTurn Degrees / minute @throws IllegalStateException If mixing short and long update method usage in same instance!
[ "Updates", "values", "and", "calculates", "speed", "and", "bearing", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/navi/cpa/Vessel.java#L81-L109
152,058
tvesalainen/util
util/src/main/java/org/vesalainen/navi/cpa/Vessel.java
Vessel.update
public void update(long time, double latitude, double longitude, double speed, double bearing, double rateOfTurn) { if (strat == Strategy.SHORT) { throw new IllegalStateException("mixing short/long update"); } strat = Strategy.LONG; lock.lock(); try { this.time = time; this.latitude = latitude; this.longitude = longitude; this.speed = speed; this.bearing = bearing; this.rateOfTurn = rateOfTurn; calculated = false; } finally { lock.unlock(); } }
java
public void update(long time, double latitude, double longitude, double speed, double bearing, double rateOfTurn) { if (strat == Strategy.SHORT) { throw new IllegalStateException("mixing short/long update"); } strat = Strategy.LONG; lock.lock(); try { this.time = time; this.latitude = latitude; this.longitude = longitude; this.speed = speed; this.bearing = bearing; this.rateOfTurn = rateOfTurn; calculated = false; } finally { lock.unlock(); } }
[ "public", "void", "update", "(", "long", "time", ",", "double", "latitude", ",", "double", "longitude", ",", "double", "speed", ",", "double", "bearing", ",", "double", "rateOfTurn", ")", "{", "if", "(", "strat", "==", "Strategy", ".", "SHORT", ")", "{", "throw", "new", "IllegalStateException", "(", "\"mixing short/long update\"", ")", ";", "}", "strat", "=", "Strategy", ".", "LONG", ";", "lock", ".", "lock", "(", ")", ";", "try", "{", "this", ".", "time", "=", "time", ";", "this", ".", "latitude", "=", "latitude", ";", "this", ".", "longitude", "=", "longitude", ";", "this", ".", "speed", "=", "speed", ";", "this", ".", "bearing", "=", "bearing", ";", "this", ".", "rateOfTurn", "=", "rateOfTurn", ";", "calculated", "=", "false", ";", "}", "finally", "{", "lock", ".", "unlock", "(", ")", ";", "}", "}" ]
Updates values. <p>Don't mix short and long update method usage in same instance! @param time @param latitude @param longitude @param speed @param bearing Degrees @param rateOfTurn Degrees / minute @throws IllegalStateException If mixing short and long update method usage in same instance!
[ "Updates", "values", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/navi/cpa/Vessel.java#L123-L145
152,059
tvesalainen/util
util/src/main/java/org/vesalainen/navi/cpa/Vessel.java
Vessel.estimatedLatitude
public final double estimatedLatitude(long et) { et = correctedTime(et); lock.lock(); try { calc(); if (rateOfTurn == 0) { double dist = calcDist(et); return latitude+deltaLatitude(dist, bearing); } else { double deg = calcDeg(et); return centerLatitude+deltaLatitude(radius, deg); } } finally { lock.unlock(); } }
java
public final double estimatedLatitude(long et) { et = correctedTime(et); lock.lock(); try { calc(); if (rateOfTurn == 0) { double dist = calcDist(et); return latitude+deltaLatitude(dist, bearing); } else { double deg = calcDeg(et); return centerLatitude+deltaLatitude(radius, deg); } } finally { lock.unlock(); } }
[ "public", "final", "double", "estimatedLatitude", "(", "long", "et", ")", "{", "et", "=", "correctedTime", "(", "et", ")", ";", "lock", ".", "lock", "(", ")", ";", "try", "{", "calc", "(", ")", ";", "if", "(", "rateOfTurn", "==", "0", ")", "{", "double", "dist", "=", "calcDist", "(", "et", ")", ";", "return", "latitude", "+", "deltaLatitude", "(", "dist", ",", "bearing", ")", ";", "}", "else", "{", "double", "deg", "=", "calcDeg", "(", "et", ")", ";", "return", "centerLatitude", "+", "deltaLatitude", "(", "radius", ",", "deg", ")", ";", "}", "}", "finally", "{", "lock", ".", "unlock", "(", ")", ";", "}", "}" ]
Returns estimated latitude at et @param et @return
[ "Returns", "estimated", "latitude", "at", "et" ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/navi/cpa/Vessel.java#L197-L219
152,060
tvesalainen/util
util/src/main/java/org/vesalainen/navi/cpa/Vessel.java
Vessel.estimatedLongitude
public final double estimatedLongitude(long et) { et = correctedTime(et); lock.lock(); try { calc(); if (rateOfTurn == 0) { double dist = calcDist(et); return addLongitude(longitude, deltaLongitude(latitude, dist, bearing)); } else { double deg = calcDeg(et); return addLongitude(centerLongitude, deltaLongitude(latitude, radius, deg)); } } finally { lock.unlock(); } }
java
public final double estimatedLongitude(long et) { et = correctedTime(et); lock.lock(); try { calc(); if (rateOfTurn == 0) { double dist = calcDist(et); return addLongitude(longitude, deltaLongitude(latitude, dist, bearing)); } else { double deg = calcDeg(et); return addLongitude(centerLongitude, deltaLongitude(latitude, radius, deg)); } } finally { lock.unlock(); } }
[ "public", "final", "double", "estimatedLongitude", "(", "long", "et", ")", "{", "et", "=", "correctedTime", "(", "et", ")", ";", "lock", ".", "lock", "(", ")", ";", "try", "{", "calc", "(", ")", ";", "if", "(", "rateOfTurn", "==", "0", ")", "{", "double", "dist", "=", "calcDist", "(", "et", ")", ";", "return", "addLongitude", "(", "longitude", ",", "deltaLongitude", "(", "latitude", ",", "dist", ",", "bearing", ")", ")", ";", "}", "else", "{", "double", "deg", "=", "calcDeg", "(", "et", ")", ";", "return", "addLongitude", "(", "centerLongitude", ",", "deltaLongitude", "(", "latitude", ",", "radius", ",", "deg", ")", ")", ";", "}", "}", "finally", "{", "lock", ".", "unlock", "(", ")", ";", "}", "}" ]
Return estimated longitude at et @param et @return
[ "Return", "estimated", "longitude", "at", "et" ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/navi/cpa/Vessel.java#L225-L247
152,061
tvesalainen/util
util/src/main/java/org/vesalainen/navi/cpa/Vessel.java
Vessel.estimatedLocation
public final Location estimatedLocation(long et) { lock.lock(); try { return new Location(estimatedLatitude(et), estimatedLongitude(et)); } finally { lock.unlock(); } }
java
public final Location estimatedLocation(long et) { lock.lock(); try { return new Location(estimatedLatitude(et), estimatedLongitude(et)); } finally { lock.unlock(); } }
[ "public", "final", "Location", "estimatedLocation", "(", "long", "et", ")", "{", "lock", ".", "lock", "(", ")", ";", "try", "{", "return", "new", "Location", "(", "estimatedLatitude", "(", "et", ")", ",", "estimatedLongitude", "(", "et", ")", ")", ";", "}", "finally", "{", "lock", ".", "unlock", "(", ")", ";", "}", "}" ]
Using this method protects from parallel updates @param et Estimated time @return
[ "Using", "this", "method", "protects", "from", "parallel", "updates" ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/navi/cpa/Vessel.java#L253-L264
152,062
Shredder121/jda-async-packetprovider
src/main/java/com/github/shredder121/asyncaudio/common/ProvideForkJoinTask.java
ProvideForkJoinTask.optionallyCopyData
private static DatagramPacket optionallyCopyData(DatagramPacket packet) { if (packet != null) { packet.setData(packet.getData().clone(), packet.getOffset(), packet.getLength()); } return packet; }
java
private static DatagramPacket optionallyCopyData(DatagramPacket packet) { if (packet != null) { packet.setData(packet.getData().clone(), packet.getOffset(), packet.getLength()); } return packet; }
[ "private", "static", "DatagramPacket", "optionallyCopyData", "(", "DatagramPacket", "packet", ")", "{", "if", "(", "packet", "!=", "null", ")", "{", "packet", ".", "setData", "(", "packet", ".", "getData", "(", ")", ".", "clone", "(", ")", ",", "packet", ".", "getOffset", "(", ")", ",", "packet", ".", "getLength", "(", ")", ")", ";", "}", "return", "packet", ";", "}" ]
Makes a copy of the data in the packet to make the packet safe to store for longer periods of time. <p> JDA changed to have only one backing array for all packets, to reduce allocations. This means that in JAPP code we have to copy the packet data before storing it for longer periods of time. </p> @param packet the packet to copy the data for @return the adjusted packet
[ "Makes", "a", "copy", "of", "the", "data", "in", "the", "packet", "to", "make", "the", "packet", "safe", "to", "store", "for", "longer", "periods", "of", "time", "." ]
ef9cedd3136bbc31ee751511586351c21042b291
https://github.com/Shredder121/jda-async-packetprovider/blob/ef9cedd3136bbc31ee751511586351c21042b291/src/main/java/com/github/shredder121/asyncaudio/common/ProvideForkJoinTask.java#L73-L78
152,063
jbundle/jbundle
thin/base/remote/src/main/java/org/jbundle/thin/base/remote/proxy/SendQueueProxy.java
SendQueueProxy.sendMessage
public void sendMessage(Message message) throws RemoteException { BaseTransport transport = this.createProxyTransport(SEND_MESSAGE); transport.addParam(MESSAGE, message); // Don't use COMMAND transport.sendMessageAndGetReply(); }
java
public void sendMessage(Message message) throws RemoteException { BaseTransport transport = this.createProxyTransport(SEND_MESSAGE); transport.addParam(MESSAGE, message); // Don't use COMMAND transport.sendMessageAndGetReply(); }
[ "public", "void", "sendMessage", "(", "Message", "message", ")", "throws", "RemoteException", "{", "BaseTransport", "transport", "=", "this", ".", "createProxyTransport", "(", "SEND_MESSAGE", ")", ";", "transport", ".", "addParam", "(", "MESSAGE", ",", "message", ")", ";", "// Don't use COMMAND", "transport", ".", "sendMessageAndGetReply", "(", ")", ";", "}" ]
Send a remote message. @param message The message to send.
[ "Send", "a", "remote", "message", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/remote/src/main/java/org/jbundle/thin/base/remote/proxy/SendQueueProxy.java#L60-L65
152,064
JM-Lab/utils-java9
src/main/java/kr/jm/utils/flow/subscriber/JMSubscriberBuilder.java
JMSubscriberBuilder.getSOPLSubscriber
public static <I> JMSubscriber<I> getSOPLSubscriber( Function<I, ?> transformFunction) { return build(o -> System.out.println(transformFunction.apply(o))); }
java
public static <I> JMSubscriber<I> getSOPLSubscriber( Function<I, ?> transformFunction) { return build(o -> System.out.println(transformFunction.apply(o))); }
[ "public", "static", "<", "I", ">", "JMSubscriber", "<", "I", ">", "getSOPLSubscriber", "(", "Function", "<", "I", ",", "?", ">", "transformFunction", ")", "{", "return", "build", "(", "o", "->", "System", ".", "out", ".", "println", "(", "transformFunction", ".", "apply", "(", "o", ")", ")", ")", ";", "}" ]
Gets sopl subscriber. @param <I> the type parameter @param transformFunction the transform function @return the sopl subscriber
[ "Gets", "sopl", "subscriber", "." ]
ee80235b2760396a616cf7563cbdc98d4affe8e1
https://github.com/JM-Lab/utils-java9/blob/ee80235b2760396a616cf7563cbdc98d4affe8e1/src/main/java/kr/jm/utils/flow/subscriber/JMSubscriberBuilder.java#L40-L43
152,065
JM-Lab/utils-java9
src/main/java/kr/jm/utils/flow/subscriber/JMSubscriberBuilder.java
JMSubscriberBuilder.getJsonStringSOPLSubscriber
public static <I> JMSubscriber<I> getJsonStringSOPLSubscriber( Function<I, ?> transformFunction) { return getSOPLSubscriber( o -> JMJson.toJsonString(transformFunction.apply(o))); }
java
public static <I> JMSubscriber<I> getJsonStringSOPLSubscriber( Function<I, ?> transformFunction) { return getSOPLSubscriber( o -> JMJson.toJsonString(transformFunction.apply(o))); }
[ "public", "static", "<", "I", ">", "JMSubscriber", "<", "I", ">", "getJsonStringSOPLSubscriber", "(", "Function", "<", "I", ",", "?", ">", "transformFunction", ")", "{", "return", "getSOPLSubscriber", "(", "o", "->", "JMJson", ".", "toJsonString", "(", "transformFunction", ".", "apply", "(", "o", ")", ")", ")", ";", "}" ]
Gets json string sopl subscriber. @param <I> the type parameter @param transformFunction the transform function @return the json string sopl subscriber
[ "Gets", "json", "string", "sopl", "subscriber", "." ]
ee80235b2760396a616cf7563cbdc98d4affe8e1
https://github.com/JM-Lab/utils-java9/blob/ee80235b2760396a616cf7563cbdc98d4affe8e1/src/main/java/kr/jm/utils/flow/subscriber/JMSubscriberBuilder.java#L52-L56
152,066
JM-Lab/utils-java9
src/main/java/kr/jm/utils/flow/subscriber/JMSubscriberBuilder.java
JMSubscriberBuilder.buildJsonStringFileSubscriber
public static <I> JMFileSubscriber<I> buildJsonStringFileSubscriber( String filePath, Function<Object, String> toStringFunction) { return new JMFileSubscriber<>(filePath, toStringFunction); }
java
public static <I> JMFileSubscriber<I> buildJsonStringFileSubscriber( String filePath, Function<Object, String> toStringFunction) { return new JMFileSubscriber<>(filePath, toStringFunction); }
[ "public", "static", "<", "I", ">", "JMFileSubscriber", "<", "I", ">", "buildJsonStringFileSubscriber", "(", "String", "filePath", ",", "Function", "<", "Object", ",", "String", ">", "toStringFunction", ")", "{", "return", "new", "JMFileSubscriber", "<>", "(", "filePath", ",", "toStringFunction", ")", ";", "}" ]
Build json string file subscriber jm file subscriber. @param <I> the type parameter @param filePath the file path @param toStringFunction the to string function @return the jm file subscriber
[ "Build", "json", "string", "file", "subscriber", "jm", "file", "subscriber", "." ]
ee80235b2760396a616cf7563cbdc98d4affe8e1
https://github.com/JM-Lab/utils-java9/blob/ee80235b2760396a616cf7563cbdc98d4affe8e1/src/main/java/kr/jm/utils/flow/subscriber/JMSubscriberBuilder.java#L89-L92
152,067
tacitknowledge/discovery
src/main/java/com/tacitknowledge/util/discovery/ClasspathFileReader.java
ClasspathFileReader.findFile
private File findFile(String fileName, List path) { final String methodName = "findFile(): "; String fileSeparator = System.getProperty("file.separator"); for (Iterator i = path.iterator(); i.hasNext();) { String directory = (String) i.next(); if (!directory.endsWith(fileSeparator) && !fileName.startsWith(fileSeparator)) { directory = directory + fileSeparator; } File file = new File(directory + fileName); if (log.isDebugEnabled()) { log.debug(methodName + " checking '" + file.getAbsolutePath() + "'"); } if (file.exists() && file.canRead()) { log.debug(methodName + " found it - file is '" + file.getAbsolutePath() + "'"); cache.put(fileName, new CacheEntry(file)); return file; } } return null; }
java
private File findFile(String fileName, List path) { final String methodName = "findFile(): "; String fileSeparator = System.getProperty("file.separator"); for (Iterator i = path.iterator(); i.hasNext();) { String directory = (String) i.next(); if (!directory.endsWith(fileSeparator) && !fileName.startsWith(fileSeparator)) { directory = directory + fileSeparator; } File file = new File(directory + fileName); if (log.isDebugEnabled()) { log.debug(methodName + " checking '" + file.getAbsolutePath() + "'"); } if (file.exists() && file.canRead()) { log.debug(methodName + " found it - file is '" + file.getAbsolutePath() + "'"); cache.put(fileName, new CacheEntry(file)); return file; } } return null; }
[ "private", "File", "findFile", "(", "String", "fileName", ",", "List", "path", ")", "{", "final", "String", "methodName", "=", "\"findFile(): \"", ";", "String", "fileSeparator", "=", "System", ".", "getProperty", "(", "\"file.separator\"", ")", ";", "for", "(", "Iterator", "i", "=", "path", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "String", "directory", "=", "(", "String", ")", "i", ".", "next", "(", ")", ";", "if", "(", "!", "directory", ".", "endsWith", "(", "fileSeparator", ")", "&&", "!", "fileName", ".", "startsWith", "(", "fileSeparator", ")", ")", "{", "directory", "=", "directory", "+", "fileSeparator", ";", "}", "File", "file", "=", "new", "File", "(", "directory", "+", "fileName", ")", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "methodName", "+", "\" checking '\"", "+", "file", ".", "getAbsolutePath", "(", ")", "+", "\"'\"", ")", ";", "}", "if", "(", "file", ".", "exists", "(", ")", "&&", "file", ".", "canRead", "(", ")", ")", "{", "log", ".", "debug", "(", "methodName", "+", "\" found it - file is '\"", "+", "file", ".", "getAbsolutePath", "(", ")", "+", "\"'\"", ")", ";", "cache", ".", "put", "(", "fileName", ",", "new", "CacheEntry", "(", "file", ")", ")", ";", "return", "file", ";", "}", "}", "return", "null", ";", "}" ]
Finds a file if it exists in a list of provided paths @param fileName the name of the file @param path a list of file paths @return a file or null if none is found
[ "Finds", "a", "file", "if", "it", "exists", "in", "a", "list", "of", "provided", "paths" ]
700f5492c9cb5c0146d684acb38b71fd4ef4e97a
https://github.com/tacitknowledge/discovery/blob/700f5492c9cb5c0146d684acb38b71fd4ef4e97a/src/main/java/com/tacitknowledge/util/discovery/ClasspathFileReader.java#L184-L208
152,068
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/db/event/MoveIDToCodeHandler.java
MoveIDToCodeHandler.getCodeField
public BaseField getCodeField() { Record record = this.getOwner(); if (m_iCodeField != null) return record.getField(m_iCodeField); else return record.getKeyArea(record.getCodeKeyArea()).getField(DBConstants.MAIN_KEY_FIELD); }
java
public BaseField getCodeField() { Record record = this.getOwner(); if (m_iCodeField != null) return record.getField(m_iCodeField); else return record.getKeyArea(record.getCodeKeyArea()).getField(DBConstants.MAIN_KEY_FIELD); }
[ "public", "BaseField", "getCodeField", "(", ")", "{", "Record", "record", "=", "this", ".", "getOwner", "(", ")", ";", "if", "(", "m_iCodeField", "!=", "null", ")", "return", "record", ".", "getField", "(", "m_iCodeField", ")", ";", "else", "return", "record", ".", "getKeyArea", "(", "record", ".", "getCodeKeyArea", "(", ")", ")", ".", "getField", "(", "DBConstants", ".", "MAIN_KEY_FIELD", ")", ";", "}" ]
Get the code field. @return The code field (or the index field if not found)
[ "Get", "the", "code", "field", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/event/MoveIDToCodeHandler.java#L96-L103
152,069
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/db/event/MoveIDToCodeHandler.java
MoveIDToCodeHandler.moveIDToCodeField
public int moveIDToCodeField() { if (this.getCodeField().isNull()) return getCodeField().moveFieldToThis((BaseField)this.getOwner().getCounterField()); else return DBConstants.NORMAL_RETURN; }
java
public int moveIDToCodeField() { if (this.getCodeField().isNull()) return getCodeField().moveFieldToThis((BaseField)this.getOwner().getCounterField()); else return DBConstants.NORMAL_RETURN; }
[ "public", "int", "moveIDToCodeField", "(", ")", "{", "if", "(", "this", ".", "getCodeField", "(", ")", ".", "isNull", "(", ")", ")", "return", "getCodeField", "(", ")", ".", "moveFieldToThis", "(", "(", "BaseField", ")", "this", ".", "getOwner", "(", ")", ".", "getCounterField", "(", ")", ")", ";", "else", "return", "DBConstants", ".", "NORMAL_RETURN", ";", "}" ]
Move the ID field to the code field. @return
[ "Move", "the", "ID", "field", "to", "the", "code", "field", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/event/MoveIDToCodeHandler.java#L108-L114
152,070
jbundle/jbundle
app/program/script/src/main/java/org/jbundle/app/program/manual/convert/ConvertBase.java
ConvertBase.tabsToSpaces
public String tabsToSpaces(String string) { int iOffset = 0; for (int i = 0; i < string.length(); i++) { if (string.charAt(i) == '\n') iOffset = i + 1; if (string.charAt(i) == '\t') { int iSpaces = (i - iOffset) % 4; if (iSpaces == 0) iSpaces = 4; string = string.substring(0, i) + FOUR_SPACES.substring(0, iSpaces) + string.substring(i + 1); } } return string; }
java
public String tabsToSpaces(String string) { int iOffset = 0; for (int i = 0; i < string.length(); i++) { if (string.charAt(i) == '\n') iOffset = i + 1; if (string.charAt(i) == '\t') { int iSpaces = (i - iOffset) % 4; if (iSpaces == 0) iSpaces = 4; string = string.substring(0, i) + FOUR_SPACES.substring(0, iSpaces) + string.substring(i + 1); } } return string; }
[ "public", "String", "tabsToSpaces", "(", "String", "string", ")", "{", "int", "iOffset", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "string", ".", "length", "(", ")", ";", "i", "++", ")", "{", "if", "(", "string", ".", "charAt", "(", "i", ")", "==", "'", "'", ")", "iOffset", "=", "i", "+", "1", ";", "if", "(", "string", ".", "charAt", "(", "i", ")", "==", "'", "'", ")", "{", "int", "iSpaces", "=", "(", "i", "-", "iOffset", ")", "%", "4", ";", "if", "(", "iSpaces", "==", "0", ")", "iSpaces", "=", "4", ";", "string", "=", "string", ".", "substring", "(", "0", ",", "i", ")", "+", "FOUR_SPACES", ".", "substring", "(", "0", ",", "iSpaces", ")", "+", "string", ".", "substring", "(", "i", "+", "1", ")", ";", "}", "}", "return", "string", ";", "}" ]
Convert the tabs to spaces.
[ "Convert", "the", "tabs", "to", "spaces", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/script/src/main/java/org/jbundle/app/program/manual/convert/ConvertBase.java#L134-L150
152,071
jbundle/jbundle
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/landf/ScreenDialog.java
ScreenDialog.setSampleStyle
public void setSampleStyle() { Color colorBackground = ScreenUtil.getColor(ScreenUtil.BACKGROUND_COLOR, null, properties); Color colorControl = ScreenUtil.getColor(ScreenUtil.CONTROL_COLOR, null, properties); Color colorText = ScreenUtil.getColor(ScreenUtil.TEXT_COLOR, null, properties); samplePanel.setBackground(colorBackground); if (colorBackground == null) samplePanel.setBackground(SystemColor.window); Font font = ScreenUtil.getFont(null, properties, true); sampleLabel.setFont(font); sampleTextField.setFont(font); sampleTextField.setBackground(colorControl); if (colorControl == null) sampleTextField.setBackground(SystemColor.text); sampleLabel.setForeground(colorText); if (colorText == null) sampleLabel.setForeground(SystemColor.textText); sampleTextField.setForeground(colorText); if (colorText == null) sampleTextField.setForeground(SystemColor.textText); if (colorBackground != null) backgroundButton.setBackground(colorBackground); if (colorControl != null) controlColorButton.setBackground(colorControl); if (colorText != null) textColorButton.setBackground(colorText); this.invalidate(); }
java
public void setSampleStyle() { Color colorBackground = ScreenUtil.getColor(ScreenUtil.BACKGROUND_COLOR, null, properties); Color colorControl = ScreenUtil.getColor(ScreenUtil.CONTROL_COLOR, null, properties); Color colorText = ScreenUtil.getColor(ScreenUtil.TEXT_COLOR, null, properties); samplePanel.setBackground(colorBackground); if (colorBackground == null) samplePanel.setBackground(SystemColor.window); Font font = ScreenUtil.getFont(null, properties, true); sampleLabel.setFont(font); sampleTextField.setFont(font); sampleTextField.setBackground(colorControl); if (colorControl == null) sampleTextField.setBackground(SystemColor.text); sampleLabel.setForeground(colorText); if (colorText == null) sampleLabel.setForeground(SystemColor.textText); sampleTextField.setForeground(colorText); if (colorText == null) sampleTextField.setForeground(SystemColor.textText); if (colorBackground != null) backgroundButton.setBackground(colorBackground); if (colorControl != null) controlColorButton.setBackground(colorControl); if (colorText != null) textColorButton.setBackground(colorText); this.invalidate(); }
[ "public", "void", "setSampleStyle", "(", ")", "{", "Color", "colorBackground", "=", "ScreenUtil", ".", "getColor", "(", "ScreenUtil", ".", "BACKGROUND_COLOR", ",", "null", ",", "properties", ")", ";", "Color", "colorControl", "=", "ScreenUtil", ".", "getColor", "(", "ScreenUtil", ".", "CONTROL_COLOR", ",", "null", ",", "properties", ")", ";", "Color", "colorText", "=", "ScreenUtil", ".", "getColor", "(", "ScreenUtil", ".", "TEXT_COLOR", ",", "null", ",", "properties", ")", ";", "samplePanel", ".", "setBackground", "(", "colorBackground", ")", ";", "if", "(", "colorBackground", "==", "null", ")", "samplePanel", ".", "setBackground", "(", "SystemColor", ".", "window", ")", ";", "Font", "font", "=", "ScreenUtil", ".", "getFont", "(", "null", ",", "properties", ",", "true", ")", ";", "sampleLabel", ".", "setFont", "(", "font", ")", ";", "sampleTextField", ".", "setFont", "(", "font", ")", ";", "sampleTextField", ".", "setBackground", "(", "colorControl", ")", ";", "if", "(", "colorControl", "==", "null", ")", "sampleTextField", ".", "setBackground", "(", "SystemColor", ".", "text", ")", ";", "sampleLabel", ".", "setForeground", "(", "colorText", ")", ";", "if", "(", "colorText", "==", "null", ")", "sampleLabel", ".", "setForeground", "(", "SystemColor", ".", "textText", ")", ";", "sampleTextField", ".", "setForeground", "(", "colorText", ")", ";", "if", "(", "colorText", "==", "null", ")", "sampleTextField", ".", "setForeground", "(", "SystemColor", ".", "textText", ")", ";", "if", "(", "colorBackground", "!=", "null", ")", "backgroundButton", ".", "setBackground", "(", "colorBackground", ")", ";", "if", "(", "colorControl", "!=", "null", ")", "controlColorButton", ".", "setBackground", "(", "colorControl", ")", ";", "if", "(", "colorText", "!=", "null", ")", "textColorButton", ".", "setBackground", "(", "colorText", ")", ";", "this", ".", "invalidate", "(", ")", ";", "}" ]
Handle the button actions.
[ "Handle", "the", "button", "actions", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/landf/ScreenDialog.java#L499-L528
152,072
PuyallupFoursquare/ccb-api-client-java
src/main/java/com/p4square/ccbapi/CCBXmlBinder.java
CCBXmlBinder.getJAXBContext
private JAXBContext getJAXBContext(Class<? extends CCBAPIResponse> responseClass) { if (!jaxbContextCache.containsKey(responseClass)) { synchronized (jaxbContextCache) { // Check again to be sure. if (!jaxbContextCache.containsKey(responseClass)) { try { final JAXBContext jaxbContext = JAXBContext.newInstance(responseClass); jaxbContextCache.put(responseClass, jaxbContext); } catch (JAXBException e) { throw new AssertionError("Could not construct JAXBContext for " + responseClass.getName(), e); } } } } return jaxbContextCache.get(responseClass); }
java
private JAXBContext getJAXBContext(Class<? extends CCBAPIResponse> responseClass) { if (!jaxbContextCache.containsKey(responseClass)) { synchronized (jaxbContextCache) { // Check again to be sure. if (!jaxbContextCache.containsKey(responseClass)) { try { final JAXBContext jaxbContext = JAXBContext.newInstance(responseClass); jaxbContextCache.put(responseClass, jaxbContext); } catch (JAXBException e) { throw new AssertionError("Could not construct JAXBContext for " + responseClass.getName(), e); } } } } return jaxbContextCache.get(responseClass); }
[ "private", "JAXBContext", "getJAXBContext", "(", "Class", "<", "?", "extends", "CCBAPIResponse", ">", "responseClass", ")", "{", "if", "(", "!", "jaxbContextCache", ".", "containsKey", "(", "responseClass", ")", ")", "{", "synchronized", "(", "jaxbContextCache", ")", "{", "// Check again to be sure.", "if", "(", "!", "jaxbContextCache", ".", "containsKey", "(", "responseClass", ")", ")", "{", "try", "{", "final", "JAXBContext", "jaxbContext", "=", "JAXBContext", ".", "newInstance", "(", "responseClass", ")", ";", "jaxbContextCache", ".", "put", "(", "responseClass", ",", "jaxbContext", ")", ";", "}", "catch", "(", "JAXBException", "e", ")", "{", "throw", "new", "AssertionError", "(", "\"Could not construct JAXBContext for \"", "+", "responseClass", ".", "getName", "(", ")", ",", "e", ")", ";", "}", "}", "}", "}", "return", "jaxbContextCache", ".", "get", "(", "responseClass", ")", ";", "}" ]
Find or create the JAXBContext for a CCBAPIResponse implementation. @param responseClass The response implementation class. @return a JAXBContext which can be used to unmarshell the responseClass.
[ "Find", "or", "create", "the", "JAXBContext", "for", "a", "CCBAPIResponse", "implementation", "." ]
54a7a3184dc565fe513aa520e1344b2303ea6834
https://github.com/PuyallupFoursquare/ccb-api-client-java/blob/54a7a3184dc565fe513aa520e1344b2303ea6834/src/main/java/com/p4square/ccbapi/CCBXmlBinder.java#L62-L77
152,073
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/field/event/ChangeOnChangeHandler.java
ChangeOnChangeHandler.fieldChanged
public int fieldChanged(boolean bDisplayOption, int iMoveMode) { if (m_bSetModified) m_fldTarget.setModified(true); return m_fldTarget.handleFieldChanged(bDisplayOption, iMoveMode); // init dependent field }
java
public int fieldChanged(boolean bDisplayOption, int iMoveMode) { if (m_bSetModified) m_fldTarget.setModified(true); return m_fldTarget.handleFieldChanged(bDisplayOption, iMoveMode); // init dependent field }
[ "public", "int", "fieldChanged", "(", "boolean", "bDisplayOption", ",", "int", "iMoveMode", ")", "{", "if", "(", "m_bSetModified", ")", "m_fldTarget", ".", "setModified", "(", "true", ")", ";", "return", "m_fldTarget", ".", "handleFieldChanged", "(", "bDisplayOption", ",", "iMoveMode", ")", ";", "// init dependent field", "}" ]
The Field has Changed. Initialize the target field also. @param bDisplayOption If true, display the change. @param iMoveMode The type of move being done (init/read/screen). @return The error code (or NORMAL_RETURN if okay). Field Changed, init the field.
[ "The", "Field", "has", "Changed", ".", "Initialize", "the", "target", "field", "also", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/event/ChangeOnChangeHandler.java#L109-L114
152,074
tvesalainen/hoski-lib
src/main/java/fi/hoski/datastore/repository/DataObjectModel.java
DataObjectModel.convert
public Object convert(String property, Object value) { if (value == null) { return defaultMap.get(property); } Class<?> type = getType(property); if (type == null) { throw new IllegalArgumentException(property+" unknown"); } return ConvertUtil.convertTo(value, type); }
java
public Object convert(String property, Object value) { if (value == null) { return defaultMap.get(property); } Class<?> type = getType(property); if (type == null) { throw new IllegalArgumentException(property+" unknown"); } return ConvertUtil.convertTo(value, type); }
[ "public", "Object", "convert", "(", "String", "property", ",", "Object", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "defaultMap", ".", "get", "(", "property", ")", ";", "}", "Class", "<", "?", ">", "type", "=", "getType", "(", "property", ")", ";", "if", "(", "type", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "property", "+", "\" unknown\"", ")", ";", "}", "return", "ConvertUtil", ".", "convertTo", "(", "value", ",", "type", ")", ";", "}" ]
Tries to convert object to model type @param value @return
[ "Tries", "to", "convert", "object", "to", "model", "type" ]
9b5bab44113e0adb74bf1ee436013e8a7c608d00
https://github.com/tvesalainen/hoski-lib/blob/9b5bab44113e0adb74bf1ee436013e8a7c608d00/src/main/java/fi/hoski/datastore/repository/DataObjectModel.java#L141-L153
152,075
tvesalainen/hoski-lib
src/main/java/fi/hoski/datastore/repository/DataObjectModel.java
DataObjectModel.view
public DataObjectModel view(int from) { DataObjectModel view = clone(); view.propertyList = propertyList.subList(from, propertyList.size()); return view; }
java
public DataObjectModel view(int from) { DataObjectModel view = clone(); view.propertyList = propertyList.subList(from, propertyList.size()); return view; }
[ "public", "DataObjectModel", "view", "(", "int", "from", ")", "{", "DataObjectModel", "view", "=", "clone", "(", ")", ";", "view", ".", "propertyList", "=", "propertyList", ".", "subList", "(", "from", ",", "propertyList", ".", "size", "(", ")", ")", ";", "return", "view", ";", "}" ]
Returns a clone of this model where only propertyList starting from from are present. @param from @return
[ "Returns", "a", "clone", "of", "this", "model", "where", "only", "propertyList", "starting", "from", "from", "are", "present", "." ]
9b5bab44113e0adb74bf1ee436013e8a7c608d00
https://github.com/tvesalainen/hoski-lib/blob/9b5bab44113e0adb74bf1ee436013e8a7c608d00/src/main/java/fi/hoski/datastore/repository/DataObjectModel.java#L160-L165
152,076
tvesalainen/hoski-lib
src/main/java/fi/hoski/datastore/repository/DataObjectModel.java
DataObjectModel.view
public DataObjectModel view(String... properties) { DataObjectModel view = clone(); view.propertyList = new ArrayList<String>(); for (String property : properties) { view.propertyList.add(property); } return view; }
java
public DataObjectModel view(String... properties) { DataObjectModel view = clone(); view.propertyList = new ArrayList<String>(); for (String property : properties) { view.propertyList.add(property); } return view; }
[ "public", "DataObjectModel", "view", "(", "String", "...", "properties", ")", "{", "DataObjectModel", "view", "=", "clone", "(", ")", ";", "view", ".", "propertyList", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "String", "property", ":", "properties", ")", "{", "view", ".", "propertyList", ".", "add", "(", "property", ")", ";", "}", "return", "view", ";", "}" ]
Returns a clone of this model where only listed propertyList are present. @param properties @return
[ "Returns", "a", "clone", "of", "this", "model", "where", "only", "listed", "propertyList", "are", "present", "." ]
9b5bab44113e0adb74bf1ee436013e8a7c608d00
https://github.com/tvesalainen/hoski-lib/blob/9b5bab44113e0adb74bf1ee436013e8a7c608d00/src/main/java/fi/hoski/datastore/repository/DataObjectModel.java#L184-L193
152,077
tvesalainen/hoski-lib
src/main/java/fi/hoski/datastore/repository/DataObjectModel.java
DataObjectModel.view
public DataObjectModel view(Collection<? extends DataObject> dos) { DataObjectModel view = clone(); view.propertyList = new ArrayList<String>(); Set<String> propertySet = new HashSet<String>(); for (DataObject dob : dos) { for (String property : propertyList) // TODO performance { Object value = dob.get(property); if (value != null) { propertySet.add(property); } } } for (String property : propertyList) { if (propertySet.contains(property)) { view.propertyList.add(property); } } return view; }
java
public DataObjectModel view(Collection<? extends DataObject> dos) { DataObjectModel view = clone(); view.propertyList = new ArrayList<String>(); Set<String> propertySet = new HashSet<String>(); for (DataObject dob : dos) { for (String property : propertyList) // TODO performance { Object value = dob.get(property); if (value != null) { propertySet.add(property); } } } for (String property : propertyList) { if (propertySet.contains(property)) { view.propertyList.add(property); } } return view; }
[ "public", "DataObjectModel", "view", "(", "Collection", "<", "?", "extends", "DataObject", ">", "dos", ")", "{", "DataObjectModel", "view", "=", "clone", "(", ")", ";", "view", ".", "propertyList", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "Set", "<", "String", ">", "propertySet", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "for", "(", "DataObject", "dob", ":", "dos", ")", "{", "for", "(", "String", "property", ":", "propertyList", ")", "// TODO performance\r", "{", "Object", "value", "=", "dob", ".", "get", "(", "property", ")", ";", "if", "(", "value", "!=", "null", ")", "{", "propertySet", ".", "add", "(", "property", ")", ";", "}", "}", "}", "for", "(", "String", "property", ":", "propertyList", ")", "{", "if", "(", "propertySet", ".", "contains", "(", "property", ")", ")", "{", "view", ".", "propertyList", ".", "add", "(", "property", ")", ";", "}", "}", "return", "view", ";", "}" ]
Returns a clone of this model where only properties that have values are present @param dos @return
[ "Returns", "a", "clone", "of", "this", "model", "where", "only", "properties", "that", "have", "values", "are", "present" ]
9b5bab44113e0adb74bf1ee436013e8a7c608d00
https://github.com/tvesalainen/hoski-lib/blob/9b5bab44113e0adb74bf1ee436013e8a7c608d00/src/main/java/fi/hoski/datastore/repository/DataObjectModel.java#L199-L223
152,078
tvesalainen/hoski-lib
src/main/java/fi/hoski/datastore/repository/DataObjectModel.java
DataObjectModel.hide
public DataObjectModel hide(String... properties) { DataObjectModel view = clone(); view.propertyList = new ArrayList<String>(); view.propertyList.addAll(this.propertyList); for (String property : properties) { view.propertyList.remove(property); } return view; }
java
public DataObjectModel hide(String... properties) { DataObjectModel view = clone(); view.propertyList = new ArrayList<String>(); view.propertyList.addAll(this.propertyList); for (String property : properties) { view.propertyList.remove(property); } return view; }
[ "public", "DataObjectModel", "hide", "(", "String", "...", "properties", ")", "{", "DataObjectModel", "view", "=", "clone", "(", ")", ";", "view", ".", "propertyList", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "view", ".", "propertyList", ".", "addAll", "(", "this", ".", "propertyList", ")", ";", "for", "(", "String", "property", ":", "properties", ")", "{", "view", ".", "propertyList", ".", "remove", "(", "property", ")", ";", "}", "return", "view", ";", "}" ]
Returns a clone of model where listed propertyList are hidden; @param properties @return
[ "Returns", "a", "clone", "of", "model", "where", "listed", "propertyList", "are", "hidden", ";" ]
9b5bab44113e0adb74bf1ee436013e8a7c608d00
https://github.com/tvesalainen/hoski-lib/blob/9b5bab44113e0adb74bf1ee436013e8a7c608d00/src/main/java/fi/hoski/datastore/repository/DataObjectModel.java#L229-L239
152,079
fuinorg/utils4swing
src/main/java/org/fuin/utils4swing/dialogs/DirectorySelectionPanel.java
DirectorySelectionPanel.getButtonOK
protected final JButton getButtonOK() { if (buttonOK == null) { buttonOK = new JButton(); buttonOK.setText("OK"); buttonOK.setPreferredSize(new Dimension(80, 26)); buttonOK.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { if (destDirSelector != null) { destDirSelector.ok(); } } }); } return buttonOK; }
java
protected final JButton getButtonOK() { if (buttonOK == null) { buttonOK = new JButton(); buttonOK.setText("OK"); buttonOK.setPreferredSize(new Dimension(80, 26)); buttonOK.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { if (destDirSelector != null) { destDirSelector.ok(); } } }); } return buttonOK; }
[ "protected", "final", "JButton", "getButtonOK", "(", ")", "{", "if", "(", "buttonOK", "==", "null", ")", "{", "buttonOK", "=", "new", "JButton", "(", ")", ";", "buttonOK", ".", "setText", "(", "\"OK\"", ")", ";", "buttonOK", ".", "setPreferredSize", "(", "new", "Dimension", "(", "80", ",", "26", ")", ")", ";", "buttonOK", ".", "addActionListener", "(", "new", "ActionListener", "(", ")", "{", "public", "void", "actionPerformed", "(", "final", "ActionEvent", "e", ")", "{", "if", "(", "destDirSelector", "!=", "null", ")", "{", "destDirSelector", ".", "ok", "(", ")", ";", "}", "}", "}", ")", ";", "}", "return", "buttonOK", ";", "}" ]
Returns the 'OK' button for usage as default button. @return Button.
[ "Returns", "the", "OK", "button", "for", "usage", "as", "default", "button", "." ]
560fb69eac182e3473de9679c3c15433e524ef6b
https://github.com/fuinorg/utils4swing/blob/560fb69eac182e3473de9679c3c15433e524ef6b/src/main/java/org/fuin/utils4swing/dialogs/DirectorySelectionPanel.java#L153-L167
152,080
fuinorg/utils4swing
src/main/java/org/fuin/utils4swing/dialogs/DirectorySelectionPanel.java
DirectorySelectionPanel.getButtonCancel
protected final JButton getButtonCancel() { if (buttonCancel == null) { buttonCancel = new JButton(); buttonCancel.setText("Cancel"); buttonCancel.setPreferredSize(new Dimension(80, 26)); buttonCancel.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { if (destDirSelector != null) { destDirSelector.cancel(); } } }); } return buttonCancel; }
java
protected final JButton getButtonCancel() { if (buttonCancel == null) { buttonCancel = new JButton(); buttonCancel.setText("Cancel"); buttonCancel.setPreferredSize(new Dimension(80, 26)); buttonCancel.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { if (destDirSelector != null) { destDirSelector.cancel(); } } }); } return buttonCancel; }
[ "protected", "final", "JButton", "getButtonCancel", "(", ")", "{", "if", "(", "buttonCancel", "==", "null", ")", "{", "buttonCancel", "=", "new", "JButton", "(", ")", ";", "buttonCancel", ".", "setText", "(", "\"Cancel\"", ")", ";", "buttonCancel", ".", "setPreferredSize", "(", "new", "Dimension", "(", "80", ",", "26", ")", ")", ";", "buttonCancel", ".", "addActionListener", "(", "new", "ActionListener", "(", ")", "{", "public", "void", "actionPerformed", "(", "final", "ActionEvent", "e", ")", "{", "if", "(", "destDirSelector", "!=", "null", ")", "{", "destDirSelector", ".", "cancel", "(", ")", ";", "}", "}", "}", ")", ";", "}", "return", "buttonCancel", ";", "}" ]
Returns the 'Cancel' button for usage as default button. @return Button.
[ "Returns", "the", "Cancel", "button", "for", "usage", "as", "default", "button", "." ]
560fb69eac182e3473de9679c3c15433e524ef6b
https://github.com/fuinorg/utils4swing/blob/560fb69eac182e3473de9679c3c15433e524ef6b/src/main/java/org/fuin/utils4swing/dialogs/DirectorySelectionPanel.java#L174-L188
152,081
js-lib-com/net-client
src/main/java/js/net/client/EventStreamClient.java
EventStreamClient.open
public void open(URL eventStreamURL) throws IOException { log.info("Connecting to event stream |%s|.", eventStreamURL); connection = (HttpURLConnection) eventStreamURL.openConnection(); connection.setConnectTimeout(CONNECTION_TIMEOUT); connection.setReadTimeout(READ_TIMEOUT); connection.setRequestProperty("Accept", "text/event-stream"); connection.setRequestProperty("Connection", "keep-alive"); connection.setRequestProperty("Pragma", "no-cache"); connection.setRequestProperty("Cache", "no-cache"); // at this point HTTP URL connection implementation sends request and waits for response // then parses first line and headers and return input stream for body content inputStream = connection.getInputStream(); }
java
public void open(URL eventStreamURL) throws IOException { log.info("Connecting to event stream |%s|.", eventStreamURL); connection = (HttpURLConnection) eventStreamURL.openConnection(); connection.setConnectTimeout(CONNECTION_TIMEOUT); connection.setReadTimeout(READ_TIMEOUT); connection.setRequestProperty("Accept", "text/event-stream"); connection.setRequestProperty("Connection", "keep-alive"); connection.setRequestProperty("Pragma", "no-cache"); connection.setRequestProperty("Cache", "no-cache"); // at this point HTTP URL connection implementation sends request and waits for response // then parses first line and headers and return input stream for body content inputStream = connection.getInputStream(); }
[ "public", "void", "open", "(", "URL", "eventStreamURL", ")", "throws", "IOException", "{", "log", ".", "info", "(", "\"Connecting to event stream |%s|.\"", ",", "eventStreamURL", ")", ";", "connection", "=", "(", "HttpURLConnection", ")", "eventStreamURL", ".", "openConnection", "(", ")", ";", "connection", ".", "setConnectTimeout", "(", "CONNECTION_TIMEOUT", ")", ";", "connection", ".", "setReadTimeout", "(", "READ_TIMEOUT", ")", ";", "connection", ".", "setRequestProperty", "(", "\"Accept\"", ",", "\"text/event-stream\"", ")", ";", "connection", ".", "setRequestProperty", "(", "\"Connection\"", ",", "\"keep-alive\"", ")", ";", "connection", ".", "setRequestProperty", "(", "\"Pragma\"", ",", "\"no-cache\"", ")", ";", "connection", ".", "setRequestProperty", "(", "\"Cache\"", ",", "\"no-cache\"", ")", ";", "// at this point HTTP URL connection implementation sends request and waits for response\r", "// then parses first line and headers and return input stream for body content\r", "inputStream", "=", "connection", ".", "getInputStream", "(", ")", ";", "}" ]
Opens connection with given event stream and initialize internal input stream. Because this method involve networking and server side processes it is not instant. Anyway, usually cannot exceed one second or two. @param eventStreamURL event stream URL. @throws IOException if event stream connection fails including connection timeout.
[ "Opens", "connection", "with", "given", "event", "stream", "and", "initialize", "internal", "input", "stream", ".", "Because", "this", "method", "involve", "networking", "and", "server", "side", "processes", "it", "is", "not", "instant", ".", "Anyway", "usually", "cannot", "exceed", "one", "second", "or", "two", "." ]
0489f85d8baa1be1ff115aa79929e0cf05d4c72d
https://github.com/js-lib-com/net-client/blob/0489f85d8baa1be1ff115aa79929e0cf05d4c72d/src/main/java/js/net/client/EventStreamClient.java#L109-L123
152,082
js-lib-com/net-client
src/main/java/js/net/client/EventStreamClient.java
EventStreamClient.close
public void close() throws InterruptedException { assert connection != null; if (connection != null) { Files.close(inputStream); if (thread.isAlive()) { synchronized (this) { if (thread.isAlive()) { thread.wait(THREAD_STOP_TIMEOUT); } } } } }
java
public void close() throws InterruptedException { assert connection != null; if (connection != null) { Files.close(inputStream); if (thread.isAlive()) { synchronized (this) { if (thread.isAlive()) { thread.wait(THREAD_STOP_TIMEOUT); } } } } }
[ "public", "void", "close", "(", ")", "throws", "InterruptedException", "{", "assert", "connection", "!=", "null", ";", "if", "(", "connection", "!=", "null", ")", "{", "Files", ".", "close", "(", "inputStream", ")", ";", "if", "(", "thread", ".", "isAlive", "(", ")", ")", "{", "synchronized", "(", "this", ")", "{", "if", "(", "thread", ".", "isAlive", "(", ")", ")", "{", "thread", ".", "wait", "(", "THREAD_STOP_TIMEOUT", ")", ";", "}", "}", "}", "}", "}" ]
Close this event stream client. This method stops receiving thread and closes internal input stream. It is not necessary if end of event stream is controlled by server side, in with case this event stream client does auto-close. @throws InterruptedException if waiting for thread close is interrupted.
[ "Close", "this", "event", "stream", "client", ".", "This", "method", "stops", "receiving", "thread", "and", "closes", "internal", "input", "stream", ".", "It", "is", "not", "necessary", "if", "end", "of", "event", "stream", "is", "controlled", "by", "server", "side", "in", "with", "case", "this", "event", "stream", "client", "does", "auto", "-", "close", "." ]
0489f85d8baa1be1ff115aa79929e0cf05d4c72d
https://github.com/js-lib-com/net-client/blob/0489f85d8baa1be1ff115aa79929e0cf05d4c72d/src/main/java/js/net/client/EventStreamClient.java#L155-L167
152,083
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/field/event/RegisterValueHandler.java
RegisterValueHandler.retrieveUserProperties
public PropertyOwner retrieveUserProperties() { Record record = this.getOwner().getRecord(); ComponentParent screen = null; if (record.getRecordOwner() instanceof ComponentParent) screen = (ComponentParent)record.getRecordOwner(); if (screen != null) return screen.retrieveUserProperties(); // Return the registration key else return null; // Must have a screen for this to work }
java
public PropertyOwner retrieveUserProperties() { Record record = this.getOwner().getRecord(); ComponentParent screen = null; if (record.getRecordOwner() instanceof ComponentParent) screen = (ComponentParent)record.getRecordOwner(); if (screen != null) return screen.retrieveUserProperties(); // Return the registration key else return null; // Must have a screen for this to work }
[ "public", "PropertyOwner", "retrieveUserProperties", "(", ")", "{", "Record", "record", "=", "this", ".", "getOwner", "(", ")", ".", "getRecord", "(", ")", ";", "ComponentParent", "screen", "=", "null", ";", "if", "(", "record", ".", "getRecordOwner", "(", ")", "instanceof", "ComponentParent", ")", "screen", "=", "(", "ComponentParent", ")", "record", ".", "getRecordOwner", "(", ")", ";", "if", "(", "screen", "!=", "null", ")", "return", "screen", ".", "retrieveUserProperties", "(", ")", ";", "// Return the registration key", "else", "return", "null", ";", "// Must have a screen for this to work", "}" ]
Get the owner of this property key. The registration key is the screen's key. The property key is the field name. @return The owner of this property key.
[ "Get", "the", "owner", "of", "this", "property", "key", ".", "The", "registration", "key", "is", "the", "screen", "s", "key", ".", "The", "property", "key", "is", "the", "field", "name", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/event/RegisterValueHandler.java#L113-L123
152,084
BeholderTAF/beholder-selenium
src/main/java/br/ufmg/dcc/saotome/beholder/selenium/ui/form/SeleniumSelectField.java
SeleniumSelectField.select
private void select(Type type, Object value) { assert value != null; reloadElement(); this.selectByType(type, value); }
java
private void select(Type type, Object value) { assert value != null; reloadElement(); this.selectByType(type, value); }
[ "private", "void", "select", "(", "Type", "type", ",", "Object", "value", ")", "{", "assert", "value", "!=", "null", ";", "reloadElement", "(", ")", ";", "this", ".", "selectByType", "(", "type", ",", "value", ")", ";", "}" ]
this private method try to search the value of the select for n seconds specified by TIMEOUT static variable. The coerence if the data passed is or isn't the correct value is responsability of the test developer. @param type values defined by the Type private enumeration @param value value to be selected
[ "this", "private", "method", "try", "to", "search", "the", "value", "of", "the", "select", "for", "n", "seconds", "specified", "by", "TIMEOUT", "static", "variable", ".", "The", "coerence", "if", "the", "data", "passed", "is", "or", "isn", "t", "the", "correct", "value", "is", "responsability", "of", "the", "test", "developer", "." ]
8dc999e74a9c3f5c09e4e68ea0ef5634cdb760ee
https://github.com/BeholderTAF/beholder-selenium/blob/8dc999e74a9c3f5c09e4e68ea0ef5634cdb760ee/src/main/java/br/ufmg/dcc/saotome/beholder/selenium/ui/form/SeleniumSelectField.java#L112-L118
152,085
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/field/convert/BitConverter.java
BitConverter.getState
public boolean getState() { if (this.getData() == null) return m_bTrueIfNull; int fieldValue = (int)this.getValue(); boolean returnValue = false; if ((fieldValue & (1 << m_iBitNumber)) != 0) returnValue = true; if (m_bTrueIfMatch) return returnValue; else return !returnValue; }
java
public boolean getState() { if (this.getData() == null) return m_bTrueIfNull; int fieldValue = (int)this.getValue(); boolean returnValue = false; if ((fieldValue & (1 << m_iBitNumber)) != 0) returnValue = true; if (m_bTrueIfMatch) return returnValue; else return !returnValue; }
[ "public", "boolean", "getState", "(", ")", "{", "if", "(", "this", ".", "getData", "(", ")", "==", "null", ")", "return", "m_bTrueIfNull", ";", "int", "fieldValue", "=", "(", "int", ")", "this", ".", "getValue", "(", ")", ";", "boolean", "returnValue", "=", "false", ";", "if", "(", "(", "fieldValue", "&", "(", "1", "<<", "m_iBitNumber", ")", ")", "!=", "0", ")", "returnValue", "=", "true", ";", "if", "(", "m_bTrueIfMatch", ")", "return", "returnValue", ";", "else", "return", "!", "returnValue", ";", "}" ]
For binary fields, return the current state. Gets the state of the target bit. @param True is this field is true.
[ "For", "binary", "fields", "return", "the", "current", "state", ".", "Gets", "the", "state", "of", "the", "target", "bit", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/convert/BitConverter.java#L101-L113
152,086
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/field/convert/BitConverter.java
BitConverter.setState
public int setState(boolean bState, boolean bDisplayOption, int iMoveMode) { int iFieldValue = (int)this.getValue(); if (!m_bTrueIfMatch) bState = !bState; // Do opposite operation if (bState) iFieldValue |= (1 << m_iBitNumber); // Set the bit else iFieldValue &= ~(1 << m_iBitNumber); // Clear the bit return this.setValue(iFieldValue, bDisplayOption, iMoveMode); }
java
public int setState(boolean bState, boolean bDisplayOption, int iMoveMode) { int iFieldValue = (int)this.getValue(); if (!m_bTrueIfMatch) bState = !bState; // Do opposite operation if (bState) iFieldValue |= (1 << m_iBitNumber); // Set the bit else iFieldValue &= ~(1 << m_iBitNumber); // Clear the bit return this.setValue(iFieldValue, bDisplayOption, iMoveMode); }
[ "public", "int", "setState", "(", "boolean", "bState", ",", "boolean", "bDisplayOption", ",", "int", "iMoveMode", ")", "{", "int", "iFieldValue", "=", "(", "int", ")", "this", ".", "getValue", "(", ")", ";", "if", "(", "!", "m_bTrueIfMatch", ")", "bState", "=", "!", "bState", ";", "// Do opposite operation", "if", "(", "bState", ")", "iFieldValue", "|=", "(", "1", "<<", "m_iBitNumber", ")", ";", "// Set the bit", "else", "iFieldValue", "&=", "~", "(", "1", "<<", "m_iBitNumber", ")", ";", "// Clear the bit", "return", "this", ".", "setValue", "(", "iFieldValue", ",", "bDisplayOption", ",", "iMoveMode", ")", ";", "}" ]
For binary fields, set the current state. Sets the target bit to the state. @param state The state to set this field. @param bDisplayOption Display changed fields if true. @param iMoveMode The move mode. @return The error code (or NORMAL_RETURN).
[ "For", "binary", "fields", "set", "the", "current", "state", ".", "Sets", "the", "target", "bit", "to", "the", "state", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/convert/BitConverter.java#L122-L132
152,087
tsweets/jdefault
src/main/java/org/beer30/jdefault/JDefaultBase.java
JDefaultBase.findStream
private static InputStream findStream(String filename) { InputStream streamOnClass = JDefaultAddress.class.getResourceAsStream(filename); if (streamOnClass != null) { return streamOnClass; } InputStream is = JDefaultAddress.class.getClassLoader().getResourceAsStream(filename); return is; }
java
private static InputStream findStream(String filename) { InputStream streamOnClass = JDefaultAddress.class.getResourceAsStream(filename); if (streamOnClass != null) { return streamOnClass; } InputStream is = JDefaultAddress.class.getClassLoader().getResourceAsStream(filename); return is; }
[ "private", "static", "InputStream", "findStream", "(", "String", "filename", ")", "{", "InputStream", "streamOnClass", "=", "JDefaultAddress", ".", "class", ".", "getResourceAsStream", "(", "filename", ")", ";", "if", "(", "streamOnClass", "!=", "null", ")", "{", "return", "streamOnClass", ";", "}", "InputStream", "is", "=", "JDefaultAddress", ".", "class", ".", "getClassLoader", "(", ")", ".", "getResourceAsStream", "(", "filename", ")", ";", "return", "is", ";", "}" ]
Finds the InputStream of a file in a Jar @param filename of the stream to return @return the file's InputStream
[ "Finds", "the", "InputStream", "of", "a", "file", "in", "a", "Jar" ]
1793ab8e1337e930f31e362071db4af0c3978b70
https://github.com/tsweets/jdefault/blob/1793ab8e1337e930f31e362071db4af0c3978b70/src/main/java/org/beer30/jdefault/JDefaultBase.java#L56-L63
152,088
tsweets/jdefault
src/main/java/org/beer30/jdefault/JDefaultBase.java
JDefaultBase.fetch
protected static Object fetch(String key) { List valuesArray = (List) fetchObject(key); return valuesArray.get(RandomUtils.nextInt(valuesArray.size())); }
java
protected static Object fetch(String key) { List valuesArray = (List) fetchObject(key); return valuesArray.get(RandomUtils.nextInt(valuesArray.size())); }
[ "protected", "static", "Object", "fetch", "(", "String", "key", ")", "{", "List", "valuesArray", "=", "(", "List", ")", "fetchObject", "(", "key", ")", ";", "return", "valuesArray", ".", "get", "(", "RandomUtils", ".", "nextInt", "(", "valuesArray", ".", "size", "(", ")", ")", ")", ";", "}" ]
Fetches a random Object from the dictionary based on a key @param key of the object to find @return the Object that represents the key
[ "Fetches", "a", "random", "Object", "from", "the", "dictionary", "based", "on", "a", "key" ]
1793ab8e1337e930f31e362071db4af0c3978b70
https://github.com/tsweets/jdefault/blob/1793ab8e1337e930f31e362071db4af0c3978b70/src/main/java/org/beer30/jdefault/JDefaultBase.java#L71-L74
152,089
tsweets/jdefault
src/main/java/org/beer30/jdefault/JDefaultBase.java
JDefaultBase.fetchList
protected static String fetchList(String key) { List valuesArray = (List) fetchObject(key); //TODO: Make this dynamic - assumes 3 lists List<String> stringList1 = (List<String>) valuesArray.get(0); List<String> stringList2 = (List<String>) valuesArray.get(1); List<String> stringList3 = (List<String>) valuesArray.get(2); return stringList1.get(RandomUtils.nextInt(stringList1.size())) + " " + stringList2.get(RandomUtils.nextInt(stringList2.size())) + " " + stringList3.get(RandomUtils.nextInt(stringList3.size())); }
java
protected static String fetchList(String key) { List valuesArray = (List) fetchObject(key); //TODO: Make this dynamic - assumes 3 lists List<String> stringList1 = (List<String>) valuesArray.get(0); List<String> stringList2 = (List<String>) valuesArray.get(1); List<String> stringList3 = (List<String>) valuesArray.get(2); return stringList1.get(RandomUtils.nextInt(stringList1.size())) + " " + stringList2.get(RandomUtils.nextInt(stringList2.size())) + " " + stringList3.get(RandomUtils.nextInt(stringList3.size())); }
[ "protected", "static", "String", "fetchList", "(", "String", "key", ")", "{", "List", "valuesArray", "=", "(", "List", ")", "fetchObject", "(", "key", ")", ";", "//TODO: Make this dynamic - assumes 3 lists", "List", "<", "String", ">", "stringList1", "=", "(", "List", "<", "String", ">", ")", "valuesArray", ".", "get", "(", "0", ")", ";", "List", "<", "String", ">", "stringList2", "=", "(", "List", "<", "String", ">", ")", "valuesArray", ".", "get", "(", "1", ")", ";", "List", "<", "String", ">", "stringList3", "=", "(", "List", "<", "String", ">", ")", "valuesArray", ".", "get", "(", "2", ")", ";", "return", "stringList1", ".", "get", "(", "RandomUtils", ".", "nextInt", "(", "stringList1", ".", "size", "(", ")", ")", ")", "+", "\" \"", "+", "stringList2", ".", "get", "(", "RandomUtils", ".", "nextInt", "(", "stringList2", ".", "size", "(", ")", ")", ")", "+", "\" \"", "+", "stringList3", ".", "get", "(", "RandomUtils", ".", "nextInt", "(", "stringList3", ".", "size", "(", ")", ")", ")", ";", "}" ]
Fetches a List of of Values @param key of the values to find @return random value from each list
[ "Fetches", "a", "List", "of", "of", "Values" ]
1793ab8e1337e930f31e362071db4af0c3978b70
https://github.com/tsweets/jdefault/blob/1793ab8e1337e930f31e362071db4af0c3978b70/src/main/java/org/beer30/jdefault/JDefaultBase.java#L82-L92
152,090
tsweets/jdefault
src/main/java/org/beer30/jdefault/JDefaultBase.java
JDefaultBase.fetchString
protected static String fetchString(String key) { List<String> stringList = (List<String>) fetchObject(key); return stringList.get(RandomUtils.nextInt(stringList.size())); }
java
protected static String fetchString(String key) { List<String> stringList = (List<String>) fetchObject(key); return stringList.get(RandomUtils.nextInt(stringList.size())); }
[ "protected", "static", "String", "fetchString", "(", "String", "key", ")", "{", "List", "<", "String", ">", "stringList", "=", "(", "List", "<", "String", ">", ")", "fetchObject", "(", "key", ")", ";", "return", "stringList", ".", "get", "(", "RandomUtils", ".", "nextInt", "(", "stringList", ".", "size", "(", ")", ")", ")", ";", "}" ]
Fetches a value @param key of the value to find @return the value converted to type String
[ "Fetches", "a", "value" ]
1793ab8e1337e930f31e362071db4af0c3978b70
https://github.com/tsweets/jdefault/blob/1793ab8e1337e930f31e362071db4af0c3978b70/src/main/java/org/beer30/jdefault/JDefaultBase.java#L100-L105
152,091
tsweets/jdefault
src/main/java/org/beer30/jdefault/JDefaultBase.java
JDefaultBase.fetchObject
protected static Object fetchObject(String key) { String[] path = key.split("\\."); Object currentValue = fakeValuesMap; for (String pathSection : path) { currentValue = ((Map<String, Object>) currentValue).get(pathSection); } return currentValue; }
java
protected static Object fetchObject(String key) { String[] path = key.split("\\."); Object currentValue = fakeValuesMap; for (String pathSection : path) { currentValue = ((Map<String, Object>) currentValue).get(pathSection); } return currentValue; }
[ "protected", "static", "Object", "fetchObject", "(", "String", "key", ")", "{", "String", "[", "]", "path", "=", "key", ".", "split", "(", "\"\\\\.\"", ")", ";", "Object", "currentValue", "=", "fakeValuesMap", ";", "for", "(", "String", "pathSection", ":", "path", ")", "{", "currentValue", "=", "(", "(", "Map", "<", "String", ",", "Object", ">", ")", "currentValue", ")", ".", "get", "(", "pathSection", ")", ";", "}", "return", "currentValue", ";", "}" ]
Finds map of values based on a key @param key to lookup @return map of key value pairs
[ "Finds", "map", "of", "values", "based", "on", "a", "key" ]
1793ab8e1337e930f31e362071db4af0c3978b70
https://github.com/tsweets/jdefault/blob/1793ab8e1337e930f31e362071db4af0c3978b70/src/main/java/org/beer30/jdefault/JDefaultBase.java#L113-L120
152,092
tsweets/jdefault
src/main/java/org/beer30/jdefault/JDefaultBase.java
JDefaultBase.letterify
protected static String letterify(String letterString) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < letterString.length(); i++) { if (letterString.charAt(i) == '?') { sb.append((char) (97 + RandomUtils.nextInt(26))); // a-z } else { sb.append(letterString.charAt(i)); } } return sb.toString(); }
java
protected static String letterify(String letterString) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < letterString.length(); i++) { if (letterString.charAt(i) == '?') { sb.append((char) (97 + RandomUtils.nextInt(26))); // a-z } else { sb.append(letterString.charAt(i)); } } return sb.toString(); }
[ "protected", "static", "String", "letterify", "(", "String", "letterString", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "letterString", ".", "length", "(", ")", ";", "i", "++", ")", "{", "if", "(", "letterString", ".", "charAt", "(", "i", ")", "==", "'", "'", ")", "{", "sb", ".", "append", "(", "(", "char", ")", "(", "97", "+", "RandomUtils", ".", "nextInt", "(", "26", ")", ")", ")", ";", "// a-z", "}", "else", "{", "sb", ".", "append", "(", "letterString", ".", "charAt", "(", "i", ")", ")", ";", "}", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Replace '?' in a string with random letters @param letterString to insert random letters @return a string with random letters
[ "Replace", "?", "in", "a", "string", "with", "random", "letters" ]
1793ab8e1337e930f31e362071db4af0c3978b70
https://github.com/tsweets/jdefault/blob/1793ab8e1337e930f31e362071db4af0c3978b70/src/main/java/org/beer30/jdefault/JDefaultBase.java#L147-L158
152,093
tsweets/jdefault
src/main/java/org/beer30/jdefault/JDefaultBase.java
JDefaultBase.parseFoundKey
protected static String parseFoundKey(String value) { // System.out.println("Start Value: " + value); String regex = "#\\{([A-Za-z]+\\.)?([^\\}]+)\\}"; Pattern p = Pattern.compile(regex); Matcher matcher = p.matcher(value); while (matcher.find()) { // System.out.print("Start index: " + matcher.start()); // System.out.print(" End index: " + matcher.end() + " \n"); String keyMatched = matcher.group().trim(); // System.out.println("Key: " + keyMatched); String trimmedKey = StringUtils.substring(keyMatched, 2, keyMatched.length() - 1); // System.out.println("Trimmed Key: " + trimmedKey); String replacedValue = fetchString(trimmedKey); // System.out.println("Replaced Value: " + replacedValue); if (StringUtils.contains(replacedValue, "#{")) { replacedValue = parseFoundKey(replacedValue); } value = StringUtils.replace(value, keyMatched, replacedValue); // System.out.println("New Value: " + value); } return value; }
java
protected static String parseFoundKey(String value) { // System.out.println("Start Value: " + value); String regex = "#\\{([A-Za-z]+\\.)?([^\\}]+)\\}"; Pattern p = Pattern.compile(regex); Matcher matcher = p.matcher(value); while (matcher.find()) { // System.out.print("Start index: " + matcher.start()); // System.out.print(" End index: " + matcher.end() + " \n"); String keyMatched = matcher.group().trim(); // System.out.println("Key: " + keyMatched); String trimmedKey = StringUtils.substring(keyMatched, 2, keyMatched.length() - 1); // System.out.println("Trimmed Key: " + trimmedKey); String replacedValue = fetchString(trimmedKey); // System.out.println("Replaced Value: " + replacedValue); if (StringUtils.contains(replacedValue, "#{")) { replacedValue = parseFoundKey(replacedValue); } value = StringUtils.replace(value, keyMatched, replacedValue); // System.out.println("New Value: " + value); } return value; }
[ "protected", "static", "String", "parseFoundKey", "(", "String", "value", ")", "{", "// System.out.println(\"Start Value: \" + value);", "String", "regex", "=", "\"#\\\\{([A-Za-z]+\\\\.)?([^\\\\}]+)\\\\}\"", ";", "Pattern", "p", "=", "Pattern", ".", "compile", "(", "regex", ")", ";", "Matcher", "matcher", "=", "p", ".", "matcher", "(", "value", ")", ";", "while", "(", "matcher", ".", "find", "(", ")", ")", "{", "// System.out.print(\"Start index: \" + matcher.start());", "// System.out.print(\" End index: \" + matcher.end() + \" \\n\");", "String", "keyMatched", "=", "matcher", ".", "group", "(", ")", ".", "trim", "(", ")", ";", "// System.out.println(\"Key: \" + keyMatched);", "String", "trimmedKey", "=", "StringUtils", ".", "substring", "(", "keyMatched", ",", "2", ",", "keyMatched", ".", "length", "(", ")", "-", "1", ")", ";", "// System.out.println(\"Trimmed Key: \" + trimmedKey);", "String", "replacedValue", "=", "fetchString", "(", "trimmedKey", ")", ";", "// System.out.println(\"Replaced Value: \" + replacedValue);", "if", "(", "StringUtils", ".", "contains", "(", "replacedValue", ",", "\"#{\"", ")", ")", "{", "replacedValue", "=", "parseFoundKey", "(", "replacedValue", ")", ";", "}", "value", "=", "StringUtils", ".", "replace", "(", "value", ",", "keyMatched", ",", "replacedValue", ")", ";", "// System.out.println(\"New Value: \" + value);", "}", "return", "value", ";", "}" ]
resolves an embedded key @param value embedded key that has been already fetched @return fully resolved string
[ "resolves", "an", "embedded", "key" ]
1793ab8e1337e930f31e362071db4af0c3978b70
https://github.com/tsweets/jdefault/blob/1793ab8e1337e930f31e362071db4af0c3978b70/src/main/java/org/beer30/jdefault/JDefaultBase.java#L189-L213
152,094
jbundle/jbundle
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/thread/SyncPageWorker.java
SyncPageWorker.run
public void run() { // Note: To make sure the user gets a chance to see the // html text, we wait for a paint before returing. // Since these threads are stacked in a private thread queue, the next // thread is not executed until this one is finished. if (! EventQueue.isDispatchThread() )// && Runtime.getRuntime().availableProcessors() == 1) { if (!m_syncPage.isPaintCalled()) { // Wait for the previous call to finish synchronized (m_syncPage) { while (!m_syncPage.isPaintCalled()) { try { m_syncPage.wait(); } catch (InterruptedException e) {} } } } synchronized (m_syncPage) { m_syncPage.setPaintCalled(false); this.runPageLoader(); while (!m_syncPage.isPaintCalled()) { try { m_syncPage.wait(); } catch (InterruptedException e) {} } this.afterPageDisplay(); } } }
java
public void run() { // Note: To make sure the user gets a chance to see the // html text, we wait for a paint before returing. // Since these threads are stacked in a private thread queue, the next // thread is not executed until this one is finished. if (! EventQueue.isDispatchThread() )// && Runtime.getRuntime().availableProcessors() == 1) { if (!m_syncPage.isPaintCalled()) { // Wait for the previous call to finish synchronized (m_syncPage) { while (!m_syncPage.isPaintCalled()) { try { m_syncPage.wait(); } catch (InterruptedException e) {} } } } synchronized (m_syncPage) { m_syncPage.setPaintCalled(false); this.runPageLoader(); while (!m_syncPage.isPaintCalled()) { try { m_syncPage.wait(); } catch (InterruptedException e) {} } this.afterPageDisplay(); } } }
[ "public", "void", "run", "(", ")", "{", "// Note: To make sure the user gets a chance to see the", "// html text, we wait for a paint before returing.", "// Since these threads are stacked in a private thread queue, the next", "// thread is not executed until this one is finished.", "if", "(", "!", "EventQueue", ".", "isDispatchThread", "(", ")", ")", "// && Runtime.getRuntime().availableProcessors() == 1)", "{", "if", "(", "!", "m_syncPage", ".", "isPaintCalled", "(", ")", ")", "{", "// Wait for the previous call to finish", "synchronized", "(", "m_syncPage", ")", "{", "while", "(", "!", "m_syncPage", ".", "isPaintCalled", "(", ")", ")", "{", "try", "{", "m_syncPage", ".", "wait", "(", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "}", "}", "}", "synchronized", "(", "m_syncPage", ")", "{", "m_syncPage", ".", "setPaintCalled", "(", "false", ")", ";", "this", ".", "runPageLoader", "(", ")", ";", "while", "(", "!", "m_syncPage", ".", "isPaintCalled", "(", ")", ")", "{", "try", "{", "m_syncPage", ".", "wait", "(", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "}", "this", ".", "afterPageDisplay", "(", ")", ";", "}", "}", "}" ]
Make sure everything goes in the right order.
[ "Make", "sure", "everything", "goes", "in", "the", "right", "order", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/thread/SyncPageWorker.java#L61-L90
152,095
carewebframework/carewebframework-vista
org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/Security.java
Security.validatePassword
public static boolean validatePassword(BrokerSession session, String password) { password = encrypt(password, session.getServerCaps().getCipherKey()); return session.callRPCBool("RGCWFUSR VALIDPSW", password); }
java
public static boolean validatePassword(BrokerSession session, String password) { password = encrypt(password, session.getServerCaps().getCipherKey()); return session.callRPCBool("RGCWFUSR VALIDPSW", password); }
[ "public", "static", "boolean", "validatePassword", "(", "BrokerSession", "session", ",", "String", "password", ")", "{", "password", "=", "encrypt", "(", "password", ",", "session", ".", "getServerCaps", "(", ")", ".", "getCipherKey", "(", ")", ")", ";", "return", "session", ".", "callRPCBool", "(", "\"RGCWFUSR VALIDPSW\"", ",", "password", ")", ";", "}" ]
Validates the current user's password. @param session Broker session. @param password Password. @return True if the password is valid.
[ "Validates", "the", "current", "user", "s", "password", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/Security.java#L69-L72
152,096
carewebframework/carewebframework-vista
org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/Security.java
Security.changePassword
public static String changePassword(BrokerSession session, String oldPassword, String newPassword) { String cipherKey = session.getServerCaps().getCipherKey(); String result = session.callRPC("RGNETBRP CVC", encrypt(oldPassword, cipherKey), encrypt(newPassword, cipherKey)); return result.startsWith("0") ? null : StrUtil.piece(result, StrUtil.U, 2); }
java
public static String changePassword(BrokerSession session, String oldPassword, String newPassword) { String cipherKey = session.getServerCaps().getCipherKey(); String result = session.callRPC("RGNETBRP CVC", encrypt(oldPassword, cipherKey), encrypt(newPassword, cipherKey)); return result.startsWith("0") ? null : StrUtil.piece(result, StrUtil.U, 2); }
[ "public", "static", "String", "changePassword", "(", "BrokerSession", "session", ",", "String", "oldPassword", ",", "String", "newPassword", ")", "{", "String", "cipherKey", "=", "session", ".", "getServerCaps", "(", ")", ".", "getCipherKey", "(", ")", ";", "String", "result", "=", "session", ".", "callRPC", "(", "\"RGNETBRP CVC\"", ",", "encrypt", "(", "oldPassword", ",", "cipherKey", ")", ",", "encrypt", "(", "newPassword", ",", "cipherKey", ")", ")", ";", "return", "result", ".", "startsWith", "(", "\"0\"", ")", "?", "null", ":", "StrUtil", ".", "piece", "(", "result", ",", "StrUtil", ".", "U", ",", "2", ")", ";", "}" ]
Change a password. @param session Broker session. @param oldPassword Old password. @param newPassword New password. @return Status message from server.
[ "Change", "a", "password", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/Security.java#L82-L86
152,097
carewebframework/carewebframework-vista
org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/Security.java
Security.encrypt
protected static String encrypt(String value, String cipherKey) { String[] cipher = CipherRegistry.getCipher(cipherKey); int associatorIndex = randomIndex(cipher.length); int identifierIndex; do { identifierIndex = randomIndex(cipher.length); } while (associatorIndex == identifierIndex); return ((char) (associatorIndex + 32)) + StrUtil.xlate(value, cipher[associatorIndex], cipher[identifierIndex]) + ((char) (identifierIndex + 32)); }
java
protected static String encrypt(String value, String cipherKey) { String[] cipher = CipherRegistry.getCipher(cipherKey); int associatorIndex = randomIndex(cipher.length); int identifierIndex; do { identifierIndex = randomIndex(cipher.length); } while (associatorIndex == identifierIndex); return ((char) (associatorIndex + 32)) + StrUtil.xlate(value, cipher[associatorIndex], cipher[identifierIndex]) + ((char) (identifierIndex + 32)); }
[ "protected", "static", "String", "encrypt", "(", "String", "value", ",", "String", "cipherKey", ")", "{", "String", "[", "]", "cipher", "=", "CipherRegistry", ".", "getCipher", "(", "cipherKey", ")", ";", "int", "associatorIndex", "=", "randomIndex", "(", "cipher", ".", "length", ")", ";", "int", "identifierIndex", ";", "do", "{", "identifierIndex", "=", "randomIndex", "(", "cipher", ".", "length", ")", ";", "}", "while", "(", "associatorIndex", "==", "identifierIndex", ")", ";", "return", "(", "(", "char", ")", "(", "associatorIndex", "+", "32", ")", ")", "+", "StrUtil", ".", "xlate", "(", "value", ",", "cipher", "[", "associatorIndex", "]", ",", "cipher", "[", "identifierIndex", "]", ")", "+", "(", "(", "char", ")", "(", "identifierIndex", "+", "32", ")", ")", ";", "}" ]
Encrypt a string value. @param value Value to encrypt. @return Encrypted value.
[ "Encrypt", "a", "string", "value", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/Security.java#L94-L105
152,098
carewebframework/carewebframework-vista
org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/Security.java
Security.decrypt
protected static final String decrypt(String value, String cipherKey) { int len = value == null ? 0 : value.length(); if (len < 3) { return ""; } int identifierIndex = value.charAt(0) - 32; int associatorIndex = value.charAt(len - 1) - 32; String[] cipher = CipherRegistry.getCipher(cipherKey); return StrUtil.xlate(value.substring(1, len - 1), cipher[associatorIndex], cipher[identifierIndex]); }
java
protected static final String decrypt(String value, String cipherKey) { int len = value == null ? 0 : value.length(); if (len < 3) { return ""; } int identifierIndex = value.charAt(0) - 32; int associatorIndex = value.charAt(len - 1) - 32; String[] cipher = CipherRegistry.getCipher(cipherKey); return StrUtil.xlate(value.substring(1, len - 1), cipher[associatorIndex], cipher[identifierIndex]); }
[ "protected", "static", "final", "String", "decrypt", "(", "String", "value", ",", "String", "cipherKey", ")", "{", "int", "len", "=", "value", "==", "null", "?", "0", ":", "value", ".", "length", "(", ")", ";", "if", "(", "len", "<", "3", ")", "{", "return", "\"\"", ";", "}", "int", "identifierIndex", "=", "value", ".", "charAt", "(", "0", ")", "-", "32", ";", "int", "associatorIndex", "=", "value", ".", "charAt", "(", "len", "-", "1", ")", "-", "32", ";", "String", "[", "]", "cipher", "=", "CipherRegistry", ".", "getCipher", "(", "cipherKey", ")", ";", "return", "StrUtil", ".", "xlate", "(", "value", ".", "substring", "(", "1", ",", "len", "-", "1", ")", ",", "cipher", "[", "associatorIndex", "]", ",", "cipher", "[", "identifierIndex", "]", ")", ";", "}" ]
Decrypt a string value. @param value Value to decrypt. @return Decrypted value.
[ "Decrypt", "a", "string", "value", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/Security.java#L113-L125
152,099
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/PublicanDocBookBuilder.java
PublicanDocBookBuilder.processConditions
@Override protected void processConditions(final BuildData buildData, final SpecTopic specTopic, final Document doc) { if (buildData.getContentSpec().getPublicanCfg() == null || !buildData.getContentSpec().getPublicanCfg().contains("condition:")) { super.processConditions(buildData, specTopic, doc); } }
java
@Override protected void processConditions(final BuildData buildData, final SpecTopic specTopic, final Document doc) { if (buildData.getContentSpec().getPublicanCfg() == null || !buildData.getContentSpec().getPublicanCfg().contains("condition:")) { super.processConditions(buildData, specTopic, doc); } }
[ "@", "Override", "protected", "void", "processConditions", "(", "final", "BuildData", "buildData", ",", "final", "SpecTopic", "specTopic", ",", "final", "Document", "doc", ")", "{", "if", "(", "buildData", ".", "getContentSpec", "(", ")", ".", "getPublicanCfg", "(", ")", "==", "null", "||", "!", "buildData", ".", "getContentSpec", "(", ")", ".", "getPublicanCfg", "(", ")", ".", "contains", "(", "\"condition:\"", ")", ")", "{", "super", ".", "processConditions", "(", "buildData", ",", "specTopic", ",", "doc", ")", ";", "}", "}" ]
Checks if the conditional pass should be done by checking to see if the publican.cfg has it's own condition set. If none are set then the conditions are processed. @param buildData Information and data structures for the build. @param specTopic The spec topic the conditions should be processed for, @param doc The DOM Document to process the conditions against.
[ "Checks", "if", "the", "conditional", "pass", "should", "be", "done", "by", "checking", "to", "see", "if", "the", "publican", ".", "cfg", "has", "it", "s", "own", "condition", "set", ".", "If", "none", "are", "set", "then", "the", "conditions", "are", "processed", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/PublicanDocBookBuilder.java#L59-L64