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
partition
stringclasses
1 value
Pkmmte/PkRSS
pkrss/src/main/java/com/pkmmte/pkrss/PkRSS.java
PkRSS.get
public List<Article> get(String url) { if(url.equals(KEY_FAVORITES)) return getFavorites(); return articleMap.get(url); }
java
public List<Article> get(String url) { if(url.equals(KEY_FAVORITES)) return getFavorites(); return articleMap.get(url); }
[ "public", "List", "<", "Article", ">", "get", "(", "String", "url", ")", "{", "if", "(", "url", ".", "equals", "(", "KEY_FAVORITES", ")", ")", "return", "getFavorites", "(", ")", ";", "return", "articleMap", ".", "get", "(", "url", ")", ";", "}" ]
Looks up the specified URL String from the saved HashMap. @param url Safe URL to look up loaded articles from. May also be {@link PkRSS#KEY_FAVORITES}. @return A {@link List} containing all loaded articles associated with that URL. May be null if no such URL has yet been loaded.
[ "Looks", "up", "the", "specified", "URL", "String", "from", "the", "saved", "HashMap", "." ]
0bc536d3bad1dade4538616f71c3a8f068eac89a
https://github.com/Pkmmte/PkRSS/blob/0bc536d3bad1dade4538616f71c3a8f068eac89a/pkrss/src/main/java/com/pkmmte/pkrss/PkRSS.java#L201-L206
train
Pkmmte/PkRSS
pkrss/src/main/java/com/pkmmte/pkrss/PkRSS.java
PkRSS.deleteAllFavorites
public void deleteAllFavorites() { long time = System.currentTimeMillis(); log("Deleting all favorites..."); favoriteDatabase.deleteAll(); log("Deleting all favorites took " + (System.currentTimeMillis() - time) + "ms"); }
java
public void deleteAllFavorites() { long time = System.currentTimeMillis(); log("Deleting all favorites..."); favoriteDatabase.deleteAll(); log("Deleting all favorites took " + (System.currentTimeMillis() - time) + "ms"); }
[ "public", "void", "deleteAllFavorites", "(", ")", "{", "long", "time", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "log", "(", "\"Deleting all favorites...\"", ")", ";", "favoriteDatabase", ".", "deleteAll", "(", ")", ";", "log", "(", "\"Deleting a...
Clears the favorites database.
[ "Clears", "the", "favorites", "database", "." ]
0bc536d3bad1dade4538616f71c3a8f068eac89a
https://github.com/Pkmmte/PkRSS/blob/0bc536d3bad1dade4538616f71c3a8f068eac89a/pkrss/src/main/java/com/pkmmte/pkrss/PkRSS.java#L371-L376
train
Pkmmte/PkRSS
pkrss/src/main/java/com/pkmmte/pkrss/PkRSS.java
PkRSS.insert
private void insert(String url, List<Article> newArticles) { if(!articleMap.containsKey(url)) articleMap.put(url, new ArrayList<Article>()); List<Article> articleList = articleMap.get(url); articleList.addAll(newArticles); log("New size for " + url + " is " + articleList.size()); }
java
private void insert(String url, List<Article> newArticles) { if(!articleMap.containsKey(url)) articleMap.put(url, new ArrayList<Article>()); List<Article> articleList = articleMap.get(url); articleList.addAll(newArticles); log("New size for " + url + " is " + articleList.size()); }
[ "private", "void", "insert", "(", "String", "url", ",", "List", "<", "Article", ">", "newArticles", ")", "{", "if", "(", "!", "articleMap", ".", "containsKey", "(", "url", ")", ")", "articleMap", ".", "put", "(", "url", ",", "new", "ArrayList", "<", ...
Inserts the passed list into the article map database. This will be cleared once the instance dies. @param url URL to associate this list with. @param newArticles Article list to store.
[ "Inserts", "the", "passed", "list", "into", "the", "article", "map", "database", ".", "This", "will", "be", "cleared", "once", "the", "instance", "dies", "." ]
0bc536d3bad1dade4538616f71c3a8f068eac89a
https://github.com/Pkmmte/PkRSS/blob/0bc536d3bad1dade4538616f71c3a8f068eac89a/pkrss/src/main/java/com/pkmmte/pkrss/PkRSS.java#L425-L433
train
Pkmmte/PkRSS
pkrss/src/main/java/com/pkmmte/pkrss/PkRSS.java
PkRSS.getRead
private void getRead() { // Execute on background thread as we don't know how large this is new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { int size = mPrefs.getInt("READ_ARRAY_SIZE", 0); boolean value; if(size < 1) return null; for(int i = 0, key; i < size; i++) { key = mPrefs.getInt("READ_ARRAY_KEY_" + i, 0); value = mPrefs.getBoolean("READ_ARRAY_VALUE_" + i, false); readList.put(key, value); } return null; } }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); }
java
private void getRead() { // Execute on background thread as we don't know how large this is new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { int size = mPrefs.getInt("READ_ARRAY_SIZE", 0); boolean value; if(size < 1) return null; for(int i = 0, key; i < size; i++) { key = mPrefs.getInt("READ_ARRAY_KEY_" + i, 0); value = mPrefs.getBoolean("READ_ARRAY_VALUE_" + i, false); readList.put(key, value); } return null; } }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); }
[ "private", "void", "getRead", "(", ")", "{", "// Execute on background thread as we don't know how large this is", "new", "AsyncTask", "<", "Void", ",", "Void", ",", "Void", ">", "(", ")", "{", "@", "Override", "protected", "Void", "doInBackground", "(", "Void", "...
Asynchronously loads read data.
[ "Asynchronously", "loads", "read", "data", "." ]
0bc536d3bad1dade4538616f71c3a8f068eac89a
https://github.com/Pkmmte/PkRSS/blob/0bc536d3bad1dade4538616f71c3a8f068eac89a/pkrss/src/main/java/com/pkmmte/pkrss/PkRSS.java#L438-L457
train
Pkmmte/PkRSS
pkrss/src/main/java/com/pkmmte/pkrss/PkRSS.java
PkRSS.writeRead
private void writeRead() { // Execute on background thread as we don't know how large this is new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { // Get editor & basic variables SharedPreferences.Editor editor = mPrefs.edit(); int size = readList.size(); boolean value; editor.putInt("READ_ARRAY_SIZE", size); for(int i = 0, key; i < size; i++) { key = readList.keyAt(i); value = readList.get(key); editor.putInt("READ_ARRAY_KEY_" + i, key); editor.putBoolean("READ_ARRAY_VALUE_" + i, value); } editor.commit(); return null; } }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); }
java
private void writeRead() { // Execute on background thread as we don't know how large this is new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { // Get editor & basic variables SharedPreferences.Editor editor = mPrefs.edit(); int size = readList.size(); boolean value; editor.putInt("READ_ARRAY_SIZE", size); for(int i = 0, key; i < size; i++) { key = readList.keyAt(i); value = readList.get(key); editor.putInt("READ_ARRAY_KEY_" + i, key); editor.putBoolean("READ_ARRAY_VALUE_" + i, value); } editor.commit(); return null; } }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); }
[ "private", "void", "writeRead", "(", ")", "{", "// Execute on background thread as we don't know how large this is", "new", "AsyncTask", "<", "Void", ",", "Void", ",", "Void", ">", "(", ")", "{", "@", "Override", "protected", "Void", "doInBackground", "(", "Void", ...
Asynchronously saves read data.
[ "Asynchronously", "saves", "read", "data", "." ]
0bc536d3bad1dade4538616f71c3a8f068eac89a
https://github.com/Pkmmte/PkRSS/blob/0bc536d3bad1dade4538616f71c3a8f068eac89a/pkrss/src/main/java/com/pkmmte/pkrss/PkRSS.java#L462-L485
train
Pkmmte/PkRSS
pkrss/src/main/java/com/pkmmte/pkrss/parser/AtomParser.java
AtomParser.pullImageLink
private String pullImageLink(String encoded) { try { XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); XmlPullParser xpp = factory.newPullParser(); xpp.setInput(new StringReader(encoded)); int eventType = xpp.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG && "img".equals(xpp.getName())) { int count = xpp.getAttributeCount(); for (int x = 0; x < count; x++) { if (xpp.getAttributeName(x).equalsIgnoreCase("src")) return pattern.matcher(xpp.getAttributeValue(x)).replaceAll(""); } } eventType = xpp.next(); } } catch (Exception e) { log(TAG, "Error pulling image link from description!\n" + e.getMessage(), Log.WARN); } return ""; }
java
private String pullImageLink(String encoded) { try { XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); XmlPullParser xpp = factory.newPullParser(); xpp.setInput(new StringReader(encoded)); int eventType = xpp.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG && "img".equals(xpp.getName())) { int count = xpp.getAttributeCount(); for (int x = 0; x < count; x++) { if (xpp.getAttributeName(x).equalsIgnoreCase("src")) return pattern.matcher(xpp.getAttributeValue(x)).replaceAll(""); } } eventType = xpp.next(); } } catch (Exception e) { log(TAG, "Error pulling image link from description!\n" + e.getMessage(), Log.WARN); } return ""; }
[ "private", "String", "pullImageLink", "(", "String", "encoded", ")", "{", "try", "{", "XmlPullParserFactory", "factory", "=", "XmlPullParserFactory", ".", "newInstance", "(", ")", ";", "XmlPullParser", "xpp", "=", "factory", ".", "newPullParser", "(", ")", ";", ...
Pulls an image URL from an encoded String. @param encoded The String which to extract an image URL from. @return The first image URL found on the encoded String. May return an empty String if none were found.
[ "Pulls", "an", "image", "URL", "from", "an", "encoded", "String", "." ]
0bc536d3bad1dade4538616f71c3a8f068eac89a
https://github.com/Pkmmte/PkRSS/blob/0bc536d3bad1dade4538616f71c3a8f068eac89a/pkrss/src/main/java/com/pkmmte/pkrss/parser/AtomParser.java#L189-L212
train
STIXProject/java-stix
src/main/java/org/mitre/stix/STIXSchema.java
STIXSchema.validate
public boolean validate(URL url) throws SAXException { String xmlText = null; try { xmlText = IOUtils.toString(url.openStream()); } catch (IOException e) { throw new RuntimeException(e); } return validate(xmlText); }
java
public boolean validate(URL url) throws SAXException { String xmlText = null; try { xmlText = IOUtils.toString(url.openStream()); } catch (IOException e) { throw new RuntimeException(e); } return validate(xmlText); }
[ "public", "boolean", "validate", "(", "URL", "url", ")", "throws", "SAXException", "{", "String", "xmlText", "=", "null", ";", "try", "{", "xmlText", "=", "IOUtils", ".", "toString", "(", "url", ".", "openStream", "(", ")", ")", ";", "}", "catch", "(",...
Validate XML text retrieved from URL @param url The URL object for the XML to be validated. @return boolean True If the xmlText validates against the schema @throws SAXException If the a validation ErrorHandler has not been set, and validation throws a SAXException
[ "Validate", "XML", "text", "retrieved", "from", "URL" ]
796b1314253fac3ebafca347f6eeb2c51ba4b009
https://github.com/STIXProject/java-stix/blob/796b1314253fac3ebafca347f6eeb2c51ba4b009/src/main/java/org/mitre/stix/STIXSchema.java#L196-L207
train
STIXProject/java-stix
src/main/java/org/mitre/stix/STIXSchema.java
STIXSchema.validate
public boolean validate(String xmlText) throws SAXException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); // This section removes the schema hint as we have the schema docs // otherwise exceptions may be thrown try { DocumentBuilder b = factory.newDocumentBuilder(); Document document = b.parse(new ByteArrayInputStream(xmlText .getBytes())); Element root = document.getDocumentElement(); root.removeAttribute("xsi:schemaLocation"); TransformerFactory transFactory = TransformerFactory.newInstance(); Transformer transformer = transFactory.newTransformer(); StringWriter buffer = new StringWriter(); transformer .transform(new DOMSource(root), new StreamResult(buffer)); xmlText = buffer.toString(); } catch (ParserConfigurationException e) { throw new RuntimeException(e); } catch (TransformerConfigurationException e) { throw new RuntimeException(e); } catch (TransformerException e) { throw new RuntimeException(e); } catch (SAXException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } try { // synchronized to avoid org.xml.sax.SAXException: FWK005 parse may // not be called while parsing. synchronized (this) { validator.validate(new StreamSource(new ByteArrayInputStream( xmlText.getBytes(StandardCharsets.UTF_8)))); } } catch (IOException e) { throw new RuntimeException(e); } catch (SAXException e) { if (this.validator.getErrorHandler() != null) { return false; } else { // re-throw the SAXException throw e; } } return true; }
java
public boolean validate(String xmlText) throws SAXException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); // This section removes the schema hint as we have the schema docs // otherwise exceptions may be thrown try { DocumentBuilder b = factory.newDocumentBuilder(); Document document = b.parse(new ByteArrayInputStream(xmlText .getBytes())); Element root = document.getDocumentElement(); root.removeAttribute("xsi:schemaLocation"); TransformerFactory transFactory = TransformerFactory.newInstance(); Transformer transformer = transFactory.newTransformer(); StringWriter buffer = new StringWriter(); transformer .transform(new DOMSource(root), new StreamResult(buffer)); xmlText = buffer.toString(); } catch (ParserConfigurationException e) { throw new RuntimeException(e); } catch (TransformerConfigurationException e) { throw new RuntimeException(e); } catch (TransformerException e) { throw new RuntimeException(e); } catch (SAXException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } try { // synchronized to avoid org.xml.sax.SAXException: FWK005 parse may // not be called while parsing. synchronized (this) { validator.validate(new StreamSource(new ByteArrayInputStream( xmlText.getBytes(StandardCharsets.UTF_8)))); } } catch (IOException e) { throw new RuntimeException(e); } catch (SAXException e) { if (this.validator.getErrorHandler() != null) { return false; } else { // re-throw the SAXException throw e; } } return true; }
[ "public", "boolean", "validate", "(", "String", "xmlText", ")", "throws", "SAXException", "{", "DocumentBuilderFactory", "factory", "=", "DocumentBuilderFactory", ".", "newInstance", "(", ")", ";", "factory", ".", "setNamespaceAware", "(", "true", ")", ";", "// Th...
Validate an XML text String against the STIX schema @param xmlText A string of XML text to be validated @return boolean True If the xmlText validates against the schema @throws SAXException If the a validation ErrorHandler has not been set, and validation throws a SAXException
[ "Validate", "an", "XML", "text", "String", "against", "the", "STIX", "schema" ]
796b1314253fac3ebafca347f6eeb2c51ba4b009
https://github.com/STIXProject/java-stix/blob/796b1314253fac3ebafca347f6eeb2c51ba4b009/src/main/java/org/mitre/stix/STIXSchema.java#L219-L274
train
STIXProject/java-stix
src/main/java/org/mitre/stix/STIXSchema.java
STIXSchema.getNamespaceURI
public static String getNamespaceURI(Object obj) { Package pkg = obj.getClass().getPackage(); XmlSchema xmlSchemaAnnotation = pkg.getAnnotation(XmlSchema.class); return xmlSchemaAnnotation.namespace(); }
java
public static String getNamespaceURI(Object obj) { Package pkg = obj.getClass().getPackage(); XmlSchema xmlSchemaAnnotation = pkg.getAnnotation(XmlSchema.class); return xmlSchemaAnnotation.namespace(); }
[ "public", "static", "String", "getNamespaceURI", "(", "Object", "obj", ")", "{", "Package", "pkg", "=", "obj", ".", "getClass", "(", ")", ".", "getPackage", "(", ")", ";", "XmlSchema", "xmlSchemaAnnotation", "=", "pkg", ".", "getAnnotation", "(", "XmlSchema"...
Return the namespace URI from the package for the class of the object. @param obj Expects a JAXB model object. @return Name of the XML namespace.
[ "Return", "the", "namespace", "URI", "from", "the", "package", "for", "the", "class", "of", "the", "object", "." ]
796b1314253fac3ebafca347f6eeb2c51ba4b009
https://github.com/STIXProject/java-stix/blob/796b1314253fac3ebafca347f6eeb2c51ba4b009/src/main/java/org/mitre/stix/STIXSchema.java#L307-L314
train
STIXProject/java-stix
src/main/java/org/mitre/stix/STIXSchema.java
STIXSchema.getName
public static String getName(Object obj) { try { return obj.getClass().getAnnotation(XmlRootElement.class).name(); } catch (NullPointerException e) { return obj.getClass().getAnnotation(XmlType.class).name(); } }
java
public static String getName(Object obj) { try { return obj.getClass().getAnnotation(XmlRootElement.class).name(); } catch (NullPointerException e) { return obj.getClass().getAnnotation(XmlType.class).name(); } }
[ "public", "static", "String", "getName", "(", "Object", "obj", ")", "{", "try", "{", "return", "obj", ".", "getClass", "(", ")", ".", "getAnnotation", "(", "XmlRootElement", ".", "class", ")", ".", "name", "(", ")", ";", "}", "catch", "(", "NullPointer...
Return the name from the JAXB model object. @param obj Expects a JAXB model object. @return element name
[ "Return", "the", "name", "from", "the", "JAXB", "model", "object", "." ]
796b1314253fac3ebafca347f6eeb2c51ba4b009
https://github.com/STIXProject/java-stix/blob/796b1314253fac3ebafca347f6eeb2c51ba4b009/src/main/java/org/mitre/stix/STIXSchema.java#L323-L329
train
STIXProject/java-stix
src/main/java/org/mitre/stix/STIXSchema.java
STIXSchema.getQualifiedName
public static QName getQualifiedName(Object obj) { return new QName(STIXSchema.getNamespaceURI(obj), STIXSchema.getName(obj)); }
java
public static QName getQualifiedName(Object obj) { return new QName(STIXSchema.getNamespaceURI(obj), STIXSchema.getName(obj)); }
[ "public", "static", "QName", "getQualifiedName", "(", "Object", "obj", ")", "{", "return", "new", "QName", "(", "STIXSchema", ".", "getNamespaceURI", "(", "obj", ")", ",", "STIXSchema", ".", "getName", "(", "obj", ")", ")", ";", "}" ]
Return the QualifiedNam from the JAXB model object. @param obj Expects a JAXB model object. @return Qualified dName as defined by JAXB model
[ "Return", "the", "QualifiedNam", "from", "the", "JAXB", "model", "object", "." ]
796b1314253fac3ebafca347f6eeb2c51ba4b009
https://github.com/STIXProject/java-stix/blob/796b1314253fac3ebafca347f6eeb2c51ba4b009/src/main/java/org/mitre/stix/STIXSchema.java#L338-L341
train
Pkmmte/PkRSS
pkrss/src/main/java/com/pkmmte/pkrss/RequestCreator.java
RequestCreator.nextPage
public RequestCreator nextPage() { Request request = data.build(); String url = request.url; int page = request.page; if(request.search != null) url += "?s=" + request.search; Map<String, Integer> pageTracker = singleton.getPageTracker(); if(pageTracker.containsKey(url)) page = pageTracker.get(url); this.data.page(page + 1); return this; }
java
public RequestCreator nextPage() { Request request = data.build(); String url = request.url; int page = request.page; if(request.search != null) url += "?s=" + request.search; Map<String, Integer> pageTracker = singleton.getPageTracker(); if(pageTracker.containsKey(url)) page = pageTracker.get(url); this.data.page(page + 1); return this; }
[ "public", "RequestCreator", "nextPage", "(", ")", "{", "Request", "request", "=", "data", ".", "build", "(", ")", ";", "String", "url", "=", "request", ".", "url", ";", "int", "page", "=", "request", ".", "page", ";", "if", "(", "request", ".", "sear...
Loads the next page of the current RSS feed. If no page was previously loaded, this will request the first page.
[ "Loads", "the", "next", "page", "of", "the", "current", "RSS", "feed", ".", "If", "no", "page", "was", "previously", "loaded", "this", "will", "request", "the", "first", "page", "." ]
0bc536d3bad1dade4538616f71c3a8f068eac89a
https://github.com/Pkmmte/PkRSS/blob/0bc536d3bad1dade4538616f71c3a8f068eac89a/pkrss/src/main/java/com/pkmmte/pkrss/RequestCreator.java#L104-L118
train
STIXProject/java-stix
src/main/java/org/mitre/stix/DocumentUtilities.java
DocumentUtilities.toDocument
public static Document toDocument(JAXBElement<?> jaxbElement, boolean prettyPrint) { Document document = null; try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory .newInstance(); documentBuilderFactory.setNamespaceAware(true); documentBuilderFactory.setIgnoringElementContentWhitespace(true); documentBuilderFactory.isIgnoringComments(); documentBuilderFactory.setCoalescing(true); document = documentBuilderFactory.newDocumentBuilder() .newDocument(); String packName = jaxbElement.getDeclaredType().getPackage().getName(); JAXBContext jaxbContext; if (packName.startsWith("org.mitre")){ jaxbContext = stixJaxbContext(); } else { jaxbContext = JAXBContext.newInstance(packName); } Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, prettyPrint); marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); try { marshaller.marshal(jaxbElement, document); } catch (JAXBException e) { // otherwise handle non-XMLRootElements QName qualifiedName = new QName( STIXSchema.getNamespaceURI(jaxbElement), jaxbElement .getClass().getSimpleName()); @SuppressWarnings({ "rawtypes", "unchecked" }) JAXBElement root = new JAXBElement(qualifiedName, jaxbElement.getClass(), jaxbElement); marshaller.marshal(root, document); } removeUnusedNamespaces(document); } catch (ParserConfigurationException e) { throw new RuntimeException(e); } catch (JAXBException e) { throw new RuntimeException(e); } return document; }
java
public static Document toDocument(JAXBElement<?> jaxbElement, boolean prettyPrint) { Document document = null; try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory .newInstance(); documentBuilderFactory.setNamespaceAware(true); documentBuilderFactory.setIgnoringElementContentWhitespace(true); documentBuilderFactory.isIgnoringComments(); documentBuilderFactory.setCoalescing(true); document = documentBuilderFactory.newDocumentBuilder() .newDocument(); String packName = jaxbElement.getDeclaredType().getPackage().getName(); JAXBContext jaxbContext; if (packName.startsWith("org.mitre")){ jaxbContext = stixJaxbContext(); } else { jaxbContext = JAXBContext.newInstance(packName); } Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, prettyPrint); marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); try { marshaller.marshal(jaxbElement, document); } catch (JAXBException e) { // otherwise handle non-XMLRootElements QName qualifiedName = new QName( STIXSchema.getNamespaceURI(jaxbElement), jaxbElement .getClass().getSimpleName()); @SuppressWarnings({ "rawtypes", "unchecked" }) JAXBElement root = new JAXBElement(qualifiedName, jaxbElement.getClass(), jaxbElement); marshaller.marshal(root, document); } removeUnusedNamespaces(document); } catch (ParserConfigurationException e) { throw new RuntimeException(e); } catch (JAXBException e) { throw new RuntimeException(e); } return document; }
[ "public", "static", "Document", "toDocument", "(", "JAXBElement", "<", "?", ">", "jaxbElement", ",", "boolean", "prettyPrint", ")", "{", "Document", "document", "=", "null", ";", "try", "{", "DocumentBuilderFactory", "documentBuilderFactory", "=", "DocumentBuilderFa...
Returns a Document for a JAXBElement @param jaxbElement JAXB representation of an XML Element @param prettyPrint True for pretty print, otherwise false @return The Document representation
[ "Returns", "a", "Document", "for", "a", "JAXBElement" ]
796b1314253fac3ebafca347f6eeb2c51ba4b009
https://github.com/STIXProject/java-stix/blob/796b1314253fac3ebafca347f6eeb2c51ba4b009/src/main/java/org/mitre/stix/DocumentUtilities.java#L111-L166
train
STIXProject/java-stix
src/main/java/org/mitre/stix/DocumentUtilities.java
DocumentUtilities.toXMLString
public static String toXMLString(JAXBElement<?> jaxbElement, boolean prettyPrint) { Document document = toDocument(jaxbElement); return toXMLString(document, prettyPrint); }
java
public static String toXMLString(JAXBElement<?> jaxbElement, boolean prettyPrint) { Document document = toDocument(jaxbElement); return toXMLString(document, prettyPrint); }
[ "public", "static", "String", "toXMLString", "(", "JAXBElement", "<", "?", ">", "jaxbElement", ",", "boolean", "prettyPrint", ")", "{", "Document", "document", "=", "toDocument", "(", "jaxbElement", ")", ";", "return", "toXMLString", "(", "document", ",", "pre...
Returns a String for a JAXBElement @param jaxbElement JAXB representation of an XML Element to be printed. @param prettyPrint True for pretty print, otherwise false @return String containing the XML mark-up.
[ "Returns", "a", "String", "for", "a", "JAXBElement" ]
796b1314253fac3ebafca347f6eeb2c51ba4b009
https://github.com/STIXProject/java-stix/blob/796b1314253fac3ebafca347f6eeb2c51ba4b009/src/main/java/org/mitre/stix/DocumentUtilities.java#L177-L184
train
STIXProject/java-stix
src/main/java/org/mitre/stix/DocumentUtilities.java
DocumentUtilities.traverse
private final static void traverse(Element element, ElementVisitor visitor) { visitor.visit(element); NodeList children = element.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node node = children.item(i); if (node.getNodeType() != Node.ELEMENT_NODE) continue; traverse((Element) node, visitor); } }
java
private final static void traverse(Element element, ElementVisitor visitor) { visitor.visit(element); NodeList children = element.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node node = children.item(i); if (node.getNodeType() != Node.ELEMENT_NODE) continue; traverse((Element) node, visitor); } }
[ "private", "final", "static", "void", "traverse", "(", "Element", "element", ",", "ElementVisitor", "visitor", ")", "{", "visitor", ".", "visit", "(", "element", ")", ";", "NodeList", "children", "=", "element", ".", "getChildNodes", "(", ")", ";", "for", ...
Used to traverse an XML document. @param element Represents an element in an XML document. @param visitor Code to be executed.
[ "Used", "to", "traverse", "an", "XML", "document", "." ]
796b1314253fac3ebafca347f6eeb2c51ba4b009
https://github.com/STIXProject/java-stix/blob/796b1314253fac3ebafca347f6eeb2c51ba4b009/src/main/java/org/mitre/stix/DocumentUtilities.java#L264-L278
train
STIXProject/java-stix
src/main/java/org/mitre/stix/DocumentUtilities.java
DocumentUtilities.toDocument
public static Document toDocument(String xml) { try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory .newInstance(); documentBuilderFactory.setNamespaceAware(true); documentBuilderFactory.setIgnoringElementContentWhitespace(true); documentBuilderFactory.isIgnoringComments(); documentBuilderFactory.setCoalescing(true); DocumentBuilder documentBuilder = documentBuilderFactory .newDocumentBuilder(); InputSource inputSource = new InputSource(); inputSource.setCharacterStream(new StringReader(xml)); Document document = documentBuilder.parse(inputSource); removeUnusedNamespaces(document); return document; } catch (ParserConfigurationException e) { throw new RuntimeException(e); } catch (SAXException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } }
java
public static Document toDocument(String xml) { try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory .newInstance(); documentBuilderFactory.setNamespaceAware(true); documentBuilderFactory.setIgnoringElementContentWhitespace(true); documentBuilderFactory.isIgnoringComments(); documentBuilderFactory.setCoalescing(true); DocumentBuilder documentBuilder = documentBuilderFactory .newDocumentBuilder(); InputSource inputSource = new InputSource(); inputSource.setCharacterStream(new StringReader(xml)); Document document = documentBuilder.parse(inputSource); removeUnusedNamespaces(document); return document; } catch (ParserConfigurationException e) { throw new RuntimeException(e); } catch (SAXException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } }
[ "public", "static", "Document", "toDocument", "(", "String", "xml", ")", "{", "try", "{", "DocumentBuilderFactory", "documentBuilderFactory", "=", "DocumentBuilderFactory", ".", "newInstance", "(", ")", ";", "documentBuilderFactory", ".", "setNamespaceAware", "(", "tr...
Creates a Document from XML String @param xml The XML String @return The Document representation
[ "Creates", "a", "Document", "from", "XML", "String" ]
796b1314253fac3ebafca347f6eeb2c51ba4b009
https://github.com/STIXProject/java-stix/blob/796b1314253fac3ebafca347f6eeb2c51ba4b009/src/main/java/org/mitre/stix/DocumentUtilities.java#L394-L424
train
STIXProject/java-stix
src/main/java/org/mitre/stix/DocumentUtilities.java
DocumentUtilities.stripFormattingfromXMLString
public static String stripFormattingfromXMLString(String xml) { try { Document document = DocumentUtilities.toDocument(xml); DOMImplementationRegistry registry = DOMImplementationRegistry .newInstance(); DOMImplementationLS domImplementationLS = (DOMImplementationLS) registry .getDOMImplementation("LS"); LSSerializer serializaer = domImplementationLS.createLSSerializer(); serializaer.getDomConfig().setParameter("format-pretty-print", Boolean.FALSE); serializaer.getDomConfig().setParameter("xml-declaration", Boolean.TRUE); // otherwise UTF-16 is used by default LSOutput lsOutput = domImplementationLS.createLSOutput(); lsOutput.setEncoding("UTF-8"); ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); lsOutput.setByteStream(byteStream); serializaer.write(document, lsOutput); return new String(byteStream.toByteArray(), "UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (ClassCastException e) { throw new RuntimeException(e); } }
java
public static String stripFormattingfromXMLString(String xml) { try { Document document = DocumentUtilities.toDocument(xml); DOMImplementationRegistry registry = DOMImplementationRegistry .newInstance(); DOMImplementationLS domImplementationLS = (DOMImplementationLS) registry .getDOMImplementation("LS"); LSSerializer serializaer = domImplementationLS.createLSSerializer(); serializaer.getDomConfig().setParameter("format-pretty-print", Boolean.FALSE); serializaer.getDomConfig().setParameter("xml-declaration", Boolean.TRUE); // otherwise UTF-16 is used by default LSOutput lsOutput = domImplementationLS.createLSOutput(); lsOutput.setEncoding("UTF-8"); ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); lsOutput.setByteStream(byteStream); serializaer.write(document, lsOutput); return new String(byteStream.toByteArray(), "UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (ClassCastException e) { throw new RuntimeException(e); } }
[ "public", "static", "String", "stripFormattingfromXMLString", "(", "String", "xml", ")", "{", "try", "{", "Document", "document", "=", "DocumentUtilities", ".", "toDocument", "(", "xml", ")", ";", "DOMImplementationRegistry", "registry", "=", "DOMImplementationRegistr...
Strips formatting from an XML String @param xml The XML String to reformatted @return The XML String as on line.
[ "Strips", "formatting", "from", "an", "XML", "String" ]
796b1314253fac3ebafca347f6eeb2c51ba4b009
https://github.com/STIXProject/java-stix/blob/796b1314253fac3ebafca347f6eeb2c51ba4b009/src/main/java/org/mitre/stix/DocumentUtilities.java#L433-L470
train
square/pagerduty-incidents
src/main/java/com/squareup/pagerduty/incidents/PagerDuty.java
PagerDuty.create
public static PagerDuty create(String apiKey) { Retrofit retrofit = new Retrofit.Builder() // .baseUrl(HOST) // .addConverterFactory(GsonConverterFactory.create()) .build(); return create(apiKey, retrofit); }
java
public static PagerDuty create(String apiKey) { Retrofit retrofit = new Retrofit.Builder() // .baseUrl(HOST) // .addConverterFactory(GsonConverterFactory.create()) .build(); return create(apiKey, retrofit); }
[ "public", "static", "PagerDuty", "create", "(", "String", "apiKey", ")", "{", "Retrofit", "retrofit", "=", "new", "Retrofit", ".", "Builder", "(", ")", "//", ".", "baseUrl", "(", "HOST", ")", "//", ".", "addConverterFactory", "(", "GsonConverterFactory", "."...
Create a new instance using the specified API key.
[ "Create", "a", "new", "instance", "using", "the", "specified", "API", "key", "." ]
81f29c2bd5b08c8a2f0d2abd2083f23d150fc8dd
https://github.com/square/pagerduty-incidents/blob/81f29c2bd5b08c8a2f0d2abd2083f23d150fc8dd/src/main/java/com/squareup/pagerduty/incidents/PagerDuty.java#L30-L36
train
Pkmmte/PkRSS
pkrss/src/main/java/com/pkmmte/pkrss/FavoriteDatabase.java
FavoriteDatabase.add
public void add(Article article) { // Get Write Access SQLiteDatabase db = this.getWritableDatabase(); // Build Content Values ContentValues values = new ContentValues(); values.put(KEY_TAGS, TextUtils.join("_PCX_", article.getTags())); values.put(KEY_MEDIA_CONTENT, Article.MediaContent.toByteArray(article.getMediaContent())); values.put(KEY_SOURCE, article.getSource().toString()); values.put(KEY_IMAGE, article.getImage().toString()); values.put(KEY_TITLE, article.getTitle()); values.put(KEY_DESCRIPTION, article.getDescription()); values.put(KEY_CONTENT, article.getContent()); values.put(KEY_COMMENTS, article.getComments()); values.put(KEY_AUTHOR, article.getAuthor()); values.put(KEY_DATE, article.getDate()); values.put(KEY_ID, article.getId()); // Insert & Close db.insert(TABLE_ARTICLES, null, values); db.close(); }
java
public void add(Article article) { // Get Write Access SQLiteDatabase db = this.getWritableDatabase(); // Build Content Values ContentValues values = new ContentValues(); values.put(KEY_TAGS, TextUtils.join("_PCX_", article.getTags())); values.put(KEY_MEDIA_CONTENT, Article.MediaContent.toByteArray(article.getMediaContent())); values.put(KEY_SOURCE, article.getSource().toString()); values.put(KEY_IMAGE, article.getImage().toString()); values.put(KEY_TITLE, article.getTitle()); values.put(KEY_DESCRIPTION, article.getDescription()); values.put(KEY_CONTENT, article.getContent()); values.put(KEY_COMMENTS, article.getComments()); values.put(KEY_AUTHOR, article.getAuthor()); values.put(KEY_DATE, article.getDate()); values.put(KEY_ID, article.getId()); // Insert & Close db.insert(TABLE_ARTICLES, null, values); db.close(); }
[ "public", "void", "add", "(", "Article", "article", ")", "{", "// Get Write Access", "SQLiteDatabase", "db", "=", "this", ".", "getWritableDatabase", "(", ")", ";", "// Build Content Values", "ContentValues", "values", "=", "new", "ContentValues", "(", ")", ";", ...
Inserts an Article object to this database. @param article Object to save into database.
[ "Inserts", "an", "Article", "object", "to", "this", "database", "." ]
0bc536d3bad1dade4538616f71c3a8f068eac89a
https://github.com/Pkmmte/PkRSS/blob/0bc536d3bad1dade4538616f71c3a8f068eac89a/pkrss/src/main/java/com/pkmmte/pkrss/FavoriteDatabase.java#L84-L105
train
Pkmmte/PkRSS
pkrss/src/main/java/com/pkmmte/pkrss/FavoriteDatabase.java
FavoriteDatabase.delete
public void delete(Article article) { SQLiteDatabase db = this.getWritableDatabase(); db.delete(TABLE_ARTICLES, KEY_ID + " = ?", new String[] {String.valueOf(article.getId())}); db.close(); }
java
public void delete(Article article) { SQLiteDatabase db = this.getWritableDatabase(); db.delete(TABLE_ARTICLES, KEY_ID + " = ?", new String[] {String.valueOf(article.getId())}); db.close(); }
[ "public", "void", "delete", "(", "Article", "article", ")", "{", "SQLiteDatabase", "db", "=", "this", ".", "getWritableDatabase", "(", ")", ";", "db", ".", "delete", "(", "TABLE_ARTICLES", ",", "KEY_ID", "+", "\" = ?\"", ",", "new", "String", "[", "]", "...
Removes a specified Article from this database based on its ID value. @param article Article to remove. May contain dummy data as long as the id is valid.
[ "Removes", "a", "specified", "Article", "from", "this", "database", "based", "on", "its", "ID", "value", "." ]
0bc536d3bad1dade4538616f71c3a8f068eac89a
https://github.com/Pkmmte/PkRSS/blob/0bc536d3bad1dade4538616f71c3a8f068eac89a/pkrss/src/main/java/com/pkmmte/pkrss/FavoriteDatabase.java#L189-L193
train
Pkmmte/PkRSS
pkrss/src/main/java/com/pkmmte/pkrss/FavoriteDatabase.java
FavoriteDatabase.deleteAll
public void deleteAll() { SQLiteDatabase db = this.getWritableDatabase(); db.delete(TABLE_ARTICLES, null, null); db.close(); }
java
public void deleteAll() { SQLiteDatabase db = this.getWritableDatabase(); db.delete(TABLE_ARTICLES, null, null); db.close(); }
[ "public", "void", "deleteAll", "(", ")", "{", "SQLiteDatabase", "db", "=", "this", ".", "getWritableDatabase", "(", ")", ";", "db", ".", "delete", "(", "TABLE_ARTICLES", ",", "null", ",", "null", ")", ";", "db", ".", "close", "(", ")", ";", "}" ]
Removes ALL content stored in this database!
[ "Removes", "ALL", "content", "stored", "in", "this", "database!" ]
0bc536d3bad1dade4538616f71c3a8f068eac89a
https://github.com/Pkmmte/PkRSS/blob/0bc536d3bad1dade4538616f71c3a8f068eac89a/pkrss/src/main/java/com/pkmmte/pkrss/FavoriteDatabase.java#L198-L202
train
Pkmmte/PkRSS
pkrss/src/main/java/com/pkmmte/pkrss/Article.java
Article.putExtra
public Article putExtra(String key, String value) { this.extras.putString(key, value); return this; }
java
public Article putExtra(String key, String value) { this.extras.putString(key, value); return this; }
[ "public", "Article", "putExtra", "(", "String", "key", ",", "String", "value", ")", "{", "this", ".", "extras", ".", "putString", "(", "key", ",", "value", ")", ";", "return", "this", ";", "}" ]
Inserts a given value into a Bundle associated with this Article instance. @param key A String key. @param value Value to insert.
[ "Inserts", "a", "given", "value", "into", "a", "Bundle", "associated", "with", "this", "Article", "instance", "." ]
0bc536d3bad1dade4538616f71c3a8f068eac89a
https://github.com/Pkmmte/PkRSS/blob/0bc536d3bad1dade4538616f71c3a8f068eac89a/pkrss/src/main/java/com/pkmmte/pkrss/Article.java#L118-L121
train
Pkmmte/PkRSS
pkrss/src/main/java/com/pkmmte/pkrss/Article.java
Article.addMediaContent
public Article addMediaContent(MediaContent mediaContent) { if(mediaContent == null) return this; if(this.mediaContentVec == null) this.mediaContentVec = new Vector<>(); this.mediaContentVec.add(mediaContent); return this; }
java
public Article addMediaContent(MediaContent mediaContent) { if(mediaContent == null) return this; if(this.mediaContentVec == null) this.mediaContentVec = new Vector<>(); this.mediaContentVec.add(mediaContent); return this; }
[ "public", "Article", "addMediaContent", "(", "MediaContent", "mediaContent", ")", "{", "if", "(", "mediaContent", "==", "null", ")", "return", "this", ";", "if", "(", "this", ".", "mediaContentVec", "==", "null", ")", "this", ".", "mediaContentVec", "=", "ne...
Adds a single media content item to the list @param mediaContent The media content object to add
[ "Adds", "a", "single", "media", "content", "item", "to", "the", "list" ]
0bc536d3bad1dade4538616f71c3a8f068eac89a
https://github.com/Pkmmte/PkRSS/blob/0bc536d3bad1dade4538616f71c3a8f068eac89a/pkrss/src/main/java/com/pkmmte/pkrss/Article.java#L188-L198
train
Pkmmte/PkRSS
pkrss/src/main/java/com/pkmmte/pkrss/Article.java
Article.removeMediaContent
public Article removeMediaContent(MediaContent mediaContent) { if(mediaContent == null || this.mediaContentVec == null) return this; this.mediaContentVec.remove(mediaContent); return this; }
java
public Article removeMediaContent(MediaContent mediaContent) { if(mediaContent == null || this.mediaContentVec == null) return this; this.mediaContentVec.remove(mediaContent); return this; }
[ "public", "Article", "removeMediaContent", "(", "MediaContent", "mediaContent", ")", "{", "if", "(", "mediaContent", "==", "null", "||", "this", ".", "mediaContentVec", "==", "null", ")", "return", "this", ";", "this", ".", "mediaContentVec", ".", "remove", "(...
Removes a single media content item from the list @param mediaContent The media content object to remove
[ "Removes", "a", "single", "media", "content", "item", "from", "the", "list" ]
0bc536d3bad1dade4538616f71c3a8f068eac89a
https://github.com/Pkmmte/PkRSS/blob/0bc536d3bad1dade4538616f71c3a8f068eac89a/pkrss/src/main/java/com/pkmmte/pkrss/Article.java#L204-L211
train
Pkmmte/PkRSS
pkrss/src/main/java/com/pkmmte/pkrss/Article.java
Article.markRead
public boolean markRead(boolean read) { if (PkRSS.getInstance() == null) return false; PkRSS.getInstance().markRead(id, read); return true; }
java
public boolean markRead(boolean read) { if (PkRSS.getInstance() == null) return false; PkRSS.getInstance().markRead(id, read); return true; }
[ "public", "boolean", "markRead", "(", "boolean", "read", ")", "{", "if", "(", "PkRSS", ".", "getInstance", "(", ")", "==", "null", ")", "return", "false", ";", "PkRSS", ".", "getInstance", "(", ")", ".", "markRead", "(", "id", ",", "read", ")", ";", ...
Adds this article's id to the read index. @param read Whether or not to mark it as read. @return {@code true} if successful, {@code false} if otherwise.
[ "Adds", "this", "article", "s", "id", "to", "the", "read", "index", "." ]
0bc536d3bad1dade4538616f71c3a8f068eac89a
https://github.com/Pkmmte/PkRSS/blob/0bc536d3bad1dade4538616f71c3a8f068eac89a/pkrss/src/main/java/com/pkmmte/pkrss/Article.java#L405-L410
train
Pkmmte/PkRSS
pkrss/src/main/java/com/pkmmte/pkrss/Article.java
Article.saveFavorite
public boolean saveFavorite(boolean favorite) { if (PkRSS.getInstance() == null) return false; return PkRSS.getInstance().saveFavorite(this, favorite); }
java
public boolean saveFavorite(boolean favorite) { if (PkRSS.getInstance() == null) return false; return PkRSS.getInstance().saveFavorite(this, favorite); }
[ "public", "boolean", "saveFavorite", "(", "boolean", "favorite", ")", "{", "if", "(", "PkRSS", ".", "getInstance", "(", ")", "==", "null", ")", "return", "false", ";", "return", "PkRSS", ".", "getInstance", "(", ")", ".", "saveFavorite", "(", "this", ","...
Adds this article into the favorites database. @param favorite Whether to add it or remove it. @return {@code true} if successful, {@code false} if otherwise.
[ "Adds", "this", "article", "into", "the", "favorites", "database", "." ]
0bc536d3bad1dade4538616f71c3a8f068eac89a
https://github.com/Pkmmte/PkRSS/blob/0bc536d3bad1dade4538616f71c3a8f068eac89a/pkrss/src/main/java/com/pkmmte/pkrss/Article.java#L434-L438
train
Pkmmte/PkRSS
pkrss/src/main/java/com/pkmmte/pkrss/parser/Rss2Parser.java
Rss2Parser.handleNode
private boolean handleNode(String tag, Article article) { try { if(xmlParser.next() != XmlPullParser.TEXT) return false; if (tag.equalsIgnoreCase("link")) article.setSource(Uri.parse(xmlParser.getText())); else if (tag.equalsIgnoreCase("title")) article.setTitle(xmlParser.getText()); else if (tag.equalsIgnoreCase("description")) { String encoded = xmlParser.getText(); article.setImage(Uri.parse(pullImageLink(encoded))); article.setDescription(Html.fromHtml(encoded.replaceAll("<img.+?>", "")).toString()); } else if (tag.equalsIgnoreCase("content:encoded")) article.setContent(xmlParser.getText().replaceAll("[<](/)?div[^>]*[>]", "")); else if (tag.equalsIgnoreCase("wfw:commentRss")) article.setComments(xmlParser.getText()); else if (tag.equalsIgnoreCase("category")) article.setNewTag(xmlParser.getText()); else if (tag.equalsIgnoreCase("dc:creator")) article.setAuthor(xmlParser.getText()); else if (tag.equalsIgnoreCase("pubDate")) { article.setDate(getParsedDate(xmlParser.getText())); } return true; } catch (IOException e) { e.printStackTrace(); return false; } catch (XmlPullParserException e) { e.printStackTrace(); return false; } }
java
private boolean handleNode(String tag, Article article) { try { if(xmlParser.next() != XmlPullParser.TEXT) return false; if (tag.equalsIgnoreCase("link")) article.setSource(Uri.parse(xmlParser.getText())); else if (tag.equalsIgnoreCase("title")) article.setTitle(xmlParser.getText()); else if (tag.equalsIgnoreCase("description")) { String encoded = xmlParser.getText(); article.setImage(Uri.parse(pullImageLink(encoded))); article.setDescription(Html.fromHtml(encoded.replaceAll("<img.+?>", "")).toString()); } else if (tag.equalsIgnoreCase("content:encoded")) article.setContent(xmlParser.getText().replaceAll("[<](/)?div[^>]*[>]", "")); else if (tag.equalsIgnoreCase("wfw:commentRss")) article.setComments(xmlParser.getText()); else if (tag.equalsIgnoreCase("category")) article.setNewTag(xmlParser.getText()); else if (tag.equalsIgnoreCase("dc:creator")) article.setAuthor(xmlParser.getText()); else if (tag.equalsIgnoreCase("pubDate")) { article.setDate(getParsedDate(xmlParser.getText())); } return true; } catch (IOException e) { e.printStackTrace(); return false; } catch (XmlPullParserException e) { e.printStackTrace(); return false; } }
[ "private", "boolean", "handleNode", "(", "String", "tag", ",", "Article", "article", ")", "{", "try", "{", "if", "(", "xmlParser", ".", "next", "(", ")", "!=", "XmlPullParser", ".", "TEXT", ")", "return", "false", ";", "if", "(", "tag", ".", "equalsIgn...
Handles a node from the tag node and assigns it to the correct article value. @param tag The tag which to handle. @param article Article object to assign the node value to. @return True if a proper tag was given or handled. False if improper tag was given or if an exception if triggered.
[ "Handles", "a", "node", "from", "the", "tag", "node", "and", "assigns", "it", "to", "the", "correct", "article", "value", "." ]
0bc536d3bad1dade4538616f71c3a8f068eac89a
https://github.com/Pkmmte/PkRSS/blob/0bc536d3bad1dade4538616f71c3a8f068eac89a/pkrss/src/main/java/com/pkmmte/pkrss/parser/Rss2Parser.java#L130-L166
train
Pkmmte/PkRSS
pkrss/src/main/java/com/pkmmte/pkrss/parser/Rss2Parser.java
Rss2Parser.handleMediaContent
private void handleMediaContent(String tag, Article article) { String url = xmlParser.getAttributeValue(null, "url"); if(url == null) { throw new IllegalArgumentException("Url argument must not be null"); } Article.MediaContent mc = new Article.MediaContent(); article.addMediaContent(mc); mc.setUrl(url); if(xmlParser.getAttributeValue(null, "type") != null) { mc.setType(xmlParser.getAttributeValue(null, "type")); } if(xmlParser.getAttributeValue(null, "fileSize") != null) { mc.setFileSize(Integer.parseInt(xmlParser.getAttributeValue(null, "fileSize"))); } if(xmlParser.getAttributeValue(null, "medium") != null) { mc.setMedium(xmlParser.getAttributeValue(null, "medium")); } if(xmlParser.getAttributeValue(null, "isDefault") != null) { mc.setIsDefault(Boolean.parseBoolean(xmlParser.getAttributeValue(null, "isDefault"))); } if(xmlParser.getAttributeValue(null, "expression") != null) { mc.setExpression(xmlParser.getAttributeValue(null, "expression")); } if(xmlParser.getAttributeValue(null, "bitrate") != null) { mc.setBitrate(Integer.parseInt(xmlParser.getAttributeValue(null, "bitrate"))); } if(xmlParser.getAttributeValue(null, "framerate") != null) { mc.setFramerate(Integer.parseInt(xmlParser.getAttributeValue(null, "framerate"))); } if(xmlParser.getAttributeValue(null, "samplingrate") != null) { mc.setSamplingrate(Integer.parseInt(xmlParser.getAttributeValue(null, "samplingrate"))); } if(xmlParser.getAttributeValue(null, "channels") != null) { mc.setChannels(Integer.parseInt(xmlParser.getAttributeValue(null, "channels"))); } if(xmlParser.getAttributeValue(null, "duration") != null) { mc.setDuration(Integer.parseInt(xmlParser.getAttributeValue(null, "duration"))); } if(xmlParser.getAttributeValue(null, "height") != null) { mc.setHeight(Integer.parseInt(xmlParser.getAttributeValue(null, "height"))); } if(xmlParser.getAttributeValue(null, "width") != null) { mc.setWidth(Integer.parseInt(xmlParser.getAttributeValue(null, "width"))); } if(xmlParser.getAttributeValue(null, "lang") != null) { mc.setLang(xmlParser.getAttributeValue(null, "lang")); } }
java
private void handleMediaContent(String tag, Article article) { String url = xmlParser.getAttributeValue(null, "url"); if(url == null) { throw new IllegalArgumentException("Url argument must not be null"); } Article.MediaContent mc = new Article.MediaContent(); article.addMediaContent(mc); mc.setUrl(url); if(xmlParser.getAttributeValue(null, "type") != null) { mc.setType(xmlParser.getAttributeValue(null, "type")); } if(xmlParser.getAttributeValue(null, "fileSize") != null) { mc.setFileSize(Integer.parseInt(xmlParser.getAttributeValue(null, "fileSize"))); } if(xmlParser.getAttributeValue(null, "medium") != null) { mc.setMedium(xmlParser.getAttributeValue(null, "medium")); } if(xmlParser.getAttributeValue(null, "isDefault") != null) { mc.setIsDefault(Boolean.parseBoolean(xmlParser.getAttributeValue(null, "isDefault"))); } if(xmlParser.getAttributeValue(null, "expression") != null) { mc.setExpression(xmlParser.getAttributeValue(null, "expression")); } if(xmlParser.getAttributeValue(null, "bitrate") != null) { mc.setBitrate(Integer.parseInt(xmlParser.getAttributeValue(null, "bitrate"))); } if(xmlParser.getAttributeValue(null, "framerate") != null) { mc.setFramerate(Integer.parseInt(xmlParser.getAttributeValue(null, "framerate"))); } if(xmlParser.getAttributeValue(null, "samplingrate") != null) { mc.setSamplingrate(Integer.parseInt(xmlParser.getAttributeValue(null, "samplingrate"))); } if(xmlParser.getAttributeValue(null, "channels") != null) { mc.setChannels(Integer.parseInt(xmlParser.getAttributeValue(null, "channels"))); } if(xmlParser.getAttributeValue(null, "duration") != null) { mc.setDuration(Integer.parseInt(xmlParser.getAttributeValue(null, "duration"))); } if(xmlParser.getAttributeValue(null, "height") != null) { mc.setHeight(Integer.parseInt(xmlParser.getAttributeValue(null, "height"))); } if(xmlParser.getAttributeValue(null, "width") != null) { mc.setWidth(Integer.parseInt(xmlParser.getAttributeValue(null, "width"))); } if(xmlParser.getAttributeValue(null, "lang") != null) { mc.setLang(xmlParser.getAttributeValue(null, "lang")); } }
[ "private", "void", "handleMediaContent", "(", "String", "tag", ",", "Article", "article", ")", "{", "String", "url", "=", "xmlParser", ".", "getAttributeValue", "(", "null", ",", "\"url\"", ")", ";", "if", "(", "url", "==", "null", ")", "{", "throw", "ne...
Parses the media content of the entry @param tag The tag which to handle. @param article Article object to assign the node value to.
[ "Parses", "the", "media", "content", "of", "the", "entry" ]
0bc536d3bad1dade4538616f71c3a8f068eac89a
https://github.com/Pkmmte/PkRSS/blob/0bc536d3bad1dade4538616f71c3a8f068eac89a/pkrss/src/main/java/com/pkmmte/pkrss/parser/Rss2Parser.java#L173-L235
train
Pkmmte/PkRSS
pkrss/src/main/java/com/pkmmte/pkrss/Utils.java
Utils.deleteDir
public static boolean deleteDir(File dir) { if (dir != null && dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { if (!deleteDir(new File(dir, children[i]))) return false; } } return dir.delete(); }
java
public static boolean deleteDir(File dir) { if (dir != null && dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { if (!deleteDir(new File(dir, children[i]))) return false; } } return dir.delete(); }
[ "public", "static", "boolean", "deleteDir", "(", "File", "dir", ")", "{", "if", "(", "dir", "!=", "null", "&&", "dir", ".", "isDirectory", "(", ")", ")", "{", "String", "[", "]", "children", "=", "dir", ".", "list", "(", ")", ";", "for", "(", "in...
Deletes the specified directory. Returns true if successful, false if not. @param dir Directory to delete. @return {@code true} if successful, {@code false} if otherwise.
[ "Deletes", "the", "specified", "directory", ".", "Returns", "true", "if", "successful", "false", "if", "not", "." ]
0bc536d3bad1dade4538616f71c3a8f068eac89a
https://github.com/Pkmmte/PkRSS/blob/0bc536d3bad1dade4538616f71c3a8f068eac89a/pkrss/src/main/java/com/pkmmte/pkrss/Utils.java#L20-L29
train
Pkmmte/PkRSS
pkrss/src/main/java/com/pkmmte/pkrss/Utils.java
Utils.createDefaultDownloader
public static Downloader createDefaultDownloader(Context context) { Downloader downloaderInstance = null; try { Class.forName("com.squareup.okhttp.OkHttpClient"); downloaderInstance = new OkHttpDownloader(context); } catch (ClassNotFoundException ignored) {} try { Class.forName("okhttp3.OkHttpClient"); downloaderInstance = new OkHttp3Downloader(context); } catch (ClassNotFoundException ignored) {} if (downloaderInstance == null) { downloaderInstance = new DefaultDownloader(context); } Log.d(TAG, "Downloader is " + downloaderInstance); return downloaderInstance; }
java
public static Downloader createDefaultDownloader(Context context) { Downloader downloaderInstance = null; try { Class.forName("com.squareup.okhttp.OkHttpClient"); downloaderInstance = new OkHttpDownloader(context); } catch (ClassNotFoundException ignored) {} try { Class.forName("okhttp3.OkHttpClient"); downloaderInstance = new OkHttp3Downloader(context); } catch (ClassNotFoundException ignored) {} if (downloaderInstance == null) { downloaderInstance = new DefaultDownloader(context); } Log.d(TAG, "Downloader is " + downloaderInstance); return downloaderInstance; }
[ "public", "static", "Downloader", "createDefaultDownloader", "(", "Context", "context", ")", "{", "Downloader", "downloaderInstance", "=", "null", ";", "try", "{", "Class", ".", "forName", "(", "\"com.squareup.okhttp.OkHttpClient\"", ")", ";", "downloaderInstance", "=...
Creates a Downloader object depending on the dependencies present. @param context Application context. @return {@link OkHttp3Downloader} or {@link OkHttpDownloader} if the OkHttp library is present, {@link DefaultDownloader} if not.
[ "Creates", "a", "Downloader", "object", "depending", "on", "the", "dependencies", "present", "." ]
0bc536d3bad1dade4538616f71c3a8f068eac89a
https://github.com/Pkmmte/PkRSS/blob/0bc536d3bad1dade4538616f71c3a8f068eac89a/pkrss/src/main/java/com/pkmmte/pkrss/Utils.java#L38-L58
train
sephiroth74/Android-Easing
library/src/main/java/it/sephiroth/android/library/easing/EasingManager.java
EasingManager.start
public void start( Class<? extends Easing> clazz, EaseType type, double fromValue, double endValue, int durationMillis, long delayMillis ) { if ( !mRunning ) { mEasing = createInstance( clazz ); if( null == mEasing ){ return; } mMethod = getEasingMethod( mEasing, type ); if( mMethod == null ){ return; } mInverted = fromValue > endValue; if( mInverted ){ mStartValue = endValue; mEndValue = fromValue; } else { mStartValue = fromValue; mEndValue = endValue; } mValue = mStartValue; mDuration = durationMillis; mBase = SystemClock.uptimeMillis() + delayMillis; mRunning = true; mTicker = new Ticker(); long next = SystemClock.uptimeMillis() + FRAME_TIME + delayMillis; if( delayMillis == 0 ) { mEasingCallback.onEasingStarted( fromValue ); } else { mHandler.postAtTime( new TickerStart( fromValue ), mToken, next - FRAME_TIME ); } mHandler.postAtTime( mTicker, mToken, next ); } }
java
public void start( Class<? extends Easing> clazz, EaseType type, double fromValue, double endValue, int durationMillis, long delayMillis ) { if ( !mRunning ) { mEasing = createInstance( clazz ); if( null == mEasing ){ return; } mMethod = getEasingMethod( mEasing, type ); if( mMethod == null ){ return; } mInverted = fromValue > endValue; if( mInverted ){ mStartValue = endValue; mEndValue = fromValue; } else { mStartValue = fromValue; mEndValue = endValue; } mValue = mStartValue; mDuration = durationMillis; mBase = SystemClock.uptimeMillis() + delayMillis; mRunning = true; mTicker = new Ticker(); long next = SystemClock.uptimeMillis() + FRAME_TIME + delayMillis; if( delayMillis == 0 ) { mEasingCallback.onEasingStarted( fromValue ); } else { mHandler.postAtTime( new TickerStart( fromValue ), mToken, next - FRAME_TIME ); } mHandler.postAtTime( mTicker, mToken, next ); } }
[ "public", "void", "start", "(", "Class", "<", "?", "extends", "Easing", ">", "clazz", ",", "EaseType", "type", ",", "double", "fromValue", ",", "double", "endValue", ",", "int", "durationMillis", ",", "long", "delayMillis", ")", "{", "if", "(", "!", "mRu...
Start the easing with a delay @param clazz the Easing class to be used for the interpolation @param type the Easing Type @param fromValue the start value of the easing @param endValue the end value of the easing @param durationMillis the duration in ms of the easing @param delayMillis the delay
[ "Start", "the", "easing", "with", "a", "delay" ]
89caead2e0da4287631250e1dbb182d51b66055b
https://github.com/sephiroth74/Android-Easing/blob/89caead2e0da4287631250e1dbb182d51b66055b/library/src/main/java/it/sephiroth/android/library/easing/EasingManager.java#L78-L116
train
DJCordhose/jmte
src/com/floreysoft/jmte/ModelBuilder.java
ModelBuilder.mergeLists
public static List<Map<String, Object>> mergeLists(String[] names, List<Object>... lists) { List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>(); if (lists.length != 0) { // first check if all looks good int expectedSize = lists[0].size(); for (int i = 1; i < lists.length; i++) { List<Object> list = lists[i]; if (list.size() != expectedSize) { throw new IllegalArgumentException( "All lists and array of names must have the same size!"); } } // yes, things are ok List<Object> masterList = lists[0]; for (int i = 0; i < masterList.size(); i++) { Map<String, Object> map = new HashMap<String, Object>(); for (int j = 0; j < lists.length; j++) { String name = names[j]; List<Object> list = lists[j]; Object value = list.get(i); map.put(name, value); } resultList.add(map); } } return resultList; }
java
public static List<Map<String, Object>> mergeLists(String[] names, List<Object>... lists) { List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>(); if (lists.length != 0) { // first check if all looks good int expectedSize = lists[0].size(); for (int i = 1; i < lists.length; i++) { List<Object> list = lists[i]; if (list.size() != expectedSize) { throw new IllegalArgumentException( "All lists and array of names must have the same size!"); } } // yes, things are ok List<Object> masterList = lists[0]; for (int i = 0; i < masterList.size(); i++) { Map<String, Object> map = new HashMap<String, Object>(); for (int j = 0; j < lists.length; j++) { String name = names[j]; List<Object> list = lists[j]; Object value = list.get(i); map.put(name, value); } resultList.add(map); } } return resultList; }
[ "public", "static", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "mergeLists", "(", "String", "[", "]", "names", ",", "List", "<", "Object", ">", "...", "lists", ")", "{", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ...
Merges any number of named lists into a single one containing their combined values. Can be very handy in case of a servlet request which might contain several lists of parameters that you want to iterate over in a combined way. @param names the names of the variables in the following lists @param lists the lists containing the values for the named variables @return a merge list containing the combined values of the lists
[ "Merges", "any", "number", "of", "named", "lists", "into", "a", "single", "one", "containing", "their", "combined", "values", ".", "Can", "be", "very", "handy", "in", "case", "of", "a", "servlet", "request", "which", "might", "contain", "several", "lists", ...
7334e6d111cc2198c5cf69ee336584ab9e192fe5
https://github.com/DJCordhose/jmte/blob/7334e6d111cc2198c5cf69ee336584ab9e192fe5/src/com/floreysoft/jmte/ModelBuilder.java#L92-L121
train
DJCordhose/jmte
src/com/floreysoft/jmte/util/MiniParser.java
MiniParser.append
private void append(StringBuilder buffer, char c) { // version manually simplified // final boolean shouldAppend = rawOutput || escaped // || (c != quoteChar && c != escapeChar); // final boolean newEscaped = c == escapeChar && !escaped; // final boolean newQuoted = (c == quoteChar && !escaped) ? !quoted // : quoted; // side-effect free version directly extracted from if // final boolean shouldAppend = (c == escapeChar && (escaped || // rawOutput)) // || (c == quoteChar && (escaped || rawOutput)) // || !(c == quoteChar || c == escapeChar); // final boolean newEscaped = c == escapeChar ? !escaped // : (c == quoteChar ? false : false); // final boolean newQuoted = c == escapeChar ? quoted // : (c == quoteChar ? (!escaped ? !quoted : quoted) : quoted); // if (shouldAppend) { // buffer.append(c); // } // // escaped = newEscaped; // quoted = newQuoted; // original version // XXX needed to revert to this original version as micro benchmark // tests // showed a slow down of more than 100% if (c == escapeChar) { if (escaped || rawOutput) { buffer.append(c); } escaped = !escaped; } else if (c == quoteChar) { if (escaped) { buffer.append(c); escaped = false; } else { quoted = !quoted; if (rawOutput) { buffer.append(c); } } } else { buffer.append(c); escaped = false; } }
java
private void append(StringBuilder buffer, char c) { // version manually simplified // final boolean shouldAppend = rawOutput || escaped // || (c != quoteChar && c != escapeChar); // final boolean newEscaped = c == escapeChar && !escaped; // final boolean newQuoted = (c == quoteChar && !escaped) ? !quoted // : quoted; // side-effect free version directly extracted from if // final boolean shouldAppend = (c == escapeChar && (escaped || // rawOutput)) // || (c == quoteChar && (escaped || rawOutput)) // || !(c == quoteChar || c == escapeChar); // final boolean newEscaped = c == escapeChar ? !escaped // : (c == quoteChar ? false : false); // final boolean newQuoted = c == escapeChar ? quoted // : (c == quoteChar ? (!escaped ? !quoted : quoted) : quoted); // if (shouldAppend) { // buffer.append(c); // } // // escaped = newEscaped; // quoted = newQuoted; // original version // XXX needed to revert to this original version as micro benchmark // tests // showed a slow down of more than 100% if (c == escapeChar) { if (escaped || rawOutput) { buffer.append(c); } escaped = !escaped; } else if (c == quoteChar) { if (escaped) { buffer.append(c); escaped = false; } else { quoted = !quoted; if (rawOutput) { buffer.append(c); } } } else { buffer.append(c); escaped = false; } }
[ "private", "void", "append", "(", "StringBuilder", "buffer", ",", "char", "c", ")", "{", "// version manually simplified\r", "// final boolean shouldAppend = rawOutput || escaped\r", "// || (c != quoteChar && c != escapeChar);\r", "// final boolean newEscaped = c == escapeChar && !escape...
the heart of it all
[ "the", "heart", "of", "it", "all" ]
7334e6d111cc2198c5cf69ee336584ab9e192fe5
https://github.com/DJCordhose/jmte/blob/7334e6d111cc2198c5cf69ee336584ab9e192fe5/src/com/floreysoft/jmte/util/MiniParser.java#L277-L327
train
DJCordhose/jmte
src/com/floreysoft/jmte/Engine.java
Engine.variablesAvailable
public boolean variablesAvailable(Map<String, Object> model, String... vars) { final TemplateContext context = new TemplateContext(null, null, null, new ScopedMap(model), modelAdaptor, this, new SilentErrorHandler(), null); for (String var : vars) { final IfToken token = new IfToken(var, false); if (!(Boolean) token.evaluate(context)) { return false; } } return true; }
java
public boolean variablesAvailable(Map<String, Object> model, String... vars) { final TemplateContext context = new TemplateContext(null, null, null, new ScopedMap(model), modelAdaptor, this, new SilentErrorHandler(), null); for (String var : vars) { final IfToken token = new IfToken(var, false); if (!(Boolean) token.evaluate(context)) { return false; } } return true; }
[ "public", "boolean", "variablesAvailable", "(", "Map", "<", "String", ",", "Object", ">", "model", ",", "String", "...", "vars", ")", "{", "final", "TemplateContext", "context", "=", "new", "TemplateContext", "(", "null", ",", "null", ",", "null", ",", "ne...
Checks if all given variables are there and if so, that they evaluate to true inside an if.
[ "Checks", "if", "all", "given", "variables", "are", "there", "and", "if", "so", "that", "they", "evaluate", "to", "true", "inside", "an", "if", "." ]
7334e6d111cc2198c5cf69ee336584ab9e192fe5
https://github.com/DJCordhose/jmte/blob/7334e6d111cc2198c5cf69ee336584ab9e192fe5/src/com/floreysoft/jmte/Engine.java#L120-L130
train
DJCordhose/jmte
src/com/floreysoft/jmte/Engine.java
Engine.getUsedVariables
@Deprecated() public synchronized Set<String> getUsedVariables(String template) { Template templateImpl = getTemplate(template, null); return templateImpl.getUsedVariables(); }
java
@Deprecated() public synchronized Set<String> getUsedVariables(String template) { Template templateImpl = getTemplate(template, null); return templateImpl.getUsedVariables(); }
[ "@", "Deprecated", "(", ")", "public", "synchronized", "Set", "<", "String", ">", "getUsedVariables", "(", "String", "template", ")", "{", "Template", "templateImpl", "=", "getTemplate", "(", "template", ",", "null", ")", ";", "return", "templateImpl", ".", ...
Gets all variables used in the given template. @deprecated use {@link #getUsedVariableDescriptions(String)} instead
[ "Gets", "all", "variables", "used", "in", "the", "given", "template", "." ]
7334e6d111cc2198c5cf69ee336584ab9e192fe5
https://github.com/DJCordhose/jmte/blob/7334e6d111cc2198c5cf69ee336584ab9e192fe5/src/com/floreysoft/jmte/Engine.java#L239-L243
train
DJCordhose/jmte
src/com/floreysoft/jmte/Engine.java
Engine.getUsedVariableDescriptions
public synchronized List<VariableDescription> getUsedVariableDescriptions(String template) { Template templateImpl = getTemplate(template, null); return templateImpl.getUsedVariableDescriptions(); }
java
public synchronized List<VariableDescription> getUsedVariableDescriptions(String template) { Template templateImpl = getTemplate(template, null); return templateImpl.getUsedVariableDescriptions(); }
[ "public", "synchronized", "List", "<", "VariableDescription", ">", "getUsedVariableDescriptions", "(", "String", "template", ")", "{", "Template", "templateImpl", "=", "getTemplate", "(", "template", ",", "null", ")", ";", "return", "templateImpl", ".", "getUsedVari...
Gets all variables used in the given template as a detailed description.
[ "Gets", "all", "variables", "used", "in", "the", "given", "template", "as", "a", "detailed", "description", "." ]
7334e6d111cc2198c5cf69ee336584ab9e192fe5
https://github.com/DJCordhose/jmte/blob/7334e6d111cc2198c5cf69ee336584ab9e192fe5/src/com/floreysoft/jmte/Engine.java#L249-L252
train
DJCordhose/jmte
src/com/floreysoft/jmte/TemplateContext.java
TemplateContext.pop
public Token pop() { if (scopes.isEmpty()) { return null; } else { Token token = scopes.remove(scopes.size() - 1); return token; } }
java
public Token pop() { if (scopes.isEmpty()) { return null; } else { Token token = scopes.remove(scopes.size() - 1); return token; } }
[ "public", "Token", "pop", "(", ")", "{", "if", "(", "scopes", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "else", "{", "Token", "token", "=", "scopes", ".", "remove", "(", "scopes", ".", "size", "(", ")", "-", "1", ")", ";",...
Pops a token from the scope stack.
[ "Pops", "a", "token", "from", "the", "scope", "stack", "." ]
7334e6d111cc2198c5cf69ee336584ab9e192fe5
https://github.com/DJCordhose/jmte/blob/7334e6d111cc2198c5cf69ee336584ab9e192fe5/src/com/floreysoft/jmte/TemplateContext.java#L57-L64
train
DJCordhose/jmte
src/com/floreysoft/jmte/TemplateContext.java
TemplateContext.peek
public Token peek() { if (scopes.isEmpty()) { return null; } else { Token token = scopes.get(scopes.size() - 1); return token; } }
java
public Token peek() { if (scopes.isEmpty()) { return null; } else { Token token = scopes.get(scopes.size() - 1); return token; } }
[ "public", "Token", "peek", "(", ")", "{", "if", "(", "scopes", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "else", "{", "Token", "token", "=", "scopes", ".", "get", "(", "scopes", ".", "size", "(", ")", "-", "1", ")", ";", ...
Gets the top element from the stack without removing it.
[ "Gets", "the", "top", "element", "from", "the", "stack", "without", "removing", "it", "." ]
7334e6d111cc2198c5cf69ee336584ab9e192fe5
https://github.com/DJCordhose/jmte/blob/7334e6d111cc2198c5cf69ee336584ab9e192fe5/src/com/floreysoft/jmte/TemplateContext.java#L69-L76
train
DJCordhose/jmte
src/com/floreysoft/jmte/TemplateContext.java
TemplateContext.notifyProcessListener
public void notifyProcessListener(Token token, Action action) { if (processListener != null) { processListener.log(this, token, action); } }
java
public void notifyProcessListener(Token token, Action action) { if (processListener != null) { processListener.log(this, token, action); } }
[ "public", "void", "notifyProcessListener", "(", "Token", "token", ",", "Action", "action", ")", "{", "if", "(", "processListener", "!=", "null", ")", "{", "processListener", ".", "log", "(", "this", ",", "token", ",", "action", ")", ";", "}", "}" ]
Allows you to send additional notifications of executed processing steps. @param token the token that is handled @param action the action that is executed on the action
[ "Allows", "you", "to", "send", "additional", "notifications", "of", "executed", "processing", "steps", "." ]
7334e6d111cc2198c5cf69ee336584ab9e192fe5
https://github.com/DJCordhose/jmte/blob/7334e6d111cc2198c5cf69ee336584ab9e192fe5/src/com/floreysoft/jmte/TemplateContext.java#L100-L104
train
DJCordhose/jmte
src/com/floreysoft/jmte/util/Util.java
Util.streamToString
public static String streamToString(InputStream is, String charsetName) { try { Reader r = null; try { r = new BufferedReader(new InputStreamReader(is, charsetName)); return readerToString(r); } finally { if (r != null) { try { r.close(); } catch (IOException e) { } } } } catch (Exception e) { throw new RuntimeException(e); } }
java
public static String streamToString(InputStream is, String charsetName) { try { Reader r = null; try { r = new BufferedReader(new InputStreamReader(is, charsetName)); return readerToString(r); } finally { if (r != null) { try { r.close(); } catch (IOException e) { } } } } catch (Exception e) { throw new RuntimeException(e); } }
[ "public", "static", "String", "streamToString", "(", "InputStream", "is", ",", "String", "charsetName", ")", "{", "try", "{", "Reader", "r", "=", "null", ";", "try", "{", "r", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "is", ",", ...
Transforms a stream into a string. @param is the stream to be transformed @param charsetName encoding of the file @return the string containing the content of the stream
[ "Transforms", "a", "stream", "into", "a", "string", "." ]
7334e6d111cc2198c5cf69ee336584ab9e192fe5
https://github.com/DJCordhose/jmte/blob/7334e6d111cc2198c5cf69ee336584ab9e192fe5/src/com/floreysoft/jmte/util/Util.java#L124-L142
train
DJCordhose/jmte
src/com/floreysoft/jmte/util/Util.java
Util.resourceToString
public static String resourceToString(String resourceName, String charsetName) { InputStream templateStream = Thread.currentThread() .getContextClassLoader().getResourceAsStream(resourceName); String template = Util.streamToString(templateStream, "UTF-8"); return template; }
java
public static String resourceToString(String resourceName, String charsetName) { InputStream templateStream = Thread.currentThread() .getContextClassLoader().getResourceAsStream(resourceName); String template = Util.streamToString(templateStream, "UTF-8"); return template; }
[ "public", "static", "String", "resourceToString", "(", "String", "resourceName", ",", "String", "charsetName", ")", "{", "InputStream", "templateStream", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ".", "getResourceAsStream...
Loads a stream from the classpath and transforms it into a string. @param resourceName the name of the resource to be transformed @param charsetName encoding of the resource @return the string containing the content of the resource @see ClassLoader#getResourceAsStream(String)
[ "Loads", "a", "stream", "from", "the", "classpath", "and", "transforms", "it", "into", "a", "string", "." ]
7334e6d111cc2198c5cf69ee336584ab9e192fe5
https://github.com/DJCordhose/jmte/blob/7334e6d111cc2198c5cf69ee336584ab9e192fe5/src/com/floreysoft/jmte/util/Util.java#L154-L160
train
DJCordhose/jmte
src/com/floreysoft/jmte/util/Util.java
Util.readerToString
public static String readerToString(Reader reader) { try { StringBuilder sb = new StringBuilder(); char[] buf = new char[1024]; int numRead = 0; while ((numRead = reader.read(buf)) != -1) { sb.append(buf, 0, numRead); } return sb.toString(); } catch (Exception e) { throw new RuntimeException(e); } }
java
public static String readerToString(Reader reader) { try { StringBuilder sb = new StringBuilder(); char[] buf = new char[1024]; int numRead = 0; while ((numRead = reader.read(buf)) != -1) { sb.append(buf, 0, numRead); } return sb.toString(); } catch (Exception e) { throw new RuntimeException(e); } }
[ "public", "static", "String", "readerToString", "(", "Reader", "reader", ")", "{", "try", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "char", "[", "]", "buf", "=", "new", "char", "[", "1024", "]", ";", "int", "numRead", "=",...
Transforms a reader into a string. @param reader the reader to be transformed @return the string containing the content of the reader
[ "Transforms", "a", "reader", "into", "a", "string", "." ]
7334e6d111cc2198c5cf69ee336584ab9e192fe5
https://github.com/DJCordhose/jmte/blob/7334e6d111cc2198c5cf69ee336584ab9e192fe5/src/com/floreysoft/jmte/util/Util.java#L169-L182
train
DJCordhose/jmte
src/com/floreysoft/jmte/util/Util.java
Util.arrayAsList
@SuppressWarnings({ "unchecked", "rawtypes" }) public static List<Object> arrayAsList(Object value) { if (value instanceof List) { return (List<Object>) value; } List list = null; if (value instanceof int[]) { list = new ArrayList(); int[] array = (int[]) value; for (int i : array) { list.add(i); } } else if (value instanceof short[]) { list = new ArrayList(); short[] array = (short[]) value; for (short i : array) { list.add(i); } } else if (value instanceof char[]) { list = new ArrayList(); char[] array = (char[]) value; for (char i : array) { list.add(i); } } else if (value instanceof byte[]) { list = new ArrayList(); byte[] array = (byte[]) value; for (byte i : array) { list.add(i); } } else if (value instanceof long[]) { list = new ArrayList(); long[] array = (long[]) value; for (long i : array) { list.add(i); } } else if (value instanceof double[]) { list = new ArrayList(); double[] array = (double[]) value; for (double i : array) { list.add(i); } } else if (value instanceof float[]) { list = new ArrayList(); float[] array = (float[]) value; for (float i : array) { list.add(i); } } else if (value instanceof boolean[]) { list = new ArrayList(); boolean[] array = (boolean[]) value; for (boolean i : array) { list.add(i); } } else if (value.getClass().isArray()) { Object[] array = (Object[]) value; list = Arrays.asList(array); } return list; }
java
@SuppressWarnings({ "unchecked", "rawtypes" }) public static List<Object> arrayAsList(Object value) { if (value instanceof List) { return (List<Object>) value; } List list = null; if (value instanceof int[]) { list = new ArrayList(); int[] array = (int[]) value; for (int i : array) { list.add(i); } } else if (value instanceof short[]) { list = new ArrayList(); short[] array = (short[]) value; for (short i : array) { list.add(i); } } else if (value instanceof char[]) { list = new ArrayList(); char[] array = (char[]) value; for (char i : array) { list.add(i); } } else if (value instanceof byte[]) { list = new ArrayList(); byte[] array = (byte[]) value; for (byte i : array) { list.add(i); } } else if (value instanceof long[]) { list = new ArrayList(); long[] array = (long[]) value; for (long i : array) { list.add(i); } } else if (value instanceof double[]) { list = new ArrayList(); double[] array = (double[]) value; for (double i : array) { list.add(i); } } else if (value instanceof float[]) { list = new ArrayList(); float[] array = (float[]) value; for (float i : array) { list.add(i); } } else if (value instanceof boolean[]) { list = new ArrayList(); boolean[] array = (boolean[]) value; for (boolean i : array) { list.add(i); } } else if (value.getClass().isArray()) { Object[] array = (Object[]) value; list = Arrays.asList(array); } return list; }
[ "@", "SuppressWarnings", "(", "{", "\"unchecked\"", ",", "\"rawtypes\"", "}", ")", "public", "static", "List", "<", "Object", ">", "arrayAsList", "(", "Object", "value", ")", "{", "if", "(", "value", "instanceof", "List", ")", "{", "return", "(", "List", ...
Transforms any array to a matching list @param value something that might be an array @return List representation if passed in value was an array, <code>null</code> otherwise
[ "Transforms", "any", "array", "to", "a", "matching", "list" ]
7334e6d111cc2198c5cf69ee336584ab9e192fe5
https://github.com/DJCordhose/jmte/blob/7334e6d111cc2198c5cf69ee336584ab9e192fe5/src/com/floreysoft/jmte/util/Util.java#L208-L267
train
DJCordhose/jmte
src/com/floreysoft/jmte/util/Util.java
Util.trimFront
public static String trimFront(String input) { int i = 0; while (i < input.length() && Character.isWhitespace(input.charAt(i))) i++; return input.substring(i); }
java
public static String trimFront(String input) { int i = 0; while (i < input.length() && Character.isWhitespace(input.charAt(i))) i++; return input.substring(i); }
[ "public", "static", "String", "trimFront", "(", "String", "input", ")", "{", "int", "i", "=", "0", ";", "while", "(", "i", "<", "input", ".", "length", "(", ")", "&&", "Character", ".", "isWhitespace", "(", "input", ".", "charAt", "(", "i", ")", ")...
Trims off white space from the beginning of a string. @param input the string to be trimmed @return the trimmed string
[ "Trims", "off", "white", "space", "from", "the", "beginning", "of", "a", "string", "." ]
7334e6d111cc2198c5cf69ee336584ab9e192fe5
https://github.com/DJCordhose/jmte/blob/7334e6d111cc2198c5cf69ee336584ab9e192fe5/src/com/floreysoft/jmte/util/Util.java#L294-L299
train
pantsbuild/jarjar
src/main/java/org/pantsbuild/jarjar/misplaced/MisplacedClassProcessorFactory.java
MisplacedClassProcessorFactory.getProcessorForName
public MisplacedClassProcessor getProcessorForName(String name) { if (name == null) { return getDefaultProcessor(); } switch (Strategy.valueOf(name.toUpperCase())) { case FATAL: return new FatalMisplacedClassProcessor(); case MOVE: return new MoveMisplacedClassProcessor(); case OMIT: return new OmitMisplacedClassProcessor(); case SKIP: return new SkipMisplacedClassProcessor(); } throw new IllegalArgumentException("Unrecognized strategy name \"" + name + "\"."); }
java
public MisplacedClassProcessor getProcessorForName(String name) { if (name == null) { return getDefaultProcessor(); } switch (Strategy.valueOf(name.toUpperCase())) { case FATAL: return new FatalMisplacedClassProcessor(); case MOVE: return new MoveMisplacedClassProcessor(); case OMIT: return new OmitMisplacedClassProcessor(); case SKIP: return new SkipMisplacedClassProcessor(); } throw new IllegalArgumentException("Unrecognized strategy name \"" + name + "\"."); }
[ "public", "MisplacedClassProcessor", "getProcessorForName", "(", "String", "name", ")", "{", "if", "(", "name", "==", "null", ")", "{", "return", "getDefaultProcessor", "(", ")", ";", "}", "switch", "(", "Strategy", ".", "valueOf", "(", "name", ".", "toUpper...
Creates a MisplacedClassProcessor according for the given strategy name. @param name The case-insensitive user-level strategy name (see the STRATEGY_* constants). @return The MisplacedClassProcessor corresponding to the strategy name, or the result of getDefaultProcessor() if name is null. @throws IllegalArgumentException if an unrecognized non-null strategy name is specified.
[ "Creates", "a", "MisplacedClassProcessor", "according", "for", "the", "given", "strategy", "name", "." ]
57845dc73d3e2c9b916ae4a788cfa12114fd7df1
https://github.com/pantsbuild/jarjar/blob/57845dc73d3e2c9b916ae4a788cfa12114fd7df1/src/main/java/org/pantsbuild/jarjar/misplaced/MisplacedClassProcessorFactory.java#L51-L64
train
krummas/DrizzleJDBC
src/main/java/org/drizzle/jdbc/internal/common/packet/buffer/ReadUtil.java
ReadUtil.safeRead
public static int safeRead(final InputStream inputStream, final byte[] buffer) throws IOException { int readBytes = inputStream.read(buffer); if(readBytes == -1) { return -1; } if(readBytes < buffer.length) { int offset = readBytes; int left = buffer.length; left = left - readBytes; do { try { final int nr = inputStream.read(buffer, offset, left); if (nr == -1) { return nr; } offset += nr; left -= nr; } catch (InterruptedIOException exp) { /* Ignore, just retry */ } } while (left > 0); } return buffer.length; }
java
public static int safeRead(final InputStream inputStream, final byte[] buffer) throws IOException { int readBytes = inputStream.read(buffer); if(readBytes == -1) { return -1; } if(readBytes < buffer.length) { int offset = readBytes; int left = buffer.length; left = left - readBytes; do { try { final int nr = inputStream.read(buffer, offset, left); if (nr == -1) { return nr; } offset += nr; left -= nr; } catch (InterruptedIOException exp) { /* Ignore, just retry */ } } while (left > 0); } return buffer.length; }
[ "public", "static", "int", "safeRead", "(", "final", "InputStream", "inputStream", ",", "final", "byte", "[", "]", "buffer", ")", "throws", "IOException", "{", "int", "readBytes", "=", "inputStream", ".", "read", "(", "buffer", ")", ";", "if", "(", "readBy...
Read a number of bytes from the stream and store it in the buffer, and fix the problem with "incomplete" reads by doing another read if we don't have all of the data yet. @param inputStream the input stream to read from @param buffer where to store the data @return the number of bytes read (should be == length if we didn't hit EOF) @throws java.io.IOException if an error occurs while reading the stream
[ "Read", "a", "number", "of", "bytes", "from", "the", "stream", "and", "store", "it", "in", "the", "buffer", "and", "fix", "the", "problem", "with", "incomplete", "reads", "by", "doing", "another", "read", "if", "we", "don", "t", "have", "all", "of", "t...
716f31fd71f3cc289edf69844d8117deb86d98d6
https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/internal/common/packet/buffer/ReadUtil.java#L51-L74
train
krummas/DrizzleJDBC
src/main/java/org/drizzle/jdbc/internal/common/packet/buffer/ReadUtil.java
ReadUtil.eofIsNext
public static boolean eofIsNext(final RawPacket rawPacket) { final ByteBuffer buf = rawPacket.getByteBuffer(); return (buf.get(0) == (byte)0xfe && buf.capacity() < 9); }
java
public static boolean eofIsNext(final RawPacket rawPacket) { final ByteBuffer buf = rawPacket.getByteBuffer(); return (buf.get(0) == (byte)0xfe && buf.capacity() < 9); }
[ "public", "static", "boolean", "eofIsNext", "(", "final", "RawPacket", "rawPacket", ")", "{", "final", "ByteBuffer", "buf", "=", "rawPacket", ".", "getByteBuffer", "(", ")", ";", "return", "(", "buf", ".", "get", "(", "0", ")", "==", "(", "byte", ")", ...
Checks whether the next packet is EOF. @param rawPacket the raw packet @return true if the packet is an EOF packet
[ "Checks", "whether", "the", "next", "packet", "is", "EOF", "." ]
716f31fd71f3cc289edf69844d8117deb86d98d6
https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/internal/common/packet/buffer/ReadUtil.java#L81-L85
train
krummas/DrizzleJDBC
src/main/java/org/drizzle/jdbc/internal/common/packet/RawPacket.java
RawPacket.nextPacket
static RawPacket nextPacket(final InputStream is) throws IOException { byte[] lengthBuffer = readLengthSeq(is); int length = (lengthBuffer[0] & 0xff) + ((lengthBuffer[1] & 0xff) << 8) + ((lengthBuffer[2] & 0xff) << 16); if (length == -1) { return null; } if (length < 0) { throw new IOException("Got negative packet size: " + length); } final int packetSeq = lengthBuffer[3]; final byte[] rawBytes = new byte[length]; final int nr = ReadUtil.safeRead(is, rawBytes); if (nr != length) { throw new IOException("EOF. Expected " + length + ", got " + nr); } return new RawPacket(ByteBuffer.wrap(rawBytes).order(ByteOrder.LITTLE_ENDIAN), packetSeq); }
java
static RawPacket nextPacket(final InputStream is) throws IOException { byte[] lengthBuffer = readLengthSeq(is); int length = (lengthBuffer[0] & 0xff) + ((lengthBuffer[1] & 0xff) << 8) + ((lengthBuffer[2] & 0xff) << 16); if (length == -1) { return null; } if (length < 0) { throw new IOException("Got negative packet size: " + length); } final int packetSeq = lengthBuffer[3]; final byte[] rawBytes = new byte[length]; final int nr = ReadUtil.safeRead(is, rawBytes); if (nr != length) { throw new IOException("EOF. Expected " + length + ", got " + nr); } return new RawPacket(ByteBuffer.wrap(rawBytes).order(ByteOrder.LITTLE_ENDIAN), packetSeq); }
[ "static", "RawPacket", "nextPacket", "(", "final", "InputStream", "is", ")", "throws", "IOException", "{", "byte", "[", "]", "lengthBuffer", "=", "readLengthSeq", "(", "is", ")", ";", "int", "length", "=", "(", "lengthBuffer", "[", "0", "]", "&", "0xff", ...
Get the next packet from the stream @param is the input stream to read the next packet from @return The next packet from the stream, or NULL if the stream is closed @throws java.io.IOException if an error occurs while reading data
[ "Get", "the", "next", "packet", "from", "the", "stream" ]
716f31fd71f3cc289edf69844d8117deb86d98d6
https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/internal/common/packet/RawPacket.java#L50-L72
train
krummas/DrizzleJDBC
src/main/java/org/drizzle/jdbc/DrizzleStatement.java
DrizzleStatement.execute
public boolean execute(final String query) throws SQLException { startTimer(); try { if (queryResult != null) { queryResult.close(); } queryResult = protocol.executeQuery(queryFactory.createQuery(query)); if (queryResult.getResultSetType() == ResultSetType.SELECT) { setResultSet(new DrizzleResultSet(queryResult, this, getProtocol())); return true; } setUpdateCount(((ModifyQueryResult) queryResult).getUpdateCount()); return false; } catch (QueryException e) { throw SQLExceptionMapper.get(e); } finally { stopTimer(); } }
java
public boolean execute(final String query) throws SQLException { startTimer(); try { if (queryResult != null) { queryResult.close(); } queryResult = protocol.executeQuery(queryFactory.createQuery(query)); if (queryResult.getResultSetType() == ResultSetType.SELECT) { setResultSet(new DrizzleResultSet(queryResult, this, getProtocol())); return true; } setUpdateCount(((ModifyQueryResult) queryResult).getUpdateCount()); return false; } catch (QueryException e) { throw SQLExceptionMapper.get(e); } finally { stopTimer(); } }
[ "public", "boolean", "execute", "(", "final", "String", "query", ")", "throws", "SQLException", "{", "startTimer", "(", ")", ";", "try", "{", "if", "(", "queryResult", "!=", "null", ")", "{", "queryResult", ".", "close", "(", ")", ";", "}", "queryResult"...
executes a query. @param query the query @return true if there was a result set, false otherwise. @throws SQLException
[ "executes", "a", "query", "." ]
716f31fd71f3cc289edf69844d8117deb86d98d6
https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/DrizzleStatement.java#L204-L222
train
krummas/DrizzleJDBC
src/main/java/org/drizzle/jdbc/internal/common/query/parameters/BlobStreamingParameter.java
BlobStreamingParameter.writeTo
public final int writeTo(final OutputStream os,int offset, int maxWriteSize) throws IOException { int bytesToWrite = Math.min(blobReference.getBytes().length - offset, maxWriteSize); os.write(blobReference.getBytes(), offset, blobReference.getBytes().length); return bytesToWrite; }
java
public final int writeTo(final OutputStream os,int offset, int maxWriteSize) throws IOException { int bytesToWrite = Math.min(blobReference.getBytes().length - offset, maxWriteSize); os.write(blobReference.getBytes(), offset, blobReference.getBytes().length); return bytesToWrite; }
[ "public", "final", "int", "writeTo", "(", "final", "OutputStream", "os", ",", "int", "offset", ",", "int", "maxWriteSize", ")", "throws", "IOException", "{", "int", "bytesToWrite", "=", "Math", ".", "min", "(", "blobReference", ".", "getBytes", "(", ")", "...
Writes the parameter to an outputstream. @param os the outputstream to write to @throws java.io.IOException if we cannot write to the stream
[ "Writes", "the", "parameter", "to", "an", "outputstream", "." ]
716f31fd71f3cc289edf69844d8117deb86d98d6
https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/internal/common/query/parameters/BlobStreamingParameter.java#L62-L66
train
krummas/DrizzleJDBC
src/main/java/org/drizzle/jdbc/internal/common/packet/buffer/Reader.java
Reader.readString
public String readString(final String charset) throws IOException { byte ch; int cnt = 0; final byte [] byteArrBuff = new byte[byteBuffer.remaining()]; while (byteBuffer.remaining() > 0 && ((ch = byteBuffer.get()) != 0)) { byteArrBuff[cnt++] = ch; } return new String(byteArrBuff,0,cnt); }
java
public String readString(final String charset) throws IOException { byte ch; int cnt = 0; final byte [] byteArrBuff = new byte[byteBuffer.remaining()]; while (byteBuffer.remaining() > 0 && ((ch = byteBuffer.get()) != 0)) { byteArrBuff[cnt++] = ch; } return new String(byteArrBuff,0,cnt); }
[ "public", "String", "readString", "(", "final", "String", "charset", ")", "throws", "IOException", "{", "byte", "ch", ";", "int", "cnt", "=", "0", ";", "final", "byte", "[", "]", "byteArrBuff", "=", "new", "byte", "[", "byteBuffer", ".", "remaining", "("...
Reads a string from the buffer, looks for a 0 to end the string @param charset the charset to use, for example ASCII @return the read string @throws java.io.IOException if it is not possible to create the string from the buffer
[ "Reads", "a", "string", "from", "the", "buffer", "looks", "for", "a", "0", "to", "end", "the", "string" ]
716f31fd71f3cc289edf69844d8117deb86d98d6
https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/internal/common/packet/buffer/Reader.java#L53-L61
train
krummas/DrizzleJDBC
src/main/java/org/drizzle/jdbc/internal/common/queryresults/DrizzleQueryResult.java
DrizzleQueryResult.getValueObject
public ValueObject getValueObject(final int i) throws NoSuchColumnException { if (i < 0 || i > resultSet.get(rowPointer).size()) { throw new NoSuchColumnException("No such column: " + i); } return resultSet.get(rowPointer).get(i); }
java
public ValueObject getValueObject(final int i) throws NoSuchColumnException { if (i < 0 || i > resultSet.get(rowPointer).size()) { throw new NoSuchColumnException("No such column: " + i); } return resultSet.get(rowPointer).get(i); }
[ "public", "ValueObject", "getValueObject", "(", "final", "int", "i", ")", "throws", "NoSuchColumnException", "{", "if", "(", "i", "<", "0", "||", "i", ">", "resultSet", ".", "get", "(", "rowPointer", ")", ".", "size", "(", ")", ")", "{", "throw", "new"...
gets the value at position i in the result set. i starts at zero! @param i index, starts at 0 @return
[ "gets", "the", "value", "at", "position", "i", "in", "the", "result", "set", ".", "i", "starts", "at", "zero!" ]
716f31fd71f3cc289edf69844d8117deb86d98d6
https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/internal/common/queryresults/DrizzleQueryResult.java#L89-L94
train
krummas/DrizzleJDBC
src/main/java/org/drizzle/jdbc/internal/common/Utils.java
Utils.sqlEscapeString
public static String sqlEscapeString(final String str) { StringBuilder buffer = new StringBuilder(str.length() * 2); boolean neededEscaping = false; for (int i = 0; i < str.length(); i++) { final char c = str.charAt(i); if (needsEscaping((byte) c)) { neededEscaping = true; buffer.append('\\'); } buffer.append(c); } return neededEscaping ? buffer.toString() : str; }
java
public static String sqlEscapeString(final String str) { StringBuilder buffer = new StringBuilder(str.length() * 2); boolean neededEscaping = false; for (int i = 0; i < str.length(); i++) { final char c = str.charAt(i); if (needsEscaping((byte) c)) { neededEscaping = true; buffer.append('\\'); } buffer.append(c); } return neededEscaping ? buffer.toString() : str; }
[ "public", "static", "String", "sqlEscapeString", "(", "final", "String", "str", ")", "{", "StringBuilder", "buffer", "=", "new", "StringBuilder", "(", "str", ".", "length", "(", ")", "*", "2", ")", ";", "boolean", "neededEscaping", "=", "false", ";", "for"...
escapes the given string, new string length is at most twice the length of str @param str the string to escape @return an escaped string
[ "escapes", "the", "given", "string", "new", "string", "length", "is", "at", "most", "twice", "the", "length", "of", "str" ]
716f31fd71f3cc289edf69844d8117deb86d98d6
https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/internal/common/Utils.java#L98-L110
train
krummas/DrizzleJDBC
src/main/java/org/drizzle/jdbc/internal/common/Utils.java
Utils.unpackTime
public static long unpackTime(final int packedTime) { final int hours = (packedTime & MASK_HOURS); final int minutes = (packedTime & MASK_MINUTES) >> (START_BIT_MINUTES); final int seconds = (packedTime & MASK_SECONDS) >> (START_BIT_SECONDS); final int millis = (packedTime & MASK_MILLISECONDS) >> (START_BIT_MILLISECONDS); long returnValue = (long) hours * 60 * 60 * 1000; returnValue += (long) minutes * 60 * 1000; returnValue += (long) seconds * 1000; returnValue += (long) millis; return returnValue; }
java
public static long unpackTime(final int packedTime) { final int hours = (packedTime & MASK_HOURS); final int minutes = (packedTime & MASK_MINUTES) >> (START_BIT_MINUTES); final int seconds = (packedTime & MASK_SECONDS) >> (START_BIT_SECONDS); final int millis = (packedTime & MASK_MILLISECONDS) >> (START_BIT_MILLISECONDS); long returnValue = (long) hours * 60 * 60 * 1000; returnValue += (long) minutes * 60 * 1000; returnValue += (long) seconds * 1000; returnValue += (long) millis; return returnValue; }
[ "public", "static", "long", "unpackTime", "(", "final", "int", "packedTime", ")", "{", "final", "int", "hours", "=", "(", "packedTime", "&", "MASK_HOURS", ")", ";", "final", "int", "minutes", "=", "(", "packedTime", "&", "MASK_MINUTES", ")", ">>", "(", "...
unpacks an integer packed by packTime @param packedTime the packed time @return a millisecond time @see Utils#packTime(long)
[ "unpacks", "an", "integer", "packed", "by", "packTime" ]
716f31fd71f3cc289edf69844d8117deb86d98d6
https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/internal/common/Utils.java#L319-L329
train
krummas/DrizzleJDBC
src/main/java/org/drizzle/jdbc/internal/common/Utils.java
Utils.isJava5
public static boolean isJava5() { if (!java5Determined) { try { java.util.Arrays.copyOf(new byte[0], 0); isJava5 = false; } catch (java.lang.NoSuchMethodError e) { isJava5 = true; } java5Determined = true; } return isJava5; }
java
public static boolean isJava5() { if (!java5Determined) { try { java.util.Arrays.copyOf(new byte[0], 0); isJava5 = false; } catch (java.lang.NoSuchMethodError e) { isJava5 = true; } java5Determined = true; } return isJava5; }
[ "public", "static", "boolean", "isJava5", "(", ")", "{", "if", "(", "!", "java5Determined", ")", "{", "try", "{", "java", ".", "util", ".", "Arrays", ".", "copyOf", "(", "new", "byte", "[", "0", "]", ",", "0", ")", ";", "isJava5", "=", "false", "...
Returns if it is a Java version up to Java 5. @return true if the VM is <= Java 5
[ "Returns", "if", "it", "is", "a", "Java", "version", "up", "to", "Java", "5", "." ]
716f31fd71f3cc289edf69844d8117deb86d98d6
https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/internal/common/Utils.java#L372-L383
train
krummas/DrizzleJDBC
src/main/java/org/drizzle/jdbc/DrizzlePreparedStatement.java
DrizzlePreparedStatement.setTime
public void setTime(final int parameterIndex, final Time x) throws SQLException { if(x == null) { setNull(parameterIndex, Types.TIME); return; } setParameter(parameterIndex, new TimeParameter(x.getTime())); }
java
public void setTime(final int parameterIndex, final Time x) throws SQLException { if(x == null) { setNull(parameterIndex, Types.TIME); return; } setParameter(parameterIndex, new TimeParameter(x.getTime())); }
[ "public", "void", "setTime", "(", "final", "int", "parameterIndex", ",", "final", "Time", "x", ")", "throws", "SQLException", "{", "if", "(", "x", "==", "null", ")", "{", "setNull", "(", "parameterIndex", ",", "Types", ".", "TIME", ")", ";", "return", ...
Since Drizzle has no TIME datatype, time in milliseconds is stored in a packed integer @param parameterIndex the first parameter is 1, the second is 2, ... @param x the parameter value @throws java.sql.SQLException if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closed <code>PreparedStatement</code> @see org.drizzle.jdbc.internal.common.Utils#packTime(long) @see org.drizzle.jdbc.internal.common.Utils#unpackTime(int) <p/> Sets the designated parameter to the given <code>java.sql.Time</code> value. The driver converts this to an SQL <code>TIME</code> value when it sends it to the database.
[ "Since", "Drizzle", "has", "no", "TIME", "datatype", "time", "in", "milliseconds", "is", "stored", "in", "a", "packed", "integer" ]
716f31fd71f3cc289edf69844d8117deb86d98d6
https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/DrizzlePreparedStatement.java#L1154-L1162
train
krummas/DrizzleJDBC
src/main/java/org/drizzle/jdbc/internal/mysql/MySQLProtocol.java
MySQLProtocol.createDrizzleQueryResult
private QueryResult createDrizzleQueryResult(final ResultSetPacket packet) throws IOException, QueryException { final List<ColumnInformation> columnInformation = new ArrayList<ColumnInformation>(); for (int i = 0; i < packet.getFieldCount(); i++) { final RawPacket rawPacket = packetFetcher.getRawPacket(); final ColumnInformation columnInfo = MySQLFieldPacket.columnInformationFactory(rawPacket); columnInformation.add(columnInfo); } packetFetcher.getRawPacket(); final List<List<ValueObject>> valueObjects = new ArrayList<List<ValueObject>>(); while (true) { final RawPacket rawPacket = packetFetcher.getRawPacket(); if (ReadUtil.isErrorPacket(rawPacket)) { ErrorPacket errorPacket = (ErrorPacket) ResultPacketFactory.createResultPacket(rawPacket); checkIfCancelled(); throw new QueryException(errorPacket.getMessage(), errorPacket.getErrorNumber(), errorPacket.getSqlState()); } if (ReadUtil.eofIsNext(rawPacket)) { final EOFPacket eofPacket = (EOFPacket) ResultPacketFactory.createResultPacket(rawPacket); this.hasMoreResults = eofPacket.getStatusFlags().contains(EOFPacket.ServerStatus.SERVER_MORE_RESULTS_EXISTS); checkIfCancelled(); return new DrizzleQueryResult(columnInformation, valueObjects, eofPacket.getWarningCount()); } if (getDatabaseType() == SupportedDatabases.MYSQL) { final MySQLRowPacket rowPacket = new MySQLRowPacket(rawPacket, columnInformation); valueObjects.add(rowPacket.getRow(packetFetcher)); } else { final DrizzleRowPacket rowPacket = new DrizzleRowPacket(rawPacket, columnInformation); valueObjects.add(rowPacket.getRow()); } } }
java
private QueryResult createDrizzleQueryResult(final ResultSetPacket packet) throws IOException, QueryException { final List<ColumnInformation> columnInformation = new ArrayList<ColumnInformation>(); for (int i = 0; i < packet.getFieldCount(); i++) { final RawPacket rawPacket = packetFetcher.getRawPacket(); final ColumnInformation columnInfo = MySQLFieldPacket.columnInformationFactory(rawPacket); columnInformation.add(columnInfo); } packetFetcher.getRawPacket(); final List<List<ValueObject>> valueObjects = new ArrayList<List<ValueObject>>(); while (true) { final RawPacket rawPacket = packetFetcher.getRawPacket(); if (ReadUtil.isErrorPacket(rawPacket)) { ErrorPacket errorPacket = (ErrorPacket) ResultPacketFactory.createResultPacket(rawPacket); checkIfCancelled(); throw new QueryException(errorPacket.getMessage(), errorPacket.getErrorNumber(), errorPacket.getSqlState()); } if (ReadUtil.eofIsNext(rawPacket)) { final EOFPacket eofPacket = (EOFPacket) ResultPacketFactory.createResultPacket(rawPacket); this.hasMoreResults = eofPacket.getStatusFlags().contains(EOFPacket.ServerStatus.SERVER_MORE_RESULTS_EXISTS); checkIfCancelled(); return new DrizzleQueryResult(columnInformation, valueObjects, eofPacket.getWarningCount()); } if (getDatabaseType() == SupportedDatabases.MYSQL) { final MySQLRowPacket rowPacket = new MySQLRowPacket(rawPacket, columnInformation); valueObjects.add(rowPacket.getRow(packetFetcher)); } else { final DrizzleRowPacket rowPacket = new DrizzleRowPacket(rawPacket, columnInformation); valueObjects.add(rowPacket.getRow()); } } }
[ "private", "QueryResult", "createDrizzleQueryResult", "(", "final", "ResultSetPacket", "packet", ")", "throws", "IOException", ",", "QueryException", "{", "final", "List", "<", "ColumnInformation", ">", "columnInformation", "=", "new", "ArrayList", "<", "ColumnInformati...
create a DrizzleQueryResult - precondition is that a result set packet has been read @param packet the result set packet from the server @return a DrizzleQueryResult @throws java.io.IOException when something goes wrong while reading/writing from the server
[ "create", "a", "DrizzleQueryResult", "-", "precondition", "is", "that", "a", "result", "set", "packet", "has", "been", "read" ]
716f31fd71f3cc289edf69844d8117deb86d98d6
https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/internal/mysql/MySQLProtocol.java#L297-L332
train
krummas/DrizzleJDBC
src/main/java/org/drizzle/jdbc/internal/common/AbstractValueObject.java
AbstractValueObject.getTime
public Time getTime() throws ParseException { if (rawBytes == null) { return null; } String rawValue = getString(); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); sdf.setLenient(false); final java.util.Date utilTime = sdf.parse(rawValue); return new Time(utilTime.getTime()); }
java
public Time getTime() throws ParseException { if (rawBytes == null) { return null; } String rawValue = getString(); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); sdf.setLenient(false); final java.util.Date utilTime = sdf.parse(rawValue); return new Time(utilTime.getTime()); }
[ "public", "Time", "getTime", "(", ")", "throws", "ParseException", "{", "if", "(", "rawBytes", "==", "null", ")", "{", "return", "null", ";", "}", "String", "rawValue", "=", "getString", "(", ")", ";", "SimpleDateFormat", "sdf", "=", "new", "SimpleDateForm...
Since drizzle has no TIME datatype, JDBC Time is stored in a packed integer @return the time @throws java.text.ParseException @see Utils#packTime(long) @see Utils#unpackTime(int)
[ "Since", "drizzle", "has", "no", "TIME", "datatype", "JDBC", "Time", "is", "stored", "in", "a", "packed", "integer" ]
716f31fd71f3cc289edf69844d8117deb86d98d6
https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/internal/common/AbstractValueObject.java#L145-L155
train
krummas/DrizzleJDBC
src/main/java/org/drizzle/jdbc/DrizzleConnection.java
DrizzleConnection.prepareStatement
public PreparedStatement prepareStatement(final String sql) throws SQLException { if (parameterizedBatchHandlerFactory == null) { this.parameterizedBatchHandlerFactory = new DefaultParameterizedBatchHandlerFactory(); } final String strippedQuery = Utils.stripQuery(sql); return new DrizzlePreparedStatement(protocol, this, strippedQuery, queryFactory, parameterizedBatchHandlerFactory.get(strippedQuery, protocol)); }
java
public PreparedStatement prepareStatement(final String sql) throws SQLException { if (parameterizedBatchHandlerFactory == null) { this.parameterizedBatchHandlerFactory = new DefaultParameterizedBatchHandlerFactory(); } final String strippedQuery = Utils.stripQuery(sql); return new DrizzlePreparedStatement(protocol, this, strippedQuery, queryFactory, parameterizedBatchHandlerFactory.get(strippedQuery, protocol)); }
[ "public", "PreparedStatement", "prepareStatement", "(", "final", "String", "sql", ")", "throws", "SQLException", "{", "if", "(", "parameterizedBatchHandlerFactory", "==", "null", ")", "{", "this", ".", "parameterizedBatchHandlerFactory", "=", "new", "DefaultParameterize...
creates a new prepared statement. Only client side prepared statement emulation right now. @param sql the query. @return a prepared statement. @throws SQLException if there is a problem preparing the statement.
[ "creates", "a", "new", "prepared", "statement", ".", "Only", "client", "side", "prepared", "statement", "emulation", "right", "now", "." ]
716f31fd71f3cc289edf69844d8117deb86d98d6
https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/DrizzleConnection.java#L119-L129
train
krummas/DrizzleJDBC
src/main/java/org/drizzle/jdbc/DrizzleConnection.java
DrizzleConnection.getAutoCommit
public boolean getAutoCommit() throws SQLException { Statement stmt = createStatement(); ResultSet rs = stmt.executeQuery("select @@autocommit"); rs.next(); boolean autocommit = rs.getBoolean(1); rs.close(); stmt.close(); return autocommit; }
java
public boolean getAutoCommit() throws SQLException { Statement stmt = createStatement(); ResultSet rs = stmt.executeQuery("select @@autocommit"); rs.next(); boolean autocommit = rs.getBoolean(1); rs.close(); stmt.close(); return autocommit; }
[ "public", "boolean", "getAutoCommit", "(", ")", "throws", "SQLException", "{", "Statement", "stmt", "=", "createStatement", "(", ")", ";", "ResultSet", "rs", "=", "stmt", ".", "executeQuery", "(", "\"select @@autocommit\"", ")", ";", "rs", ".", "next", "(", ...
returns true if statements on this connection are auto commited. @return true if auto commit is on. @throws SQLException
[ "returns", "true", "if", "statements", "on", "this", "connection", "are", "auto", "commited", "." ]
716f31fd71f3cc289edf69844d8117deb86d98d6
https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/DrizzleConnection.java#L178-L186
train
krummas/DrizzleJDBC
src/main/java/org/drizzle/jdbc/DrizzleConnection.java
DrizzleConnection.close
public void close() throws SQLException { if (isClosed()) return; try { this.timeoutExecutor.shutdown(); protocol.close(); } catch (QueryException e) { throw SQLExceptionMapper.get(e); } }
java
public void close() throws SQLException { if (isClosed()) return; try { this.timeoutExecutor.shutdown(); protocol.close(); } catch (QueryException e) { throw SQLExceptionMapper.get(e); } }
[ "public", "void", "close", "(", ")", "throws", "SQLException", "{", "if", "(", "isClosed", "(", ")", ")", "return", ";", "try", "{", "this", ".", "timeoutExecutor", ".", "shutdown", "(", ")", ";", "protocol", ".", "close", "(", ")", ";", "}", "catch"...
close the connection. @throws SQLException if there is a problem talking to the server.
[ "close", "the", "connection", "." ]
716f31fd71f3cc289edf69844d8117deb86d98d6
https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/DrizzleConnection.java#L228-L238
train
krummas/DrizzleJDBC
src/main/java/org/drizzle/jdbc/DrizzleConnection.java
DrizzleConnection.getMetaData
public DatabaseMetaData getMetaData() throws SQLException { return new CommonDatabaseMetaData.Builder(protocol.getDatabaseType(), this). url("jdbc:drizzle://" + protocol.getHost() + ":" + protocol.getPort() + "/" + protocol.getDatabase()). username(protocol.getUsername()). version(protocol.getServerVersion()). databaseProductName(protocol.getDatabaseType().getDatabaseName()). build(); }
java
public DatabaseMetaData getMetaData() throws SQLException { return new CommonDatabaseMetaData.Builder(protocol.getDatabaseType(), this). url("jdbc:drizzle://" + protocol.getHost() + ":" + protocol.getPort() + "/" + protocol.getDatabase()). username(protocol.getUsername()). version(protocol.getServerVersion()). databaseProductName(protocol.getDatabaseType().getDatabaseName()). build(); }
[ "public", "DatabaseMetaData", "getMetaData", "(", ")", "throws", "SQLException", "{", "return", "new", "CommonDatabaseMetaData", ".", "Builder", "(", "protocol", ".", "getDatabaseType", "(", ")", ",", "this", ")", ".", "url", "(", "\"jdbc:drizzle://\"", "+", "pr...
returns the meta data about the database. @return meta data about the db. @throws SQLException if there is a problem creating the meta data.
[ "returns", "the", "meta", "data", "about", "the", "database", "." ]
716f31fd71f3cc289edf69844d8117deb86d98d6
https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/DrizzleConnection.java#L256-L265
train
krummas/DrizzleJDBC
src/main/java/org/drizzle/jdbc/DrizzleConnection.java
DrizzleConnection.startBinlogDump
public List<RawPacket> startBinlogDump(final int position, final String logfile) throws SQLException { try { return this.protocol.startBinlogDump(position, logfile); } catch (BinlogDumpException e) { throw SQLExceptionMapper.getSQLException("Could not dump binlog", e); } }
java
public List<RawPacket> startBinlogDump(final int position, final String logfile) throws SQLException { try { return this.protocol.startBinlogDump(position, logfile); } catch (BinlogDumpException e) { throw SQLExceptionMapper.getSQLException("Could not dump binlog", e); } }
[ "public", "List", "<", "RawPacket", ">", "startBinlogDump", "(", "final", "int", "position", ",", "final", "String", "logfile", ")", "throws", "SQLException", "{", "try", "{", "return", "this", ".", "protocol", ".", "startBinlogDump", "(", "position", ",", "...
returns a list of binlog entries. @param position the position to start at @param logfile the log file to use @return a list of rawpackets from the server @throws SQLException if there is a problem talking to the server.
[ "returns", "a", "list", "of", "binlog", "entries", "." ]
716f31fd71f3cc289edf69844d8117deb86d98d6
https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/DrizzleConnection.java#L1259-L1265
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/windows/WindowsProcessFaxClientSpi.java
WindowsProcessFaxClientSpi.addCommandLineArgument
protected void addCommandLineArgument(StringBuilder buffer,String argument,String value) { if((value!=null)&&(value.length()>0)) { buffer.append(argument); buffer.append(Fax4jExeConstants.SPACE_STR); buffer.append(Fax4jExeConstants.VALUE_WRAPPER); buffer.append(value); buffer.append(Fax4jExeConstants.VALUE_WRAPPER); buffer.append(Fax4jExeConstants.SPACE_STR); } }
java
protected void addCommandLineArgument(StringBuilder buffer,String argument,String value) { if((value!=null)&&(value.length()>0)) { buffer.append(argument); buffer.append(Fax4jExeConstants.SPACE_STR); buffer.append(Fax4jExeConstants.VALUE_WRAPPER); buffer.append(value); buffer.append(Fax4jExeConstants.VALUE_WRAPPER); buffer.append(Fax4jExeConstants.SPACE_STR); } }
[ "protected", "void", "addCommandLineArgument", "(", "StringBuilder", "buffer", ",", "String", "argument", ",", "String", "value", ")", "{", "if", "(", "(", "value", "!=", "null", ")", "&&", "(", "value", ".", "length", "(", ")", ">", "0", ")", ")", "{"...
This function adds the given command line argument to the buffer. @param buffer The buffer @param argument The argument @param value The argument value
[ "This", "function", "adds", "the", "given", "command", "line", "argument", "to", "the", "buffer", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/windows/WindowsProcessFaxClientSpi.java#L299-L310
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/windows/WindowsProcessFaxClientSpi.java
WindowsProcessFaxClientSpi.createProcessCommand
protected String createProcessCommand(String commandArguments) { //create command StringBuilder buffer=new StringBuilder(500); buffer.append("\""); buffer.append(this.fax4jExecutableFileLocation); buffer.append("\""); buffer.append(Fax4jExeConstants.SPACE_STR); buffer.append(commandArguments); String command=buffer.toString(); return command; }
java
protected String createProcessCommand(String commandArguments) { //create command StringBuilder buffer=new StringBuilder(500); buffer.append("\""); buffer.append(this.fax4jExecutableFileLocation); buffer.append("\""); buffer.append(Fax4jExeConstants.SPACE_STR); buffer.append(commandArguments); String command=buffer.toString(); return command; }
[ "protected", "String", "createProcessCommand", "(", "String", "commandArguments", ")", "{", "//create command", "StringBuilder", "buffer", "=", "new", "StringBuilder", "(", "500", ")", ";", "buffer", ".", "append", "(", "\"\\\"\"", ")", ";", "buffer", ".", "appe...
This function creates and returns the fax4j.exe command. @param commandArguments The command line arguments @return The fax4j.exe command
[ "This", "function", "creates", "and", "returns", "the", "fax4j", ".", "exe", "command", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/windows/WindowsProcessFaxClientSpi.java#L319-L331
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/windows/WindowsProcessFaxClientSpi.java
WindowsProcessFaxClientSpi.createProcessCommandArgumentsForSubmitFaxJob
protected String createProcessCommandArgumentsForSubmitFaxJob(FaxJob faxJob) { //get values from fax job String targetAddress=faxJob.getTargetAddress(); String targetName=faxJob.getTargetName(); String senderName=faxJob.getSenderName(); File file=faxJob.getFile(); String fileName=null; try { fileName=file.getCanonicalPath(); } catch(Exception exception) { throw new FaxException("Unable to extract canonical path from file: "+file,exception); } String documentName=faxJob.getProperty(WindowsFaxClientSpi.FaxJobExtendedPropertyConstants.DOCUMENT_NAME_PROPERTY_KEY.toString(), null); //init buffer StringBuilder buffer=new StringBuilder(); //create command line arguments this.addCommandLineArgument(buffer,Fax4jExeConstants.ACTION_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),Fax4jExeConstants.SUBMIT_ACTION_FAX4J_EXE_COMMAND_LINE_ARGUMENT_VALUE.toString()); this.addCommandLineArgument(buffer,Fax4jExeConstants.SERVER_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),this.faxServerName); this.addCommandLineArgument(buffer,Fax4jExeConstants.TARGET_ADDRESS_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),targetAddress); this.addCommandLineArgument(buffer,Fax4jExeConstants.TARGET_NAME_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),targetName); this.addCommandLineArgument(buffer,Fax4jExeConstants.SENDER_NAME_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),senderName); this.addCommandLineArgument(buffer,Fax4jExeConstants.FILE_NAME_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),fileName); this.addCommandLineArgument(buffer,Fax4jExeConstants.DOCUMENT_NAME_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),documentName); //get text String commandArguments=buffer.toString(); return commandArguments; }
java
protected String createProcessCommandArgumentsForSubmitFaxJob(FaxJob faxJob) { //get values from fax job String targetAddress=faxJob.getTargetAddress(); String targetName=faxJob.getTargetName(); String senderName=faxJob.getSenderName(); File file=faxJob.getFile(); String fileName=null; try { fileName=file.getCanonicalPath(); } catch(Exception exception) { throw new FaxException("Unable to extract canonical path from file: "+file,exception); } String documentName=faxJob.getProperty(WindowsFaxClientSpi.FaxJobExtendedPropertyConstants.DOCUMENT_NAME_PROPERTY_KEY.toString(), null); //init buffer StringBuilder buffer=new StringBuilder(); //create command line arguments this.addCommandLineArgument(buffer,Fax4jExeConstants.ACTION_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),Fax4jExeConstants.SUBMIT_ACTION_FAX4J_EXE_COMMAND_LINE_ARGUMENT_VALUE.toString()); this.addCommandLineArgument(buffer,Fax4jExeConstants.SERVER_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),this.faxServerName); this.addCommandLineArgument(buffer,Fax4jExeConstants.TARGET_ADDRESS_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),targetAddress); this.addCommandLineArgument(buffer,Fax4jExeConstants.TARGET_NAME_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),targetName); this.addCommandLineArgument(buffer,Fax4jExeConstants.SENDER_NAME_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),senderName); this.addCommandLineArgument(buffer,Fax4jExeConstants.FILE_NAME_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),fileName); this.addCommandLineArgument(buffer,Fax4jExeConstants.DOCUMENT_NAME_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),documentName); //get text String commandArguments=buffer.toString(); return commandArguments; }
[ "protected", "String", "createProcessCommandArgumentsForSubmitFaxJob", "(", "FaxJob", "faxJob", ")", "{", "//get values from fax job", "String", "targetAddress", "=", "faxJob", ".", "getTargetAddress", "(", ")", ";", "String", "targetName", "=", "faxJob", ".", "getTarge...
This function creates and returns the command line arguments for the fax4j external exe when running the submit fax job action. @param faxJob The fax job object @return The full command line arguments line
[ "This", "function", "creates", "and", "returns", "the", "command", "line", "arguments", "for", "the", "fax4j", "external", "exe", "when", "running", "the", "submit", "fax", "job", "action", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/windows/WindowsProcessFaxClientSpi.java#L341-L375
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/windows/WindowsProcessFaxClientSpi.java
WindowsProcessFaxClientSpi.createProcessCommandArgumentsForExistingFaxJob
protected String createProcessCommandArgumentsForExistingFaxJob(String faxActionTypeArgument,FaxJob faxJob) { //get values from fax job String faxJobID=faxJob.getID(); //init buffer StringBuilder buffer=new StringBuilder(); //create command line arguments this.addCommandLineArgument(buffer,Fax4jExeConstants.ACTION_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),faxActionTypeArgument); this.addCommandLineArgument(buffer,Fax4jExeConstants.SERVER_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),this.faxServerName); this.addCommandLineArgument(buffer,Fax4jExeConstants.FAX_JOB_ID_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),String.valueOf(faxJobID)); //get text String commandArguments=buffer.toString(); return commandArguments; }
java
protected String createProcessCommandArgumentsForExistingFaxJob(String faxActionTypeArgument,FaxJob faxJob) { //get values from fax job String faxJobID=faxJob.getID(); //init buffer StringBuilder buffer=new StringBuilder(); //create command line arguments this.addCommandLineArgument(buffer,Fax4jExeConstants.ACTION_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),faxActionTypeArgument); this.addCommandLineArgument(buffer,Fax4jExeConstants.SERVER_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),this.faxServerName); this.addCommandLineArgument(buffer,Fax4jExeConstants.FAX_JOB_ID_FAX4J_EXE_COMMAND_LINE_ARGUMENT.toString(),String.valueOf(faxJobID)); //get text String commandArguments=buffer.toString(); return commandArguments; }
[ "protected", "String", "createProcessCommandArgumentsForExistingFaxJob", "(", "String", "faxActionTypeArgument", ",", "FaxJob", "faxJob", ")", "{", "//get values from fax job", "String", "faxJobID", "=", "faxJob", ".", "getID", "(", ")", ";", "//init buffer", "StringBuild...
This function creates and returns the command line arguments for the fax4j external exe when running an action on an existing fax job. @param faxActionTypeArgument The fax action type argument @param faxJob The fax job object @return The full command line arguments line
[ "This", "function", "creates", "and", "returns", "the", "command", "line", "arguments", "for", "the", "fax4j", "external", "exe", "when", "running", "an", "action", "on", "an", "existing", "fax", "job", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/windows/WindowsProcessFaxClientSpi.java#L387-L404
train
sagiegurari/fax4j
src/main/java/org/fax4j/bridge/AbstractVendorPolicy.java
AbstractVendorPolicy.initialize
public final synchronized void initialize(Object flowOwner) { if(this.initialized) { throw new FaxException("Vendor policy already initialized."); } if(flowOwner==null) { throw new FaxException("Flow owner not provided."); } //set flag this.initialized=true; //get flow owner this.vendorPolicyFlowOwner=flowOwner; //initialize this.initializeImpl(); }
java
public final synchronized void initialize(Object flowOwner) { if(this.initialized) { throw new FaxException("Vendor policy already initialized."); } if(flowOwner==null) { throw new FaxException("Flow owner not provided."); } //set flag this.initialized=true; //get flow owner this.vendorPolicyFlowOwner=flowOwner; //initialize this.initializeImpl(); }
[ "public", "final", "synchronized", "void", "initialize", "(", "Object", "flowOwner", ")", "{", "if", "(", "this", ".", "initialized", ")", "{", "throw", "new", "FaxException", "(", "\"Vendor policy already initialized.\"", ")", ";", "}", "if", "(", "flowOwner", ...
This function initializes the vendor policy. @param flowOwner The flow owner (the servlet, CLI main, ....)
[ "This", "function", "initializes", "the", "vendor", "policy", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/bridge/AbstractVendorPolicy.java#L73-L93
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/phaxio/PhaxioFaxClientSpi.java
PhaxioFaxClientSpi.createHTTPClientConfiguration
@Override protected HTTPClientConfiguration createHTTPClientConfiguration() { CommonHTTPClientConfiguration configuration=new CommonHTTPClientConfiguration(); configuration.setHostName("api.phaxio.com"); configuration.setSSL(true); configuration.setMethod(FaxActionType.SUBMIT_FAX_JOB,HTTPMethod.POST); configuration.setMethod(FaxActionType.CANCEL_FAX_JOB,HTTPMethod.POST); configuration.setMethod(FaxActionType.GET_FAX_JOB_STATUS,HTTPMethod.POST); return configuration; }
java
@Override protected HTTPClientConfiguration createHTTPClientConfiguration() { CommonHTTPClientConfiguration configuration=new CommonHTTPClientConfiguration(); configuration.setHostName("api.phaxio.com"); configuration.setSSL(true); configuration.setMethod(FaxActionType.SUBMIT_FAX_JOB,HTTPMethod.POST); configuration.setMethod(FaxActionType.CANCEL_FAX_JOB,HTTPMethod.POST); configuration.setMethod(FaxActionType.GET_FAX_JOB_STATUS,HTTPMethod.POST); return configuration; }
[ "@", "Override", "protected", "HTTPClientConfiguration", "createHTTPClientConfiguration", "(", ")", "{", "CommonHTTPClientConfiguration", "configuration", "=", "new", "CommonHTTPClientConfiguration", "(", ")", ";", "configuration", ".", "setHostName", "(", "\"api.phaxio.com\"...
This function creates and returns the HTTP configuration object. @return The HTTP configuration object
[ "This", "function", "creates", "and", "returns", "the", "HTTP", "configuration", "object", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/phaxio/PhaxioFaxClientSpi.java#L153-L164
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/AbstractMappingHTTPResponseHandler.java
AbstractMappingHTTPResponseHandler.updateFaxJob
public void updateFaxJob(FaxJob faxJob,HTTPResponse httpResponse,FaxActionType faxActionType) { //get path String path=this.getPathToResponseData(faxActionType); //get fax job ID String id=this.findValue(httpResponse,path); if(id!=null) { faxJob.setID(id); } }
java
public void updateFaxJob(FaxJob faxJob,HTTPResponse httpResponse,FaxActionType faxActionType) { //get path String path=this.getPathToResponseData(faxActionType); //get fax job ID String id=this.findValue(httpResponse,path); if(id!=null) { faxJob.setID(id); } }
[ "public", "void", "updateFaxJob", "(", "FaxJob", "faxJob", ",", "HTTPResponse", "httpResponse", ",", "FaxActionType", "faxActionType", ")", "{", "//get path", "String", "path", "=", "this", ".", "getPathToResponseData", "(", "faxActionType", ")", ";", "//get fax job...
Updates the fax job based on the data from the HTTP response data. @param faxJob The fax job object @param httpResponse The HTTP response @param faxActionType The fax action type
[ "Updates", "the", "fax", "job", "based", "on", "the", "data", "from", "the", "HTTP", "response", "data", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/AbstractMappingHTTPResponseHandler.java#L172-L184
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/AbstractMappingHTTPResponseHandler.java
AbstractMappingHTTPResponseHandler.getFaxJobStatus
public FaxJobStatus getFaxJobStatus(HTTPResponse httpResponse) { //get path String path=this.getPathToResponseData(FaxActionType.GET_FAX_JOB_STATUS); //get fax job status string String faxJobStatusStr=this.findValue(httpResponse,path); FaxJobStatus faxJobStatus=FaxJobStatus.UNKNOWN; if(faxJobStatusStr!=null) { faxJobStatus=this.getFaxJobStatusFromStatusString(faxJobStatusStr); if(faxJobStatus==null) { faxJobStatus=FaxJobStatus.UNKNOWN; } } return faxJobStatus; }
java
public FaxJobStatus getFaxJobStatus(HTTPResponse httpResponse) { //get path String path=this.getPathToResponseData(FaxActionType.GET_FAX_JOB_STATUS); //get fax job status string String faxJobStatusStr=this.findValue(httpResponse,path); FaxJobStatus faxJobStatus=FaxJobStatus.UNKNOWN; if(faxJobStatusStr!=null) { faxJobStatus=this.getFaxJobStatusFromStatusString(faxJobStatusStr); if(faxJobStatus==null) { faxJobStatus=FaxJobStatus.UNKNOWN; } } return faxJobStatus; }
[ "public", "FaxJobStatus", "getFaxJobStatus", "(", "HTTPResponse", "httpResponse", ")", "{", "//get path", "String", "path", "=", "this", ".", "getPathToResponseData", "(", "FaxActionType", ".", "GET_FAX_JOB_STATUS", ")", ";", "//get fax job status string", "String", "fa...
This function extracts the fax job status from the HTTP response data. @param httpResponse The HTTP response @return The fax job status
[ "This", "function", "extracts", "the", "fax", "job", "status", "from", "the", "HTTP", "response", "data", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/AbstractMappingHTTPResponseHandler.java#L193-L212
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/vbs/VBSProcessOutputValidator.java
VBSProcessOutputValidator.getVBSFailedLineErrorMessage
protected String getVBSFailedLineErrorMessage(String errorPut) { String message=""; if(errorPut!=null) { String prefix=".vbs("; int start=errorPut.indexOf(prefix); if(start!=-1) { start=start+prefix.length(); int end=errorPut.indexOf(", ",start-1); if(end!=-1) { String lineNumberStr=errorPut.substring(start,end); if(lineNumberStr.length()>0) { int lineNumber=-1; try { lineNumber=Integer.parseInt(lineNumberStr); } catch(NumberFormatException exception) { //ignore } if(lineNumber>=1) { message=" error found at line "+lineNumber+", "; } } } } } return message; }
java
protected String getVBSFailedLineErrorMessage(String errorPut) { String message=""; if(errorPut!=null) { String prefix=".vbs("; int start=errorPut.indexOf(prefix); if(start!=-1) { start=start+prefix.length(); int end=errorPut.indexOf(", ",start-1); if(end!=-1) { String lineNumberStr=errorPut.substring(start,end); if(lineNumberStr.length()>0) { int lineNumber=-1; try { lineNumber=Integer.parseInt(lineNumberStr); } catch(NumberFormatException exception) { //ignore } if(lineNumber>=1) { message=" error found at line "+lineNumber+", "; } } } } } return message; }
[ "protected", "String", "getVBSFailedLineErrorMessage", "(", "String", "errorPut", ")", "{", "String", "message", "=", "\"\"", ";", "if", "(", "errorPut", "!=", "null", ")", "{", "String", "prefix", "=", "\".vbs(\"", ";", "int", "start", "=", "errorPut", ".",...
This function returns the VBS error line for the exception message. @param errorPut The error put @return The message
[ "This", "function", "returns", "the", "VBS", "error", "line", "for", "the", "exception", "message", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/vbs/VBSProcessOutputValidator.java#L38-L74
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/LogFaxClientSpiInterceptor.java
LogFaxClientSpiInterceptor.logEvent
protected void logEvent(FaxClientSpiProxyEventType eventType,Method method,Object[] arguments,Object output,Throwable throwable) { //init log data int amount=3; int argumentsAmount=0; if(arguments!=null) { argumentsAmount=arguments.length; } if(eventType==FaxClientSpiProxyEventType.POST_EVENT_TYPE) { amount=amount+2; } Object[] logData=new Object[amount+argumentsAmount]; //set log data values switch(eventType) { case PRE_EVENT_TYPE: logData[0]="Invoking "; break; case POST_EVENT_TYPE: logData[0]="Invoked "; break; case ERROR_EVENT_TYPE: logData[0]="Error while invoking "; break; } logData[1]=method.getName(); if(argumentsAmount>0) { logData[2]=" with data: "; System.arraycopy(arguments,0,logData,3,argumentsAmount); } else { logData[2]=""; } if(eventType==FaxClientSpiProxyEventType.POST_EVENT_TYPE) { logData[3+argumentsAmount]="\nOutput: "; logData[4+argumentsAmount]=output; } //get logger Logger logger=this.getLogger(); //log event switch(eventType) { case PRE_EVENT_TYPE: case POST_EVENT_TYPE: logger.logDebug(logData,throwable); break; case ERROR_EVENT_TYPE: logger.logError(logData,throwable); break; } }
java
protected void logEvent(FaxClientSpiProxyEventType eventType,Method method,Object[] arguments,Object output,Throwable throwable) { //init log data int amount=3; int argumentsAmount=0; if(arguments!=null) { argumentsAmount=arguments.length; } if(eventType==FaxClientSpiProxyEventType.POST_EVENT_TYPE) { amount=amount+2; } Object[] logData=new Object[amount+argumentsAmount]; //set log data values switch(eventType) { case PRE_EVENT_TYPE: logData[0]="Invoking "; break; case POST_EVENT_TYPE: logData[0]="Invoked "; break; case ERROR_EVENT_TYPE: logData[0]="Error while invoking "; break; } logData[1]=method.getName(); if(argumentsAmount>0) { logData[2]=" with data: "; System.arraycopy(arguments,0,logData,3,argumentsAmount); } else { logData[2]=""; } if(eventType==FaxClientSpiProxyEventType.POST_EVENT_TYPE) { logData[3+argumentsAmount]="\nOutput: "; logData[4+argumentsAmount]=output; } //get logger Logger logger=this.getLogger(); //log event switch(eventType) { case PRE_EVENT_TYPE: case POST_EVENT_TYPE: logger.logDebug(logData,throwable); break; case ERROR_EVENT_TYPE: logger.logError(logData,throwable); break; } }
[ "protected", "void", "logEvent", "(", "FaxClientSpiProxyEventType", "eventType", ",", "Method", "method", ",", "Object", "[", "]", "arguments", ",", "Object", "output", ",", "Throwable", "throwable", ")", "{", "//init log data", "int", "amount", "=", "3", ";", ...
This function logs the event. @param eventType The event type @param method The method invoked @param arguments The method arguments @param output The method output @param throwable The throwable while invoking the method
[ "This", "function", "logs", "the", "event", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/LogFaxClientSpiInterceptor.java#L90-L148
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/LogFaxClientSpiInterceptor.java
LogFaxClientSpiInterceptor.preMethodInvocation
public final void preMethodInvocation(Method method,Object[] arguments) { this.logEvent(FaxClientSpiProxyEventType.PRE_EVENT_TYPE,method,arguments,null,null); }
java
public final void preMethodInvocation(Method method,Object[] arguments) { this.logEvent(FaxClientSpiProxyEventType.PRE_EVENT_TYPE,method,arguments,null,null); }
[ "public", "final", "void", "preMethodInvocation", "(", "Method", "method", ",", "Object", "[", "]", "arguments", ")", "{", "this", ".", "logEvent", "(", "FaxClientSpiProxyEventType", ".", "PRE_EVENT_TYPE", ",", "method", ",", "arguments", ",", "null", ",", "nu...
This function is invoked by the fax client SPI proxy before invoking the method in the fax client SPI itself. @param method The method invoked @param arguments The method arguments
[ "This", "function", "is", "invoked", "by", "the", "fax", "client", "SPI", "proxy", "before", "invoking", "the", "method", "in", "the", "fax", "client", "SPI", "itself", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/LogFaxClientSpiInterceptor.java#L159-L162
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/LogFaxClientSpiInterceptor.java
LogFaxClientSpiInterceptor.postMethodInvocation
public final void postMethodInvocation(Method method,Object[] arguments,Object output) { this.logEvent(FaxClientSpiProxyEventType.POST_EVENT_TYPE,method,arguments,output,null); }
java
public final void postMethodInvocation(Method method,Object[] arguments,Object output) { this.logEvent(FaxClientSpiProxyEventType.POST_EVENT_TYPE,method,arguments,output,null); }
[ "public", "final", "void", "postMethodInvocation", "(", "Method", "method", ",", "Object", "[", "]", "arguments", ",", "Object", "output", ")", "{", "this", ".", "logEvent", "(", "FaxClientSpiProxyEventType", ".", "POST_EVENT_TYPE", ",", "method", ",", "argument...
This function is invoked by the fax client SPI proxy after invoking the method in the fax client SPI itself. @param method The method invoked @param arguments The method arguments @param output The method output
[ "This", "function", "is", "invoked", "by", "the", "fax", "client", "SPI", "proxy", "after", "invoking", "the", "method", "in", "the", "fax", "client", "SPI", "itself", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/LogFaxClientSpiInterceptor.java#L175-L178
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/LogFaxClientSpiInterceptor.java
LogFaxClientSpiInterceptor.onMethodInvocationError
public final void onMethodInvocationError(Method method,Object[] arguments,Throwable throwable) { this.logEvent(FaxClientSpiProxyEventType.ERROR_EVENT_TYPE,method,arguments,null,throwable); }
java
public final void onMethodInvocationError(Method method,Object[] arguments,Throwable throwable) { this.logEvent(FaxClientSpiProxyEventType.ERROR_EVENT_TYPE,method,arguments,null,throwable); }
[ "public", "final", "void", "onMethodInvocationError", "(", "Method", "method", ",", "Object", "[", "]", "arguments", ",", "Throwable", "throwable", ")", "{", "this", ".", "logEvent", "(", "FaxClientSpiProxyEventType", ".", "ERROR_EVENT_TYPE", ",", "method", ",", ...
This function is invoked by the fax client SPI proxy in of an error while invoking the method in the fax client SPI itself. @param method The method invoked @param arguments The method arguments @param throwable The throwable while invoking the method
[ "This", "function", "is", "invoked", "by", "the", "fax", "client", "SPI", "proxy", "in", "of", "an", "error", "while", "invoking", "the", "method", "in", "the", "fax", "client", "SPI", "itself", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/LogFaxClientSpiInterceptor.java#L191-L194
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/hylafax/HylaFaxJob.java
HylaFaxJob.getPriority
public FaxJobPriority getPriority() { int priority=Job.PRIORITY_NORMAL; try { priority=this.JOB.getPriority(); } catch(Exception exception) { throw new FaxException("Error while extracting job priority.",exception); } FaxJobPriority faxJobPriority=null; switch(priority) { case Job.PRIORITY_HIGH: faxJobPriority=FaxJobPriority.HIGH_PRIORITY; break; default: faxJobPriority=FaxJobPriority.MEDIUM_PRIORITY; break; } return faxJobPriority; }
java
public FaxJobPriority getPriority() { int priority=Job.PRIORITY_NORMAL; try { priority=this.JOB.getPriority(); } catch(Exception exception) { throw new FaxException("Error while extracting job priority.",exception); } FaxJobPriority faxJobPriority=null; switch(priority) { case Job.PRIORITY_HIGH: faxJobPriority=FaxJobPriority.HIGH_PRIORITY; break; default: faxJobPriority=FaxJobPriority.MEDIUM_PRIORITY; break; } return faxJobPriority; }
[ "public", "FaxJobPriority", "getPriority", "(", ")", "{", "int", "priority", "=", "Job", ".", "PRIORITY_NORMAL", ";", "try", "{", "priority", "=", "this", ".", "JOB", ".", "getPriority", "(", ")", ";", "}", "catch", "(", "Exception", "exception", ")", "{...
This function returns the priority. @return The priority
[ "This", "function", "returns", "the", "priority", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/hylafax/HylaFaxJob.java#L110-L134
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/hylafax/HylaFaxJob.java
HylaFaxJob.setPriority
public void setPriority(FaxJobPriority priority) { try { if(priority==FaxJobPriority.HIGH_PRIORITY) { this.JOB.setPriority(Job.PRIORITY_HIGH); } else { this.JOB.setPriority(Job.PRIORITY_NORMAL); } } catch(Exception exception) { throw new FaxException("Error while setting job priority.",exception); } }
java
public void setPriority(FaxJobPriority priority) { try { if(priority==FaxJobPriority.HIGH_PRIORITY) { this.JOB.setPriority(Job.PRIORITY_HIGH); } else { this.JOB.setPriority(Job.PRIORITY_NORMAL); } } catch(Exception exception) { throw new FaxException("Error while setting job priority.",exception); } }
[ "public", "void", "setPriority", "(", "FaxJobPriority", "priority", ")", "{", "try", "{", "if", "(", "priority", "==", "FaxJobPriority", ".", "HIGH_PRIORITY", ")", "{", "this", ".", "JOB", ".", "setPriority", "(", "Job", ".", "PRIORITY_HIGH", ")", ";", "}"...
This function sets the priority. @param priority The priority
[ "This", "function", "sets", "the", "priority", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/hylafax/HylaFaxJob.java#L142-L159
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/hylafax/HylaFaxJob.java
HylaFaxJob.getTargetAddress
public String getTargetAddress() { String value=null; try { value=this.JOB.getDialstring(); } catch(Exception exception) { throw new FaxException("Error while extracting job target address.",exception); } return value; }
java
public String getTargetAddress() { String value=null; try { value=this.JOB.getDialstring(); } catch(Exception exception) { throw new FaxException("Error while extracting job target address.",exception); } return value; }
[ "public", "String", "getTargetAddress", "(", ")", "{", "String", "value", "=", "null", ";", "try", "{", "value", "=", "this", ".", "JOB", ".", "getDialstring", "(", ")", ";", "}", "catch", "(", "Exception", "exception", ")", "{", "throw", "new", "FaxEx...
This function returns the fax job target address. @return The fax job target address
[ "This", "function", "returns", "the", "fax", "job", "target", "address", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/hylafax/HylaFaxJob.java#L166-L179
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/hylafax/HylaFaxJob.java
HylaFaxJob.setTargetAddress
public void setTargetAddress(String targetAddress) { try { this.JOB.setDialstring(targetAddress); } catch(Exception exception) { throw new FaxException("Error while setting job target address.",exception); } }
java
public void setTargetAddress(String targetAddress) { try { this.JOB.setDialstring(targetAddress); } catch(Exception exception) { throw new FaxException("Error while setting job target address.",exception); } }
[ "public", "void", "setTargetAddress", "(", "String", "targetAddress", ")", "{", "try", "{", "this", ".", "JOB", ".", "setDialstring", "(", "targetAddress", ")", ";", "}", "catch", "(", "Exception", "exception", ")", "{", "throw", "new", "FaxException", "(", ...
This function sets the fax job target address. @param targetAddress The fax job target address
[ "This", "function", "sets", "the", "fax", "job", "target", "address", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/hylafax/HylaFaxJob.java#L187-L197
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/hylafax/HylaFaxJob.java
HylaFaxJob.getSenderName
public String getSenderName() { String value=null; try { value=this.JOB.getFromUser(); } catch(Exception exception) { throw new FaxException("Error while extracting job sender name.",exception); } return value; }
java
public String getSenderName() { String value=null; try { value=this.JOB.getFromUser(); } catch(Exception exception) { throw new FaxException("Error while extracting job sender name.",exception); } return value; }
[ "public", "String", "getSenderName", "(", ")", "{", "String", "value", "=", "null", ";", "try", "{", "value", "=", "this", ".", "JOB", ".", "getFromUser", "(", ")", ";", "}", "catch", "(", "Exception", "exception", ")", "{", "throw", "new", "FaxExcepti...
This function returns the fax job sender name. @return The fax job sender name
[ "This", "function", "returns", "the", "fax", "job", "sender", "name", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/hylafax/HylaFaxJob.java#L225-L238
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/hylafax/HylaFaxJob.java
HylaFaxJob.setSenderName
public void setSenderName(String senderName) { try { this.JOB.setFromUser(senderName); } catch(Exception exception) { throw new FaxException("Error while setting job sender name.",exception); } }
java
public void setSenderName(String senderName) { try { this.JOB.setFromUser(senderName); } catch(Exception exception) { throw new FaxException("Error while setting job sender name.",exception); } }
[ "public", "void", "setSenderName", "(", "String", "senderName", ")", "{", "try", "{", "this", ".", "JOB", ".", "setFromUser", "(", "senderName", ")", ";", "}", "catch", "(", "Exception", "exception", ")", "{", "throw", "new", "FaxException", "(", "\"Error ...
This function sets the fax job sender name. @param senderName The fax job sender name
[ "This", "function", "sets", "the", "fax", "job", "sender", "name", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/hylafax/HylaFaxJob.java#L246-L256
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/hylafax/HylaFaxJob.java
HylaFaxJob.setProperty
public void setProperty(String key,String value) { try { this.JOB.setProperty(key,value); } catch(Exception exception) { throw new FaxException("Error while setting job property.",exception); } }
java
public void setProperty(String key,String value) { try { this.JOB.setProperty(key,value); } catch(Exception exception) { throw new FaxException("Error while setting job property.",exception); } }
[ "public", "void", "setProperty", "(", "String", "key", ",", "String", "value", ")", "{", "try", "{", "this", ".", "JOB", ".", "setProperty", "(", "key", ",", "value", ")", ";", "}", "catch", "(", "Exception", "exception", ")", "{", "throw", "new", "F...
This function sets the fax job property. @param key The property key @param value The property value
[ "This", "function", "sets", "the", "fax", "job", "property", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/hylafax/HylaFaxJob.java#L308-L318
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/TemplateFaxJob2HTTPRequestConverter.java
TemplateFaxJob2HTTPRequestConverter.formatHTTPResource
protected String formatHTTPResource(HTTPFaxClientSpi faxClientSpi,FaxActionType faxActionType,FaxJob faxJob) { //get resource String resourceTemplate=faxClientSpi.getHTTPResource(faxActionType); //format resource String resource=SpiUtil.formatTemplate(resourceTemplate,faxJob,SpiUtil.URL_ENCODER,false,false); return resource; }
java
protected String formatHTTPResource(HTTPFaxClientSpi faxClientSpi,FaxActionType faxActionType,FaxJob faxJob) { //get resource String resourceTemplate=faxClientSpi.getHTTPResource(faxActionType); //format resource String resource=SpiUtil.formatTemplate(resourceTemplate,faxJob,SpiUtil.URL_ENCODER,false,false); return resource; }
[ "protected", "String", "formatHTTPResource", "(", "HTTPFaxClientSpi", "faxClientSpi", ",", "FaxActionType", "faxActionType", ",", "FaxJob", "faxJob", ")", "{", "//get resource", "String", "resourceTemplate", "=", "faxClientSpi", ".", "getHTTPResource", "(", "faxActionType...
This function formats the HTTP resource. @param faxClientSpi The HTTP fax client SPI @param faxActionType The fax action type @param faxJob The fax job object @return The formatted HTTP resource
[ "This", "function", "formats", "the", "HTTP", "resource", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/TemplateFaxJob2HTTPRequestConverter.java#L308-L317
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/TemplateFaxJob2HTTPRequestConverter.java
TemplateFaxJob2HTTPRequestConverter.formatHTTPURLParameters
protected String formatHTTPURLParameters(HTTPFaxClientSpi faxClientSpi,FaxJob faxJob) { //get URL parameters String urlParametersTemplate=faxClientSpi.getHTTPURLParameters(); //format URL parameters String urlParameters=SpiUtil.formatTemplate(urlParametersTemplate,faxJob,SpiUtil.URL_ENCODER,false,false); return urlParameters; }
java
protected String formatHTTPURLParameters(HTTPFaxClientSpi faxClientSpi,FaxJob faxJob) { //get URL parameters String urlParametersTemplate=faxClientSpi.getHTTPURLParameters(); //format URL parameters String urlParameters=SpiUtil.formatTemplate(urlParametersTemplate,faxJob,SpiUtil.URL_ENCODER,false,false); return urlParameters; }
[ "protected", "String", "formatHTTPURLParameters", "(", "HTTPFaxClientSpi", "faxClientSpi", ",", "FaxJob", "faxJob", ")", "{", "//get URL parameters", "String", "urlParametersTemplate", "=", "faxClientSpi", ".", "getHTTPURLParameters", "(", ")", ";", "//format URL parameters...
This function formats the HTTP URL parameters. @param faxClientSpi The HTTP fax client SPI @param faxJob The fax job object @return The formatted HTTP URL parameters
[ "This", "function", "formats", "the", "HTTP", "URL", "parameters", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/TemplateFaxJob2HTTPRequestConverter.java#L328-L337
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/LibraryConfigurationLoader.java
LibraryConfigurationLoader.loadProperties
private static void loadProperties(Properties properties,InputStream inputStream,boolean internal) { try { properties.load(inputStream); LibraryConfigurationLoader.closeResource(inputStream); } catch(Exception exception) { LibraryConfigurationLoader.closeResource(inputStream); String prefix="External"; if(internal) { prefix="Internal"; } throw new FaxException(prefix+" "+LibraryConfigurationLoader.CONFIGURATION_FILE_NAME+" not found.",exception); } }
java
private static void loadProperties(Properties properties,InputStream inputStream,boolean internal) { try { properties.load(inputStream); LibraryConfigurationLoader.closeResource(inputStream); } catch(Exception exception) { LibraryConfigurationLoader.closeResource(inputStream); String prefix="External"; if(internal) { prefix="Internal"; } throw new FaxException(prefix+" "+LibraryConfigurationLoader.CONFIGURATION_FILE_NAME+" not found.",exception); } }
[ "private", "static", "void", "loadProperties", "(", "Properties", "properties", ",", "InputStream", "inputStream", ",", "boolean", "internal", ")", "{", "try", "{", "properties", ".", "load", "(", "inputStream", ")", ";", "LibraryConfigurationLoader", ".", "closeR...
This function loads the properties from the input stream to the provided properties object. @param properties The target properties object @param inputStream The input stream to the configuration file @param internal True internal, else external
[ "This", "function", "loads", "the", "properties", "from", "the", "input", "stream", "to", "the", "provided", "properties", "object", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/LibraryConfigurationLoader.java#L67-L84
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/LibraryConfigurationLoader.java
LibraryConfigurationLoader.readInternalConfiguration
public static Properties readInternalConfiguration() { //init properties Properties properties=new Properties(); //get class loader ClassLoader classLoader=ReflectionHelper.getThreadContextClassLoader(); //load internal properties InputStream inputStream=classLoader.getResourceAsStream("org/fax4j/"+LibraryConfigurationLoader.CONFIGURATION_FILE_NAME); LibraryConfigurationLoader.loadProperties(properties,inputStream,true); return properties; }
java
public static Properties readInternalConfiguration() { //init properties Properties properties=new Properties(); //get class loader ClassLoader classLoader=ReflectionHelper.getThreadContextClassLoader(); //load internal properties InputStream inputStream=classLoader.getResourceAsStream("org/fax4j/"+LibraryConfigurationLoader.CONFIGURATION_FILE_NAME); LibraryConfigurationLoader.loadProperties(properties,inputStream,true); return properties; }
[ "public", "static", "Properties", "readInternalConfiguration", "(", ")", "{", "//init properties", "Properties", "properties", "=", "new", "Properties", "(", ")", ";", "//get class loader", "ClassLoader", "classLoader", "=", "ReflectionHelper", ".", "getThreadContextClass...
This function reads and returns the internal fax4j properties. @return The fax4j.properties data
[ "This", "function", "reads", "and", "returns", "the", "internal", "fax4j", "properties", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/LibraryConfigurationLoader.java#L91-L104
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/LibraryConfigurationLoader.java
LibraryConfigurationLoader.readInternalAndExternalConfiguration
public static Properties readInternalAndExternalConfiguration() { //read properties Properties properties=LibraryConfigurationLoader.readInternalConfiguration(); ClassLoader classLoader=ReflectionHelper.getThreadContextClassLoader(); InputStream inputStream=classLoader.getResourceAsStream(LibraryConfigurationLoader.CONFIGURATION_FILE_NAME); if(inputStream!=null) { LibraryConfigurationLoader.loadProperties(properties,inputStream,false); } return properties; }
java
public static Properties readInternalAndExternalConfiguration() { //read properties Properties properties=LibraryConfigurationLoader.readInternalConfiguration(); ClassLoader classLoader=ReflectionHelper.getThreadContextClassLoader(); InputStream inputStream=classLoader.getResourceAsStream(LibraryConfigurationLoader.CONFIGURATION_FILE_NAME); if(inputStream!=null) { LibraryConfigurationLoader.loadProperties(properties,inputStream,false); } return properties; }
[ "public", "static", "Properties", "readInternalAndExternalConfiguration", "(", ")", "{", "//read properties", "Properties", "properties", "=", "LibraryConfigurationLoader", ".", "readInternalConfiguration", "(", ")", ";", "ClassLoader", "classLoader", "=", "ReflectionHelper",...
This function reads and returns the internal and external fax4j properties. @return The internal and external fax4j.properties data
[ "This", "function", "reads", "and", "returns", "the", "internal", "and", "external", "fax4j", "properties", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/LibraryConfigurationLoader.java#L111-L125
train
hivemq/hivemq-spi
src/main/java/com/hivemq/spi/topic/MqttTopicPermission.java
MqttTopicPermission.implies
public boolean implies(final MqttTopicPermission other) { if (other == null) { return false; } return implies(other.getTopic(), other.splitTopic, other.getQos(), other.getActivity()); }
java
public boolean implies(final MqttTopicPermission other) { if (other == null) { return false; } return implies(other.getTopic(), other.splitTopic, other.getQos(), other.getActivity()); }
[ "public", "boolean", "implies", "(", "final", "MqttTopicPermission", "other", ")", "{", "if", "(", "other", "==", "null", ")", "{", "return", "false", ";", "}", "return", "implies", "(", "other", ".", "getTopic", "(", ")", ",", "other", ".", "splitTopic"...
Checks the MqttTopicPermission implies a given MqttTopicPermission @param other the MqttTopicPermission which should be checked if it is implied by the current MqttTopicPermission @return <code>true</code> if the given MqttTopicPermission is implied
[ "Checks", "the", "MqttTopicPermission", "implies", "a", "given", "MqttTopicPermission" ]
55fa89ccb081ad5b6d46eaca02179272148e64ed
https://github.com/hivemq/hivemq-spi/blob/55fa89ccb081ad5b6d46eaca02179272148e64ed/src/main/java/com/hivemq/spi/topic/MqttTopicPermission.java#L227-L234
train
hivemq/hivemq-spi
src/main/java/com/hivemq/spi/topic/MqttTopicPermission.java
MqttTopicPermission.topicImplicity
private boolean topicImplicity(final String topic, final String[] splitTopic) { try { return topicMatcher.matches(stripedTopic, this.splitTopic, nonWildCard, endsWithWildCard, rootWildCard, topic, splitTopic); } catch (InvalidTopicException e) { return false; } }
java
private boolean topicImplicity(final String topic, final String[] splitTopic) { try { return topicMatcher.matches(stripedTopic, this.splitTopic, nonWildCard, endsWithWildCard, rootWildCard, topic, splitTopic); } catch (InvalidTopicException e) { return false; } }
[ "private", "boolean", "topicImplicity", "(", "final", "String", "topic", ",", "final", "String", "[", "]", "splitTopic", ")", "{", "try", "{", "return", "topicMatcher", ".", "matches", "(", "stripedTopic", ",", "this", ".", "splitTopic", ",", "nonWildCard", ...
Checks if the topic implies a given MqttTopicPermissions topic @param topic the topic to check @return <code>true</code> if the given MqttTopicPermissions topic is implied by the current one
[ "Checks", "if", "the", "topic", "implies", "a", "given", "MqttTopicPermissions", "topic" ]
55fa89ccb081ad5b6d46eaca02179272148e64ed
https://github.com/hivemq/hivemq-spi/blob/55fa89ccb081ad5b6d46eaca02179272148e64ed/src/main/java/com/hivemq/spi/topic/MqttTopicPermission.java#L368-L375
train
hivemq/hivemq-spi
src/main/java/com/hivemq/spi/topic/MqttTopicPermission.java
MqttTopicPermission.getQosImplicity
private boolean getQosImplicity(final QOS qos) { if (this.getQos() == QOS.ALL) { return true; } if (qos == QOS.ALL) { return false; } else if (this.getQos() == QOS.ZERO_ONE) { return (qos == QOS.ZERO) || (qos == QOS.ONE) || (qos == QOS.ZERO_ONE); } else if (this.getQos() == QOS.ONE_TWO) { return (qos == QOS.ONE) || (qos == QOS.TWO) || (qos == QOS.ONE_TWO); } else if (this.getQos() == QOS.ZERO_TWO) { return (qos == QOS.ZERO) || (qos == QOS.TWO) || (qos == QOS.ZERO_TWO); } return this.getQos() == qos; }
java
private boolean getQosImplicity(final QOS qos) { if (this.getQos() == QOS.ALL) { return true; } if (qos == QOS.ALL) { return false; } else if (this.getQos() == QOS.ZERO_ONE) { return (qos == QOS.ZERO) || (qos == QOS.ONE) || (qos == QOS.ZERO_ONE); } else if (this.getQos() == QOS.ONE_TWO) { return (qos == QOS.ONE) || (qos == QOS.TWO) || (qos == QOS.ONE_TWO); } else if (this.getQos() == QOS.ZERO_TWO) { return (qos == QOS.ZERO) || (qos == QOS.TWO) || (qos == QOS.ZERO_TWO); } return this.getQos() == qos; }
[ "private", "boolean", "getQosImplicity", "(", "final", "QOS", "qos", ")", "{", "if", "(", "this", ".", "getQos", "(", ")", "==", "QOS", ".", "ALL", ")", "{", "return", "true", ";", "}", "if", "(", "qos", "==", "QOS", ".", "ALL", ")", "{", "return...
Checks if the MqttTopicPermission implies a given QoS @param qos the activity to check @return <code>true</code> if the QoS level implies the given QoS
[ "Checks", "if", "the", "MqttTopicPermission", "implies", "a", "given", "QoS" ]
55fa89ccb081ad5b6d46eaca02179272148e64ed
https://github.com/hivemq/hivemq-spi/blob/55fa89ccb081ad5b6d46eaca02179272148e64ed/src/main/java/com/hivemq/spi/topic/MqttTopicPermission.java#L383-L398
train
hivemq/hivemq-spi
src/main/java/com/hivemq/spi/topic/MqttTopicPermission.java
MqttTopicPermission.getActivityImplicity
private boolean getActivityImplicity(final ACTIVITY activity) { if (this.activity == ACTIVITY.ALL) { return true; } if ((activity == ACTIVITY.SUBSCRIBE) && (this.activity == ACTIVITY.PUBLISH)) { return false; } else if ((activity == ACTIVITY.PUBLISH) && (this.activity == ACTIVITY.SUBSCRIBE)) { return false; } else if (activity == ACTIVITY.ALL && this.getActivity() != ACTIVITY.ALL) { return false; } return true; }
java
private boolean getActivityImplicity(final ACTIVITY activity) { if (this.activity == ACTIVITY.ALL) { return true; } if ((activity == ACTIVITY.SUBSCRIBE) && (this.activity == ACTIVITY.PUBLISH)) { return false; } else if ((activity == ACTIVITY.PUBLISH) && (this.activity == ACTIVITY.SUBSCRIBE)) { return false; } else if (activity == ACTIVITY.ALL && this.getActivity() != ACTIVITY.ALL) { return false; } return true; }
[ "private", "boolean", "getActivityImplicity", "(", "final", "ACTIVITY", "activity", ")", "{", "if", "(", "this", ".", "activity", "==", "ACTIVITY", ".", "ALL", ")", "{", "return", "true", ";", "}", "if", "(", "(", "activity", "==", "ACTIVITY", ".", "SUBS...
Checks if an activity implies another activity @param activity the activity to check @return <code>true</code> if the permission activity imply the other permission activity
[ "Checks", "if", "an", "activity", "implies", "another", "activity" ]
55fa89ccb081ad5b6d46eaca02179272148e64ed
https://github.com/hivemq/hivemq-spi/blob/55fa89ccb081ad5b6d46eaca02179272148e64ed/src/main/java/com/hivemq/spi/topic/MqttTopicPermission.java#L406-L419
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/interfax/InterfaxMailFaxClientSpi.java
InterfaxMailFaxClientSpi.initializeMailTemplates
@Override protected void initializeMailTemplates() { //mail address template this.mailAddressTemplate=FaxClientSpiConfigurationConstants.MAIL_ADDRESS_TEMPLATE_VALUE.toString(); //mail subject template this.mailSubjectTemplate=FaxClientSpiConfigurationConstants.MAIL_SUBJECT_TEMPLATE_VALUE.toString(); }
java
@Override protected void initializeMailTemplates() { //mail address template this.mailAddressTemplate=FaxClientSpiConfigurationConstants.MAIL_ADDRESS_TEMPLATE_VALUE.toString(); //mail subject template this.mailSubjectTemplate=FaxClientSpiConfigurationConstants.MAIL_SUBJECT_TEMPLATE_VALUE.toString(); }
[ "@", "Override", "protected", "void", "initializeMailTemplates", "(", ")", "{", "//mail address template", "this", ".", "mailAddressTemplate", "=", "FaxClientSpiConfigurationConstants", ".", "MAIL_ADDRESS_TEMPLATE_VALUE", ".", "toString", "(", ")", ";", "//mail subject temp...
This function initializes the mail templates.
[ "This", "function", "initializes", "the", "mail", "templates", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/interfax/InterfaxMailFaxClientSpi.java#L154-L162
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/vbs/VBSFaxClientSpi.java
VBSFaxClientSpi.setupSubmitFaxJobInput
protected Object[] setupSubmitFaxJobInput(FaxJob faxJob) { //init list List<Object> inputList=new LinkedList<Object>(); //set fax server information inputList.add(this.faxServerName); //set fax values File file=faxJob.getFile(); inputList.add(file); String documentName=faxJob.getProperty(FaxJobExtendedPropertyConstants.DOCUMENT_NAME_FAX_JOB_PROPERTY_KEY.toString(),null); if((documentName==null)||(documentName.length()==0)) { documentName=file.getName(); } inputList.add(documentName); if(this.useWin2kAPI) { //set target information inputList.add(faxJob.getTargetAddress()); inputList.add(faxJob.getTargetName()); //set sender information inputList.add(faxJob.getSenderName()); inputList.add(faxJob.getSenderFaxNumber()); } else { FaxJobPriority priority=faxJob.getPriority(); String valueStr="fptNORMAL"; if(priority!=null) { switch(priority) { case LOW_PRIORITY: valueStr="fptLOW"; break; case MEDIUM_PRIORITY: valueStr="fptNORMAL"; break; case HIGH_PRIORITY: valueStr="fptHIGH"; break; } } inputList.add(valueStr); //set target information inputList.add(faxJob.getTargetAddress()); inputList.add(faxJob.getTargetName()); //set sender information inputList.add(faxJob.getSenderName()); inputList.add(faxJob.getSenderFaxNumber()); inputList.add(faxJob.getSenderEmail()); } //convert to array int size=inputList.size(); Object[] input=inputList.toArray(new Object[size]); return input; }
java
protected Object[] setupSubmitFaxJobInput(FaxJob faxJob) { //init list List<Object> inputList=new LinkedList<Object>(); //set fax server information inputList.add(this.faxServerName); //set fax values File file=faxJob.getFile(); inputList.add(file); String documentName=faxJob.getProperty(FaxJobExtendedPropertyConstants.DOCUMENT_NAME_FAX_JOB_PROPERTY_KEY.toString(),null); if((documentName==null)||(documentName.length()==0)) { documentName=file.getName(); } inputList.add(documentName); if(this.useWin2kAPI) { //set target information inputList.add(faxJob.getTargetAddress()); inputList.add(faxJob.getTargetName()); //set sender information inputList.add(faxJob.getSenderName()); inputList.add(faxJob.getSenderFaxNumber()); } else { FaxJobPriority priority=faxJob.getPriority(); String valueStr="fptNORMAL"; if(priority!=null) { switch(priority) { case LOW_PRIORITY: valueStr="fptLOW"; break; case MEDIUM_PRIORITY: valueStr="fptNORMAL"; break; case HIGH_PRIORITY: valueStr="fptHIGH"; break; } } inputList.add(valueStr); //set target information inputList.add(faxJob.getTargetAddress()); inputList.add(faxJob.getTargetName()); //set sender information inputList.add(faxJob.getSenderName()); inputList.add(faxJob.getSenderFaxNumber()); inputList.add(faxJob.getSenderEmail()); } //convert to array int size=inputList.size(); Object[] input=inputList.toArray(new Object[size]); return input; }
[ "protected", "Object", "[", "]", "setupSubmitFaxJobInput", "(", "FaxJob", "faxJob", ")", "{", "//init list", "List", "<", "Object", ">", "inputList", "=", "new", "LinkedList", "<", "Object", ">", "(", ")", ";", "//set fax server information", "inputList", ".", ...
This function creates an input array with the needed info to submit a new fax job based on the provided data. @param faxJob The fax job object containing the needed information @return The submit fax job script input
[ "This", "function", "creates", "an", "input", "array", "with", "the", "needed", "info", "to", "submit", "a", "new", "fax", "job", "based", "on", "the", "provided", "data", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/vbs/VBSFaxClientSpi.java#L460-L524
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/vbs/VBSFaxClientSpi.java
VBSFaxClientSpi.formatObject
protected Object formatObject(Object object) { Object formattedObject=object; if(object==null) { formattedObject=""; } else if(object instanceof String) { //get string String string=(String)object; //remove characters string=string.replaceAll("\n",""); string=string.replaceAll("\r",""); string=string.replaceAll("\t",""); string=string.replaceAll("\f",""); string=string.replaceAll("\b",""); string=string.replaceAll("'",""); string=string.replaceAll("\"",""); //get reference formattedObject=string; } else if(object instanceof File) { //get file File file=(File)object; String filePath=null; try { filePath=file.getCanonicalPath(); } catch(IOException exception) { throw new FaxException("Unable to get file path.",exception); } filePath=filePath.replaceAll("\\\\","\\\\\\\\"); //get reference formattedObject=filePath; } return formattedObject; }
java
protected Object formatObject(Object object) { Object formattedObject=object; if(object==null) { formattedObject=""; } else if(object instanceof String) { //get string String string=(String)object; //remove characters string=string.replaceAll("\n",""); string=string.replaceAll("\r",""); string=string.replaceAll("\t",""); string=string.replaceAll("\f",""); string=string.replaceAll("\b",""); string=string.replaceAll("'",""); string=string.replaceAll("\"",""); //get reference formattedObject=string; } else if(object instanceof File) { //get file File file=(File)object; String filePath=null; try { filePath=file.getCanonicalPath(); } catch(IOException exception) { throw new FaxException("Unable to get file path.",exception); } filePath=filePath.replaceAll("\\\\","\\\\\\\\"); //get reference formattedObject=filePath; } return formattedObject; }
[ "protected", "Object", "formatObject", "(", "Object", "object", ")", "{", "Object", "formattedObject", "=", "object", ";", "if", "(", "object", "==", "null", ")", "{", "formattedObject", "=", "\"\"", ";", "}", "else", "if", "(", "object", "instanceof", "St...
This function formats the provided object to enable embedding in VBS code. @param object The object to format @return The formatted object
[ "This", "function", "formats", "the", "provided", "object", "to", "enable", "embedding", "in", "VBS", "code", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/vbs/VBSFaxClientSpi.java#L534-L579
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/vbs/VBSFaxClientSpi.java
VBSFaxClientSpi.invokeExistingFaxJobAction
protected FaxJobStatus invokeExistingFaxJobAction(String scriptName,FaxJob faxJob,FaxActionType faxActionType) { //initialize array Object[] input=new String[2]; //set fax server information input[0]=this.faxServerName; //set fax job ID input[1]=faxJob.getID(); //invoke script return this.invokeScript(faxJob,scriptName,input,faxActionType); }
java
protected FaxJobStatus invokeExistingFaxJobAction(String scriptName,FaxJob faxJob,FaxActionType faxActionType) { //initialize array Object[] input=new String[2]; //set fax server information input[0]=this.faxServerName; //set fax job ID input[1]=faxJob.getID(); //invoke script return this.invokeScript(faxJob,scriptName,input,faxActionType); }
[ "protected", "FaxJobStatus", "invokeExistingFaxJobAction", "(", "String", "scriptName", ",", "FaxJob", "faxJob", ",", "FaxActionType", "faxActionType", ")", "{", "//initialize array", "Object", "[", "]", "input", "=", "new", "String", "[", "2", "]", ";", "//set fa...
Invokes a basic fax action @param scriptName The script name @param faxJob The fax job object containing the needed information @param faxActionType The fax action type @return The fax job status (only for get fax job status action, for others null will be returned)
[ "Invokes", "a", "basic", "fax", "action" ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/vbs/VBSFaxClientSpi.java#L592-L605
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/vbs/VBSFaxClientSpi.java
VBSFaxClientSpi.invokeScript
protected FaxJobStatus invokeScript(FaxJob faxJob,String name,Object[] input,FaxActionType faxActionType) { //generate script String script=this.generateScript(name,input); //invoke script ProcessOutput processOutput=this.invokeScript(script); //validate output this.processOutputValidator.validateProcessOutput(this,processOutput,faxActionType); //handle output FaxJobStatus output=null; switch(faxActionType) { case SUBMIT_FAX_JOB: this.processOutputHandler.updateFaxJob(this,faxJob,processOutput,faxActionType); break; case GET_FAX_JOB_STATUS: output=this.processOutputHandler.getFaxJobStatus(this,processOutput); break; default: //do nothing break; } return output; }
java
protected FaxJobStatus invokeScript(FaxJob faxJob,String name,Object[] input,FaxActionType faxActionType) { //generate script String script=this.generateScript(name,input); //invoke script ProcessOutput processOutput=this.invokeScript(script); //validate output this.processOutputValidator.validateProcessOutput(this,processOutput,faxActionType); //handle output FaxJobStatus output=null; switch(faxActionType) { case SUBMIT_FAX_JOB: this.processOutputHandler.updateFaxJob(this,faxJob,processOutput,faxActionType); break; case GET_FAX_JOB_STATUS: output=this.processOutputHandler.getFaxJobStatus(this,processOutput); break; default: //do nothing break; } return output; }
[ "protected", "FaxJobStatus", "invokeScript", "(", "FaxJob", "faxJob", ",", "String", "name", ",", "Object", "[", "]", "input", ",", "FaxActionType", "faxActionType", ")", "{", "//generate script", "String", "script", "=", "this", ".", "generateScript", "(", "nam...
Invokes the VB script and returns its output. @param faxJob The fax job object containing the needed information @param name The script name @param input The script input @param faxActionType The fax action type @return The fax job status (only for get fax job status action, for others null will be returned)
[ "Invokes", "the", "VB", "script", "and", "returns", "its", "output", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/vbs/VBSFaxClientSpi.java#L620-L647
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/vbs/VBSFaxClientSpi.java
VBSFaxClientSpi.invokeScript
protected ProcessOutput invokeScript(String script) { File file=null; try { //create temporary file file=File.createTempFile("fax4j_",".vbs"); } catch(IOException exception) { throw new FaxException("Unable to create temporary vbscript file.",exception); } file.deleteOnExit(); //generate command string StringBuilder buffer=new StringBuilder(); buffer.append(this.getVBSExePath()); buffer.append(" \""); buffer.append(file.getAbsolutePath()); buffer.append("\""); String command=buffer.toString(); try { //write script to file IOHelper.writeTextFile(script,file); } catch(IOException exception) { throw new FaxException("Unable to write vbscript to temporary file.",exception); } //get logger Logger logger=this.getLogger(); logger.logDebug(new Object[]{"Invoking command: ",command," script:",Logger.SYSTEM_EOL,script},null); //execute command ProcessOutput vbsOutput=ProcessExecutorHelper.executeProcess(this,command); //get exit code int exitCode=vbsOutput.getExitCode(); //delete temp file boolean fileDeleted=file.delete(); logger.logDebug(new Object[]{"Temp script file deleted: ",String.valueOf(fileDeleted)},null); if(exitCode!=0) { throw new FaxException("Error while invoking script, exit code: "+exitCode+" script output:\n"+vbsOutput.getOutputText()+"\nScript error:\n"+vbsOutput.getErrorText()); } return vbsOutput; }
java
protected ProcessOutput invokeScript(String script) { File file=null; try { //create temporary file file=File.createTempFile("fax4j_",".vbs"); } catch(IOException exception) { throw new FaxException("Unable to create temporary vbscript file.",exception); } file.deleteOnExit(); //generate command string StringBuilder buffer=new StringBuilder(); buffer.append(this.getVBSExePath()); buffer.append(" \""); buffer.append(file.getAbsolutePath()); buffer.append("\""); String command=buffer.toString(); try { //write script to file IOHelper.writeTextFile(script,file); } catch(IOException exception) { throw new FaxException("Unable to write vbscript to temporary file.",exception); } //get logger Logger logger=this.getLogger(); logger.logDebug(new Object[]{"Invoking command: ",command," script:",Logger.SYSTEM_EOL,script},null); //execute command ProcessOutput vbsOutput=ProcessExecutorHelper.executeProcess(this,command); //get exit code int exitCode=vbsOutput.getExitCode(); //delete temp file boolean fileDeleted=file.delete(); logger.logDebug(new Object[]{"Temp script file deleted: ",String.valueOf(fileDeleted)},null); if(exitCode!=0) { throw new FaxException("Error while invoking script, exit code: "+exitCode+" script output:\n"+vbsOutput.getOutputText()+"\nScript error:\n"+vbsOutput.getErrorText()); } return vbsOutput; }
[ "protected", "ProcessOutput", "invokeScript", "(", "String", "script", ")", "{", "File", "file", "=", "null", ";", "try", "{", "//create temporary file", "file", "=", "File", ".", "createTempFile", "(", "\"fax4j_\"", ",", "\".vbs\"", ")", ";", "}", "catch", ...
Invokes the VB script and returns the output. @param script The script to invoke @return The script output
[ "Invokes", "the", "VB", "script", "and", "returns", "the", "output", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/vbs/VBSFaxClientSpi.java#L656-L708
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/vbs/VBSFaxClientSpi.java
VBSFaxClientSpi.generateScript
protected String generateScript(String name,Object[] input) { //get template String template=VBSFaxClientSpi.VBS_SCRIPTS.get(name); if((template==null)||(template.length()==0)) { this.throwUnsupportedException(); } //get common script String commonScript=VBSFaxClientSpi.VBS_SCRIPTS.get(VBSFaxClientSpi.VBS_SCRIPT); //format input Object[] formattedInput=null; if(input!=null) { //get size int size=input.length; //create array formattedInput=new Object[size]; Object object=null; for(int index=0;index<size;index++) { //get next element object=input[index]; //format object object=this.formatObject(object); //push to array formattedInput[index]=object; } } //push input to template String updatedScript=MessageFormat.format(template,formattedInput); //merge scripts StringBuilder buffer=new StringBuilder(commonScript.length()+updatedScript.length()); buffer.append(commonScript); buffer.append(updatedScript); String script=buffer.toString(); return script; }
java
protected String generateScript(String name,Object[] input) { //get template String template=VBSFaxClientSpi.VBS_SCRIPTS.get(name); if((template==null)||(template.length()==0)) { this.throwUnsupportedException(); } //get common script String commonScript=VBSFaxClientSpi.VBS_SCRIPTS.get(VBSFaxClientSpi.VBS_SCRIPT); //format input Object[] formattedInput=null; if(input!=null) { //get size int size=input.length; //create array formattedInput=new Object[size]; Object object=null; for(int index=0;index<size;index++) { //get next element object=input[index]; //format object object=this.formatObject(object); //push to array formattedInput[index]=object; } } //push input to template String updatedScript=MessageFormat.format(template,formattedInput); //merge scripts StringBuilder buffer=new StringBuilder(commonScript.length()+updatedScript.length()); buffer.append(commonScript); buffer.append(updatedScript); String script=buffer.toString(); return script; }
[ "protected", "String", "generateScript", "(", "String", "name", ",", "Object", "[", "]", "input", ")", "{", "//get template", "String", "template", "=", "VBSFaxClientSpi", ".", "VBS_SCRIPTS", ".", "get", "(", "name", ")", ";", "if", "(", "(", "template", "...
This function generates the script and returns it. @param name The script name @param input The script input @return The formatted script
[ "This", "function", "generates", "the", "script", "and", "returns", "it", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/vbs/VBSFaxClientSpi.java#L719-L765
train
sagiegurari/fax4j
src/main/java/org/fax4j/common/JDKLogger.java
JDKLogger.initializeLogger
protected static final Logger initializeLogger() { //get logger Logger logger=Logger.getLogger(FaxClient.class.getName()); //enable all log events (fax4j logger filters out uneeded log events) logger.setLevel(Level.ALL); logger.setFilter(null); //enable to pass log events to parent loggers logger.setUseParentHandlers(true); //create handler Formatter formatter=new SimpleFormatter(); Handler handler=new StreamHandler(System.out,formatter); //set filtering handler.setLevel(logger.getLevel()); handler.setFilter(logger.getFilter()); //add handler logger.addHandler(handler); return logger; }
java
protected static final Logger initializeLogger() { //get logger Logger logger=Logger.getLogger(FaxClient.class.getName()); //enable all log events (fax4j logger filters out uneeded log events) logger.setLevel(Level.ALL); logger.setFilter(null); //enable to pass log events to parent loggers logger.setUseParentHandlers(true); //create handler Formatter formatter=new SimpleFormatter(); Handler handler=new StreamHandler(System.out,formatter); //set filtering handler.setLevel(logger.getLevel()); handler.setFilter(logger.getFilter()); //add handler logger.addHandler(handler); return logger; }
[ "protected", "static", "final", "Logger", "initializeLogger", "(", ")", "{", "//get logger", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "FaxClient", ".", "class", ".", "getName", "(", ")", ")", ";", "//enable all log events (fax4j logger filters out u...
This function initializes and returns the logger. @return The logger
[ "This", "function", "initializes", "and", "returns", "the", "logger", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/common/JDKLogger.java#L40-L64
train