id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
151,600
tvesalainen/util
util/src/main/java/org/vesalainen/navi/Navis.java
Navis.deltaLongitude
public static final double deltaLongitude(double latitude, double distance, double bearing) { double departure = departure(latitude); double sin = Math.sin(Math.toRadians(bearing)); return (sin*distance)/(60*departure); }
java
public static final double deltaLongitude(double latitude, double distance, double bearing) { double departure = departure(latitude); double sin = Math.sin(Math.toRadians(bearing)); return (sin*distance)/(60*departure); }
[ "public", "static", "final", "double", "deltaLongitude", "(", "double", "latitude", ",", "double", "distance", ",", "double", "bearing", ")", "{", "double", "departure", "=", "departure", "(", "latitude", ")", ";", "double", "sin", "=", "Math", ".", "sin", "(", "Math", ".", "toRadians", "(", "bearing", ")", ")", ";", "return", "(", "sin", "*", "distance", ")", "/", "(", "60", "*", "departure", ")", ";", "}" ]
Return longitude change after moving distance at bearing @param latitude @param distance @param bearing @return
[ "Return", "longitude", "change", "after", "moving", "distance", "at", "bearing" ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/navi/Navis.java#L55-L60
151,601
tvesalainen/util
util/src/main/java/org/vesalainen/navi/Navis.java
Navis.departure
public static final double departure(WayPoint loc1, WayPoint loc2) { return departure(loc2.getLatitude(), loc1.getLatitude()); }
java
public static final double departure(WayPoint loc1, WayPoint loc2) { return departure(loc2.getLatitude(), loc1.getLatitude()); }
[ "public", "static", "final", "double", "departure", "(", "WayPoint", "loc1", ",", "WayPoint", "loc2", ")", "{", "return", "departure", "(", "loc2", ".", "getLatitude", "(", ")", ",", "loc1", ".", "getLatitude", "(", ")", ")", ";", "}" ]
Return average departure of two waypoints @param loc1 @param loc2 @return
[ "Return", "average", "departure", "of", "two", "waypoints" ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/navi/Navis.java#L67-L70
151,602
tvesalainen/util
util/src/main/java/org/vesalainen/navi/Navis.java
Navis.departure
public static final double departure(double latitude1, double latitude2) { checkLatitude(latitude1); checkLatitude(latitude2); return departure((latitude1+latitude2)/2); }
java
public static final double departure(double latitude1, double latitude2) { checkLatitude(latitude1); checkLatitude(latitude2); return departure((latitude1+latitude2)/2); }
[ "public", "static", "final", "double", "departure", "(", "double", "latitude1", ",", "double", "latitude2", ")", "{", "checkLatitude", "(", "latitude1", ")", ";", "checkLatitude", "(", "latitude2", ")", ";", "return", "departure", "(", "(", "latitude1", "+", "latitude2", ")", "/", "2", ")", ";", "}" ]
Returns departure of average latitude @param latitude1 @param latitude2 @return
[ "Returns", "departure", "of", "average", "latitude" ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/navi/Navis.java#L77-L82
151,603
tvesalainen/util
util/src/main/java/org/vesalainen/navi/Navis.java
Navis.bearing
public static final double bearing(WayPoint wp1, WayPoint wp2) { double lat1 = wp1.getLatitude(); double lat2 = wp2.getLatitude(); double lon1 = wp1.getLongitude(); double lon2 = wp2.getLongitude(); return bearing(lat1, lon1, lat2, lon2); }
java
public static final double bearing(WayPoint wp1, WayPoint wp2) { double lat1 = wp1.getLatitude(); double lat2 = wp2.getLatitude(); double lon1 = wp1.getLongitude(); double lon2 = wp2.getLongitude(); return bearing(lat1, lon1, lat2, lon2); }
[ "public", "static", "final", "double", "bearing", "(", "WayPoint", "wp1", ",", "WayPoint", "wp2", ")", "{", "double", "lat1", "=", "wp1", ".", "getLatitude", "(", ")", ";", "double", "lat2", "=", "wp2", ".", "getLatitude", "(", ")", ";", "double", "lon1", "=", "wp1", ".", "getLongitude", "(", ")", ";", "double", "lon2", "=", "wp2", ".", "getLongitude", "(", ")", ";", "return", "bearing", "(", "lat1", ",", "lon1", ",", "lat2", ",", "lon2", ")", ";", "}" ]
Return bearing from wp1 to wp2 in degrees @param wp1 @param wp2 @return Degrees
[ "Return", "bearing", "from", "wp1", "to", "wp2", "in", "degrees" ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/navi/Navis.java#L103-L110
151,604
tvesalainen/util
util/src/main/java/org/vesalainen/navi/Navis.java
Navis.speed
public static final double speed(WayPoint wp1, WayPoint wp2) { double lat1 = wp1.getLatitude(); double lat2 = wp2.getLatitude(); double lon1 = wp1.getLongitude(); double lon2 = wp2.getLongitude(); long time1 = wp1.getTime(); long time2 = wp2.getTime(); return speed(time1, lat1, lon1, time2, lat2, lon2); }
java
public static final double speed(WayPoint wp1, WayPoint wp2) { double lat1 = wp1.getLatitude(); double lat2 = wp2.getLatitude(); double lon1 = wp1.getLongitude(); double lon2 = wp2.getLongitude(); long time1 = wp1.getTime(); long time2 = wp2.getTime(); return speed(time1, lat1, lon1, time2, lat2, lon2); }
[ "public", "static", "final", "double", "speed", "(", "WayPoint", "wp1", ",", "WayPoint", "wp2", ")", "{", "double", "lat1", "=", "wp1", ".", "getLatitude", "(", ")", ";", "double", "lat2", "=", "wp2", ".", "getLatitude", "(", ")", ";", "double", "lon1", "=", "wp1", ".", "getLongitude", "(", ")", ";", "double", "lon2", "=", "wp2", ".", "getLongitude", "(", ")", ";", "long", "time1", "=", "wp1", ".", "getTime", "(", ")", ";", "long", "time2", "=", "wp2", ".", "getTime", "(", ")", ";", "return", "speed", "(", "time1", ",", "lat1", ",", "lon1", ",", "time2", ",", "lat2", ",", "lon2", ")", ";", "}" ]
Returns the speed needed to move from wp1 to wp2 @param wp1 @param wp2 @return Kts
[ "Returns", "the", "speed", "needed", "to", "move", "from", "wp1", "to", "wp2" ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/navi/Navis.java#L194-L203
151,605
tvesalainen/util
util/src/main/java/org/vesalainen/navi/Navis.java
Navis.addLongitude
public static final double addLongitude(double longitude, double delta) { double gha = longitudeToGHA(longitude); gha -= delta; return ghaToLongitude(normalizeAngle(gha)); }
java
public static final double addLongitude(double longitude, double delta) { double gha = longitudeToGHA(longitude); gha -= delta; return ghaToLongitude(normalizeAngle(gha)); }
[ "public", "static", "final", "double", "addLongitude", "(", "double", "longitude", ",", "double", "delta", ")", "{", "double", "gha", "=", "longitudeToGHA", "(", "longitude", ")", ";", "gha", "-=", "delta", ";", "return", "ghaToLongitude", "(", "normalizeAngle", "(", "gha", ")", ")", ";", "}" ]
Adds delta to longitude. Positive delta is to east @param longitude @param delta @return
[ "Adds", "delta", "to", "longitude", ".", "Positive", "delta", "is", "to", "east" ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/navi/Navis.java#L232-L237
151,606
carewebframework/carewebframework-vista
org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/Version.java
Version.setVersion
public void setVersion(String value) { clear(); if (value == null || value.length() == 0) { return; } String pcs[] = value.split("\\.", 4); int len = Math.min(pcs.length, 4); for (int i = 0; i < len; i++) { ver[i] = Long.parseLong(pcs[i]); } }
java
public void setVersion(String value) { clear(); if (value == null || value.length() == 0) { return; } String pcs[] = value.split("\\.", 4); int len = Math.min(pcs.length, 4); for (int i = 0; i < len; i++) { ver[i] = Long.parseLong(pcs[i]); } }
[ "public", "void", "setVersion", "(", "String", "value", ")", "{", "clear", "(", ")", ";", "if", "(", "value", "==", "null", "||", "value", ".", "length", "(", ")", "==", "0", ")", "{", "return", ";", "}", "String", "pcs", "[", "]", "=", "value", ".", "split", "(", "\"\\\\.\"", ",", "4", ")", ";", "int", "len", "=", "Math", ".", "min", "(", "pcs", ".", "length", ",", "4", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "ver", "[", "i", "]", "=", "Long", ".", "parseLong", "(", "pcs", "[", "i", "]", ")", ";", "}", "}" ]
Set version components from input value. @param value Input value.
[ "Set", "version", "components", "from", "input", "value", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/Version.java#L59-L72
151,607
carewebframework/carewebframework-vista
org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/Version.java
Version.appendVersion
private void appendVersion(StringBuilder sb, long ver) { if (sb.length() > 0) { sb.append("."); } sb.append(ver); }
java
private void appendVersion(StringBuilder sb, long ver) { if (sb.length() > 0) { sb.append("."); } sb.append(ver); }
[ "private", "void", "appendVersion", "(", "StringBuilder", "sb", ",", "long", "ver", ")", "{", "if", "(", "sb", ".", "length", "(", ")", ">", "0", ")", "{", "sb", ".", "append", "(", "\".\"", ")", ";", "}", "sb", ".", "append", "(", "ver", ")", ";", "}" ]
Append version component. @param sb String builder. @param ver Version component value.
[ "Append", "version", "component", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/Version.java#L109-L115
151,608
the-fascinator/plugin-authentication-internal
src/main/java/com/googlecode/fascinator/authentication/internal/InternalAuthentication.java
InternalAuthentication.init
@Override public void init(String jsonString) throws AuthenticationException { try { setConfig(new JsonSimpleConfig(jsonString)); } catch (UnsupportedEncodingException e) { throw new AuthenticationException(e); } catch (IOException e) { throw new AuthenticationException(e); } }
java
@Override public void init(String jsonString) throws AuthenticationException { try { setConfig(new JsonSimpleConfig(jsonString)); } catch (UnsupportedEncodingException e) { throw new AuthenticationException(e); } catch (IOException e) { throw new AuthenticationException(e); } }
[ "@", "Override", "public", "void", "init", "(", "String", "jsonString", ")", "throws", "AuthenticationException", "{", "try", "{", "setConfig", "(", "new", "JsonSimpleConfig", "(", "jsonString", ")", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "throw", "new", "AuthenticationException", "(", "e", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "AuthenticationException", "(", "e", ")", ";", "}", "}" ]
Initialisation of Internal Authentication plugin @throws AuthenticationException if fails to initialise
[ "Initialisation", "of", "Internal", "Authentication", "plugin" ]
a2b9a0eda9b43bf20583036a406c83c938be3042
https://github.com/the-fascinator/plugin-authentication-internal/blob/a2b9a0eda9b43bf20583036a406c83c938be3042/src/main/java/com/googlecode/fascinator/authentication/internal/InternalAuthentication.java#L139-L148
151,609
the-fascinator/plugin-authentication-internal
src/main/java/com/googlecode/fascinator/authentication/internal/InternalAuthentication.java
InternalAuthentication.setConfig
private void setConfig(JsonSimpleConfig config) throws IOException { // Get the basics user_object = new InternalUser(); file_path = config.getString(null, "authentication", "internal", "path"); loadUsers(); }
java
private void setConfig(JsonSimpleConfig config) throws IOException { // Get the basics user_object = new InternalUser(); file_path = config.getString(null, "authentication", "internal", "path"); loadUsers(); }
[ "private", "void", "setConfig", "(", "JsonSimpleConfig", "config", ")", "throws", "IOException", "{", "// Get the basics", "user_object", "=", "new", "InternalUser", "(", ")", ";", "file_path", "=", "config", ".", "getString", "(", "null", ",", "\"authentication\"", ",", "\"internal\"", ",", "\"path\"", ")", ";", "loadUsers", "(", ")", ";", "}" ]
Set default configuration @param config JSON configuration @throws IOException if fails to initialise
[ "Set", "default", "configuration" ]
a2b9a0eda9b43bf20583036a406c83c938be3042
https://github.com/the-fascinator/plugin-authentication-internal/blob/a2b9a0eda9b43bf20583036a406c83c938be3042/src/main/java/com/googlecode/fascinator/authentication/internal/InternalAuthentication.java#L165-L171
151,610
the-fascinator/plugin-authentication-internal
src/main/java/com/googlecode/fascinator/authentication/internal/InternalAuthentication.java
InternalAuthentication.loadUsers
private void loadUsers() throws IOException { file_store = new Properties(); // Load our userbase from disk try { File user_file = new File(file_path); if (!user_file.exists()) { user_file.getParentFile().mkdirs(); OutputStream out = new FileOutputStream(user_file); IOUtils.copy( getClass().getResourceAsStream("/" + DEFAULT_FILE_NAME), out); out.close(); } file_store.load(new FileInputStream(file_path)); } catch (Exception e) { throw new IOException(e); } }
java
private void loadUsers() throws IOException { file_store = new Properties(); // Load our userbase from disk try { File user_file = new File(file_path); if (!user_file.exists()) { user_file.getParentFile().mkdirs(); OutputStream out = new FileOutputStream(user_file); IOUtils.copy( getClass().getResourceAsStream("/" + DEFAULT_FILE_NAME), out); out.close(); } file_store.load(new FileInputStream(file_path)); } catch (Exception e) { throw new IOException(e); } }
[ "private", "void", "loadUsers", "(", ")", "throws", "IOException", "{", "file_store", "=", "new", "Properties", "(", ")", ";", "// Load our userbase from disk", "try", "{", "File", "user_file", "=", "new", "File", "(", "file_path", ")", ";", "if", "(", "!", "user_file", ".", "exists", "(", ")", ")", "{", "user_file", ".", "getParentFile", "(", ")", ".", "mkdirs", "(", ")", ";", "OutputStream", "out", "=", "new", "FileOutputStream", "(", "user_file", ")", ";", "IOUtils", ".", "copy", "(", "getClass", "(", ")", ".", "getResourceAsStream", "(", "\"/\"", "+", "DEFAULT_FILE_NAME", ")", ",", "out", ")", ";", "out", ".", "close", "(", ")", ";", "}", "file_store", ".", "load", "(", "new", "FileInputStream", "(", "file_path", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "IOException", "(", "e", ")", ";", "}", "}" ]
Load users from the file @throws IOException if fail to load from file
[ "Load", "users", "from", "the", "file" ]
a2b9a0eda9b43bf20583036a406c83c938be3042
https://github.com/the-fascinator/plugin-authentication-internal/blob/a2b9a0eda9b43bf20583036a406c83c938be3042/src/main/java/com/googlecode/fascinator/authentication/internal/InternalAuthentication.java#L178-L197
151,611
the-fascinator/plugin-authentication-internal
src/main/java/com/googlecode/fascinator/authentication/internal/InternalAuthentication.java
InternalAuthentication.saveUsers
private void saveUsers() throws IOException { if (file_store != null) { try { file_store.store(new FileOutputStream(file_path), ""); } catch (Exception e) { throw new IOException(e); } } }
java
private void saveUsers() throws IOException { if (file_store != null) { try { file_store.store(new FileOutputStream(file_path), ""); } catch (Exception e) { throw new IOException(e); } } }
[ "private", "void", "saveUsers", "(", ")", "throws", "IOException", "{", "if", "(", "file_store", "!=", "null", ")", "{", "try", "{", "file_store", ".", "store", "(", "new", "FileOutputStream", "(", "file_path", ")", ",", "\"\"", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "IOException", "(", "e", ")", ";", "}", "}", "}" ]
Save user lists to the file on the disk @throws IOException if fail to save to file
[ "Save", "user", "lists", "to", "the", "file", "on", "the", "disk" ]
a2b9a0eda9b43bf20583036a406c83c938be3042
https://github.com/the-fascinator/plugin-authentication-internal/blob/a2b9a0eda9b43bf20583036a406c83c938be3042/src/main/java/com/googlecode/fascinator/authentication/internal/InternalAuthentication.java#L204-L212
151,612
the-fascinator/plugin-authentication-internal
src/main/java/com/googlecode/fascinator/authentication/internal/InternalAuthentication.java
InternalAuthentication.encryptPassword
private String encryptPassword(String password) throws AuthenticationException { byte[] passwordBytes = password.getBytes(); try { MessageDigest algorithm = MessageDigest.getInstance("MD5"); algorithm.reset(); algorithm.update(passwordBytes); byte messageDigest[] = algorithm.digest(); BigInteger number = new BigInteger(1, messageDigest); password = number.toString(16); if (password.length() == 31) { password = "0" + password; } } catch (Exception e) { throw new AuthenticationException( "Internal password encryption failure: " + e.getMessage()); } return password; }
java
private String encryptPassword(String password) throws AuthenticationException { byte[] passwordBytes = password.getBytes(); try { MessageDigest algorithm = MessageDigest.getInstance("MD5"); algorithm.reset(); algorithm.update(passwordBytes); byte messageDigest[] = algorithm.digest(); BigInteger number = new BigInteger(1, messageDigest); password = number.toString(16); if (password.length() == 31) { password = "0" + password; } } catch (Exception e) { throw new AuthenticationException( "Internal password encryption failure: " + e.getMessage()); } return password; }
[ "private", "String", "encryptPassword", "(", "String", "password", ")", "throws", "AuthenticationException", "{", "byte", "[", "]", "passwordBytes", "=", "password", ".", "getBytes", "(", ")", ";", "try", "{", "MessageDigest", "algorithm", "=", "MessageDigest", ".", "getInstance", "(", "\"MD5\"", ")", ";", "algorithm", ".", "reset", "(", ")", ";", "algorithm", ".", "update", "(", "passwordBytes", ")", ";", "byte", "messageDigest", "[", "]", "=", "algorithm", ".", "digest", "(", ")", ";", "BigInteger", "number", "=", "new", "BigInteger", "(", "1", ",", "messageDigest", ")", ";", "password", "=", "number", ".", "toString", "(", "16", ")", ";", "if", "(", "password", ".", "length", "(", ")", "==", "31", ")", "{", "password", "=", "\"0\"", "+", "password", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "AuthenticationException", "(", "\"Internal password encryption failure: \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "}", "return", "password", ";", "}" ]
Password encryption method @param password Password to be encrypted @return encrypted password @throws AuthenticationException if fail to encrypt
[ "Password", "encryption", "method" ]
a2b9a0eda9b43bf20583036a406c83c938be3042
https://github.com/the-fascinator/plugin-authentication-internal/blob/a2b9a0eda9b43bf20583036a406c83c938be3042/src/main/java/com/googlecode/fascinator/authentication/internal/InternalAuthentication.java#L221-L242
151,613
the-fascinator/plugin-authentication-internal
src/main/java/com/googlecode/fascinator/authentication/internal/InternalAuthentication.java
InternalAuthentication.createUser
@Override public User createUser(String username, String password) throws AuthenticationException { String user = file_store.getProperty(username); if (user != null) { throw new AuthenticationException("User '" + username + "' already exists."); } // Encrypt the new password String ePwd = encryptPassword(password); file_store.put(username, ePwd); try { saveUsers(); } catch (IOException e) { throw new AuthenticationException("Error changing password: ", e); } return getUser(username); }
java
@Override public User createUser(String username, String password) throws AuthenticationException { String user = file_store.getProperty(username); if (user != null) { throw new AuthenticationException("User '" + username + "' already exists."); } // Encrypt the new password String ePwd = encryptPassword(password); file_store.put(username, ePwd); try { saveUsers(); } catch (IOException e) { throw new AuthenticationException("Error changing password: ", e); } return getUser(username); }
[ "@", "Override", "public", "User", "createUser", "(", "String", "username", ",", "String", "password", ")", "throws", "AuthenticationException", "{", "String", "user", "=", "file_store", ".", "getProperty", "(", "username", ")", ";", "if", "(", "user", "!=", "null", ")", "{", "throw", "new", "AuthenticationException", "(", "\"User '\"", "+", "username", "+", "\"' already exists.\"", ")", ";", "}", "// Encrypt the new password", "String", "ePwd", "=", "encryptPassword", "(", "password", ")", ";", "file_store", ".", "put", "(", "username", ",", "ePwd", ")", ";", "try", "{", "saveUsers", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "AuthenticationException", "(", "\"Error changing password: \"", ",", "e", ")", ";", "}", "return", "getUser", "(", "username", ")", ";", "}" ]
Create a user. @param username The username of the new user. @param password The password of the new user. @return A user object for the newly created in user. @throws AuthenticationException if there was an error creating the user.
[ "Create", "a", "user", "." ]
a2b9a0eda9b43bf20583036a406c83c938be3042
https://github.com/the-fascinator/plugin-authentication-internal/blob/a2b9a0eda9b43bf20583036a406c83c938be3042/src/main/java/com/googlecode/fascinator/authentication/internal/InternalAuthentication.java#L319-L337
151,614
the-fascinator/plugin-authentication-internal
src/main/java/com/googlecode/fascinator/authentication/internal/InternalAuthentication.java
InternalAuthentication.changePassword
@Override public void changePassword(String username, String password) throws AuthenticationException { String user = file_store.getProperty(username); if (user == null) { throw new AuthenticationException("User '" + username + "' not found."); } // Encrypt the new password String ePwd = encryptPassword(password); file_store.put(username, ePwd); try { saveUsers(); } catch (IOException e) { throw new AuthenticationException("Error changing password: ", e); } }
java
@Override public void changePassword(String username, String password) throws AuthenticationException { String user = file_store.getProperty(username); if (user == null) { throw new AuthenticationException("User '" + username + "' not found."); } // Encrypt the new password String ePwd = encryptPassword(password); file_store.put(username, ePwd); try { saveUsers(); } catch (IOException e) { throw new AuthenticationException("Error changing password: ", e); } }
[ "@", "Override", "public", "void", "changePassword", "(", "String", "username", ",", "String", "password", ")", "throws", "AuthenticationException", "{", "String", "user", "=", "file_store", ".", "getProperty", "(", "username", ")", ";", "if", "(", "user", "==", "null", ")", "{", "throw", "new", "AuthenticationException", "(", "\"User '\"", "+", "username", "+", "\"' not found.\"", ")", ";", "}", "// Encrypt the new password", "String", "ePwd", "=", "encryptPassword", "(", "password", ")", ";", "file_store", ".", "put", "(", "username", ",", "ePwd", ")", ";", "try", "{", "saveUsers", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "AuthenticationException", "(", "\"Error changing password: \"", ",", "e", ")", ";", "}", "}" ]
Change a user's password. @param username The user changing their password. @param password The new password for the user. @throws AuthenticationException if there was an error changing the password.
[ "Change", "a", "user", "s", "password", "." ]
a2b9a0eda9b43bf20583036a406c83c938be3042
https://github.com/the-fascinator/plugin-authentication-internal/blob/a2b9a0eda9b43bf20583036a406c83c938be3042/src/main/java/com/googlecode/fascinator/authentication/internal/InternalAuthentication.java#L368-L384
151,615
the-fascinator/plugin-authentication-internal
src/main/java/com/googlecode/fascinator/authentication/internal/InternalAuthentication.java
InternalAuthentication.getUser
@Override public User getUser(String username) throws AuthenticationException { // Find our user String user = file_store.getProperty(username); if (user == null) { throw new AuthenticationException("User '" + username + "' not found."); } // Purge any old data and init() user_object = new InternalUser(); user_object.init(username); // before returning return user_object; }
java
@Override public User getUser(String username) throws AuthenticationException { // Find our user String user = file_store.getProperty(username); if (user == null) { throw new AuthenticationException("User '" + username + "' not found."); } // Purge any old data and init() user_object = new InternalUser(); user_object.init(username); // before returning return user_object; }
[ "@", "Override", "public", "User", "getUser", "(", "String", "username", ")", "throws", "AuthenticationException", "{", "// Find our user", "String", "user", "=", "file_store", ".", "getProperty", "(", "username", ")", ";", "if", "(", "user", "==", "null", ")", "{", "throw", "new", "AuthenticationException", "(", "\"User '\"", "+", "username", "+", "\"' not found.\"", ")", ";", "}", "// Purge any old data and init()", "user_object", "=", "new", "InternalUser", "(", ")", ";", "user_object", ".", "init", "(", "username", ")", ";", "// before returning", "return", "user_object", ";", "}" ]
Returns a User object if the implementing class supports user queries without authentication. @param username The username of the user required. @return An user object of the requested user. @throws AuthenticationException if there was an error retrieving the object.
[ "Returns", "a", "User", "object", "if", "the", "implementing", "class", "supports", "user", "queries", "without", "authentication", "." ]
a2b9a0eda9b43bf20583036a406c83c938be3042
https://github.com/the-fascinator/plugin-authentication-internal/blob/a2b9a0eda9b43bf20583036a406c83c938be3042/src/main/java/com/googlecode/fascinator/authentication/internal/InternalAuthentication.java#L427-L440
151,616
the-fascinator/plugin-authentication-internal
src/main/java/com/googlecode/fascinator/authentication/internal/InternalAuthentication.java
InternalAuthentication.searchUsers
@Override public List<User> searchUsers(String search) throws AuthenticationException { // Complete list of users String[] users = file_store.keySet().toArray( new String[file_store.size()]); List<User> found = new ArrayList<User>(); // Look through the list for anyone who matches for (int i = 0; i < users.length; i++) { if (users[i].toLowerCase().contains(search.toLowerCase())) { found.add(getUser(users[i])); } } // Return the list return found; }
java
@Override public List<User> searchUsers(String search) throws AuthenticationException { // Complete list of users String[] users = file_store.keySet().toArray( new String[file_store.size()]); List<User> found = new ArrayList<User>(); // Look through the list for anyone who matches for (int i = 0; i < users.length; i++) { if (users[i].toLowerCase().contains(search.toLowerCase())) { found.add(getUser(users[i])); } } // Return the list return found; }
[ "@", "Override", "public", "List", "<", "User", ">", "searchUsers", "(", "String", "search", ")", "throws", "AuthenticationException", "{", "// Complete list of users", "String", "[", "]", "users", "=", "file_store", ".", "keySet", "(", ")", ".", "toArray", "(", "new", "String", "[", "file_store", ".", "size", "(", ")", "]", ")", ";", "List", "<", "User", ">", "found", "=", "new", "ArrayList", "<", "User", ">", "(", ")", ";", "// Look through the list for anyone who matches", "for", "(", "int", "i", "=", "0", ";", "i", "<", "users", ".", "length", ";", "i", "++", ")", "{", "if", "(", "users", "[", "i", "]", ".", "toLowerCase", "(", ")", ".", "contains", "(", "search", ".", "toLowerCase", "(", ")", ")", ")", "{", "found", ".", "add", "(", "getUser", "(", "users", "[", "i", "]", ")", ")", ";", "}", "}", "// Return the list", "return", "found", ";", "}" ]
Returns a list of users matching the search. @param search The search string to execute. @return A list of usernames (String) that match the search. @throws AuthenticationException if there was an error searching.
[ "Returns", "a", "list", "of", "users", "matching", "the", "search", "." ]
a2b9a0eda9b43bf20583036a406c83c938be3042
https://github.com/the-fascinator/plugin-authentication-internal/blob/a2b9a0eda9b43bf20583036a406c83c938be3042/src/main/java/com/googlecode/fascinator/authentication/internal/InternalAuthentication.java#L449-L465
151,617
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/util/BaseApplication.java
BaseApplication.getServerProperties
public Map<String,Object> getServerProperties() { Map<String,Object> properties = super.getServerProperties(); return BaseDatabase.addDBProperties(properties, this, null); }
java
public Map<String,Object> getServerProperties() { Map<String,Object> properties = super.getServerProperties(); return BaseDatabase.addDBProperties(properties, this, null); }
[ "public", "Map", "<", "String", ",", "Object", ">", "getServerProperties", "(", ")", "{", "Map", "<", "String", ",", "Object", ">", "properties", "=", "super", ".", "getServerProperties", "(", ")", ";", "return", "BaseDatabase", ".", "addDBProperties", "(", "properties", ",", "this", ",", "null", ")", ";", "}" ]
Get the base properties to pass to the server. @return The base server properties
[ "Get", "the", "base", "properties", "to", "pass", "to", "the", "server", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/util/BaseApplication.java#L108-L112
151,618
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/util/BaseApplication.java
BaseApplication.getResourceClassName
public String getResourceClassName(String strBasePackage, String resourceName) { if (resourceName == null) resourceName = strBasePackage.substring(strBasePackage.lastIndexOf('.') + 1); strBasePackage = strBasePackage.substring(0, strBasePackage.lastIndexOf('.') + 1); resourceName = Utility.getFullClassName(null, strBasePackage, resourceName); resourceName = Utility.convertClassName(resourceName, Constants.RES_SUBPACKAGE); return strBasePackage; }
java
public String getResourceClassName(String strBasePackage, String resourceName) { if (resourceName == null) resourceName = strBasePackage.substring(strBasePackage.lastIndexOf('.') + 1); strBasePackage = strBasePackage.substring(0, strBasePackage.lastIndexOf('.') + 1); resourceName = Utility.getFullClassName(null, strBasePackage, resourceName); resourceName = Utility.convertClassName(resourceName, Constants.RES_SUBPACKAGE); return strBasePackage; }
[ "public", "String", "getResourceClassName", "(", "String", "strBasePackage", ",", "String", "resourceName", ")", "{", "if", "(", "resourceName", "==", "null", ")", "resourceName", "=", "strBasePackage", ".", "substring", "(", "strBasePackage", ".", "lastIndexOf", "(", "'", "'", ")", "+", "1", ")", ";", "strBasePackage", "=", "strBasePackage", ".", "substring", "(", "0", ",", "strBasePackage", ".", "lastIndexOf", "(", "'", "'", ")", "+", "1", ")", ";", "resourceName", "=", "Utility", ".", "getFullClassName", "(", "null", ",", "strBasePackage", ",", "resourceName", ")", ";", "resourceName", "=", "Utility", ".", "convertClassName", "(", "resourceName", ",", "Constants", ".", "RES_SUBPACKAGE", ")", ";", "return", "strBasePackage", ";", "}" ]
Given a class name in the program package, get this resource's class name in the res package. @param strBasePackage A class name in the same program directory as the res class. @param resourceName The base resource class name. @return The full resource class name.
[ "Given", "a", "class", "name", "in", "the", "program", "package", "get", "this", "resource", "s", "class", "name", "in", "the", "res", "package", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/util/BaseApplication.java#L153-L161
151,619
jmeetsma/Iglu-Util
src/main/java/org/ijsberg/iglu/util/time/SchedulingSupport.java
SchedulingSupport.calculateOffsetInMs
public static long calculateOffsetInMs(int intervalInMinutes, int offsetInMinutes) { while (offsetInMinutes < 0) { offsetInMinutes = intervalInMinutes + offsetInMinutes; } while (offsetInMinutes > intervalInMinutes) { offsetInMinutes -= intervalInMinutes; } return offsetInMinutes * MINUTE_IN_MS; }
java
public static long calculateOffsetInMs(int intervalInMinutes, int offsetInMinutes) { while (offsetInMinutes < 0) { offsetInMinutes = intervalInMinutes + offsetInMinutes; } while (offsetInMinutes > intervalInMinutes) { offsetInMinutes -= intervalInMinutes; } return offsetInMinutes * MINUTE_IN_MS; }
[ "public", "static", "long", "calculateOffsetInMs", "(", "int", "intervalInMinutes", ",", "int", "offsetInMinutes", ")", "{", "while", "(", "offsetInMinutes", "<", "0", ")", "{", "offsetInMinutes", "=", "intervalInMinutes", "+", "offsetInMinutes", ";", "}", "while", "(", "offsetInMinutes", ">", "intervalInMinutes", ")", "{", "offsetInMinutes", "-=", "intervalInMinutes", ";", "}", "return", "offsetInMinutes", "*", "MINUTE_IN_MS", ";", "}" ]
Reformulates negative offsets or offsets larger than interval. @param intervalInMinutes @param offsetInMinutes @return offset in milliseconds
[ "Reformulates", "negative", "offsets", "or", "offsets", "larger", "than", "interval", "." ]
971eb022115247b1e34dc26dd02e7e621e29e910
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/time/SchedulingSupport.java#L68-L76
151,620
jbundle/jbundle
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/landf/ScreenUtil.java
ScreenUtil.updateLookAndFeel
public static void updateLookAndFeel(Container container, PropertyOwner propertyOwner, Map<String,Object> properties) { String lookAndFeelClassName = ScreenUtil.getPropery(ScreenUtil.LOOK_AND_FEEL, propertyOwner, properties, null); if (lookAndFeelClassName == null) lookAndFeelClassName = ScreenUtil.DEFAULT; if (ScreenUtil.DEFAULT.equalsIgnoreCase(lookAndFeelClassName)) { // lookAndFeelClassName = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"; lookAndFeelClassName = UIManager.getCrossPlatformLookAndFeelClassName(); } if (ScreenUtil.SYSTEM.equalsIgnoreCase(lookAndFeelClassName)) lookAndFeelClassName = UIManager.getSystemLookAndFeelClassName(); String themeClassName = ScreenUtil.getPropery(ScreenUtil.THEME, propertyOwner, properties, null); MetalTheme theme = null; FontUIResource font = ScreenUtil.getFont(propertyOwner, properties, false); ColorUIResource colorText = ScreenUtil.getColor(ScreenUtil.TEXT_COLOR, propertyOwner, properties); ColorUIResource colorControl = ScreenUtil.getColor(ScreenUtil.CONTROL_COLOR, propertyOwner, properties); ColorUIResource colorBackground = ScreenUtil.getColor(ScreenUtil.BACKGROUND_COLOR, propertyOwner, properties); if ((themeClassName == null) || (themeClassName.equalsIgnoreCase(ScreenUtil.DEFAULT))) if (font == null) font = ScreenUtil.getFont(propertyOwner, properties, true); if ((font != null) || (colorControl != null) || (colorText != null)) { if (!(theme instanceof CustomTheme)) theme = new CustomTheme(); if (font != null) ((CustomTheme)theme).setDefaultFont(font); if (colorControl != null) ((CustomTheme)theme).setWhite(colorControl); if (colorText != null) ((CustomTheme)theme).setBlack(colorText); if (colorBackground != null) { ((CustomTheme)theme).setSecondaryColor(colorBackground); ((CustomTheme)theme).setPrimaryColor(colorBackground); } } else { if ((themeClassName == null) || (themeClassName.equalsIgnoreCase(ScreenUtil.DEFAULT))) theme = null; //? createDefaultTheme(); else theme = (MetalTheme)ClassServiceUtility.getClassService().makeObjectFromClassName(themeClassName); } if (MetalLookAndFeel.class.getName().equals(lookAndFeelClassName)) { if (theme == null) theme = new OceanTheme(); MetalLookAndFeel.setCurrentTheme(theme); } try { UIManager.setLookAndFeel(lookAndFeelClassName); } catch (Exception ex) { ex.printStackTrace(); } SwingUtilities.updateComponentTreeUI(container); }
java
public static void updateLookAndFeel(Container container, PropertyOwner propertyOwner, Map<String,Object> properties) { String lookAndFeelClassName = ScreenUtil.getPropery(ScreenUtil.LOOK_AND_FEEL, propertyOwner, properties, null); if (lookAndFeelClassName == null) lookAndFeelClassName = ScreenUtil.DEFAULT; if (ScreenUtil.DEFAULT.equalsIgnoreCase(lookAndFeelClassName)) { // lookAndFeelClassName = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"; lookAndFeelClassName = UIManager.getCrossPlatformLookAndFeelClassName(); } if (ScreenUtil.SYSTEM.equalsIgnoreCase(lookAndFeelClassName)) lookAndFeelClassName = UIManager.getSystemLookAndFeelClassName(); String themeClassName = ScreenUtil.getPropery(ScreenUtil.THEME, propertyOwner, properties, null); MetalTheme theme = null; FontUIResource font = ScreenUtil.getFont(propertyOwner, properties, false); ColorUIResource colorText = ScreenUtil.getColor(ScreenUtil.TEXT_COLOR, propertyOwner, properties); ColorUIResource colorControl = ScreenUtil.getColor(ScreenUtil.CONTROL_COLOR, propertyOwner, properties); ColorUIResource colorBackground = ScreenUtil.getColor(ScreenUtil.BACKGROUND_COLOR, propertyOwner, properties); if ((themeClassName == null) || (themeClassName.equalsIgnoreCase(ScreenUtil.DEFAULT))) if (font == null) font = ScreenUtil.getFont(propertyOwner, properties, true); if ((font != null) || (colorControl != null) || (colorText != null)) { if (!(theme instanceof CustomTheme)) theme = new CustomTheme(); if (font != null) ((CustomTheme)theme).setDefaultFont(font); if (colorControl != null) ((CustomTheme)theme).setWhite(colorControl); if (colorText != null) ((CustomTheme)theme).setBlack(colorText); if (colorBackground != null) { ((CustomTheme)theme).setSecondaryColor(colorBackground); ((CustomTheme)theme).setPrimaryColor(colorBackground); } } else { if ((themeClassName == null) || (themeClassName.equalsIgnoreCase(ScreenUtil.DEFAULT))) theme = null; //? createDefaultTheme(); else theme = (MetalTheme)ClassServiceUtility.getClassService().makeObjectFromClassName(themeClassName); } if (MetalLookAndFeel.class.getName().equals(lookAndFeelClassName)) { if (theme == null) theme = new OceanTheme(); MetalLookAndFeel.setCurrentTheme(theme); } try { UIManager.setLookAndFeel(lookAndFeelClassName); } catch (Exception ex) { ex.printStackTrace(); } SwingUtilities.updateComponentTreeUI(container); }
[ "public", "static", "void", "updateLookAndFeel", "(", "Container", "container", ",", "PropertyOwner", "propertyOwner", ",", "Map", "<", "String", ",", "Object", ">", "properties", ")", "{", "String", "lookAndFeelClassName", "=", "ScreenUtil", ".", "getPropery", "(", "ScreenUtil", ".", "LOOK_AND_FEEL", ",", "propertyOwner", ",", "properties", ",", "null", ")", ";", "if", "(", "lookAndFeelClassName", "==", "null", ")", "lookAndFeelClassName", "=", "ScreenUtil", ".", "DEFAULT", ";", "if", "(", "ScreenUtil", ".", "DEFAULT", ".", "equalsIgnoreCase", "(", "lookAndFeelClassName", ")", ")", "{", "// lookAndFeelClassName = \"com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel\";", "lookAndFeelClassName", "=", "UIManager", ".", "getCrossPlatformLookAndFeelClassName", "(", ")", ";", "}", "if", "(", "ScreenUtil", ".", "SYSTEM", ".", "equalsIgnoreCase", "(", "lookAndFeelClassName", ")", ")", "lookAndFeelClassName", "=", "UIManager", ".", "getSystemLookAndFeelClassName", "(", ")", ";", "String", "themeClassName", "=", "ScreenUtil", ".", "getPropery", "(", "ScreenUtil", ".", "THEME", ",", "propertyOwner", ",", "properties", ",", "null", ")", ";", "MetalTheme", "theme", "=", "null", ";", "FontUIResource", "font", "=", "ScreenUtil", ".", "getFont", "(", "propertyOwner", ",", "properties", ",", "false", ")", ";", "ColorUIResource", "colorText", "=", "ScreenUtil", ".", "getColor", "(", "ScreenUtil", ".", "TEXT_COLOR", ",", "propertyOwner", ",", "properties", ")", ";", "ColorUIResource", "colorControl", "=", "ScreenUtil", ".", "getColor", "(", "ScreenUtil", ".", "CONTROL_COLOR", ",", "propertyOwner", ",", "properties", ")", ";", "ColorUIResource", "colorBackground", "=", "ScreenUtil", ".", "getColor", "(", "ScreenUtil", ".", "BACKGROUND_COLOR", ",", "propertyOwner", ",", "properties", ")", ";", "if", "(", "(", "themeClassName", "==", "null", ")", "||", "(", "themeClassName", ".", "equalsIgnoreCase", "(", "ScreenUtil", ".", "DEFAULT", ")", ")", ")", "if", "(", "font", "==", "null", ")", "font", "=", "ScreenUtil", ".", "getFont", "(", "propertyOwner", ",", "properties", ",", "true", ")", ";", "if", "(", "(", "font", "!=", "null", ")", "||", "(", "colorControl", "!=", "null", ")", "||", "(", "colorText", "!=", "null", ")", ")", "{", "if", "(", "!", "(", "theme", "instanceof", "CustomTheme", ")", ")", "theme", "=", "new", "CustomTheme", "(", ")", ";", "if", "(", "font", "!=", "null", ")", "(", "(", "CustomTheme", ")", "theme", ")", ".", "setDefaultFont", "(", "font", ")", ";", "if", "(", "colorControl", "!=", "null", ")", "(", "(", "CustomTheme", ")", "theme", ")", ".", "setWhite", "(", "colorControl", ")", ";", "if", "(", "colorText", "!=", "null", ")", "(", "(", "CustomTheme", ")", "theme", ")", ".", "setBlack", "(", "colorText", ")", ";", "if", "(", "colorBackground", "!=", "null", ")", "{", "(", "(", "CustomTheme", ")", "theme", ")", ".", "setSecondaryColor", "(", "colorBackground", ")", ";", "(", "(", "CustomTheme", ")", "theme", ")", ".", "setPrimaryColor", "(", "colorBackground", ")", ";", "}", "}", "else", "{", "if", "(", "(", "themeClassName", "==", "null", ")", "||", "(", "themeClassName", ".", "equalsIgnoreCase", "(", "ScreenUtil", ".", "DEFAULT", ")", ")", ")", "theme", "=", "null", ";", "//? createDefaultTheme();", "else", "theme", "=", "(", "MetalTheme", ")", "ClassServiceUtility", ".", "getClassService", "(", ")", ".", "makeObjectFromClassName", "(", "themeClassName", ")", ";", "}", "if", "(", "MetalLookAndFeel", ".", "class", ".", "getName", "(", ")", ".", "equals", "(", "lookAndFeelClassName", ")", ")", "{", "if", "(", "theme", "==", "null", ")", "theme", "=", "new", "OceanTheme", "(", ")", ";", "MetalLookAndFeel", ".", "setCurrentTheme", "(", "theme", ")", ";", "}", "try", "{", "UIManager", ".", "setLookAndFeel", "(", "lookAndFeelClassName", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "SwingUtilities", ".", "updateComponentTreeUI", "(", "container", ")", ";", "}" ]
Set the look and feel.
[ "Set", "the", "look", "and", "feel", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/landf/ScreenUtil.java#L70-L133
151,621
jbundle/jbundle
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/landf/ScreenUtil.java
ScreenUtil.getPropery
public static String getPropery(String key, PropertyOwner propertyOwner, Map<String,Object> properties, String defaultValue) { String returnValue = null; if (propertyOwner != null) returnValue = propertyOwner.getProperty(key); if (properties != null) if (returnValue == null) returnValue = (String)properties.get(key); if (returnValue == null) returnValue = defaultValue; return returnValue; }
java
public static String getPropery(String key, PropertyOwner propertyOwner, Map<String,Object> properties, String defaultValue) { String returnValue = null; if (propertyOwner != null) returnValue = propertyOwner.getProperty(key); if (properties != null) if (returnValue == null) returnValue = (String)properties.get(key); if (returnValue == null) returnValue = defaultValue; return returnValue; }
[ "public", "static", "String", "getPropery", "(", "String", "key", ",", "PropertyOwner", "propertyOwner", ",", "Map", "<", "String", ",", "Object", ">", "properties", ",", "String", "defaultValue", ")", "{", "String", "returnValue", "=", "null", ";", "if", "(", "propertyOwner", "!=", "null", ")", "returnValue", "=", "propertyOwner", ".", "getProperty", "(", "key", ")", ";", "if", "(", "properties", "!=", "null", ")", "if", "(", "returnValue", "==", "null", ")", "returnValue", "=", "(", "String", ")", "properties", ".", "get", "(", "key", ")", ";", "if", "(", "returnValue", "==", "null", ")", "returnValue", "=", "defaultValue", ";", "return", "returnValue", ";", "}" ]
A utility to get the property from the propertyowner or the property.
[ "A", "utility", "to", "get", "the", "property", "from", "the", "propertyowner", "or", "the", "property", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/landf/ScreenUtil.java#L210-L220
151,622
jbundle/jbundle
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/landf/ScreenUtil.java
ScreenUtil.setProperty
public static void setProperty(String key, String value, PropertyOwner propertyOwner, Map<String,Object> properties) { if (propertyOwner != null) { propertyOwner.setProperty(key, value); } if (properties != null) { if (value != null) properties.put(key, value); else properties.remove(key); } }
java
public static void setProperty(String key, String value, PropertyOwner propertyOwner, Map<String,Object> properties) { if (propertyOwner != null) { propertyOwner.setProperty(key, value); } if (properties != null) { if (value != null) properties.put(key, value); else properties.remove(key); } }
[ "public", "static", "void", "setProperty", "(", "String", "key", ",", "String", "value", ",", "PropertyOwner", "propertyOwner", ",", "Map", "<", "String", ",", "Object", ">", "properties", ")", "{", "if", "(", "propertyOwner", "!=", "null", ")", "{", "propertyOwner", ".", "setProperty", "(", "key", ",", "value", ")", ";", "}", "if", "(", "properties", "!=", "null", ")", "{", "if", "(", "value", "!=", "null", ")", "properties", ".", "put", "(", "key", ",", "value", ")", ";", "else", "properties", ".", "remove", "(", "key", ")", ";", "}", "}" ]
A utility to set the property from the propertyowner or the property.
[ "A", "utility", "to", "set", "the", "property", "from", "the", "propertyowner", "or", "the", "property", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/landf/ScreenUtil.java#L224-L237
151,623
jbundle/jbundle
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/landf/ScreenUtil.java
ScreenUtil.getFrame
public static Frame getFrame(Component component) { while (component != null) { if (component instanceof Frame) return (Frame)component; component = component.getParent(); } return null; }
java
public static Frame getFrame(Component component) { while (component != null) { if (component instanceof Frame) return (Frame)component; component = component.getParent(); } return null; }
[ "public", "static", "Frame", "getFrame", "(", "Component", "component", ")", "{", "while", "(", "component", "!=", "null", ")", "{", "if", "(", "component", "instanceof", "Frame", ")", "return", "(", "Frame", ")", "component", ";", "component", "=", "component", ".", "getParent", "(", ")", ";", "}", "return", "null", ";", "}" ]
Get the frame for this component. @param component The component to get the frame for. @return The frame (or null).
[ "Get", "the", "frame", "for", "this", "component", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/landf/ScreenUtil.java#L250-L259
151,624
jbundle/jbundle
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/landf/ScreenUtil.java
ScreenUtil.setEnabled
public static void setEnabled(Component component, boolean bEnabled) { if (component instanceof JPanel) { for (int i = 0; i < ((JPanel)component).getComponentCount(); i++) { JComponent componentSub = (JComponent)((JPanel)component).getComponent(i); ScreenUtil.setEnabled(componentSub, bEnabled); } } else if (component instanceof JScrollPane) { JComponent componentSub = (JComponent)((JScrollPane)component).getViewport().getView(); ScreenUtil.setEnabled(componentSub, bEnabled); } else component.setEnabled(bEnabled); }
java
public static void setEnabled(Component component, boolean bEnabled) { if (component instanceof JPanel) { for (int i = 0; i < ((JPanel)component).getComponentCount(); i++) { JComponent componentSub = (JComponent)((JPanel)component).getComponent(i); ScreenUtil.setEnabled(componentSub, bEnabled); } } else if (component instanceof JScrollPane) { JComponent componentSub = (JComponent)((JScrollPane)component).getViewport().getView(); ScreenUtil.setEnabled(componentSub, bEnabled); } else component.setEnabled(bEnabled); }
[ "public", "static", "void", "setEnabled", "(", "Component", "component", ",", "boolean", "bEnabled", ")", "{", "if", "(", "component", "instanceof", "JPanel", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "(", "(", "JPanel", ")", "component", ")", ".", "getComponentCount", "(", ")", ";", "i", "++", ")", "{", "JComponent", "componentSub", "=", "(", "JComponent", ")", "(", "(", "JPanel", ")", "component", ")", ".", "getComponent", "(", "i", ")", ";", "ScreenUtil", ".", "setEnabled", "(", "componentSub", ",", "bEnabled", ")", ";", "}", "}", "else", "if", "(", "component", "instanceof", "JScrollPane", ")", "{", "JComponent", "componentSub", "=", "(", "JComponent", ")", "(", "(", "JScrollPane", ")", "component", ")", ".", "getViewport", "(", ")", ".", "getView", "(", ")", ";", "ScreenUtil", ".", "setEnabled", "(", "componentSub", ",", "bEnabled", ")", ";", "}", "else", "component", ".", "setEnabled", "(", "bEnabled", ")", ";", "}" ]
Fake disable a control.
[ "Fake", "disable", "a", "control", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/landf/ScreenUtil.java#L263-L280
151,625
microfocus-idol/java-configuration-impl
src/main/java/com/hp/autonomy/frontend/configuration/BaseConfigFileService.java
BaseConfigFileService.init
@SuppressWarnings("ProhibitedExceptionDeclared") @PostConstruct public void init() throws Exception { final String configFileLocation = getConfigFileLocation(); T fileConfig = getEmptyConfig(); boolean fileExists = false; log.info("Using {} as config file location", configFileLocation); try (Reader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFileLocation), "UTF-8"))) { fileConfig = mapper.readValue(reader, getConfigClass()); if (fileConfig instanceof PasswordsConfig<?>) { fileConfig = ((PasswordsConfig<T>) fileConfig).withDecryptedPasswords(textEncryptor); } fileExists = true; } catch (final FileNotFoundException e) { log.warn("Config file not found, using empty configuration object"); } catch (final IOException e) { log.error("Error reading config file at {}", configFileLocation); log.error("Recording stack trace", e); // throw this so we don't continue to start the webapp throw new IllegalStateException("Could not initialize configuration", e); } if (StringUtils.isNotBlank(defaultConfigFile)) { try (InputStream defaultConfigInputStream = getClass().getResourceAsStream(defaultConfigFile)) { if (defaultConfigInputStream != null) { final T defaultConfig = mapper.readValue(defaultConfigInputStream, getConfigClass()); fileConfig = fileConfig.merge(defaultConfig); if (!fileExists) { fileConfig = generateDefaultLogin(fileConfig); try { writeOutConfigFile(fileConfig, configFileLocation); } catch (final IOException e) { throw new IllegalStateException("Could not initialize configuration", e); } } } } catch (final IOException e) { log.error("Error reading default config file", e); // throw this so we don't continue to start the webapp throw new IllegalStateException("Could not initialize configuration", e); } } try { fileConfig.basicValidate("Root"); } catch (final ConfigException e) { log.error("Config validation failed in " + e); throw new IllegalStateException("Could not initialize configuration", e); } config.set(fileConfig); postInitialise(getConfig()); }
java
@SuppressWarnings("ProhibitedExceptionDeclared") @PostConstruct public void init() throws Exception { final String configFileLocation = getConfigFileLocation(); T fileConfig = getEmptyConfig(); boolean fileExists = false; log.info("Using {} as config file location", configFileLocation); try (Reader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFileLocation), "UTF-8"))) { fileConfig = mapper.readValue(reader, getConfigClass()); if (fileConfig instanceof PasswordsConfig<?>) { fileConfig = ((PasswordsConfig<T>) fileConfig).withDecryptedPasswords(textEncryptor); } fileExists = true; } catch (final FileNotFoundException e) { log.warn("Config file not found, using empty configuration object"); } catch (final IOException e) { log.error("Error reading config file at {}", configFileLocation); log.error("Recording stack trace", e); // throw this so we don't continue to start the webapp throw new IllegalStateException("Could not initialize configuration", e); } if (StringUtils.isNotBlank(defaultConfigFile)) { try (InputStream defaultConfigInputStream = getClass().getResourceAsStream(defaultConfigFile)) { if (defaultConfigInputStream != null) { final T defaultConfig = mapper.readValue(defaultConfigInputStream, getConfigClass()); fileConfig = fileConfig.merge(defaultConfig); if (!fileExists) { fileConfig = generateDefaultLogin(fileConfig); try { writeOutConfigFile(fileConfig, configFileLocation); } catch (final IOException e) { throw new IllegalStateException("Could not initialize configuration", e); } } } } catch (final IOException e) { log.error("Error reading default config file", e); // throw this so we don't continue to start the webapp throw new IllegalStateException("Could not initialize configuration", e); } } try { fileConfig.basicValidate("Root"); } catch (final ConfigException e) { log.error("Config validation failed in " + e); throw new IllegalStateException("Could not initialize configuration", e); } config.set(fileConfig); postInitialise(getConfig()); }
[ "@", "SuppressWarnings", "(", "\"ProhibitedExceptionDeclared\"", ")", "@", "PostConstruct", "public", "void", "init", "(", ")", "throws", "Exception", "{", "final", "String", "configFileLocation", "=", "getConfigFileLocation", "(", ")", ";", "T", "fileConfig", "=", "getEmptyConfig", "(", ")", ";", "boolean", "fileExists", "=", "false", ";", "log", ".", "info", "(", "\"Using {} as config file location\"", ",", "configFileLocation", ")", ";", "try", "(", "Reader", "reader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "new", "FileInputStream", "(", "configFileLocation", ")", ",", "\"UTF-8\"", ")", ")", ")", "{", "fileConfig", "=", "mapper", ".", "readValue", "(", "reader", ",", "getConfigClass", "(", ")", ")", ";", "if", "(", "fileConfig", "instanceof", "PasswordsConfig", "<", "?", ">", ")", "{", "fileConfig", "=", "(", "(", "PasswordsConfig", "<", "T", ">", ")", "fileConfig", ")", ".", "withDecryptedPasswords", "(", "textEncryptor", ")", ";", "}", "fileExists", "=", "true", ";", "}", "catch", "(", "final", "FileNotFoundException", "e", ")", "{", "log", ".", "warn", "(", "\"Config file not found, using empty configuration object\"", ")", ";", "}", "catch", "(", "final", "IOException", "e", ")", "{", "log", ".", "error", "(", "\"Error reading config file at {}\"", ",", "configFileLocation", ")", ";", "log", ".", "error", "(", "\"Recording stack trace\"", ",", "e", ")", ";", "// throw this so we don't continue to start the webapp", "throw", "new", "IllegalStateException", "(", "\"Could not initialize configuration\"", ",", "e", ")", ";", "}", "if", "(", "StringUtils", ".", "isNotBlank", "(", "defaultConfigFile", ")", ")", "{", "try", "(", "InputStream", "defaultConfigInputStream", "=", "getClass", "(", ")", ".", "getResourceAsStream", "(", "defaultConfigFile", ")", ")", "{", "if", "(", "defaultConfigInputStream", "!=", "null", ")", "{", "final", "T", "defaultConfig", "=", "mapper", ".", "readValue", "(", "defaultConfigInputStream", ",", "getConfigClass", "(", ")", ")", ";", "fileConfig", "=", "fileConfig", ".", "merge", "(", "defaultConfig", ")", ";", "if", "(", "!", "fileExists", ")", "{", "fileConfig", "=", "generateDefaultLogin", "(", "fileConfig", ")", ";", "try", "{", "writeOutConfigFile", "(", "fileConfig", ",", "configFileLocation", ")", ";", "}", "catch", "(", "final", "IOException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Could not initialize configuration\"", ",", "e", ")", ";", "}", "}", "}", "}", "catch", "(", "final", "IOException", "e", ")", "{", "log", ".", "error", "(", "\"Error reading default config file\"", ",", "e", ")", ";", "// throw this so we don't continue to start the webapp", "throw", "new", "IllegalStateException", "(", "\"Could not initialize configuration\"", ",", "e", ")", ";", "}", "}", "try", "{", "fileConfig", ".", "basicValidate", "(", "\"Root\"", ")", ";", "}", "catch", "(", "final", "ConfigException", "e", ")", "{", "log", ".", "error", "(", "\"Config validation failed in \"", "+", "e", ")", ";", "throw", "new", "IllegalStateException", "(", "\"Could not initialize configuration\"", ",", "e", ")", ";", "}", "config", ".", "set", "(", "fileConfig", ")", ";", "postInitialise", "(", "getConfig", "(", ")", ")", ";", "}" ]
Exception thrown by method in library
[ "Exception", "thrown", "by", "method", "in", "library" ]
cd9d744cacfaaae3c76cacc211e65742bbc7b00a
https://github.com/microfocus-idol/java-configuration-impl/blob/cd9d744cacfaaae3c76cacc211e65742bbc7b00a/src/main/java/com/hp/autonomy/frontend/configuration/BaseConfigFileService.java#L78-L138
151,626
microfocus-idol/java-configuration-impl
src/main/java/com/hp/autonomy/frontend/configuration/BaseConfigFileService.java
BaseConfigFileService.getConfigResponse
@Override public ConfigResponse<T> getConfigResponse() { T config = this.config.get(); config = withoutDefaultLogin(config); if (config instanceof PasswordsConfig<?>) { config = ((PasswordsConfig<T>) config).withoutPasswords(); } return new ConfigResponse<>(config, getConfigFileLocation(), configFileLocation); }
java
@Override public ConfigResponse<T> getConfigResponse() { T config = this.config.get(); config = withoutDefaultLogin(config); if (config instanceof PasswordsConfig<?>) { config = ((PasswordsConfig<T>) config).withoutPasswords(); } return new ConfigResponse<>(config, getConfigFileLocation(), configFileLocation); }
[ "@", "Override", "public", "ConfigResponse", "<", "T", ">", "getConfigResponse", "(", ")", "{", "T", "config", "=", "this", ".", "config", ".", "get", "(", ")", ";", "config", "=", "withoutDefaultLogin", "(", "config", ")", ";", "if", "(", "config", "instanceof", "PasswordsConfig", "<", "?", ">", ")", "{", "config", "=", "(", "(", "PasswordsConfig", "<", "T", ">", ")", "config", ")", ".", "withoutPasswords", "(", ")", ";", "}", "return", "new", "ConfigResponse", "<>", "(", "config", ",", "getConfigFileLocation", "(", ")", ",", "configFileLocation", ")", ";", "}" ]
Returns the Config in a format suitable for revealing to users. @return A ConfigResponse of the current config. Passwords will be encrypted and the default login wil be removed.
[ "Returns", "the", "Config", "in", "a", "format", "suitable", "for", "revealing", "to", "users", "." ]
cd9d744cacfaaae3c76cacc211e65742bbc7b00a
https://github.com/microfocus-idol/java-configuration-impl/blob/cd9d744cacfaaae3c76cacc211e65742bbc7b00a/src/main/java/com/hp/autonomy/frontend/configuration/BaseConfigFileService.java#L185-L196
151,627
jbundle/jbundle
thin/base/db/base/src/main/java/org/jbundle/thin/base/db/buff/VectorBuffer.java
VectorBuffer.clearBuffer
public void clearBuffer() { super.clearBuffer(); if (m_vector == null) m_vector = new Vector<Object>(); else m_vector.removeAllElements(); m_iCurrentIndex = 0; }
java
public void clearBuffer() { super.clearBuffer(); if (m_vector == null) m_vector = new Vector<Object>(); else m_vector.removeAllElements(); m_iCurrentIndex = 0; }
[ "public", "void", "clearBuffer", "(", ")", "{", "super", ".", "clearBuffer", "(", ")", ";", "if", "(", "m_vector", "==", "null", ")", "m_vector", "=", "new", "Vector", "<", "Object", ">", "(", ")", ";", "else", "m_vector", ".", "removeAllElements", "(", ")", ";", "m_iCurrentIndex", "=", "0", ";", "}" ]
Initialize the physical data buffer.
[ "Initialize", "the", "physical", "data", "buffer", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/db/base/src/main/java/org/jbundle/thin/base/db/buff/VectorBuffer.java#L103-L111
151,628
kirgor/enklib
sql/src/main/java/com/kirgor/enklib/sql/Cursor.java
Cursor.fetchList
public List<T> fetchList(int limit) throws SQLException, InstantiationException, IllegalAccessException { ArrayList<T> result = new ArrayList<T>(); if (primitive) { for (int i = 0; i < limit; i++) { if (!finished) { result.add(fetchSingleInternal()); next(); } else { break; } } } else { for (int i = 0; i < limit; i++) { if (!finished) { result.add(fetchSingleInternal()); next(); } else { break; } } } return result; }
java
public List<T> fetchList(int limit) throws SQLException, InstantiationException, IllegalAccessException { ArrayList<T> result = new ArrayList<T>(); if (primitive) { for (int i = 0; i < limit; i++) { if (!finished) { result.add(fetchSingleInternal()); next(); } else { break; } } } else { for (int i = 0; i < limit; i++) { if (!finished) { result.add(fetchSingleInternal()); next(); } else { break; } } } return result; }
[ "public", "List", "<", "T", ">", "fetchList", "(", "int", "limit", ")", "throws", "SQLException", ",", "InstantiationException", ",", "IllegalAccessException", "{", "ArrayList", "<", "T", ">", "result", "=", "new", "ArrayList", "<", "T", ">", "(", ")", ";", "if", "(", "primitive", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "limit", ";", "i", "++", ")", "{", "if", "(", "!", "finished", ")", "{", "result", ".", "add", "(", "fetchSingleInternal", "(", ")", ")", ";", "next", "(", ")", ";", "}", "else", "{", "break", ";", "}", "}", "}", "else", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "limit", ";", "i", "++", ")", "{", "if", "(", "!", "finished", ")", "{", "result", ".", "add", "(", "fetchSingleInternal", "(", ")", ")", ";", "next", "(", ")", ";", "}", "else", "{", "break", ";", "}", "}", "}", "return", "result", ";", "}" ]
Fetches limited list of entities. @param limit Maximum amount of entities to fetch. @return List of fetched entities. @throws SQLException @throws InstantiationException @throws IllegalAccessException
[ "Fetches", "limited", "list", "of", "entities", "." ]
8a24db296dc43db5d8fe509cf64ace0a0c7be8f2
https://github.com/kirgor/enklib/blob/8a24db296dc43db5d8fe509cf64ace0a0c7be8f2/sql/src/main/java/com/kirgor/enklib/sql/Cursor.java#L78-L101
151,629
kirgor/enklib
sql/src/main/java/com/kirgor/enklib/sql/Cursor.java
Cursor.fetchList
public List<T> fetchList() throws SQLException, InstantiationException, IllegalAccessException { ArrayList<T> result = new ArrayList<T>(); if (primitive) { while (!finished) { result.add(fetchSinglePrimitiveInternal()); next(); } } else { while (!finished) { result.add(fetchSingleInternal()); next(); } } return result; }
java
public List<T> fetchList() throws SQLException, InstantiationException, IllegalAccessException { ArrayList<T> result = new ArrayList<T>(); if (primitive) { while (!finished) { result.add(fetchSinglePrimitiveInternal()); next(); } } else { while (!finished) { result.add(fetchSingleInternal()); next(); } } return result; }
[ "public", "List", "<", "T", ">", "fetchList", "(", ")", "throws", "SQLException", ",", "InstantiationException", ",", "IllegalAccessException", "{", "ArrayList", "<", "T", ">", "result", "=", "new", "ArrayList", "<", "T", ">", "(", ")", ";", "if", "(", "primitive", ")", "{", "while", "(", "!", "finished", ")", "{", "result", ".", "add", "(", "fetchSinglePrimitiveInternal", "(", ")", ")", ";", "next", "(", ")", ";", "}", "}", "else", "{", "while", "(", "!", "finished", ")", "{", "result", ".", "add", "(", "fetchSingleInternal", "(", ")", ")", ";", "next", "(", ")", ";", "}", "}", "return", "result", ";", "}" ]
Fetches the whole list of entities. It will not stop until entire result set will end. @return List of fetched entities. @throws SQLException @throws InstantiationException @throws IllegalAccessException
[ "Fetches", "the", "whole", "list", "of", "entities", ".", "It", "will", "not", "stop", "until", "entire", "result", "set", "will", "end", "." ]
8a24db296dc43db5d8fe509cf64ace0a0c7be8f2
https://github.com/kirgor/enklib/blob/8a24db296dc43db5d8fe509cf64ace0a0c7be8f2/sql/src/main/java/com/kirgor/enklib/sql/Cursor.java#L111-L126
151,630
kirgor/enklib
sql/src/main/java/com/kirgor/enklib/sql/Cursor.java
Cursor.fetchSingle
public T fetchSingle() throws InstantiationException, IllegalAccessException, SQLException { if (!finished) { T result = primitive ? fetchSinglePrimitiveInternal() : fetchSingleInternal(); next(); return result; } else { throw new SQLException("Result set don't have data for single fetch."); } }
java
public T fetchSingle() throws InstantiationException, IllegalAccessException, SQLException { if (!finished) { T result = primitive ? fetchSinglePrimitiveInternal() : fetchSingleInternal(); next(); return result; } else { throw new SQLException("Result set don't have data for single fetch."); } }
[ "public", "T", "fetchSingle", "(", ")", "throws", "InstantiationException", ",", "IllegalAccessException", ",", "SQLException", "{", "if", "(", "!", "finished", ")", "{", "T", "result", "=", "primitive", "?", "fetchSinglePrimitiveInternal", "(", ")", ":", "fetchSingleInternal", "(", ")", ";", "next", "(", ")", ";", "return", "result", ";", "}", "else", "{", "throw", "new", "SQLException", "(", "\"Result set don't have data for single fetch.\"", ")", ";", "}", "}" ]
Fetches single entity, being sure that it exists. Throws exception if there is no entity. @return Single entity. @throws InstantiationException @throws IllegalAccessException @throws SQLException
[ "Fetches", "single", "entity", "being", "sure", "that", "it", "exists", ".", "Throws", "exception", "if", "there", "is", "no", "entity", "." ]
8a24db296dc43db5d8fe509cf64ace0a0c7be8f2
https://github.com/kirgor/enklib/blob/8a24db296dc43db5d8fe509cf64ace0a0c7be8f2/sql/src/main/java/com/kirgor/enklib/sql/Cursor.java#L136-L144
151,631
kirgor/enklib
sql/src/main/java/com/kirgor/enklib/sql/Cursor.java
Cursor.fetchSingleOrNull
public T fetchSingleOrNull() throws InstantiationException, IllegalAccessException, SQLException { if (!finished) { T result = primitive ? fetchSinglePrimitiveInternal() : fetchSingleInternal(); next(); return result; } else { return null; } }
java
public T fetchSingleOrNull() throws InstantiationException, IllegalAccessException, SQLException { if (!finished) { T result = primitive ? fetchSinglePrimitiveInternal() : fetchSingleInternal(); next(); return result; } else { return null; } }
[ "public", "T", "fetchSingleOrNull", "(", ")", "throws", "InstantiationException", ",", "IllegalAccessException", ",", "SQLException", "{", "if", "(", "!", "finished", ")", "{", "T", "result", "=", "primitive", "?", "fetchSinglePrimitiveInternal", "(", ")", ":", "fetchSingleInternal", "(", ")", ";", "next", "(", ")", ";", "return", "result", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Fetches single entity or null. @return Single entity if result set have one more, otherwise null. @throws InstantiationException @throws IllegalAccessException @throws SQLException
[ "Fetches", "single", "entity", "or", "null", "." ]
8a24db296dc43db5d8fe509cf64ace0a0c7be8f2
https://github.com/kirgor/enklib/blob/8a24db296dc43db5d8fe509cf64ace0a0c7be8f2/sql/src/main/java/com/kirgor/enklib/sql/Cursor.java#L154-L162
151,632
kirgor/enklib
sql/src/main/java/com/kirgor/enklib/sql/Cursor.java
Cursor.close
public void close(boolean closeConnection) throws SQLException { if (closeConnection) { resultSet.getStatement().getConnection().close(); } else { resultSet.close(); } finished = true; }
java
public void close(boolean closeConnection) throws SQLException { if (closeConnection) { resultSet.getStatement().getConnection().close(); } else { resultSet.close(); } finished = true; }
[ "public", "void", "close", "(", "boolean", "closeConnection", ")", "throws", "SQLException", "{", "if", "(", "closeConnection", ")", "{", "resultSet", ".", "getStatement", "(", ")", ".", "getConnection", "(", ")", ".", "close", "(", ")", ";", "}", "else", "{", "resultSet", ".", "close", "(", ")", ";", "}", "finished", "=", "true", ";", "}" ]
Closes underlying result set and, optionally, the whole connection. @param closeConnection Close underlying connection also. Be aware of this if connection is used somewhere else. @throws SQLException
[ "Closes", "underlying", "result", "set", "and", "optionally", "the", "whole", "connection", "." ]
8a24db296dc43db5d8fe509cf64ace0a0c7be8f2
https://github.com/kirgor/enklib/blob/8a24db296dc43db5d8fe509cf64ace0a0c7be8f2/sql/src/main/java/com/kirgor/enklib/sql/Cursor.java#L171-L179
151,633
jbundle/jbundle
base/db/client/src/main/java/org/jbundle/base/db/client/ClientDatabase.java
ClientDatabase.close
public void close() { super.close(); // Do any inherited try { if (m_remoteDatabase != null) { synchronized (this.getSyncObject(m_remoteDatabase)) { // In case this is called from another task m_remoteDatabase.close(); } } } catch (RemoteException ex) { Utility.getLogger().warning("Remote close error: " + ex.getMessage()); ex.printStackTrace(); } }
java
public void close() { super.close(); // Do any inherited try { if (m_remoteDatabase != null) { synchronized (this.getSyncObject(m_remoteDatabase)) { // In case this is called from another task m_remoteDatabase.close(); } } } catch (RemoteException ex) { Utility.getLogger().warning("Remote close error: " + ex.getMessage()); ex.printStackTrace(); } }
[ "public", "void", "close", "(", ")", "{", "super", ".", "close", "(", ")", ";", "// Do any inherited", "try", "{", "if", "(", "m_remoteDatabase", "!=", "null", ")", "{", "synchronized", "(", "this", ".", "getSyncObject", "(", "m_remoteDatabase", ")", ")", "{", "// In case this is called from another task", "m_remoteDatabase", ".", "close", "(", ")", ";", "}", "}", "}", "catch", "(", "RemoteException", "ex", ")", "{", "Utility", ".", "getLogger", "(", ")", ".", "warning", "(", "\"Remote close error: \"", "+", "ex", ".", "getMessage", "(", ")", ")", ";", "ex", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
Close the remote databases.
[ "Close", "the", "remote", "databases", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/db/client/src/main/java/org/jbundle/base/db/client/ClientDatabase.java#L125-L140
151,634
jbundle/jbundle
base/db/client/src/main/java/org/jbundle/base/db/client/ClientDatabase.java
ClientDatabase.getRemoteDatabase
public RemoteDatabase getRemoteDatabase() throws RemoteException { if (m_remoteDatabase != null) return m_remoteDatabase; try { if (this.getTableCount() == 0) return null; // Never ClientTable table = (ClientTable)m_vTableList.get(0); RemoteTable tableRemote = table.getRemoteTable(); if (tableRemote != null) { synchronized (this.getSyncObject(tableRemote)) { // In case this is called from another task // Move these properties up in case they are in the environment properties. Map<String,Object> propDatabase = BaseDatabase.addDBProperties(this.getProperties(), this, null); BaseDatabase.addDBProperty(propDatabase, this, null, this.getDatabaseName(false) + BaseDatabase.DBSHARED_PARAM_SUFFIX); BaseDatabase.addDBProperty(propDatabase, this, null, this.getDatabaseName(false) + BaseDatabase.DBUSER_PARAM_SUFFIX); m_remoteDatabase = tableRemote.getRemoteDatabase(propDatabase); } } if (m_remoteDatabase != null) { synchronized (this.getSyncObject(m_remoteDatabase)) { // In case this is called from another task m_remoteProperties = m_remoteDatabase.getDBProperties(); } } } catch (RemoteException ex) { Utility.getLogger().warning("dbServer exception: " + ex.getMessage()); throw ex; } catch (Exception ex) { ex.printStackTrace(); } return m_remoteDatabase; }
java
public RemoteDatabase getRemoteDatabase() throws RemoteException { if (m_remoteDatabase != null) return m_remoteDatabase; try { if (this.getTableCount() == 0) return null; // Never ClientTable table = (ClientTable)m_vTableList.get(0); RemoteTable tableRemote = table.getRemoteTable(); if (tableRemote != null) { synchronized (this.getSyncObject(tableRemote)) { // In case this is called from another task // Move these properties up in case they are in the environment properties. Map<String,Object> propDatabase = BaseDatabase.addDBProperties(this.getProperties(), this, null); BaseDatabase.addDBProperty(propDatabase, this, null, this.getDatabaseName(false) + BaseDatabase.DBSHARED_PARAM_SUFFIX); BaseDatabase.addDBProperty(propDatabase, this, null, this.getDatabaseName(false) + BaseDatabase.DBUSER_PARAM_SUFFIX); m_remoteDatabase = tableRemote.getRemoteDatabase(propDatabase); } } if (m_remoteDatabase != null) { synchronized (this.getSyncObject(m_remoteDatabase)) { // In case this is called from another task m_remoteProperties = m_remoteDatabase.getDBProperties(); } } } catch (RemoteException ex) { Utility.getLogger().warning("dbServer exception: " + ex.getMessage()); throw ex; } catch (Exception ex) { ex.printStackTrace(); } return m_remoteDatabase; }
[ "public", "RemoteDatabase", "getRemoteDatabase", "(", ")", "throws", "RemoteException", "{", "if", "(", "m_remoteDatabase", "!=", "null", ")", "return", "m_remoteDatabase", ";", "try", "{", "if", "(", "this", ".", "getTableCount", "(", ")", "==", "0", ")", "return", "null", ";", "// Never", "ClientTable", "table", "=", "(", "ClientTable", ")", "m_vTableList", ".", "get", "(", "0", ")", ";", "RemoteTable", "tableRemote", "=", "table", ".", "getRemoteTable", "(", ")", ";", "if", "(", "tableRemote", "!=", "null", ")", "{", "synchronized", "(", "this", ".", "getSyncObject", "(", "tableRemote", ")", ")", "{", "// In case this is called from another task", "// Move these properties up in case they are in the environment properties.", "Map", "<", "String", ",", "Object", ">", "propDatabase", "=", "BaseDatabase", ".", "addDBProperties", "(", "this", ".", "getProperties", "(", ")", ",", "this", ",", "null", ")", ";", "BaseDatabase", ".", "addDBProperty", "(", "propDatabase", ",", "this", ",", "null", ",", "this", ".", "getDatabaseName", "(", "false", ")", "+", "BaseDatabase", ".", "DBSHARED_PARAM_SUFFIX", ")", ";", "BaseDatabase", ".", "addDBProperty", "(", "propDatabase", ",", "this", ",", "null", ",", "this", ".", "getDatabaseName", "(", "false", ")", "+", "BaseDatabase", ".", "DBUSER_PARAM_SUFFIX", ")", ";", "m_remoteDatabase", "=", "tableRemote", ".", "getRemoteDatabase", "(", "propDatabase", ")", ";", "}", "}", "if", "(", "m_remoteDatabase", "!=", "null", ")", "{", "synchronized", "(", "this", ".", "getSyncObject", "(", "m_remoteDatabase", ")", ")", "{", "// In case this is called from another task", "m_remoteProperties", "=", "m_remoteDatabase", ".", "getDBProperties", "(", ")", ";", "}", "}", "}", "catch", "(", "RemoteException", "ex", ")", "{", "Utility", ".", "getLogger", "(", ")", ".", "warning", "(", "\"dbServer exception: \"", "+", "ex", ".", "getMessage", "(", ")", ")", ";", "throw", "ex", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "return", "m_remoteDatabase", ";", "}" ]
Open the remote database. @param environment The remote server object. @param The user id/name (recommended on the initial server open). @return The RemoteDatabase.
[ "Open", "the", "remote", "database", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/db/client/src/main/java/org/jbundle/base/db/client/ClientDatabase.java#L197-L232
151,635
jbundle/jbundle
base/db/client/src/main/java/org/jbundle/base/db/client/ClientDatabase.java
ClientDatabase.getRemoteProperty
public String getRemoteProperty(String strProperty, boolean readIfNotCached) { if (m_remoteProperties == null) if (readIfNotCached) { try { this.getRemoteDatabase(); } catch (RemoteException e) { e.printStackTrace(); } } if (m_remoteProperties != null) return (String)m_remoteProperties.get(strProperty); return this.getFakeRemoteProperty(strProperty); }
java
public String getRemoteProperty(String strProperty, boolean readIfNotCached) { if (m_remoteProperties == null) if (readIfNotCached) { try { this.getRemoteDatabase(); } catch (RemoteException e) { e.printStackTrace(); } } if (m_remoteProperties != null) return (String)m_remoteProperties.get(strProperty); return this.getFakeRemoteProperty(strProperty); }
[ "public", "String", "getRemoteProperty", "(", "String", "strProperty", ",", "boolean", "readIfNotCached", ")", "{", "if", "(", "m_remoteProperties", "==", "null", ")", "if", "(", "readIfNotCached", ")", "{", "try", "{", "this", ".", "getRemoteDatabase", "(", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "if", "(", "m_remoteProperties", "!=", "null", ")", "return", "(", "String", ")", "m_remoteProperties", ".", "get", "(", "strProperty", ")", ";", "return", "this", ".", "getFakeRemoteProperty", "(", "strProperty", ")", ";", "}" ]
Get this property from the remote database. This does not make a remote call, it just return the property cached on remote db open. @param strProperty The key to the remote property. @return The value.
[ "Get", "this", "property", "from", "the", "remote", "database", ".", "This", "does", "not", "make", "a", "remote", "call", "it", "just", "return", "the", "property", "cached", "on", "remote", "db", "open", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/db/client/src/main/java/org/jbundle/base/db/client/ClientDatabase.java#L239-L253
151,636
jbundle/jbundle
base/db/client/src/main/java/org/jbundle/base/db/client/ClientDatabase.java
ClientDatabase.getFakeRemoteProperty
public String getFakeRemoteProperty(String strProperty) { if (SQLParams.EDIT_DB_PROPERTY.equalsIgnoreCase(strProperty)) return SQLParams.DB_EDIT_NOT_SUPPORTED; // By default, remote locks are not supported natively by the database return null; }
java
public String getFakeRemoteProperty(String strProperty) { if (SQLParams.EDIT_DB_PROPERTY.equalsIgnoreCase(strProperty)) return SQLParams.DB_EDIT_NOT_SUPPORTED; // By default, remote locks are not supported natively by the database return null; }
[ "public", "String", "getFakeRemoteProperty", "(", "String", "strProperty", ")", "{", "if", "(", "SQLParams", ".", "EDIT_DB_PROPERTY", ".", "equalsIgnoreCase", "(", "strProperty", ")", ")", "return", "SQLParams", ".", "DB_EDIT_NOT_SUPPORTED", ";", "// By default, remote locks are not supported natively by the database", "return", "null", ";", "}" ]
To keep from having to contact the remote database, remote a property that will not effect the logic. @param properties The properties object to add these properties to.
[ "To", "keep", "from", "having", "to", "contact", "the", "remote", "database", "remote", "a", "property", "that", "will", "not", "effect", "the", "logic", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/db/client/src/main/java/org/jbundle/base/db/client/ClientDatabase.java#L258-L263
151,637
jbundle/jbundle
base/db/client/src/main/java/org/jbundle/base/db/client/ClientDatabase.java
ClientDatabase.commit
public void commit() throws DBException { super.commit(); // Will throw an error if something is not set up right. try { if (this.getRemoteDatabase() != null) { synchronized (this.getSyncObject(this.getRemoteDatabase())) { this.getRemoteDatabase().commit(); } } } catch (RemoteException ex) { Utility.getLogger().warning("Remote commit error: " + ex.getMessage()); ex.printStackTrace(); } catch (Exception ex) { throw this.convertError(ex); } }
java
public void commit() throws DBException { super.commit(); // Will throw an error if something is not set up right. try { if (this.getRemoteDatabase() != null) { synchronized (this.getSyncObject(this.getRemoteDatabase())) { this.getRemoteDatabase().commit(); } } } catch (RemoteException ex) { Utility.getLogger().warning("Remote commit error: " + ex.getMessage()); ex.printStackTrace(); } catch (Exception ex) { throw this.convertError(ex); } }
[ "public", "void", "commit", "(", ")", "throws", "DBException", "{", "super", ".", "commit", "(", ")", ";", "// Will throw an error if something is not set up right.", "try", "{", "if", "(", "this", ".", "getRemoteDatabase", "(", ")", "!=", "null", ")", "{", "synchronized", "(", "this", ".", "getSyncObject", "(", "this", ".", "getRemoteDatabase", "(", ")", ")", ")", "{", "this", ".", "getRemoteDatabase", "(", ")", ".", "commit", "(", ")", ";", "}", "}", "}", "catch", "(", "RemoteException", "ex", ")", "{", "Utility", ".", "getLogger", "(", ")", ".", "warning", "(", "\"Remote commit error: \"", "+", "ex", ".", "getMessage", "(", ")", ")", ";", "ex", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "this", ".", "convertError", "(", "ex", ")", ";", "}", "}" ]
Commit the transactions since the last commit. @exception DBException An exception.
[ "Commit", "the", "transactions", "since", "the", "last", "commit", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/db/client/src/main/java/org/jbundle/base/db/client/ClientDatabase.java#L268-L285
151,638
jbundle/jbundle
base/message/trx/src/main/java/org/jbundle/base/message/trx/processor/BaseMessageReplyInProcessor.java
BaseMessageReplyInProcessor.processMessage
public BaseMessage processMessage(BaseMessage message) { if (message == null) return null; this.updateLogFiles(message, true); // Need to change log status to SENTOK (also associate return message log trx ID) (todo) String strReturnQueueName = null; if (message.getMessageHeader() instanceof TrxMessageHeader) strReturnQueueName = (String)((TrxMessageHeader)message.getMessageHeader()).getMessageHeaderMap().get(MessageConstants.RETURN_QUEUE_NAME); if (strReturnQueueName == null) strReturnQueueName = MessageConstants.TRX_RETURN_QUEUE; TrxMessageHeader privateMessageHeader = new TrxMessageHeader(strReturnQueueName, MessageConstants.INTERNET_QUEUE, null); if (message.getMessageHeader().getRegistryIDMatch() == null) { // The registry is probably in the message header Integer intRegistryID = this.getRegistryID(message); if (intRegistryID != null) message.getMessageHeader().setRegistryIDMatch(intRegistryID); } privateMessageHeader.setRegistryIDMatch(message.getMessageHeader().getRegistryIDMatch()); message.setMessageHeader(privateMessageHeader); Environment env = null; if ((this.getTask() != null) && (this.getTask().getApplication() != null)) env = ((BaseApplication)this.getTask().getApplication()).getEnvironment(); if (env == null) env = Environment.getEnvironment(null); App app = null; if (this.getTask() != null) app = this.getTask().getApplication(); MessageManager msgManager = env.getMessageManager(app, true); msgManager.sendMessage(message); return null; }
java
public BaseMessage processMessage(BaseMessage message) { if (message == null) return null; this.updateLogFiles(message, true); // Need to change log status to SENTOK (also associate return message log trx ID) (todo) String strReturnQueueName = null; if (message.getMessageHeader() instanceof TrxMessageHeader) strReturnQueueName = (String)((TrxMessageHeader)message.getMessageHeader()).getMessageHeaderMap().get(MessageConstants.RETURN_QUEUE_NAME); if (strReturnQueueName == null) strReturnQueueName = MessageConstants.TRX_RETURN_QUEUE; TrxMessageHeader privateMessageHeader = new TrxMessageHeader(strReturnQueueName, MessageConstants.INTERNET_QUEUE, null); if (message.getMessageHeader().getRegistryIDMatch() == null) { // The registry is probably in the message header Integer intRegistryID = this.getRegistryID(message); if (intRegistryID != null) message.getMessageHeader().setRegistryIDMatch(intRegistryID); } privateMessageHeader.setRegistryIDMatch(message.getMessageHeader().getRegistryIDMatch()); message.setMessageHeader(privateMessageHeader); Environment env = null; if ((this.getTask() != null) && (this.getTask().getApplication() != null)) env = ((BaseApplication)this.getTask().getApplication()).getEnvironment(); if (env == null) env = Environment.getEnvironment(null); App app = null; if (this.getTask() != null) app = this.getTask().getApplication(); MessageManager msgManager = env.getMessageManager(app, true); msgManager.sendMessage(message); return null; }
[ "public", "BaseMessage", "processMessage", "(", "BaseMessage", "message", ")", "{", "if", "(", "message", "==", "null", ")", "return", "null", ";", "this", ".", "updateLogFiles", "(", "message", ",", "true", ")", ";", "// Need to change log status to SENTOK (also associate return message log trx ID) (todo)", "String", "strReturnQueueName", "=", "null", ";", "if", "(", "message", ".", "getMessageHeader", "(", ")", "instanceof", "TrxMessageHeader", ")", "strReturnQueueName", "=", "(", "String", ")", "(", "(", "TrxMessageHeader", ")", "message", ".", "getMessageHeader", "(", ")", ")", ".", "getMessageHeaderMap", "(", ")", ".", "get", "(", "MessageConstants", ".", "RETURN_QUEUE_NAME", ")", ";", "if", "(", "strReturnQueueName", "==", "null", ")", "strReturnQueueName", "=", "MessageConstants", ".", "TRX_RETURN_QUEUE", ";", "TrxMessageHeader", "privateMessageHeader", "=", "new", "TrxMessageHeader", "(", "strReturnQueueName", ",", "MessageConstants", ".", "INTERNET_QUEUE", ",", "null", ")", ";", "if", "(", "message", ".", "getMessageHeader", "(", ")", ".", "getRegistryIDMatch", "(", ")", "==", "null", ")", "{", "// The registry is probably in the message header", "Integer", "intRegistryID", "=", "this", ".", "getRegistryID", "(", "message", ")", ";", "if", "(", "intRegistryID", "!=", "null", ")", "message", ".", "getMessageHeader", "(", ")", ".", "setRegistryIDMatch", "(", "intRegistryID", ")", ";", "}", "privateMessageHeader", ".", "setRegistryIDMatch", "(", "message", ".", "getMessageHeader", "(", ")", ".", "getRegistryIDMatch", "(", ")", ")", ";", "message", ".", "setMessageHeader", "(", "privateMessageHeader", ")", ";", "Environment", "env", "=", "null", ";", "if", "(", "(", "this", ".", "getTask", "(", ")", "!=", "null", ")", "&&", "(", "this", ".", "getTask", "(", ")", ".", "getApplication", "(", ")", "!=", "null", ")", ")", "env", "=", "(", "(", "BaseApplication", ")", "this", ".", "getTask", "(", ")", ".", "getApplication", "(", ")", ")", ".", "getEnvironment", "(", ")", ";", "if", "(", "env", "==", "null", ")", "env", "=", "Environment", ".", "getEnvironment", "(", "null", ")", ";", "App", "app", "=", "null", ";", "if", "(", "this", ".", "getTask", "(", ")", "!=", "null", ")", "app", "=", "this", ".", "getTask", "(", ")", ".", "getApplication", "(", ")", ";", "MessageManager", "msgManager", "=", "env", ".", "getMessageManager", "(", "app", ",", "true", ")", ";", "msgManager", ".", "sendMessage", "(", "message", ")", ";", "return", "null", ";", "}" ]
Given the converted message for return, do any further processing before returning the message. @param internalMessage The internal return message just as it was converted from the source.
[ "Given", "the", "converted", "message", "for", "return", "do", "any", "further", "processing", "before", "returning", "the", "message", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/message/trx/src/main/java/org/jbundle/base/message/trx/processor/BaseMessageReplyInProcessor.java#L65-L97
151,639
krotscheck/knet-utils
src/main/java/net/krotscheck/util/ResourceUtil.java
ResourceUtil.getPathForResource
public static String getPathForResource(final String resourcePath) { URL path = ResourceUtil.class.getResource(resourcePath); if (path == null) { path = ResourceUtil.class.getResource("/"); File tmpFile = new File(path.getPath(), resourcePath); return tmpFile.getPath(); } return path.getPath(); }
java
public static String getPathForResource(final String resourcePath) { URL path = ResourceUtil.class.getResource(resourcePath); if (path == null) { path = ResourceUtil.class.getResource("/"); File tmpFile = new File(path.getPath(), resourcePath); return tmpFile.getPath(); } return path.getPath(); }
[ "public", "static", "String", "getPathForResource", "(", "final", "String", "resourcePath", ")", "{", "URL", "path", "=", "ResourceUtil", ".", "class", ".", "getResource", "(", "resourcePath", ")", ";", "if", "(", "path", "==", "null", ")", "{", "path", "=", "ResourceUtil", ".", "class", ".", "getResource", "(", "\"/\"", ")", ";", "File", "tmpFile", "=", "new", "File", "(", "path", ".", "getPath", "(", ")", ",", "resourcePath", ")", ";", "return", "tmpFile", ".", "getPath", "(", ")", ";", "}", "return", "path", ".", "getPath", "(", ")", ";", "}" ]
Convert a resource path to an absolute file path. @param resourcePath The resource-relative path to resolve. @return The absolute path to this resource.
[ "Convert", "a", "resource", "path", "to", "an", "absolute", "file", "path", "." ]
36474b012149f4a308f23480cab62e338847a0a6
https://github.com/krotscheck/knet-utils/blob/36474b012149f4a308f23480cab62e338847a0a6/src/main/java/net/krotscheck/util/ResourceUtil.java#L56-L65
151,640
krotscheck/knet-utils
src/main/java/net/krotscheck/util/ResourceUtil.java
ResourceUtil.getFileForResource
public static File getFileForResource(final String resourcePath) { URL path = ResourceUtil.class.getResource(resourcePath); if (path == null) { path = ResourceUtil.class.getResource("/"); return new File(new File(path.getPath()), resourcePath); } return new File(path.getPath()); }
java
public static File getFileForResource(final String resourcePath) { URL path = ResourceUtil.class.getResource(resourcePath); if (path == null) { path = ResourceUtil.class.getResource("/"); return new File(new File(path.getPath()), resourcePath); } return new File(path.getPath()); }
[ "public", "static", "File", "getFileForResource", "(", "final", "String", "resourcePath", ")", "{", "URL", "path", "=", "ResourceUtil", ".", "class", ".", "getResource", "(", "resourcePath", ")", ";", "if", "(", "path", "==", "null", ")", "{", "path", "=", "ResourceUtil", ".", "class", ".", "getResource", "(", "\"/\"", ")", ";", "return", "new", "File", "(", "new", "File", "(", "path", ".", "getPath", "(", ")", ")", ",", "resourcePath", ")", ";", "}", "return", "new", "File", "(", "path", ".", "getPath", "(", ")", ")", ";", "}" ]
Convert a resource path to a File object. @param resourcePath The resource-relative path to resolve. @return A file instance representing the resource in question.
[ "Convert", "a", "resource", "path", "to", "a", "File", "object", "." ]
36474b012149f4a308f23480cab62e338847a0a6
https://github.com/krotscheck/knet-utils/blob/36474b012149f4a308f23480cab62e338847a0a6/src/main/java/net/krotscheck/util/ResourceUtil.java#L73-L81
151,641
krotscheck/knet-utils
src/main/java/net/krotscheck/util/ResourceUtil.java
ResourceUtil.getResourceAsString
public static String getResourceAsString(final String resourcePath) { File resource = getFileForResource(resourcePath); if (!resource.exists() || resource.isDirectory()) { logger.error("Cannot read resource, does not exist" + " (or is a directory)."); return ""; } try { return FileUtils.readFileToString(resource); } catch (IOException ioe) { logger.error(ioe.getMessage()); return ""; } }
java
public static String getResourceAsString(final String resourcePath) { File resource = getFileForResource(resourcePath); if (!resource.exists() || resource.isDirectory()) { logger.error("Cannot read resource, does not exist" + " (or is a directory)."); return ""; } try { return FileUtils.readFileToString(resource); } catch (IOException ioe) { logger.error(ioe.getMessage()); return ""; } }
[ "public", "static", "String", "getResourceAsString", "(", "final", "String", "resourcePath", ")", "{", "File", "resource", "=", "getFileForResource", "(", "resourcePath", ")", ";", "if", "(", "!", "resource", ".", "exists", "(", ")", "||", "resource", ".", "isDirectory", "(", ")", ")", "{", "logger", ".", "error", "(", "\"Cannot read resource, does not exist\"", "+", "\" (or is a directory).\"", ")", ";", "return", "\"\"", ";", "}", "try", "{", "return", "FileUtils", ".", "readFileToString", "(", "resource", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "logger", ".", "error", "(", "ioe", ".", "getMessage", "(", ")", ")", ";", "return", "\"\"", ";", "}", "}" ]
Read the resource found at a specific path into a string. @param resourcePath The path to the resource. @return The resource as a string, or an empty string if the resource was not found.
[ "Read", "the", "resource", "found", "at", "a", "specific", "path", "into", "a", "string", "." ]
36474b012149f4a308f23480cab62e338847a0a6
https://github.com/krotscheck/knet-utils/blob/36474b012149f4a308f23480cab62e338847a0a6/src/main/java/net/krotscheck/util/ResourceUtil.java#L90-L105
151,642
krotscheck/knet-utils
src/main/java/net/krotscheck/util/ResourceUtil.java
ResourceUtil.getResourceAsStream
public static InputStream getResourceAsStream(final String resourcePath) { File resource = getFileForResource(resourcePath); if (!resource.exists() || resource.isDirectory()) { logger.error("Cannot read resource, does not exist" + " (or is a directory)."); return new NullInputStream(0); } try { return new FileInputStream(resource); } catch (IOException ioe) { logger.error(ioe.getMessage()); return new NullInputStream(0); } }
java
public static InputStream getResourceAsStream(final String resourcePath) { File resource = getFileForResource(resourcePath); if (!resource.exists() || resource.isDirectory()) { logger.error("Cannot read resource, does not exist" + " (or is a directory)."); return new NullInputStream(0); } try { return new FileInputStream(resource); } catch (IOException ioe) { logger.error(ioe.getMessage()); return new NullInputStream(0); } }
[ "public", "static", "InputStream", "getResourceAsStream", "(", "final", "String", "resourcePath", ")", "{", "File", "resource", "=", "getFileForResource", "(", "resourcePath", ")", ";", "if", "(", "!", "resource", ".", "exists", "(", ")", "||", "resource", ".", "isDirectory", "(", ")", ")", "{", "logger", ".", "error", "(", "\"Cannot read resource, does not exist\"", "+", "\" (or is a directory).\"", ")", ";", "return", "new", "NullInputStream", "(", "0", ")", ";", "}", "try", "{", "return", "new", "FileInputStream", "(", "resource", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "logger", ".", "error", "(", "ioe", ".", "getMessage", "(", ")", ")", ";", "return", "new", "NullInputStream", "(", "0", ")", ";", "}", "}" ]
Read the resource found at the given path into a stream. @param resourcePath The path to the resource. @return The resource as an input stream. If the resource was not found, this will be the NullInputStream.
[ "Read", "the", "resource", "found", "at", "the", "given", "path", "into", "a", "stream", "." ]
36474b012149f4a308f23480cab62e338847a0a6
https://github.com/krotscheck/knet-utils/blob/36474b012149f4a308f23480cab62e338847a0a6/src/main/java/net/krotscheck/util/ResourceUtil.java#L114-L129
151,643
wigforss/Ka-Commons-Collection
src/main/java/org/kasource/commons/collection/builder/SetBuilder.java
SetBuilder.add
public SetBuilder<T> add(T... items) { set.addAll(Arrays.asList(items)); return this; }
java
public SetBuilder<T> add(T... items) { set.addAll(Arrays.asList(items)); return this; }
[ "public", "SetBuilder", "<", "T", ">", "add", "(", "T", "...", "items", ")", "{", "set", ".", "addAll", "(", "Arrays", ".", "asList", "(", "items", ")", ")", ";", "return", "this", ";", "}" ]
Adds items to the set. @param items vargs of items to add. @return This builder
[ "Adds", "items", "to", "the", "set", "." ]
bee25f16ec4a65af0005bf0a9151a891cfe23e8e
https://github.com/wigforss/Ka-Commons-Collection/blob/bee25f16ec4a65af0005bf0a9151a891cfe23e8e/src/main/java/org/kasource/commons/collection/builder/SetBuilder.java#L57-L60
151,644
jbundle/jbundle
base/screen/view/html/src/main/java/org/jbundle/base/screen/view/html/HBaseGridScreen.java
HBaseGridScreen.getPrintOptions
public int getPrintOptions() throws DBException { int iHtmlOptions = HtmlConstants.HTML_DISPLAY; if (((BaseGridScreen)this.getScreenField()).getEditing()) iHtmlOptions |= HtmlConstants.HTML_INPUT; String strParamForm = this.getProperty(HtmlConstants.FORMS); // Display record if ((strParamForm == null) || (strParamForm.length() == 0)) strParamForm = HtmlConstants.BOTHIFDATA; // First, move any params up boolean bPrintReport = true; if ((strParamForm.equalsIgnoreCase(HtmlConstants.INPUT)) || (strParamForm.equalsIgnoreCase(HtmlConstants.BOTHIFDATA)) || (strParamForm.equalsIgnoreCase(HtmlConstants.BOTH))) { // For these options, check to see if the input data has been entered. bPrintReport = false; boolean bScreenFound = false; int iNumCols = ((BaseGridScreen)this.getScreenField()).getSFieldCount(); for (int iIndex = 0; iIndex < iNumCols; iIndex++) { ScreenField sField = ((BaseGridScreen)this.getScreenField()).getSField(iIndex); if (sField instanceof ToolScreen) if ((!(sField instanceof DisplayToolbar)) && (!(sField instanceof MaintToolbar)) && (!(sField instanceof MenuToolbar))) { // Output the Input screen HScreenField vField = (HScreenField)sField.getScreenFieldView(); if (vField.moveControlInput(Constants.BLANK) == DBConstants.NORMAL_RETURN) // I already moved them, but I need to know if they were passed bPrintReport = true; bScreenFound = true; } } if (!bScreenFound) bPrintReport = true; // If no screen, say params were entered if (!bPrintReport) if (this.getProperty(DBConstants.STRING_OBJECT_ID_HANDLE) != null) bPrintReport = true; // Special Grid with a header record = found } if (strParamForm.equalsIgnoreCase(HtmlConstants.DISPLAY)) iHtmlOptions |= HtmlConstants.HTML_DISPLAY; // No toolbar, print report else if (strParamForm.equalsIgnoreCase(HtmlConstants.DATA)) iHtmlOptions |= HtmlConstants.PRINT_TOOLBAR_BEFORE; // Toolbar and report else if (strParamForm.equalsIgnoreCase(HtmlConstants.INPUT)) iHtmlOptions |= HtmlConstants.PRINT_TOOLBAR_BEFORE | HtmlConstants.DONT_PRINT_SCREEN; // Toolbar, no report else if (strParamForm.equalsIgnoreCase(HtmlConstants.BOTH)) iHtmlOptions |= HtmlConstants.PRINT_TOOLBAR_BEFORE; // Toolbar and report else if (strParamForm.equalsIgnoreCase(HtmlConstants.BOTHIFDATA)) { iHtmlOptions |= HtmlConstants.PRINT_TOOLBAR_BEFORE; // Toolscreen is always displayed if (!bPrintReport) iHtmlOptions |= HtmlConstants.DONT_PRINT_SCREEN; } return iHtmlOptions; }
java
public int getPrintOptions() throws DBException { int iHtmlOptions = HtmlConstants.HTML_DISPLAY; if (((BaseGridScreen)this.getScreenField()).getEditing()) iHtmlOptions |= HtmlConstants.HTML_INPUT; String strParamForm = this.getProperty(HtmlConstants.FORMS); // Display record if ((strParamForm == null) || (strParamForm.length() == 0)) strParamForm = HtmlConstants.BOTHIFDATA; // First, move any params up boolean bPrintReport = true; if ((strParamForm.equalsIgnoreCase(HtmlConstants.INPUT)) || (strParamForm.equalsIgnoreCase(HtmlConstants.BOTHIFDATA)) || (strParamForm.equalsIgnoreCase(HtmlConstants.BOTH))) { // For these options, check to see if the input data has been entered. bPrintReport = false; boolean bScreenFound = false; int iNumCols = ((BaseGridScreen)this.getScreenField()).getSFieldCount(); for (int iIndex = 0; iIndex < iNumCols; iIndex++) { ScreenField sField = ((BaseGridScreen)this.getScreenField()).getSField(iIndex); if (sField instanceof ToolScreen) if ((!(sField instanceof DisplayToolbar)) && (!(sField instanceof MaintToolbar)) && (!(sField instanceof MenuToolbar))) { // Output the Input screen HScreenField vField = (HScreenField)sField.getScreenFieldView(); if (vField.moveControlInput(Constants.BLANK) == DBConstants.NORMAL_RETURN) // I already moved them, but I need to know if they were passed bPrintReport = true; bScreenFound = true; } } if (!bScreenFound) bPrintReport = true; // If no screen, say params were entered if (!bPrintReport) if (this.getProperty(DBConstants.STRING_OBJECT_ID_HANDLE) != null) bPrintReport = true; // Special Grid with a header record = found } if (strParamForm.equalsIgnoreCase(HtmlConstants.DISPLAY)) iHtmlOptions |= HtmlConstants.HTML_DISPLAY; // No toolbar, print report else if (strParamForm.equalsIgnoreCase(HtmlConstants.DATA)) iHtmlOptions |= HtmlConstants.PRINT_TOOLBAR_BEFORE; // Toolbar and report else if (strParamForm.equalsIgnoreCase(HtmlConstants.INPUT)) iHtmlOptions |= HtmlConstants.PRINT_TOOLBAR_BEFORE | HtmlConstants.DONT_PRINT_SCREEN; // Toolbar, no report else if (strParamForm.equalsIgnoreCase(HtmlConstants.BOTH)) iHtmlOptions |= HtmlConstants.PRINT_TOOLBAR_BEFORE; // Toolbar and report else if (strParamForm.equalsIgnoreCase(HtmlConstants.BOTHIFDATA)) { iHtmlOptions |= HtmlConstants.PRINT_TOOLBAR_BEFORE; // Toolscreen is always displayed if (!bPrintReport) iHtmlOptions |= HtmlConstants.DONT_PRINT_SCREEN; } return iHtmlOptions; }
[ "public", "int", "getPrintOptions", "(", ")", "throws", "DBException", "{", "int", "iHtmlOptions", "=", "HtmlConstants", ".", "HTML_DISPLAY", ";", "if", "(", "(", "(", "BaseGridScreen", ")", "this", ".", "getScreenField", "(", ")", ")", ".", "getEditing", "(", ")", ")", "iHtmlOptions", "|=", "HtmlConstants", ".", "HTML_INPUT", ";", "String", "strParamForm", "=", "this", ".", "getProperty", "(", "HtmlConstants", ".", "FORMS", ")", ";", "// Display record", "if", "(", "(", "strParamForm", "==", "null", ")", "||", "(", "strParamForm", ".", "length", "(", ")", "==", "0", ")", ")", "strParamForm", "=", "HtmlConstants", ".", "BOTHIFDATA", ";", "// First, move any params up", "boolean", "bPrintReport", "=", "true", ";", "if", "(", "(", "strParamForm", ".", "equalsIgnoreCase", "(", "HtmlConstants", ".", "INPUT", ")", ")", "||", "(", "strParamForm", ".", "equalsIgnoreCase", "(", "HtmlConstants", ".", "BOTHIFDATA", ")", ")", "||", "(", "strParamForm", ".", "equalsIgnoreCase", "(", "HtmlConstants", ".", "BOTH", ")", ")", ")", "{", "// For these options, check to see if the input data has been entered.", "bPrintReport", "=", "false", ";", "boolean", "bScreenFound", "=", "false", ";", "int", "iNumCols", "=", "(", "(", "BaseGridScreen", ")", "this", ".", "getScreenField", "(", ")", ")", ".", "getSFieldCount", "(", ")", ";", "for", "(", "int", "iIndex", "=", "0", ";", "iIndex", "<", "iNumCols", ";", "iIndex", "++", ")", "{", "ScreenField", "sField", "=", "(", "(", "BaseGridScreen", ")", "this", ".", "getScreenField", "(", ")", ")", ".", "getSField", "(", "iIndex", ")", ";", "if", "(", "sField", "instanceof", "ToolScreen", ")", "if", "(", "(", "!", "(", "sField", "instanceof", "DisplayToolbar", ")", ")", "&&", "(", "!", "(", "sField", "instanceof", "MaintToolbar", ")", ")", "&&", "(", "!", "(", "sField", "instanceof", "MenuToolbar", ")", ")", ")", "{", "// Output the Input screen", "HScreenField", "vField", "=", "(", "HScreenField", ")", "sField", ".", "getScreenFieldView", "(", ")", ";", "if", "(", "vField", ".", "moveControlInput", "(", "Constants", ".", "BLANK", ")", "==", "DBConstants", ".", "NORMAL_RETURN", ")", "// I already moved them, but I need to know if they were passed", "bPrintReport", "=", "true", ";", "bScreenFound", "=", "true", ";", "}", "}", "if", "(", "!", "bScreenFound", ")", "bPrintReport", "=", "true", ";", "// If no screen, say params were entered", "if", "(", "!", "bPrintReport", ")", "if", "(", "this", ".", "getProperty", "(", "DBConstants", ".", "STRING_OBJECT_ID_HANDLE", ")", "!=", "null", ")", "bPrintReport", "=", "true", ";", "// Special Grid with a header record = found", "}", "if", "(", "strParamForm", ".", "equalsIgnoreCase", "(", "HtmlConstants", ".", "DISPLAY", ")", ")", "iHtmlOptions", "|=", "HtmlConstants", ".", "HTML_DISPLAY", ";", "// No toolbar, print report", "else", "if", "(", "strParamForm", ".", "equalsIgnoreCase", "(", "HtmlConstants", ".", "DATA", ")", ")", "iHtmlOptions", "|=", "HtmlConstants", ".", "PRINT_TOOLBAR_BEFORE", ";", "// Toolbar and report", "else", "if", "(", "strParamForm", ".", "equalsIgnoreCase", "(", "HtmlConstants", ".", "INPUT", ")", ")", "iHtmlOptions", "|=", "HtmlConstants", ".", "PRINT_TOOLBAR_BEFORE", "|", "HtmlConstants", ".", "DONT_PRINT_SCREEN", ";", "// Toolbar, no report", "else", "if", "(", "strParamForm", ".", "equalsIgnoreCase", "(", "HtmlConstants", ".", "BOTH", ")", ")", "iHtmlOptions", "|=", "HtmlConstants", ".", "PRINT_TOOLBAR_BEFORE", ";", "// Toolbar and report", "else", "if", "(", "strParamForm", ".", "equalsIgnoreCase", "(", "HtmlConstants", ".", "BOTHIFDATA", ")", ")", "{", "iHtmlOptions", "|=", "HtmlConstants", ".", "PRINT_TOOLBAR_BEFORE", ";", "// Toolscreen is always displayed", "if", "(", "!", "bPrintReport", ")", "iHtmlOptions", "|=", "HtmlConstants", ".", "DONT_PRINT_SCREEN", ";", "}", "return", "iHtmlOptions", ";", "}" ]
display this screen in html input format. @return The HTML options. @exception DBException File exception.
[ "display", "this", "screen", "in", "html", "input", "format", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/view/html/src/main/java/org/jbundle/base/screen/view/html/HBaseGridScreen.java#L73-L127
151,645
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.readFileData
protected void readFileData(final ParserData parserData, final BufferedReader br) throws IOException { // Read in the entire file so we can peek ahead later on String line; while ((line = br.readLine()) != null) { parserData.addLine(line); } }
java
protected void readFileData(final ParserData parserData, final BufferedReader br) throws IOException { // Read in the entire file so we can peek ahead later on String line; while ((line = br.readLine()) != null) { parserData.addLine(line); } }
[ "protected", "void", "readFileData", "(", "final", "ParserData", "parserData", ",", "final", "BufferedReader", "br", ")", "throws", "IOException", "{", "// Read in the entire file so we can peek ahead later on", "String", "line", ";", "while", "(", "(", "line", "=", "br", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "parserData", ".", "addLine", "(", "line", ")", ";", "}", "}" ]
Reads the data from a file that is passed into a BufferedReader and processes it accordingly. @param parserData @param br A BufferedReader object that has been initialised with a file's data. @throws IOException Thrown if an IO Error occurs while reading from the BufferedReader.
[ "Reads", "the", "data", "from", "a", "file", "that", "is", "passed", "into", "a", "BufferedReader", "and", "processes", "it", "accordingly", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L198-L204
151,646
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.processSpec
protected ParserResults processSpec(final ParserData parserData, final ParsingMode mode, final boolean processProcesses) { // Find the first line that isn't a blank line or a comment while (parserData.getLines().peek() != null) { final String input = parserData.getLines().peek(); if (isCommentLine(input) || isBlankLine(input)) { parserData.setLineCount(parserData.getLineCount() + 1); if (isCommentLine(input)) { parserData.getContentSpec().appendComment(input); } else if (isBlankLine(input)) { parserData.getContentSpec().appendChild(new TextNode("\n")); } parserData.getLines().poll(); continue; } else { // We've found the first line so break the loop break; } } // Process the content spec depending on the mode if (mode == ParsingMode.NEW) { return processNewSpec(parserData, processProcesses); } else if (mode == ParsingMode.EDITED) { return processEditedSpec(parserData, processProcesses); } else { return processEitherSpec(parserData, processProcesses); } }
java
protected ParserResults processSpec(final ParserData parserData, final ParsingMode mode, final boolean processProcesses) { // Find the first line that isn't a blank line or a comment while (parserData.getLines().peek() != null) { final String input = parserData.getLines().peek(); if (isCommentLine(input) || isBlankLine(input)) { parserData.setLineCount(parserData.getLineCount() + 1); if (isCommentLine(input)) { parserData.getContentSpec().appendComment(input); } else if (isBlankLine(input)) { parserData.getContentSpec().appendChild(new TextNode("\n")); } parserData.getLines().poll(); continue; } else { // We've found the first line so break the loop break; } } // Process the content spec depending on the mode if (mode == ParsingMode.NEW) { return processNewSpec(parserData, processProcesses); } else if (mode == ParsingMode.EDITED) { return processEditedSpec(parserData, processProcesses); } else { return processEitherSpec(parserData, processProcesses); } }
[ "protected", "ParserResults", "processSpec", "(", "final", "ParserData", "parserData", ",", "final", "ParsingMode", "mode", ",", "final", "boolean", "processProcesses", ")", "{", "// Find the first line that isn't a blank line or a comment", "while", "(", "parserData", ".", "getLines", "(", ")", ".", "peek", "(", ")", "!=", "null", ")", "{", "final", "String", "input", "=", "parserData", ".", "getLines", "(", ")", ".", "peek", "(", ")", ";", "if", "(", "isCommentLine", "(", "input", ")", "||", "isBlankLine", "(", "input", ")", ")", "{", "parserData", ".", "setLineCount", "(", "parserData", ".", "getLineCount", "(", ")", "+", "1", ")", ";", "if", "(", "isCommentLine", "(", "input", ")", ")", "{", "parserData", ".", "getContentSpec", "(", ")", ".", "appendComment", "(", "input", ")", ";", "}", "else", "if", "(", "isBlankLine", "(", "input", ")", ")", "{", "parserData", ".", "getContentSpec", "(", ")", ".", "appendChild", "(", "new", "TextNode", "(", "\"\\n\"", ")", ")", ";", "}", "parserData", ".", "getLines", "(", ")", ".", "poll", "(", ")", ";", "continue", ";", "}", "else", "{", "// We've found the first line so break the loop", "break", ";", "}", "}", "// Process the content spec depending on the mode", "if", "(", "mode", "==", "ParsingMode", ".", "NEW", ")", "{", "return", "processNewSpec", "(", "parserData", ",", "processProcesses", ")", ";", "}", "else", "if", "(", "mode", "==", "ParsingMode", ".", "EDITED", ")", "{", "return", "processEditedSpec", "(", "parserData", ",", "processProcesses", ")", ";", "}", "else", "{", "return", "processEitherSpec", "(", "parserData", ",", "processProcesses", ")", ";", "}", "}" ]
Starting method to process a Content Specification string into a ContentSpec object. @param parserData @param mode The mode to parse the string as. @param processProcesses Whether or not processes should call the data provider to be processed. @return True if the content spec was processed successfully otherwise false.
[ "Starting", "method", "to", "process", "a", "Content", "Specification", "string", "into", "a", "ContentSpec", "object", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L214-L243
151,647
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.processNewSpec
protected ParserResults processNewSpec(final ParserData parserData, final boolean processProcesses) { final String input = parserData.getLines().poll(); parserData.setLineCount(parserData.getLineCount() + 1); try { final Pair<String, String> keyValuePair = ProcessorUtilities.getAndValidateKeyValuePair(input); final String key = keyValuePair.getFirst(); final String value = keyValuePair.getSecond(); if (key.equalsIgnoreCase(CommonConstants.CS_TITLE_TITLE)) { parserData.getContentSpec().setTitle(value); // Process the rest of the spec now that we know the start is correct return processSpecContents(parserData, processProcesses); } else if (key.equalsIgnoreCase(CommonConstants.CS_CHECKSUM_TITLE)) { log.error(ProcessorConstants.ERROR_INCORRECT_NEW_MODE_MSG); return new ParserResults(false, null); } else { log.error(ProcessorConstants.ERROR_INCORRECT_FILE_FORMAT_MSG); return new ParserResults(false, null); } } catch (InvalidKeyValueException e) { log.error(ProcessorConstants.ERROR_INCORRECT_FILE_FORMAT_MSG, e); return new ParserResults(false, null); } }
java
protected ParserResults processNewSpec(final ParserData parserData, final boolean processProcesses) { final String input = parserData.getLines().poll(); parserData.setLineCount(parserData.getLineCount() + 1); try { final Pair<String, String> keyValuePair = ProcessorUtilities.getAndValidateKeyValuePair(input); final String key = keyValuePair.getFirst(); final String value = keyValuePair.getSecond(); if (key.equalsIgnoreCase(CommonConstants.CS_TITLE_TITLE)) { parserData.getContentSpec().setTitle(value); // Process the rest of the spec now that we know the start is correct return processSpecContents(parserData, processProcesses); } else if (key.equalsIgnoreCase(CommonConstants.CS_CHECKSUM_TITLE)) { log.error(ProcessorConstants.ERROR_INCORRECT_NEW_MODE_MSG); return new ParserResults(false, null); } else { log.error(ProcessorConstants.ERROR_INCORRECT_FILE_FORMAT_MSG); return new ParserResults(false, null); } } catch (InvalidKeyValueException e) { log.error(ProcessorConstants.ERROR_INCORRECT_FILE_FORMAT_MSG, e); return new ParserResults(false, null); } }
[ "protected", "ParserResults", "processNewSpec", "(", "final", "ParserData", "parserData", ",", "final", "boolean", "processProcesses", ")", "{", "final", "String", "input", "=", "parserData", ".", "getLines", "(", ")", ".", "poll", "(", ")", ";", "parserData", ".", "setLineCount", "(", "parserData", ".", "getLineCount", "(", ")", "+", "1", ")", ";", "try", "{", "final", "Pair", "<", "String", ",", "String", ">", "keyValuePair", "=", "ProcessorUtilities", ".", "getAndValidateKeyValuePair", "(", "input", ")", ";", "final", "String", "key", "=", "keyValuePair", ".", "getFirst", "(", ")", ";", "final", "String", "value", "=", "keyValuePair", ".", "getSecond", "(", ")", ";", "if", "(", "key", ".", "equalsIgnoreCase", "(", "CommonConstants", ".", "CS_TITLE_TITLE", ")", ")", "{", "parserData", ".", "getContentSpec", "(", ")", ".", "setTitle", "(", "value", ")", ";", "// Process the rest of the spec now that we know the start is correct", "return", "processSpecContents", "(", "parserData", ",", "processProcesses", ")", ";", "}", "else", "if", "(", "key", ".", "equalsIgnoreCase", "(", "CommonConstants", ".", "CS_CHECKSUM_TITLE", ")", ")", "{", "log", ".", "error", "(", "ProcessorConstants", ".", "ERROR_INCORRECT_NEW_MODE_MSG", ")", ";", "return", "new", "ParserResults", "(", "false", ",", "null", ")", ";", "}", "else", "{", "log", ".", "error", "(", "ProcessorConstants", ".", "ERROR_INCORRECT_FILE_FORMAT_MSG", ")", ";", "return", "new", "ParserResults", "(", "false", ",", "null", ")", ";", "}", "}", "catch", "(", "InvalidKeyValueException", "e", ")", "{", "log", ".", "error", "(", "ProcessorConstants", ".", "ERROR_INCORRECT_FILE_FORMAT_MSG", ",", "e", ")", ";", "return", "new", "ParserResults", "(", "false", ",", "null", ")", ";", "}", "}" ]
Process a New Content Specification. That is that it should start with a Title, instead of a CHECKSUM and ID. @param parserData @param processProcesses If processes should be processed to populate the relationships. @return True if the content spec was processed successfully otherwise false.
[ "Process", "a", "New", "Content", "Specification", ".", "That", "is", "that", "it", "should", "start", "with", "a", "Title", "instead", "of", "a", "CHECKSUM", "and", "ID", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L252-L277
151,648
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.processEditedSpec
protected ParserResults processEditedSpec(final ParserData parserData, final boolean processProcesses) { final String input = parserData.getLines().poll(); parserData.setLineCount(parserData.getLineCount() + 1); try { final Pair<String, String> keyValuePair = ProcessorUtilities.getAndValidateKeyValuePair(input); final String key = keyValuePair.getFirst(); final String value = keyValuePair.getSecond(); if (key.equalsIgnoreCase(CommonConstants.CS_CHECKSUM_TITLE)) { parserData.getContentSpec().setChecksum(value); // Read in the Content Spec ID final String specIdLine = parserData.getLines().poll(); parserData.setLineCount(parserData.getLineCount() + 1); if (specIdLine != null) { final Pair<String, String> specIdPair = ProcessorUtilities.getAndValidateKeyValuePair(specIdLine); final String specIdKey = specIdPair.getFirst(); final String specIdValue = specIdPair.getSecond(); if (specIdKey.equalsIgnoreCase(CommonConstants.CS_ID_TITLE)) { int contentSpecId; try { contentSpecId = Integer.parseInt(specIdValue); } catch (NumberFormatException e) { log.error(format(ProcessorConstants.ERROR_INVALID_CS_ID_FORMAT_MSG, specIdLine.trim())); return new ParserResults(false, null); } parserData.getContentSpec().setId(contentSpecId); return processSpecContents(parserData, processProcesses); } else { log.error(ProcessorConstants.ERROR_CS_NO_CHECKSUM_MSG); return new ParserResults(false, null); } } else { log.error(ProcessorConstants.ERROR_INCORRECT_FILE_FORMAT_MSG); return new ParserResults(false, null); } } else if (key.equalsIgnoreCase(CommonConstants.CS_ID_TITLE)) { int contentSpecId; try { contentSpecId = Integer.parseInt(value); } catch (NumberFormatException e) { log.error(format(ProcessorConstants.ERROR_INVALID_CS_ID_FORMAT_MSG, input.trim())); return new ParserResults(false, null); } parserData.getContentSpec().setId(contentSpecId); return processSpecContents(parserData, processProcesses); } else { log.error(ProcessorConstants.ERROR_INCORRECT_EDIT_MODE_MSG); return new ParserResults(false, null); } } catch (InvalidKeyValueException e) { log.error(ProcessorConstants.ERROR_INCORRECT_FILE_FORMAT_MSG, e); return new ParserResults(false, null); } }
java
protected ParserResults processEditedSpec(final ParserData parserData, final boolean processProcesses) { final String input = parserData.getLines().poll(); parserData.setLineCount(parserData.getLineCount() + 1); try { final Pair<String, String> keyValuePair = ProcessorUtilities.getAndValidateKeyValuePair(input); final String key = keyValuePair.getFirst(); final String value = keyValuePair.getSecond(); if (key.equalsIgnoreCase(CommonConstants.CS_CHECKSUM_TITLE)) { parserData.getContentSpec().setChecksum(value); // Read in the Content Spec ID final String specIdLine = parserData.getLines().poll(); parserData.setLineCount(parserData.getLineCount() + 1); if (specIdLine != null) { final Pair<String, String> specIdPair = ProcessorUtilities.getAndValidateKeyValuePair(specIdLine); final String specIdKey = specIdPair.getFirst(); final String specIdValue = specIdPair.getSecond(); if (specIdKey.equalsIgnoreCase(CommonConstants.CS_ID_TITLE)) { int contentSpecId; try { contentSpecId = Integer.parseInt(specIdValue); } catch (NumberFormatException e) { log.error(format(ProcessorConstants.ERROR_INVALID_CS_ID_FORMAT_MSG, specIdLine.trim())); return new ParserResults(false, null); } parserData.getContentSpec().setId(contentSpecId); return processSpecContents(parserData, processProcesses); } else { log.error(ProcessorConstants.ERROR_CS_NO_CHECKSUM_MSG); return new ParserResults(false, null); } } else { log.error(ProcessorConstants.ERROR_INCORRECT_FILE_FORMAT_MSG); return new ParserResults(false, null); } } else if (key.equalsIgnoreCase(CommonConstants.CS_ID_TITLE)) { int contentSpecId; try { contentSpecId = Integer.parseInt(value); } catch (NumberFormatException e) { log.error(format(ProcessorConstants.ERROR_INVALID_CS_ID_FORMAT_MSG, input.trim())); return new ParserResults(false, null); } parserData.getContentSpec().setId(contentSpecId); return processSpecContents(parserData, processProcesses); } else { log.error(ProcessorConstants.ERROR_INCORRECT_EDIT_MODE_MSG); return new ParserResults(false, null); } } catch (InvalidKeyValueException e) { log.error(ProcessorConstants.ERROR_INCORRECT_FILE_FORMAT_MSG, e); return new ParserResults(false, null); } }
[ "protected", "ParserResults", "processEditedSpec", "(", "final", "ParserData", "parserData", ",", "final", "boolean", "processProcesses", ")", "{", "final", "String", "input", "=", "parserData", ".", "getLines", "(", ")", ".", "poll", "(", ")", ";", "parserData", ".", "setLineCount", "(", "parserData", ".", "getLineCount", "(", ")", "+", "1", ")", ";", "try", "{", "final", "Pair", "<", "String", ",", "String", ">", "keyValuePair", "=", "ProcessorUtilities", ".", "getAndValidateKeyValuePair", "(", "input", ")", ";", "final", "String", "key", "=", "keyValuePair", ".", "getFirst", "(", ")", ";", "final", "String", "value", "=", "keyValuePair", ".", "getSecond", "(", ")", ";", "if", "(", "key", ".", "equalsIgnoreCase", "(", "CommonConstants", ".", "CS_CHECKSUM_TITLE", ")", ")", "{", "parserData", ".", "getContentSpec", "(", ")", ".", "setChecksum", "(", "value", ")", ";", "// Read in the Content Spec ID", "final", "String", "specIdLine", "=", "parserData", ".", "getLines", "(", ")", ".", "poll", "(", ")", ";", "parserData", ".", "setLineCount", "(", "parserData", ".", "getLineCount", "(", ")", "+", "1", ")", ";", "if", "(", "specIdLine", "!=", "null", ")", "{", "final", "Pair", "<", "String", ",", "String", ">", "specIdPair", "=", "ProcessorUtilities", ".", "getAndValidateKeyValuePair", "(", "specIdLine", ")", ";", "final", "String", "specIdKey", "=", "specIdPair", ".", "getFirst", "(", ")", ";", "final", "String", "specIdValue", "=", "specIdPair", ".", "getSecond", "(", ")", ";", "if", "(", "specIdKey", ".", "equalsIgnoreCase", "(", "CommonConstants", ".", "CS_ID_TITLE", ")", ")", "{", "int", "contentSpecId", ";", "try", "{", "contentSpecId", "=", "Integer", ".", "parseInt", "(", "specIdValue", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "log", ".", "error", "(", "format", "(", "ProcessorConstants", ".", "ERROR_INVALID_CS_ID_FORMAT_MSG", ",", "specIdLine", ".", "trim", "(", ")", ")", ")", ";", "return", "new", "ParserResults", "(", "false", ",", "null", ")", ";", "}", "parserData", ".", "getContentSpec", "(", ")", ".", "setId", "(", "contentSpecId", ")", ";", "return", "processSpecContents", "(", "parserData", ",", "processProcesses", ")", ";", "}", "else", "{", "log", ".", "error", "(", "ProcessorConstants", ".", "ERROR_CS_NO_CHECKSUM_MSG", ")", ";", "return", "new", "ParserResults", "(", "false", ",", "null", ")", ";", "}", "}", "else", "{", "log", ".", "error", "(", "ProcessorConstants", ".", "ERROR_INCORRECT_FILE_FORMAT_MSG", ")", ";", "return", "new", "ParserResults", "(", "false", ",", "null", ")", ";", "}", "}", "else", "if", "(", "key", ".", "equalsIgnoreCase", "(", "CommonConstants", ".", "CS_ID_TITLE", ")", ")", "{", "int", "contentSpecId", ";", "try", "{", "contentSpecId", "=", "Integer", ".", "parseInt", "(", "value", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "log", ".", "error", "(", "format", "(", "ProcessorConstants", ".", "ERROR_INVALID_CS_ID_FORMAT_MSG", ",", "input", ".", "trim", "(", ")", ")", ")", ";", "return", "new", "ParserResults", "(", "false", ",", "null", ")", ";", "}", "parserData", ".", "getContentSpec", "(", ")", ".", "setId", "(", "contentSpecId", ")", ";", "return", "processSpecContents", "(", "parserData", ",", "processProcesses", ")", ";", "}", "else", "{", "log", ".", "error", "(", "ProcessorConstants", ".", "ERROR_INCORRECT_EDIT_MODE_MSG", ")", ";", "return", "new", "ParserResults", "(", "false", ",", "null", ")", ";", "}", "}", "catch", "(", "InvalidKeyValueException", "e", ")", "{", "log", ".", "error", "(", "ProcessorConstants", ".", "ERROR_INCORRECT_FILE_FORMAT_MSG", ",", "e", ")", ";", "return", "new", "ParserResults", "(", "false", ",", "null", ")", ";", "}", "}" ]
Process an Edited Content Specification. That is that it should start with a CHECKSUM and ID, instead of a Title. @param parserData @param processProcesses If processes should be processed to populate the relationships. @return True if the content spec was processed successfully otherwise false.
[ "Process", "an", "Edited", "Content", "Specification", ".", "That", "is", "that", "it", "should", "start", "with", "a", "CHECKSUM", "and", "ID", "instead", "of", "a", "Title", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L286-L343
151,649
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.processEitherSpec
protected ParserResults processEitherSpec(final ParserData parserData, final boolean processProcesses) { try { final Pair<String, String> keyValuePair = ProcessorUtilities.getAndValidateKeyValuePair(parserData.getLines().peek()); final String key = keyValuePair.getFirst(); if (key.equalsIgnoreCase(CommonConstants.CS_CHECKSUM_TITLE) || key.equalsIgnoreCase(CommonConstants.CS_ID_TITLE)) { return processEditedSpec(parserData, processProcesses); } else { return processNewSpec(parserData, processProcesses); } } catch (InvalidKeyValueException e) { log.error(ProcessorConstants.ERROR_INCORRECT_FILE_FORMAT_MSG, e); return new ParserResults(false, null); } }
java
protected ParserResults processEitherSpec(final ParserData parserData, final boolean processProcesses) { try { final Pair<String, String> keyValuePair = ProcessorUtilities.getAndValidateKeyValuePair(parserData.getLines().peek()); final String key = keyValuePair.getFirst(); if (key.equalsIgnoreCase(CommonConstants.CS_CHECKSUM_TITLE) || key.equalsIgnoreCase(CommonConstants.CS_ID_TITLE)) { return processEditedSpec(parserData, processProcesses); } else { return processNewSpec(parserData, processProcesses); } } catch (InvalidKeyValueException e) { log.error(ProcessorConstants.ERROR_INCORRECT_FILE_FORMAT_MSG, e); return new ParserResults(false, null); } }
[ "protected", "ParserResults", "processEitherSpec", "(", "final", "ParserData", "parserData", ",", "final", "boolean", "processProcesses", ")", "{", "try", "{", "final", "Pair", "<", "String", ",", "String", ">", "keyValuePair", "=", "ProcessorUtilities", ".", "getAndValidateKeyValuePair", "(", "parserData", ".", "getLines", "(", ")", ".", "peek", "(", ")", ")", ";", "final", "String", "key", "=", "keyValuePair", ".", "getFirst", "(", ")", ";", "if", "(", "key", ".", "equalsIgnoreCase", "(", "CommonConstants", ".", "CS_CHECKSUM_TITLE", ")", "||", "key", ".", "equalsIgnoreCase", "(", "CommonConstants", ".", "CS_ID_TITLE", ")", ")", "{", "return", "processEditedSpec", "(", "parserData", ",", "processProcesses", ")", ";", "}", "else", "{", "return", "processNewSpec", "(", "parserData", ",", "processProcesses", ")", ";", "}", "}", "catch", "(", "InvalidKeyValueException", "e", ")", "{", "log", ".", "error", "(", "ProcessorConstants", ".", "ERROR_INCORRECT_FILE_FORMAT_MSG", ",", "e", ")", ";", "return", "new", "ParserResults", "(", "false", ",", "null", ")", ";", "}", "}" ]
Process Content Specification that is either NEW or EDITED. That is that it should start with a CHECKSUM and ID or a Title. @param parserData @param processProcesses If processes should be processed to populate the relationships. @return True if the content spec was processed successfully otherwise false.
[ "Process", "Content", "Specification", "that", "is", "either", "NEW", "or", "EDITED", ".", "That", "is", "that", "it", "should", "start", "with", "a", "CHECKSUM", "and", "ID", "or", "a", "Title", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L352-L366
151,650
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.processSpecContents
protected ParserResults processSpecContents(ParserData parserData, final boolean processProcesses) { parserData.setCurrentLevel(parserData.getContentSpec().getBaseLevel()); boolean error = false; while (parserData.getLines().peek() != null) { parserData.setLineCount(parserData.getLineCount() + 1); // Process the content specification and print an error message if an error occurs try { if (!parseLine(parserData, parserData.getLines().poll(), parserData.getLineCount())) { error = true; } } catch (IndentationException e) { log.error(e.getMessage()); return new ParserResults(false, null); } } // Before validating the content specification, processes should be loaded first so that the // relationships and targets are created if (processProcesses) { for (final Process process : parserData.getProcesses()) { process.processTopics(parserData.getSpecTopics(), parserData.getTargetTopics(), topicProvider, serverSettingsProvider); } } // Setup the relationships processRelationships(parserData); return new ParserResults(!error, parserData.getContentSpec()); }
java
protected ParserResults processSpecContents(ParserData parserData, final boolean processProcesses) { parserData.setCurrentLevel(parserData.getContentSpec().getBaseLevel()); boolean error = false; while (parserData.getLines().peek() != null) { parserData.setLineCount(parserData.getLineCount() + 1); // Process the content specification and print an error message if an error occurs try { if (!parseLine(parserData, parserData.getLines().poll(), parserData.getLineCount())) { error = true; } } catch (IndentationException e) { log.error(e.getMessage()); return new ParserResults(false, null); } } // Before validating the content specification, processes should be loaded first so that the // relationships and targets are created if (processProcesses) { for (final Process process : parserData.getProcesses()) { process.processTopics(parserData.getSpecTopics(), parserData.getTargetTopics(), topicProvider, serverSettingsProvider); } } // Setup the relationships processRelationships(parserData); return new ParserResults(!error, parserData.getContentSpec()); }
[ "protected", "ParserResults", "processSpecContents", "(", "ParserData", "parserData", ",", "final", "boolean", "processProcesses", ")", "{", "parserData", ".", "setCurrentLevel", "(", "parserData", ".", "getContentSpec", "(", ")", ".", "getBaseLevel", "(", ")", ")", ";", "boolean", "error", "=", "false", ";", "while", "(", "parserData", ".", "getLines", "(", ")", ".", "peek", "(", ")", "!=", "null", ")", "{", "parserData", ".", "setLineCount", "(", "parserData", ".", "getLineCount", "(", ")", "+", "1", ")", ";", "// Process the content specification and print an error message if an error occurs", "try", "{", "if", "(", "!", "parseLine", "(", "parserData", ",", "parserData", ".", "getLines", "(", ")", ".", "poll", "(", ")", ",", "parserData", ".", "getLineCount", "(", ")", ")", ")", "{", "error", "=", "true", ";", "}", "}", "catch", "(", "IndentationException", "e", ")", "{", "log", ".", "error", "(", "e", ".", "getMessage", "(", ")", ")", ";", "return", "new", "ParserResults", "(", "false", ",", "null", ")", ";", "}", "}", "// Before validating the content specification, processes should be loaded first so that the", "// relationships and targets are created", "if", "(", "processProcesses", ")", "{", "for", "(", "final", "Process", "process", ":", "parserData", ".", "getProcesses", "(", ")", ")", "{", "process", ".", "processTopics", "(", "parserData", ".", "getSpecTopics", "(", ")", ",", "parserData", ".", "getTargetTopics", "(", ")", ",", "topicProvider", ",", "serverSettingsProvider", ")", ";", "}", "}", "// Setup the relationships", "processRelationships", "(", "parserData", ")", ";", "return", "new", "ParserResults", "(", "!", "error", ",", "parserData", ".", "getContentSpec", "(", ")", ")", ";", "}" ]
Process the contents of a content specification and parse it into a ContentSpec object. @param parserData @param processProcesses If processes should be processed to populate the relationships. @return True if the contents were processed successfully otherwise false.
[ "Process", "the", "contents", "of", "a", "content", "specification", "and", "parse", "it", "into", "a", "ContentSpec", "object", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L375-L403
151,651
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.parseLine
protected boolean parseLine(final ParserData parserData, final String line, int lineNumber) throws IndentationException { assert line != null; // Trim the whitespace final String trimmedLine = line.trim(); // If the line is a blank or a comment, then nothing needs processing. So add the line and return if (isBlankLine(trimmedLine) || isCommentLine(trimmedLine)) { return parseEmptyOrCommentLine(parserData, line); } else { // Calculate the lines indentation level int lineIndentationLevel = calculateLineIndentationLevel(parserData, line, lineNumber); if (lineIndentationLevel > parserData.getIndentationLevel()) { // The line was indented without a new level so throw an error throw new IndentationException(format(ProcessorConstants.ERROR_INCORRECT_INDENTATION_MSG, lineNumber, trimmedLine)); } else if (lineIndentationLevel < parserData.getIndentationLevel()) { // The line has left the previous level so move the current level up to the right level Level newCurrentLevel = parserData.getCurrentLevel(); for (int i = (parserData.getIndentationLevel() - lineIndentationLevel); i > 0; i--) { if (newCurrentLevel.getParent() != null) { newCurrentLevel = newCurrentLevel.getParent(); } } changeCurrentLevel(parserData, newCurrentLevel, lineIndentationLevel); } // Process the line based on what type the line is try { if (isMetaDataLine(parserData, trimmedLine)) { parseMetaDataLine(parserData, line, lineNumber); } else if (isCommonContentLine(trimmedLine)) { final CommonContent commonContent = parseCommonContentLine(parserData, line, lineNumber); parserData.getCurrentLevel().appendChild(commonContent); } else if (isLevelInitialContentLine(trimmedLine)) { final Level initialContent = parseLevelLine(parserData, trimmedLine, lineNumber); parserData.getCurrentLevel().appendChild(initialContent); // Change the current level to use the new parsed level changeCurrentLevel(parserData, initialContent, parserData.getIndentationLevel() + 1); } else if (isLevelLine(trimmedLine)) { final Level level = parseLevelLine(parserData, trimmedLine, lineNumber); if (level instanceof Process) { parserData.getProcesses().add((Process) level); } parserData.getCurrentLevel().appendChild(level); // Change the current level to use the new parsed level changeCurrentLevel(parserData, level, parserData.getIndentationLevel() + 1); // } else if (trimmedLine.toUpperCase(Locale.ENGLISH).matches("^CS[ ]*:.*")) { // processExternalLevelLine(getCurrentLevel(), line); } else if (StringUtilities.indexOf(trimmedLine, '[') == 0 && parserData.getCurrentLevel().getLevelType() == LevelType.BASE) { parseGlobalOptionsLine(parserData, line, lineNumber); } else { // Process a new topic final SpecTopic tempTopic = parseTopic(parserData, trimmedLine, lineNumber); // Adds the topic to the current level parserData.getCurrentLevel().appendSpecTopic(tempTopic); } } catch (ParsingException e) { log.error(e.getMessage()); return false; } return true; } }
java
protected boolean parseLine(final ParserData parserData, final String line, int lineNumber) throws IndentationException { assert line != null; // Trim the whitespace final String trimmedLine = line.trim(); // If the line is a blank or a comment, then nothing needs processing. So add the line and return if (isBlankLine(trimmedLine) || isCommentLine(trimmedLine)) { return parseEmptyOrCommentLine(parserData, line); } else { // Calculate the lines indentation level int lineIndentationLevel = calculateLineIndentationLevel(parserData, line, lineNumber); if (lineIndentationLevel > parserData.getIndentationLevel()) { // The line was indented without a new level so throw an error throw new IndentationException(format(ProcessorConstants.ERROR_INCORRECT_INDENTATION_MSG, lineNumber, trimmedLine)); } else if (lineIndentationLevel < parserData.getIndentationLevel()) { // The line has left the previous level so move the current level up to the right level Level newCurrentLevel = parserData.getCurrentLevel(); for (int i = (parserData.getIndentationLevel() - lineIndentationLevel); i > 0; i--) { if (newCurrentLevel.getParent() != null) { newCurrentLevel = newCurrentLevel.getParent(); } } changeCurrentLevel(parserData, newCurrentLevel, lineIndentationLevel); } // Process the line based on what type the line is try { if (isMetaDataLine(parserData, trimmedLine)) { parseMetaDataLine(parserData, line, lineNumber); } else if (isCommonContentLine(trimmedLine)) { final CommonContent commonContent = parseCommonContentLine(parserData, line, lineNumber); parserData.getCurrentLevel().appendChild(commonContent); } else if (isLevelInitialContentLine(trimmedLine)) { final Level initialContent = parseLevelLine(parserData, trimmedLine, lineNumber); parserData.getCurrentLevel().appendChild(initialContent); // Change the current level to use the new parsed level changeCurrentLevel(parserData, initialContent, parserData.getIndentationLevel() + 1); } else if (isLevelLine(trimmedLine)) { final Level level = parseLevelLine(parserData, trimmedLine, lineNumber); if (level instanceof Process) { parserData.getProcesses().add((Process) level); } parserData.getCurrentLevel().appendChild(level); // Change the current level to use the new parsed level changeCurrentLevel(parserData, level, parserData.getIndentationLevel() + 1); // } else if (trimmedLine.toUpperCase(Locale.ENGLISH).matches("^CS[ ]*:.*")) { // processExternalLevelLine(getCurrentLevel(), line); } else if (StringUtilities.indexOf(trimmedLine, '[') == 0 && parserData.getCurrentLevel().getLevelType() == LevelType.BASE) { parseGlobalOptionsLine(parserData, line, lineNumber); } else { // Process a new topic final SpecTopic tempTopic = parseTopic(parserData, trimmedLine, lineNumber); // Adds the topic to the current level parserData.getCurrentLevel().appendSpecTopic(tempTopic); } } catch (ParsingException e) { log.error(e.getMessage()); return false; } return true; } }
[ "protected", "boolean", "parseLine", "(", "final", "ParserData", "parserData", ",", "final", "String", "line", ",", "int", "lineNumber", ")", "throws", "IndentationException", "{", "assert", "line", "!=", "null", ";", "// Trim the whitespace", "final", "String", "trimmedLine", "=", "line", ".", "trim", "(", ")", ";", "// If the line is a blank or a comment, then nothing needs processing. So add the line and return", "if", "(", "isBlankLine", "(", "trimmedLine", ")", "||", "isCommentLine", "(", "trimmedLine", ")", ")", "{", "return", "parseEmptyOrCommentLine", "(", "parserData", ",", "line", ")", ";", "}", "else", "{", "// Calculate the lines indentation level", "int", "lineIndentationLevel", "=", "calculateLineIndentationLevel", "(", "parserData", ",", "line", ",", "lineNumber", ")", ";", "if", "(", "lineIndentationLevel", ">", "parserData", ".", "getIndentationLevel", "(", ")", ")", "{", "// The line was indented without a new level so throw an error", "throw", "new", "IndentationException", "(", "format", "(", "ProcessorConstants", ".", "ERROR_INCORRECT_INDENTATION_MSG", ",", "lineNumber", ",", "trimmedLine", ")", ")", ";", "}", "else", "if", "(", "lineIndentationLevel", "<", "parserData", ".", "getIndentationLevel", "(", ")", ")", "{", "// The line has left the previous level so move the current level up to the right level", "Level", "newCurrentLevel", "=", "parserData", ".", "getCurrentLevel", "(", ")", ";", "for", "(", "int", "i", "=", "(", "parserData", ".", "getIndentationLevel", "(", ")", "-", "lineIndentationLevel", ")", ";", "i", ">", "0", ";", "i", "--", ")", "{", "if", "(", "newCurrentLevel", ".", "getParent", "(", ")", "!=", "null", ")", "{", "newCurrentLevel", "=", "newCurrentLevel", ".", "getParent", "(", ")", ";", "}", "}", "changeCurrentLevel", "(", "parserData", ",", "newCurrentLevel", ",", "lineIndentationLevel", ")", ";", "}", "// Process the line based on what type the line is", "try", "{", "if", "(", "isMetaDataLine", "(", "parserData", ",", "trimmedLine", ")", ")", "{", "parseMetaDataLine", "(", "parserData", ",", "line", ",", "lineNumber", ")", ";", "}", "else", "if", "(", "isCommonContentLine", "(", "trimmedLine", ")", ")", "{", "final", "CommonContent", "commonContent", "=", "parseCommonContentLine", "(", "parserData", ",", "line", ",", "lineNumber", ")", ";", "parserData", ".", "getCurrentLevel", "(", ")", ".", "appendChild", "(", "commonContent", ")", ";", "}", "else", "if", "(", "isLevelInitialContentLine", "(", "trimmedLine", ")", ")", "{", "final", "Level", "initialContent", "=", "parseLevelLine", "(", "parserData", ",", "trimmedLine", ",", "lineNumber", ")", ";", "parserData", ".", "getCurrentLevel", "(", ")", ".", "appendChild", "(", "initialContent", ")", ";", "// Change the current level to use the new parsed level", "changeCurrentLevel", "(", "parserData", ",", "initialContent", ",", "parserData", ".", "getIndentationLevel", "(", ")", "+", "1", ")", ";", "}", "else", "if", "(", "isLevelLine", "(", "trimmedLine", ")", ")", "{", "final", "Level", "level", "=", "parseLevelLine", "(", "parserData", ",", "trimmedLine", ",", "lineNumber", ")", ";", "if", "(", "level", "instanceof", "Process", ")", "{", "parserData", ".", "getProcesses", "(", ")", ".", "add", "(", "(", "Process", ")", "level", ")", ";", "}", "parserData", ".", "getCurrentLevel", "(", ")", ".", "appendChild", "(", "level", ")", ";", "// Change the current level to use the new parsed level", "changeCurrentLevel", "(", "parserData", ",", "level", ",", "parserData", ".", "getIndentationLevel", "(", ")", "+", "1", ")", ";", "// } else if (trimmedLine.toUpperCase(Locale.ENGLISH).matches(\"^CS[ ]*:.*\")) {", "// processExternalLevelLine(getCurrentLevel(), line);", "}", "else", "if", "(", "StringUtilities", ".", "indexOf", "(", "trimmedLine", ",", "'", "'", ")", "==", "0", "&&", "parserData", ".", "getCurrentLevel", "(", ")", ".", "getLevelType", "(", ")", "==", "LevelType", ".", "BASE", ")", "{", "parseGlobalOptionsLine", "(", "parserData", ",", "line", ",", "lineNumber", ")", ";", "}", "else", "{", "// Process a new topic", "final", "SpecTopic", "tempTopic", "=", "parseTopic", "(", "parserData", ",", "trimmedLine", ",", "lineNumber", ")", ";", "// Adds the topic to the current level", "parserData", ".", "getCurrentLevel", "(", ")", ".", "appendSpecTopic", "(", "tempTopic", ")", ";", "}", "}", "catch", "(", "ParsingException", "e", ")", "{", "log", ".", "error", "(", "e", ".", "getMessage", "(", ")", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}", "}" ]
Processes a line of the content specification and stores it in objects @param parserData @param line A line of input from the content specification @return True if the line of input was processed successfully otherwise false. @throws IndentationException Thrown if any invalid indentation occurs.
[ "Processes", "a", "line", "of", "the", "content", "specification", "and", "stores", "it", "in", "objects" ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L413-L480
151,652
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.calculateLineIndentationLevel
protected int calculateLineIndentationLevel(final ParserData parserData, final String line, int lineNumber) throws IndentationException { char[] lineCharArray = line.toCharArray(); int indentationCount = 0; // Count the amount of whitespace characters before any text to determine the level if (Character.isWhitespace(lineCharArray[0])) { for (char c : lineCharArray) { if (Character.isWhitespace(c)) { indentationCount++; } else { break; } } if (indentationCount % parserData.getIndentationSize() != 0) { throw new IndentationException(format(ProcessorConstants.ERROR_INCORRECT_INDENTATION_MSG, lineNumber, line.trim())); } } return indentationCount / parserData.getIndentationSize(); }
java
protected int calculateLineIndentationLevel(final ParserData parserData, final String line, int lineNumber) throws IndentationException { char[] lineCharArray = line.toCharArray(); int indentationCount = 0; // Count the amount of whitespace characters before any text to determine the level if (Character.isWhitespace(lineCharArray[0])) { for (char c : lineCharArray) { if (Character.isWhitespace(c)) { indentationCount++; } else { break; } } if (indentationCount % parserData.getIndentationSize() != 0) { throw new IndentationException(format(ProcessorConstants.ERROR_INCORRECT_INDENTATION_MSG, lineNumber, line.trim())); } } return indentationCount / parserData.getIndentationSize(); }
[ "protected", "int", "calculateLineIndentationLevel", "(", "final", "ParserData", "parserData", ",", "final", "String", "line", ",", "int", "lineNumber", ")", "throws", "IndentationException", "{", "char", "[", "]", "lineCharArray", "=", "line", ".", "toCharArray", "(", ")", ";", "int", "indentationCount", "=", "0", ";", "// Count the amount of whitespace characters before any text to determine the level", "if", "(", "Character", ".", "isWhitespace", "(", "lineCharArray", "[", "0", "]", ")", ")", "{", "for", "(", "char", "c", ":", "lineCharArray", ")", "{", "if", "(", "Character", ".", "isWhitespace", "(", "c", ")", ")", "{", "indentationCount", "++", ";", "}", "else", "{", "break", ";", "}", "}", "if", "(", "indentationCount", "%", "parserData", ".", "getIndentationSize", "(", ")", "!=", "0", ")", "{", "throw", "new", "IndentationException", "(", "format", "(", "ProcessorConstants", ".", "ERROR_INCORRECT_INDENTATION_MSG", ",", "lineNumber", ",", "line", ".", "trim", "(", ")", ")", ")", ";", "}", "}", "return", "indentationCount", "/", "parserData", ".", "getIndentationSize", "(", ")", ";", "}" ]
Calculates the indentation level of a line using the amount of whitespace and the parsers indentation size setting. @param parserData @param line The line to calculate the indentation for. @return The lines indentation level. @throws IndentationException Thrown if the indentation for the line isn't valid.
[ "Calculates", "the", "indentation", "level", "of", "a", "line", "using", "the", "amount", "of", "whitespace", "and", "the", "parsers", "indentation", "size", "setting", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L490-L509
151,653
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.isMetaDataLine
protected boolean isMetaDataLine(ParserData parserData, String line) { return parserData.getCurrentLevel().getLevelType() == LevelType.BASE && line.trim().matches("^\\w[\\w\\.\\s-]+=.*"); }
java
protected boolean isMetaDataLine(ParserData parserData, String line) { return parserData.getCurrentLevel().getLevelType() == LevelType.BASE && line.trim().matches("^\\w[\\w\\.\\s-]+=.*"); }
[ "protected", "boolean", "isMetaDataLine", "(", "ParserData", "parserData", ",", "String", "line", ")", "{", "return", "parserData", ".", "getCurrentLevel", "(", ")", ".", "getLevelType", "(", ")", "==", "LevelType", ".", "BASE", "&&", "line", ".", "trim", "(", ")", ".", "matches", "(", "\"^\\\\w[\\\\w\\\\.\\\\s-]+=.*\"", ")", ";", "}" ]
Checks to see if a line is represents a Content Specifications Meta Data. @param parserData @param line The line to be checked. @return True if the line is meta data, otherwise false.
[ "Checks", "to", "see", "if", "a", "line", "is", "represents", "a", "Content", "Specifications", "Meta", "Data", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L518-L520
151,654
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.isLevelInitialContentLine
protected boolean isLevelInitialContentLine(String line) { final Matcher matcher = LEVEL_INITIAL_CONTENT_PATTERN.matcher(line.trim().toUpperCase(Locale.ENGLISH)); return matcher.find(); }
java
protected boolean isLevelInitialContentLine(String line) { final Matcher matcher = LEVEL_INITIAL_CONTENT_PATTERN.matcher(line.trim().toUpperCase(Locale.ENGLISH)); return matcher.find(); }
[ "protected", "boolean", "isLevelInitialContentLine", "(", "String", "line", ")", "{", "final", "Matcher", "matcher", "=", "LEVEL_INITIAL_CONTENT_PATTERN", ".", "matcher", "(", "line", ".", "trim", "(", ")", ".", "toUpperCase", "(", "Locale", ".", "ENGLISH", ")", ")", ";", "return", "matcher", ".", "find", "(", ")", ";", "}" ]
Checks to see if a line is represents a Content Specifications Level Front Matter. @param line The line to be checked. @return True if the line is a front matter declaration, otherwise false.
[ "Checks", "to", "see", "if", "a", "line", "is", "represents", "a", "Content", "Specifications", "Level", "Front", "Matter", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L559-L562
151,655
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.isLevelLine
protected boolean isLevelLine(String line) { final Matcher matcher = LEVEL_PATTERN.matcher(line.trim().toUpperCase(Locale.ENGLISH)); return matcher.find(); }
java
protected boolean isLevelLine(String line) { final Matcher matcher = LEVEL_PATTERN.matcher(line.trim().toUpperCase(Locale.ENGLISH)); return matcher.find(); }
[ "protected", "boolean", "isLevelLine", "(", "String", "line", ")", "{", "final", "Matcher", "matcher", "=", "LEVEL_PATTERN", ".", "matcher", "(", "line", ".", "trim", "(", ")", ".", "toUpperCase", "(", "Locale", ".", "ENGLISH", ")", ")", ";", "return", "matcher", ".", "find", "(", ")", ";", "}" ]
Checks to see if a line is represents a Content Specifications Level. @param line The line to be checked. @return True if the line is meta data, otherwise false.
[ "Checks", "to", "see", "if", "a", "line", "is", "represents", "a", "Content", "Specifications", "Level", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L570-L573
151,656
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.parseEmptyOrCommentLine
protected boolean parseEmptyOrCommentLine(final ParserData parserData, final String line) { if (isBlankLine(line)) { if (parserData.getCurrentLevel().getLevelType() == LevelType.BASE) { parserData.getContentSpec().appendChild(new TextNode("\n")); } else { parserData.getCurrentLevel().appendChild(new TextNode("\n")); } return true; } else { if (parserData.getCurrentLevel().getLevelType() == LevelType.BASE) { parserData.getContentSpec().appendComment(line); } else { parserData.getCurrentLevel().appendComment(line); } return true; } }
java
protected boolean parseEmptyOrCommentLine(final ParserData parserData, final String line) { if (isBlankLine(line)) { if (parserData.getCurrentLevel().getLevelType() == LevelType.BASE) { parserData.getContentSpec().appendChild(new TextNode("\n")); } else { parserData.getCurrentLevel().appendChild(new TextNode("\n")); } return true; } else { if (parserData.getCurrentLevel().getLevelType() == LevelType.BASE) { parserData.getContentSpec().appendComment(line); } else { parserData.getCurrentLevel().appendComment(line); } return true; } }
[ "protected", "boolean", "parseEmptyOrCommentLine", "(", "final", "ParserData", "parserData", ",", "final", "String", "line", ")", "{", "if", "(", "isBlankLine", "(", "line", ")", ")", "{", "if", "(", "parserData", ".", "getCurrentLevel", "(", ")", ".", "getLevelType", "(", ")", "==", "LevelType", ".", "BASE", ")", "{", "parserData", ".", "getContentSpec", "(", ")", ".", "appendChild", "(", "new", "TextNode", "(", "\"\\n\"", ")", ")", ";", "}", "else", "{", "parserData", ".", "getCurrentLevel", "(", ")", ".", "appendChild", "(", "new", "TextNode", "(", "\"\\n\"", ")", ")", ";", "}", "return", "true", ";", "}", "else", "{", "if", "(", "parserData", ".", "getCurrentLevel", "(", ")", ".", "getLevelType", "(", ")", "==", "LevelType", ".", "BASE", ")", "{", "parserData", ".", "getContentSpec", "(", ")", ".", "appendComment", "(", "line", ")", ";", "}", "else", "{", "parserData", ".", "getCurrentLevel", "(", ")", ".", "appendComment", "(", "line", ")", ";", "}", "return", "true", ";", "}", "}" ]
Processes a line that represents a comment or an empty line in a Content Specification. @param parserData @param line The line to be processed. @return True if the line was processed without errors, otherwise false.
[ "Processes", "a", "line", "that", "represents", "a", "comment", "or", "an", "empty", "line", "in", "a", "Content", "Specification", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L582-L598
151,657
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.parseLevelLine
protected Level parseLevelLine(final ParserData parserData, final String line, int lineNumber) throws ParsingException { String tempInput[] = StringUtilities.split(line, ':', 2); // Remove the whitespace from each value in the split array tempInput = CollectionUtilities.trimStringArray(tempInput); if (tempInput.length >= 1) { final LevelType levelType = LevelType.getLevelType(tempInput[0]); Level retValue = null; try { retValue = parseLevel(parserData, lineNumber, levelType, line); } catch (ParsingException e) { log.error(e.getMessage()); // Create a basic level so the rest of the spec can be processed retValue = createEmptyLevelFromType(lineNumber, levelType, line); retValue.setUniqueId("L" + lineNumber); } parserData.getLevels().put(retValue.getUniqueId(), retValue); return retValue; } else { throw new ParsingException(format(ProcessorConstants.ERROR_LEVEL_FORMAT_MSG, lineNumber, line)); } }
java
protected Level parseLevelLine(final ParserData parserData, final String line, int lineNumber) throws ParsingException { String tempInput[] = StringUtilities.split(line, ':', 2); // Remove the whitespace from each value in the split array tempInput = CollectionUtilities.trimStringArray(tempInput); if (tempInput.length >= 1) { final LevelType levelType = LevelType.getLevelType(tempInput[0]); Level retValue = null; try { retValue = parseLevel(parserData, lineNumber, levelType, line); } catch (ParsingException e) { log.error(e.getMessage()); // Create a basic level so the rest of the spec can be processed retValue = createEmptyLevelFromType(lineNumber, levelType, line); retValue.setUniqueId("L" + lineNumber); } parserData.getLevels().put(retValue.getUniqueId(), retValue); return retValue; } else { throw new ParsingException(format(ProcessorConstants.ERROR_LEVEL_FORMAT_MSG, lineNumber, line)); } }
[ "protected", "Level", "parseLevelLine", "(", "final", "ParserData", "parserData", ",", "final", "String", "line", ",", "int", "lineNumber", ")", "throws", "ParsingException", "{", "String", "tempInput", "[", "]", "=", "StringUtilities", ".", "split", "(", "line", ",", "'", "'", ",", "2", ")", ";", "// Remove the whitespace from each value in the split array", "tempInput", "=", "CollectionUtilities", ".", "trimStringArray", "(", "tempInput", ")", ";", "if", "(", "tempInput", ".", "length", ">=", "1", ")", "{", "final", "LevelType", "levelType", "=", "LevelType", ".", "getLevelType", "(", "tempInput", "[", "0", "]", ")", ";", "Level", "retValue", "=", "null", ";", "try", "{", "retValue", "=", "parseLevel", "(", "parserData", ",", "lineNumber", ",", "levelType", ",", "line", ")", ";", "}", "catch", "(", "ParsingException", "e", ")", "{", "log", ".", "error", "(", "e", ".", "getMessage", "(", ")", ")", ";", "// Create a basic level so the rest of the spec can be processed", "retValue", "=", "createEmptyLevelFromType", "(", "lineNumber", ",", "levelType", ",", "line", ")", ";", "retValue", ".", "setUniqueId", "(", "\"L\"", "+", "lineNumber", ")", ";", "}", "parserData", ".", "getLevels", "(", ")", ".", "put", "(", "retValue", ".", "getUniqueId", "(", ")", ",", "retValue", ")", ";", "return", "retValue", ";", "}", "else", "{", "throw", "new", "ParsingException", "(", "format", "(", "ProcessorConstants", ".", "ERROR_LEVEL_FORMAT_MSG", ",", "lineNumber", ",", "line", ")", ")", ";", "}", "}" ]
Processes a line that represents the start of a Content Specification Level. This method creates the level based on the data in the line and then changes the current processing level to the new level. @param parserData @param line The line to be processed as a level. @return True if the line was processed without errors, otherwise false.
[ "Processes", "a", "line", "that", "represents", "the", "start", "of", "a", "Content", "Specification", "Level", ".", "This", "method", "creates", "the", "level", "based", "on", "the", "data", "in", "the", "line", "and", "then", "changes", "the", "current", "processing", "level", "to", "the", "new", "level", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L608-L631
151,658
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.isSpecTopicMetaData
private boolean isSpecTopicMetaData(final String key, final String value) { if (ContentSpecUtilities.isSpecTopicMetaData(key)) { // Abstracts can be plain text so check an opening bracket exists if (key.equalsIgnoreCase(CommonConstants.CS_ABSTRACT_TITLE) || key.equalsIgnoreCase( CommonConstants.CS_ABSTRACT_ALTERNATE_TITLE)) { final String fixedValue = value.trim().replaceAll("(?i)^" + key + "\\s*", ""); return fixedValue.trim().startsWith("["); } else { return true; } } else { return false; } }
java
private boolean isSpecTopicMetaData(final String key, final String value) { if (ContentSpecUtilities.isSpecTopicMetaData(key)) { // Abstracts can be plain text so check an opening bracket exists if (key.equalsIgnoreCase(CommonConstants.CS_ABSTRACT_TITLE) || key.equalsIgnoreCase( CommonConstants.CS_ABSTRACT_ALTERNATE_TITLE)) { final String fixedValue = value.trim().replaceAll("(?i)^" + key + "\\s*", ""); return fixedValue.trim().startsWith("["); } else { return true; } } else { return false; } }
[ "private", "boolean", "isSpecTopicMetaData", "(", "final", "String", "key", ",", "final", "String", "value", ")", "{", "if", "(", "ContentSpecUtilities", ".", "isSpecTopicMetaData", "(", "key", ")", ")", "{", "// Abstracts can be plain text so check an opening bracket exists", "if", "(", "key", ".", "equalsIgnoreCase", "(", "CommonConstants", ".", "CS_ABSTRACT_TITLE", ")", "||", "key", ".", "equalsIgnoreCase", "(", "CommonConstants", ".", "CS_ABSTRACT_ALTERNATE_TITLE", ")", ")", "{", "final", "String", "fixedValue", "=", "value", ".", "trim", "(", ")", ".", "replaceAll", "(", "\"(?i)^\"", "+", "key", "+", "\"\\\\s*\"", ",", "\"\"", ")", ";", "return", "fixedValue", ".", "trim", "(", ")", ".", "startsWith", "(", "\"[\"", ")", ";", "}", "else", "{", "return", "true", ";", "}", "}", "else", "{", "return", "false", ";", "}", "}" ]
Checks if a metadata line is a spec topic. @param key The metadata key. @param value The metadata value. @return True if the line is a spec topic metadata element, otherwise false.
[ "Checks", "if", "a", "metadata", "line", "is", "a", "spec", "topic", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L759-L772
151,659
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.parseMultiLineMetaData
private KeyValueNode<String> parseMultiLineMetaData(final ParserData parserData, final String key, final String value, final int lineNumber) throws ParsingException { // Check if the starting brace is found, if not then assume that there is only one line. int startingPos = StringUtilities.indexOf(value, '['); if (startingPos != -1) { final StringBuilder multiLineValue = new StringBuilder(value); // If the ']' character isn't on this line try the next line if (StringUtilities.indexOf(value, ']') == -1) { multiLineValue.append("\n"); // Read the next line and increment counters String newLine = parserData.getLines().poll(); while (newLine != null) { multiLineValue.append(newLine).append("\n"); parserData.setLineCount(parserData.getLineCount() + 1); // If the ']' character still isn't found keep trying if (StringUtilities.lastIndexOf(multiLineValue.toString(), ']') == -1) { newLine = parserData.getLines().poll(); } else { break; } } } // Check that the ']' character was found and that it was found before another '[' character final String finalMultiLineValue = multiLineValue.toString().trim(); if (StringUtilities.lastIndexOf(finalMultiLineValue, ']') == -1 || StringUtilities.lastIndexOf(finalMultiLineValue, '[') != startingPos) { throw new ParsingException(format(ProcessorConstants.ERROR_INVALID_MULTILINE_METADATA_MSG, lineNumber, key + " = " + finalMultiLineValue.replaceAll("\n", "\n "))); } else { final String finalValue = finalMultiLineValue.substring(1, finalMultiLineValue.length() - 1); return new KeyValueNode<String>(key, finalValue); } } else { return new KeyValueNode<String>(key, value, lineNumber); } }
java
private KeyValueNode<String> parseMultiLineMetaData(final ParserData parserData, final String key, final String value, final int lineNumber) throws ParsingException { // Check if the starting brace is found, if not then assume that there is only one line. int startingPos = StringUtilities.indexOf(value, '['); if (startingPos != -1) { final StringBuilder multiLineValue = new StringBuilder(value); // If the ']' character isn't on this line try the next line if (StringUtilities.indexOf(value, ']') == -1) { multiLineValue.append("\n"); // Read the next line and increment counters String newLine = parserData.getLines().poll(); while (newLine != null) { multiLineValue.append(newLine).append("\n"); parserData.setLineCount(parserData.getLineCount() + 1); // If the ']' character still isn't found keep trying if (StringUtilities.lastIndexOf(multiLineValue.toString(), ']') == -1) { newLine = parserData.getLines().poll(); } else { break; } } } // Check that the ']' character was found and that it was found before another '[' character final String finalMultiLineValue = multiLineValue.toString().trim(); if (StringUtilities.lastIndexOf(finalMultiLineValue, ']') == -1 || StringUtilities.lastIndexOf(finalMultiLineValue, '[') != startingPos) { throw new ParsingException(format(ProcessorConstants.ERROR_INVALID_MULTILINE_METADATA_MSG, lineNumber, key + " = " + finalMultiLineValue.replaceAll("\n", "\n "))); } else { final String finalValue = finalMultiLineValue.substring(1, finalMultiLineValue.length() - 1); return new KeyValueNode<String>(key, finalValue); } } else { return new KeyValueNode<String>(key, value, lineNumber); } }
[ "private", "KeyValueNode", "<", "String", ">", "parseMultiLineMetaData", "(", "final", "ParserData", "parserData", ",", "final", "String", "key", ",", "final", "String", "value", ",", "final", "int", "lineNumber", ")", "throws", "ParsingException", "{", "// Check if the starting brace is found, if not then assume that there is only one line.", "int", "startingPos", "=", "StringUtilities", ".", "indexOf", "(", "value", ",", "'", "'", ")", ";", "if", "(", "startingPos", "!=", "-", "1", ")", "{", "final", "StringBuilder", "multiLineValue", "=", "new", "StringBuilder", "(", "value", ")", ";", "// If the ']' character isn't on this line try the next line", "if", "(", "StringUtilities", ".", "indexOf", "(", "value", ",", "'", "'", ")", "==", "-", "1", ")", "{", "multiLineValue", ".", "append", "(", "\"\\n\"", ")", ";", "// Read the next line and increment counters", "String", "newLine", "=", "parserData", ".", "getLines", "(", ")", ".", "poll", "(", ")", ";", "while", "(", "newLine", "!=", "null", ")", "{", "multiLineValue", ".", "append", "(", "newLine", ")", ".", "append", "(", "\"\\n\"", ")", ";", "parserData", ".", "setLineCount", "(", "parserData", ".", "getLineCount", "(", ")", "+", "1", ")", ";", "// If the ']' character still isn't found keep trying", "if", "(", "StringUtilities", ".", "lastIndexOf", "(", "multiLineValue", ".", "toString", "(", ")", ",", "'", "'", ")", "==", "-", "1", ")", "{", "newLine", "=", "parserData", ".", "getLines", "(", ")", ".", "poll", "(", ")", ";", "}", "else", "{", "break", ";", "}", "}", "}", "// Check that the ']' character was found and that it was found before another '[' character", "final", "String", "finalMultiLineValue", "=", "multiLineValue", ".", "toString", "(", ")", ".", "trim", "(", ")", ";", "if", "(", "StringUtilities", ".", "lastIndexOf", "(", "finalMultiLineValue", ",", "'", "'", ")", "==", "-", "1", "||", "StringUtilities", ".", "lastIndexOf", "(", "finalMultiLineValue", ",", "'", "'", ")", "!=", "startingPos", ")", "{", "throw", "new", "ParsingException", "(", "format", "(", "ProcessorConstants", ".", "ERROR_INVALID_MULTILINE_METADATA_MSG", ",", "lineNumber", ",", "key", "+", "\" = \"", "+", "finalMultiLineValue", ".", "replaceAll", "(", "\"\\n\"", ",", "\"\\n \"", ")", ")", ")", ";", "}", "else", "{", "final", "String", "finalValue", "=", "finalMultiLineValue", ".", "substring", "(", "1", ",", "finalMultiLineValue", ".", "length", "(", ")", "-", "1", ")", ";", "return", "new", "KeyValueNode", "<", "String", ">", "(", "key", ",", "finalValue", ")", ";", "}", "}", "else", "{", "return", "new", "KeyValueNode", "<", "String", ">", "(", "key", ",", "value", ",", "lineNumber", ")", ";", "}", "}" ]
Parses a multiple line metadata element. @param parserData @param key The metadata key. @param value The value on the metadata line. @param lineNumber The initial line number. @return The parsed multiple line value for the metadata element. @throws ParsingException
[ "Parses", "a", "multiple", "line", "metadata", "element", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L784-L821
151,660
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.parseGlobalOptionsLine
protected boolean parseGlobalOptionsLine(final ParserData parserData, final String line, int lineNumber) throws ParsingException { // Read in the variables from the line final HashMap<ParserType, String[]> variableMap = getLineVariables(parserData, line, lineNumber, '[', ']', ',', false); // Check the read in values are valid if ((variableMap.size() > 1 && variableMap.containsKey(ParserType.NONE)) || (variableMap.size() > 0 && !variableMap.containsKey( ParserType.NONE))) { throw new ParsingException(format(ProcessorConstants.ERROR_RELATIONSHIP_BASE_LEVEL_MSG, lineNumber, line)); } String[] variables = variableMap.get(ParserType.NONE); // Check that some options were found, if so then parse them if (variables.length > 0) { addOptions(parserData, parserData.getCurrentLevel(), variables, 0, line, lineNumber); } else { log.warn(format(ProcessorConstants.WARN_EMPTY_BRACKETS_MSG, lineNumber)); } return true; }
java
protected boolean parseGlobalOptionsLine(final ParserData parserData, final String line, int lineNumber) throws ParsingException { // Read in the variables from the line final HashMap<ParserType, String[]> variableMap = getLineVariables(parserData, line, lineNumber, '[', ']', ',', false); // Check the read in values are valid if ((variableMap.size() > 1 && variableMap.containsKey(ParserType.NONE)) || (variableMap.size() > 0 && !variableMap.containsKey( ParserType.NONE))) { throw new ParsingException(format(ProcessorConstants.ERROR_RELATIONSHIP_BASE_LEVEL_MSG, lineNumber, line)); } String[] variables = variableMap.get(ParserType.NONE); // Check that some options were found, if so then parse them if (variables.length > 0) { addOptions(parserData, parserData.getCurrentLevel(), variables, 0, line, lineNumber); } else { log.warn(format(ProcessorConstants.WARN_EMPTY_BRACKETS_MSG, lineNumber)); } return true; }
[ "protected", "boolean", "parseGlobalOptionsLine", "(", "final", "ParserData", "parserData", ",", "final", "String", "line", ",", "int", "lineNumber", ")", "throws", "ParsingException", "{", "// Read in the variables from the line", "final", "HashMap", "<", "ParserType", ",", "String", "[", "]", ">", "variableMap", "=", "getLineVariables", "(", "parserData", ",", "line", ",", "lineNumber", ",", "'", "'", ",", "'", "'", ",", "'", "'", ",", "false", ")", ";", "// Check the read in values are valid", "if", "(", "(", "variableMap", ".", "size", "(", ")", ">", "1", "&&", "variableMap", ".", "containsKey", "(", "ParserType", ".", "NONE", ")", ")", "||", "(", "variableMap", ".", "size", "(", ")", ">", "0", "&&", "!", "variableMap", ".", "containsKey", "(", "ParserType", ".", "NONE", ")", ")", ")", "{", "throw", "new", "ParsingException", "(", "format", "(", "ProcessorConstants", ".", "ERROR_RELATIONSHIP_BASE_LEVEL_MSG", ",", "lineNumber", ",", "line", ")", ")", ";", "}", "String", "[", "]", "variables", "=", "variableMap", ".", "get", "(", "ParserType", ".", "NONE", ")", ";", "// Check that some options were found, if so then parse them", "if", "(", "variables", ".", "length", ">", "0", ")", "{", "addOptions", "(", "parserData", ",", "parserData", ".", "getCurrentLevel", "(", ")", ",", "variables", ",", "0", ",", "line", ",", "lineNumber", ")", ";", "}", "else", "{", "log", ".", "warn", "(", "format", "(", "ProcessorConstants", ".", "WARN_EMPTY_BRACKETS_MSG", ",", "lineNumber", ")", ")", ";", "}", "return", "true", ";", "}" ]
Processes a line that represents the Global Options for the Content Specification. @param parserData @param line The line to be processed. @return True if the line was processed without errors, otherwise false.
[ "Processes", "a", "line", "that", "represents", "the", "Global", "Options", "for", "the", "Content", "Specification", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L918-L937
151,661
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.changeCurrentLevel
protected void changeCurrentLevel(ParserData parserData, final Level newLevel, int newIndentationLevel) { parserData.setIndentationLevel(newIndentationLevel); parserData.setCurrentLevel(newLevel); }
java
protected void changeCurrentLevel(ParserData parserData, final Level newLevel, int newIndentationLevel) { parserData.setIndentationLevel(newIndentationLevel); parserData.setCurrentLevel(newLevel); }
[ "protected", "void", "changeCurrentLevel", "(", "ParserData", "parserData", ",", "final", "Level", "newLevel", ",", "int", "newIndentationLevel", ")", "{", "parserData", ".", "setIndentationLevel", "(", "newIndentationLevel", ")", ";", "parserData", ".", "setCurrentLevel", "(", "newLevel", ")", ";", "}" ]
Changes the current level that content is being processed for to a new level. @param parserData @param newLevel The new level to process for, @param newIndentationLevel The new indentation level of the level in the Content Specification.
[ "Changes", "the", "current", "level", "that", "content", "is", "being", "processed", "for", "to", "a", "new", "level", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L946-L949
151,662
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.parseCommonContentLine
protected CommonContent parseCommonContentLine(final ParserData parserData, final String line, int lineNumber) throws ParsingException { // Read in the variables inside of the brackets final HashMap<ParserType, String[]> variableMap = getLineVariables(parserData, line, lineNumber, '[', ']', ',', false); if (!variableMap.containsKey(ParserType.NONE)) { throw new ParsingException(format(ProcessorConstants.ERROR_INVALID_TOPIC_FORMAT_MSG, lineNumber, line)); } // Get the title final String title = ProcessorUtilities.replaceEscapeChars(getTitle(line, '[')); // Create the common content final CommonContent commonContent = new CommonContent(title, lineNumber, line); commonContent.setUniqueId("L" + lineNumber + "-CommonContent"); // Check that no attributes were defined final String[] baseAttributes = variableMap.get(ParserType.NONE); if (baseAttributes.length > 1) { log.warn(format(ProcessorConstants.WARN_IGNORE_COMMON_CONTENT_ATTRIBUTES_MSG, lineNumber, line)); } // Throw an error for relationships variableMap.remove(ParserType.NONE); if (variableMap.size() > 0) { throw new ParsingException(format(ProcessorConstants.ERROR_COMMON_CONTENT_CONTAINS_ILLEGAL_CONTENT, lineNumber, line)); } return commonContent; }
java
protected CommonContent parseCommonContentLine(final ParserData parserData, final String line, int lineNumber) throws ParsingException { // Read in the variables inside of the brackets final HashMap<ParserType, String[]> variableMap = getLineVariables(parserData, line, lineNumber, '[', ']', ',', false); if (!variableMap.containsKey(ParserType.NONE)) { throw new ParsingException(format(ProcessorConstants.ERROR_INVALID_TOPIC_FORMAT_MSG, lineNumber, line)); } // Get the title final String title = ProcessorUtilities.replaceEscapeChars(getTitle(line, '[')); // Create the common content final CommonContent commonContent = new CommonContent(title, lineNumber, line); commonContent.setUniqueId("L" + lineNumber + "-CommonContent"); // Check that no attributes were defined final String[] baseAttributes = variableMap.get(ParserType.NONE); if (baseAttributes.length > 1) { log.warn(format(ProcessorConstants.WARN_IGNORE_COMMON_CONTENT_ATTRIBUTES_MSG, lineNumber, line)); } // Throw an error for relationships variableMap.remove(ParserType.NONE); if (variableMap.size() > 0) { throw new ParsingException(format(ProcessorConstants.ERROR_COMMON_CONTENT_CONTAINS_ILLEGAL_CONTENT, lineNumber, line)); } return commonContent; }
[ "protected", "CommonContent", "parseCommonContentLine", "(", "final", "ParserData", "parserData", ",", "final", "String", "line", ",", "int", "lineNumber", ")", "throws", "ParsingException", "{", "// Read in the variables inside of the brackets", "final", "HashMap", "<", "ParserType", ",", "String", "[", "]", ">", "variableMap", "=", "getLineVariables", "(", "parserData", ",", "line", ",", "lineNumber", ",", "'", "'", ",", "'", "'", ",", "'", "'", ",", "false", ")", ";", "if", "(", "!", "variableMap", ".", "containsKey", "(", "ParserType", ".", "NONE", ")", ")", "{", "throw", "new", "ParsingException", "(", "format", "(", "ProcessorConstants", ".", "ERROR_INVALID_TOPIC_FORMAT_MSG", ",", "lineNumber", ",", "line", ")", ")", ";", "}", "// Get the title", "final", "String", "title", "=", "ProcessorUtilities", ".", "replaceEscapeChars", "(", "getTitle", "(", "line", ",", "'", "'", ")", ")", ";", "// Create the common content", "final", "CommonContent", "commonContent", "=", "new", "CommonContent", "(", "title", ",", "lineNumber", ",", "line", ")", ";", "commonContent", ".", "setUniqueId", "(", "\"L\"", "+", "lineNumber", "+", "\"-CommonContent\"", ")", ";", "// Check that no attributes were defined", "final", "String", "[", "]", "baseAttributes", "=", "variableMap", ".", "get", "(", "ParserType", ".", "NONE", ")", ";", "if", "(", "baseAttributes", ".", "length", ">", "1", ")", "{", "log", ".", "warn", "(", "format", "(", "ProcessorConstants", ".", "WARN_IGNORE_COMMON_CONTENT_ATTRIBUTES_MSG", ",", "lineNumber", ",", "line", ")", ")", ";", "}", "// Throw an error for relationships", "variableMap", ".", "remove", "(", "ParserType", ".", "NONE", ")", ";", "if", "(", "variableMap", ".", "size", "(", ")", ">", "0", ")", "{", "throw", "new", "ParsingException", "(", "format", "(", "ProcessorConstants", ".", "ERROR_COMMON_CONTENT_CONTAINS_ILLEGAL_CONTENT", ",", "lineNumber", ",", "line", ")", ")", ";", "}", "return", "commonContent", ";", "}" ]
Processes the input to create a new common content node. @param parserData @param line The line of input to be processed @return A common contents object initialised with the data from the input line. @throws ParsingException Thrown if the line can't be parsed as a Common Content node, due to incorrect syntax.
[ "Processes", "the", "input", "to", "create", "a", "new", "common", "content", "node", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L959-L986
151,663
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.parseTopic
protected SpecTopic parseTopic(final ParserData parserData, final String line, int lineNumber) throws ParsingException { // Read in the variables inside of the brackets final HashMap<ParserType, String[]> variableMap = getLineVariables(parserData, line, lineNumber, '[', ']', ',', false); if (!variableMap.containsKey(ParserType.NONE)) { throw new ParsingException(format(ProcessorConstants.ERROR_INVALID_TOPIC_FORMAT_MSG, lineNumber, line)); } // Get the title final String title = ProcessorUtilities.replaceEscapeChars(getTitle(line, '[')); // Create the spec topic final SpecTopic tempTopic = new SpecTopic(title, lineNumber, line, null); // Add in the topic attributes addTopicAttributes(tempTopic, parserData, variableMap.get(ParserType.NONE), lineNumber, line); parserData.getSpecTopics().put(tempTopic.getUniqueId(), tempTopic); // Process the Topic Relationships processTopicRelationships(parserData, tempTopic, variableMap, line, lineNumber); // Throw an error for info if (variableMap.containsKey(ParserType.INFO)) { throw new ParsingException(format(ProcessorConstants.ERROR_TOPIC_WITH_INFO_TOPIC, lineNumber, line)); } return tempTopic; }
java
protected SpecTopic parseTopic(final ParserData parserData, final String line, int lineNumber) throws ParsingException { // Read in the variables inside of the brackets final HashMap<ParserType, String[]> variableMap = getLineVariables(parserData, line, lineNumber, '[', ']', ',', false); if (!variableMap.containsKey(ParserType.NONE)) { throw new ParsingException(format(ProcessorConstants.ERROR_INVALID_TOPIC_FORMAT_MSG, lineNumber, line)); } // Get the title final String title = ProcessorUtilities.replaceEscapeChars(getTitle(line, '[')); // Create the spec topic final SpecTopic tempTopic = new SpecTopic(title, lineNumber, line, null); // Add in the topic attributes addTopicAttributes(tempTopic, parserData, variableMap.get(ParserType.NONE), lineNumber, line); parserData.getSpecTopics().put(tempTopic.getUniqueId(), tempTopic); // Process the Topic Relationships processTopicRelationships(parserData, tempTopic, variableMap, line, lineNumber); // Throw an error for info if (variableMap.containsKey(ParserType.INFO)) { throw new ParsingException(format(ProcessorConstants.ERROR_TOPIC_WITH_INFO_TOPIC, lineNumber, line)); } return tempTopic; }
[ "protected", "SpecTopic", "parseTopic", "(", "final", "ParserData", "parserData", ",", "final", "String", "line", ",", "int", "lineNumber", ")", "throws", "ParsingException", "{", "// Read in the variables inside of the brackets", "final", "HashMap", "<", "ParserType", ",", "String", "[", "]", ">", "variableMap", "=", "getLineVariables", "(", "parserData", ",", "line", ",", "lineNumber", ",", "'", "'", ",", "'", "'", ",", "'", "'", ",", "false", ")", ";", "if", "(", "!", "variableMap", ".", "containsKey", "(", "ParserType", ".", "NONE", ")", ")", "{", "throw", "new", "ParsingException", "(", "format", "(", "ProcessorConstants", ".", "ERROR_INVALID_TOPIC_FORMAT_MSG", ",", "lineNumber", ",", "line", ")", ")", ";", "}", "// Get the title", "final", "String", "title", "=", "ProcessorUtilities", ".", "replaceEscapeChars", "(", "getTitle", "(", "line", ",", "'", "'", ")", ")", ";", "// Create the spec topic", "final", "SpecTopic", "tempTopic", "=", "new", "SpecTopic", "(", "title", ",", "lineNumber", ",", "line", ",", "null", ")", ";", "// Add in the topic attributes", "addTopicAttributes", "(", "tempTopic", ",", "parserData", ",", "variableMap", ".", "get", "(", "ParserType", ".", "NONE", ")", ",", "lineNumber", ",", "line", ")", ";", "parserData", ".", "getSpecTopics", "(", ")", ".", "put", "(", "tempTopic", ".", "getUniqueId", "(", ")", ",", "tempTopic", ")", ";", "// Process the Topic Relationships", "processTopicRelationships", "(", "parserData", ",", "tempTopic", ",", "variableMap", ",", "line", ",", "lineNumber", ")", ";", "// Throw an error for info", "if", "(", "variableMap", ".", "containsKey", "(", "ParserType", ".", "INFO", ")", ")", "{", "throw", "new", "ParsingException", "(", "format", "(", "ProcessorConstants", ".", "ERROR_TOPIC_WITH_INFO_TOPIC", ",", "lineNumber", ",", "line", ")", ")", ";", "}", "return", "tempTopic", ";", "}" ]
Processes the input to create a new topic @param parserData @param line The line of input to be processed @return A topics object initialised with the data from the input line. @throws ParsingException Thrown if the line can't be parsed as a Topic, due to incorrect syntax.
[ "Processes", "the", "input", "to", "create", "a", "new", "topic" ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L996-L1022
151,664
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.processRelationshipList
private void processRelationshipList(final ParserType parserType, final SpecNodeWithRelationships tempNode, final HashMap<ParserType, String[]> variableMap, final List<Relationship> relationships, int lineNumber) throws ParsingException { final String uniqueId = tempNode.getUniqueId(); String errorMessageFormat = null; RelationshipType relationshipType; switch (parserType) { case REFER_TO: errorMessageFormat = ProcessorConstants.ERROR_INVALID_REFERS_TO_RELATIONSHIP; relationshipType = RelationshipType.REFER_TO; break; case LINKLIST: errorMessageFormat = ProcessorConstants.ERROR_INVALID_LINK_LIST_RELATIONSHIP; relationshipType = RelationshipType.LINKLIST; break; case PREREQUISITE: errorMessageFormat = ProcessorConstants.ERROR_INVALID_PREREQUISITE_RELATIONSHIP; relationshipType = RelationshipType.PREREQUISITE; break; default: return; } if (variableMap.containsKey(parserType)) { final String[] relationshipList = variableMap.get(parserType); for (final String relationshipId : relationshipList) { if (relationshipId.matches(ProcessorConstants.RELATION_ID_REGEX)) { relationships.add(new Relationship(uniqueId, relationshipId, relationshipType)); } else if (relationshipId.matches(ProcessorConstants.RELATION_ID_LONG_REGEX)) { final Matcher matcher = RELATION_ID_LONG_PATTERN.matcher(relationshipId); matcher.find(); final String id = matcher.group("TopicID"); final String relationshipTitle = matcher.group("TopicTitle"); final String cleanedTitle = ProcessorUtilities.cleanXMLCharacterReferences(relationshipTitle.trim()); relationships.add(new Relationship(uniqueId, id, relationshipType, ProcessorUtilities.replaceEscapeChars(cleanedTitle))); } else { if (relationshipId.matches("^(" + ProcessorConstants.TARGET_BASE_REGEX + "|[0-9]+).*?(" + ProcessorConstants.TARGET_BASE_REGEX + "|[0-9]+).*")) { throw new ParsingException(format(ProcessorConstants.ERROR_MISSING_SEPARATOR_MSG, lineNumber, ',')); } else { throw new ParsingException(format(errorMessageFormat, lineNumber)); } } } } }
java
private void processRelationshipList(final ParserType parserType, final SpecNodeWithRelationships tempNode, final HashMap<ParserType, String[]> variableMap, final List<Relationship> relationships, int lineNumber) throws ParsingException { final String uniqueId = tempNode.getUniqueId(); String errorMessageFormat = null; RelationshipType relationshipType; switch (parserType) { case REFER_TO: errorMessageFormat = ProcessorConstants.ERROR_INVALID_REFERS_TO_RELATIONSHIP; relationshipType = RelationshipType.REFER_TO; break; case LINKLIST: errorMessageFormat = ProcessorConstants.ERROR_INVALID_LINK_LIST_RELATIONSHIP; relationshipType = RelationshipType.LINKLIST; break; case PREREQUISITE: errorMessageFormat = ProcessorConstants.ERROR_INVALID_PREREQUISITE_RELATIONSHIP; relationshipType = RelationshipType.PREREQUISITE; break; default: return; } if (variableMap.containsKey(parserType)) { final String[] relationshipList = variableMap.get(parserType); for (final String relationshipId : relationshipList) { if (relationshipId.matches(ProcessorConstants.RELATION_ID_REGEX)) { relationships.add(new Relationship(uniqueId, relationshipId, relationshipType)); } else if (relationshipId.matches(ProcessorConstants.RELATION_ID_LONG_REGEX)) { final Matcher matcher = RELATION_ID_LONG_PATTERN.matcher(relationshipId); matcher.find(); final String id = matcher.group("TopicID"); final String relationshipTitle = matcher.group("TopicTitle"); final String cleanedTitle = ProcessorUtilities.cleanXMLCharacterReferences(relationshipTitle.trim()); relationships.add(new Relationship(uniqueId, id, relationshipType, ProcessorUtilities.replaceEscapeChars(cleanedTitle))); } else { if (relationshipId.matches("^(" + ProcessorConstants.TARGET_BASE_REGEX + "|[0-9]+).*?(" + ProcessorConstants.TARGET_BASE_REGEX + "|[0-9]+).*")) { throw new ParsingException(format(ProcessorConstants.ERROR_MISSING_SEPARATOR_MSG, lineNumber, ',')); } else { throw new ParsingException(format(errorMessageFormat, lineNumber)); } } } } }
[ "private", "void", "processRelationshipList", "(", "final", "ParserType", "parserType", ",", "final", "SpecNodeWithRelationships", "tempNode", ",", "final", "HashMap", "<", "ParserType", ",", "String", "[", "]", ">", "variableMap", ",", "final", "List", "<", "Relationship", ">", "relationships", ",", "int", "lineNumber", ")", "throws", "ParsingException", "{", "final", "String", "uniqueId", "=", "tempNode", ".", "getUniqueId", "(", ")", ";", "String", "errorMessageFormat", "=", "null", ";", "RelationshipType", "relationshipType", ";", "switch", "(", "parserType", ")", "{", "case", "REFER_TO", ":", "errorMessageFormat", "=", "ProcessorConstants", ".", "ERROR_INVALID_REFERS_TO_RELATIONSHIP", ";", "relationshipType", "=", "RelationshipType", ".", "REFER_TO", ";", "break", ";", "case", "LINKLIST", ":", "errorMessageFormat", "=", "ProcessorConstants", ".", "ERROR_INVALID_LINK_LIST_RELATIONSHIP", ";", "relationshipType", "=", "RelationshipType", ".", "LINKLIST", ";", "break", ";", "case", "PREREQUISITE", ":", "errorMessageFormat", "=", "ProcessorConstants", ".", "ERROR_INVALID_PREREQUISITE_RELATIONSHIP", ";", "relationshipType", "=", "RelationshipType", ".", "PREREQUISITE", ";", "break", ";", "default", ":", "return", ";", "}", "if", "(", "variableMap", ".", "containsKey", "(", "parserType", ")", ")", "{", "final", "String", "[", "]", "relationshipList", "=", "variableMap", ".", "get", "(", "parserType", ")", ";", "for", "(", "final", "String", "relationshipId", ":", "relationshipList", ")", "{", "if", "(", "relationshipId", ".", "matches", "(", "ProcessorConstants", ".", "RELATION_ID_REGEX", ")", ")", "{", "relationships", ".", "add", "(", "new", "Relationship", "(", "uniqueId", ",", "relationshipId", ",", "relationshipType", ")", ")", ";", "}", "else", "if", "(", "relationshipId", ".", "matches", "(", "ProcessorConstants", ".", "RELATION_ID_LONG_REGEX", ")", ")", "{", "final", "Matcher", "matcher", "=", "RELATION_ID_LONG_PATTERN", ".", "matcher", "(", "relationshipId", ")", ";", "matcher", ".", "find", "(", ")", ";", "final", "String", "id", "=", "matcher", ".", "group", "(", "\"TopicID\"", ")", ";", "final", "String", "relationshipTitle", "=", "matcher", ".", "group", "(", "\"TopicTitle\"", ")", ";", "final", "String", "cleanedTitle", "=", "ProcessorUtilities", ".", "cleanXMLCharacterReferences", "(", "relationshipTitle", ".", "trim", "(", ")", ")", ";", "relationships", ".", "add", "(", "new", "Relationship", "(", "uniqueId", ",", "id", ",", "relationshipType", ",", "ProcessorUtilities", ".", "replaceEscapeChars", "(", "cleanedTitle", ")", ")", ")", ";", "}", "else", "{", "if", "(", "relationshipId", ".", "matches", "(", "\"^(\"", "+", "ProcessorConstants", ".", "TARGET_BASE_REGEX", "+", "\"|[0-9]+).*?(\"", "+", "ProcessorConstants", ".", "TARGET_BASE_REGEX", "+", "\"|[0-9]+).*\"", ")", ")", "{", "throw", "new", "ParsingException", "(", "format", "(", "ProcessorConstants", ".", "ERROR_MISSING_SEPARATOR_MSG", ",", "lineNumber", ",", "'", "'", ")", ")", ";", "}", "else", "{", "throw", "new", "ParsingException", "(", "format", "(", "errorMessageFormat", ",", "lineNumber", ")", ")", ";", "}", "}", "}", "}", "}" ]
Processes a list of relationships for a specific relationship type from some line processed variables. @param relationshipType The relationship type to be processed. @param tempNode The temporary node that will be turned into a full node once fully parsed. @param variableMap The list of variables containing the parsed relationships. @param lineNumber The number of the line the relationships are on. @param relationships The list of topic relationships. @throws ParsingException Thrown if the variables can't be parsed due to incorrect syntax.
[ "Processes", "a", "list", "of", "relationships", "for", "a", "specific", "relationship", "type", "from", "some", "line", "processed", "variables", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L1184-L1233
151,665
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.createEmptyLevelFromType
protected Level createEmptyLevelFromType(final int lineNumber, final LevelType levelType, final String input) { // Create the level based on the type switch (levelType) { case APPENDIX: return new Appendix(null, lineNumber, input); case CHAPTER: return new Chapter(null, lineNumber, input); case SECTION: return new Section(null, lineNumber, input); case PART: return new Part(null, lineNumber, input); case PROCESS: return new Process(null, lineNumber, input); case INITIAL_CONTENT: return new InitialContent(lineNumber, input); default: return new Level(null, lineNumber, input, levelType); } }
java
protected Level createEmptyLevelFromType(final int lineNumber, final LevelType levelType, final String input) { // Create the level based on the type switch (levelType) { case APPENDIX: return new Appendix(null, lineNumber, input); case CHAPTER: return new Chapter(null, lineNumber, input); case SECTION: return new Section(null, lineNumber, input); case PART: return new Part(null, lineNumber, input); case PROCESS: return new Process(null, lineNumber, input); case INITIAL_CONTENT: return new InitialContent(lineNumber, input); default: return new Level(null, lineNumber, input, levelType); } }
[ "protected", "Level", "createEmptyLevelFromType", "(", "final", "int", "lineNumber", ",", "final", "LevelType", "levelType", ",", "final", "String", "input", ")", "{", "// Create the level based on the type", "switch", "(", "levelType", ")", "{", "case", "APPENDIX", ":", "return", "new", "Appendix", "(", "null", ",", "lineNumber", ",", "input", ")", ";", "case", "CHAPTER", ":", "return", "new", "Chapter", "(", "null", ",", "lineNumber", ",", "input", ")", ";", "case", "SECTION", ":", "return", "new", "Section", "(", "null", ",", "lineNumber", ",", "input", ")", ";", "case", "PART", ":", "return", "new", "Part", "(", "null", ",", "lineNumber", ",", "input", ")", ";", "case", "PROCESS", ":", "return", "new", "Process", "(", "null", ",", "lineNumber", ",", "input", ")", ";", "case", "INITIAL_CONTENT", ":", "return", "new", "InitialContent", "(", "lineNumber", ",", "input", ")", ";", "default", ":", "return", "new", "Level", "(", "null", ",", "lineNumber", ",", "input", ",", "levelType", ")", ";", "}", "}" ]
Creates an empty Level using the LevelType to determine which Level subclass to instantiate. @param lineNumber The line number of the level. @param levelType The Level Type. @param input The string that represents the level, if one exists, @return The empty Level subclass object, or a plain Level object if no type matches a subclass.
[ "Creates", "an", "empty", "Level", "using", "the", "LevelType", "to", "determine", "which", "Level", "subclass", "to", "instantiate", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L1243-L1261
151,666
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.getType
protected ParserType getType(final String variableString) { final String uppercaseVarSet = variableString.trim().toUpperCase(Locale.ENGLISH); if (uppercaseVarSet.matches(ProcessorConstants.RELATED_REGEX)) { return ParserType.REFER_TO; } else if (uppercaseVarSet.matches(ProcessorConstants.PREREQUISITE_REGEX)) { return ParserType.PREREQUISITE; } else if (uppercaseVarSet.matches(ProcessorConstants.NEXT_REGEX)) { return ParserType.NEXT; } else if (uppercaseVarSet.matches(ProcessorConstants.PREV_REGEX)) { return ParserType.PREVIOUS; } else if (uppercaseVarSet.matches(ProcessorConstants.TARGET_REGEX)) { return ParserType.TARGET; } else if (uppercaseVarSet.matches(ProcessorConstants.EXTERNAL_TARGET_REGEX)) { return ParserType.EXTERNAL_TARGET; } else if (uppercaseVarSet.matches(ProcessorConstants.EXTERNAL_CSP_REGEX)) { return ParserType.EXTERNAL_CONTENT_SPEC; } else if (uppercaseVarSet.matches(ProcessorConstants.LINK_LIST_REGEX)) { return ParserType.LINKLIST; } else if (uppercaseVarSet.matches(ProcessorConstants.INFO_REGEX)) { return ParserType.INFO; } else { return ParserType.NONE; } }
java
protected ParserType getType(final String variableString) { final String uppercaseVarSet = variableString.trim().toUpperCase(Locale.ENGLISH); if (uppercaseVarSet.matches(ProcessorConstants.RELATED_REGEX)) { return ParserType.REFER_TO; } else if (uppercaseVarSet.matches(ProcessorConstants.PREREQUISITE_REGEX)) { return ParserType.PREREQUISITE; } else if (uppercaseVarSet.matches(ProcessorConstants.NEXT_REGEX)) { return ParserType.NEXT; } else if (uppercaseVarSet.matches(ProcessorConstants.PREV_REGEX)) { return ParserType.PREVIOUS; } else if (uppercaseVarSet.matches(ProcessorConstants.TARGET_REGEX)) { return ParserType.TARGET; } else if (uppercaseVarSet.matches(ProcessorConstants.EXTERNAL_TARGET_REGEX)) { return ParserType.EXTERNAL_TARGET; } else if (uppercaseVarSet.matches(ProcessorConstants.EXTERNAL_CSP_REGEX)) { return ParserType.EXTERNAL_CONTENT_SPEC; } else if (uppercaseVarSet.matches(ProcessorConstants.LINK_LIST_REGEX)) { return ParserType.LINKLIST; } else if (uppercaseVarSet.matches(ProcessorConstants.INFO_REGEX)) { return ParserType.INFO; } else { return ParserType.NONE; } }
[ "protected", "ParserType", "getType", "(", "final", "String", "variableString", ")", "{", "final", "String", "uppercaseVarSet", "=", "variableString", ".", "trim", "(", ")", ".", "toUpperCase", "(", "Locale", ".", "ENGLISH", ")", ";", "if", "(", "uppercaseVarSet", ".", "matches", "(", "ProcessorConstants", ".", "RELATED_REGEX", ")", ")", "{", "return", "ParserType", ".", "REFER_TO", ";", "}", "else", "if", "(", "uppercaseVarSet", ".", "matches", "(", "ProcessorConstants", ".", "PREREQUISITE_REGEX", ")", ")", "{", "return", "ParserType", ".", "PREREQUISITE", ";", "}", "else", "if", "(", "uppercaseVarSet", ".", "matches", "(", "ProcessorConstants", ".", "NEXT_REGEX", ")", ")", "{", "return", "ParserType", ".", "NEXT", ";", "}", "else", "if", "(", "uppercaseVarSet", ".", "matches", "(", "ProcessorConstants", ".", "PREV_REGEX", ")", ")", "{", "return", "ParserType", ".", "PREVIOUS", ";", "}", "else", "if", "(", "uppercaseVarSet", ".", "matches", "(", "ProcessorConstants", ".", "TARGET_REGEX", ")", ")", "{", "return", "ParserType", ".", "TARGET", ";", "}", "else", "if", "(", "uppercaseVarSet", ".", "matches", "(", "ProcessorConstants", ".", "EXTERNAL_TARGET_REGEX", ")", ")", "{", "return", "ParserType", ".", "EXTERNAL_TARGET", ";", "}", "else", "if", "(", "uppercaseVarSet", ".", "matches", "(", "ProcessorConstants", ".", "EXTERNAL_CSP_REGEX", ")", ")", "{", "return", "ParserType", ".", "EXTERNAL_CONTENT_SPEC", ";", "}", "else", "if", "(", "uppercaseVarSet", ".", "matches", "(", "ProcessorConstants", ".", "LINK_LIST_REGEX", ")", ")", "{", "return", "ParserType", ".", "LINKLIST", ";", "}", "else", "if", "(", "uppercaseVarSet", ".", "matches", "(", "ProcessorConstants", ".", "INFO_REGEX", ")", ")", "{", "return", "ParserType", ".", "INFO", ";", "}", "else", "{", "return", "ParserType", ".", "NONE", ";", "}", "}" ]
Processes a string of variables to find the type that exists within the string. @param variableString The variable string to be processed. @return The parser type that was found in the string otherwise a NONE type is returned.
[ "Processes", "a", "string", "of", "variables", "to", "find", "the", "type", "that", "exists", "within", "the", "string", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L1624-L1647
151,667
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.processRelationships
protected void processRelationships(final ParserData parserData) { // Process the level relationships for (final Map.Entry<String, List<Relationship>> entry : parserData.getLevelRelationships().entrySet()) { final String levelId = entry.getKey(); final Level level = parserData.getLevels().get(levelId); assert level != null; for (final Relationship relationship : entry.getValue()) { processRelationship(parserData, level, relationship); } } // Process the topic relationships for (final Map.Entry<String, List<Relationship>> entry : parserData.getTopicRelationships().entrySet()) { final String topicId = entry.getKey(); final SpecTopic specTopic = parserData.getSpecTopics().get(topicId); assert specTopic != null; for (final Relationship relationship : entry.getValue()) { processRelationship(parserData, specTopic, relationship); } } }
java
protected void processRelationships(final ParserData parserData) { // Process the level relationships for (final Map.Entry<String, List<Relationship>> entry : parserData.getLevelRelationships().entrySet()) { final String levelId = entry.getKey(); final Level level = parserData.getLevels().get(levelId); assert level != null; for (final Relationship relationship : entry.getValue()) { processRelationship(parserData, level, relationship); } } // Process the topic relationships for (final Map.Entry<String, List<Relationship>> entry : parserData.getTopicRelationships().entrySet()) { final String topicId = entry.getKey(); final SpecTopic specTopic = parserData.getSpecTopics().get(topicId); assert specTopic != null; for (final Relationship relationship : entry.getValue()) { processRelationship(parserData, specTopic, relationship); } } }
[ "protected", "void", "processRelationships", "(", "final", "ParserData", "parserData", ")", "{", "// Process the level relationships", "for", "(", "final", "Map", ".", "Entry", "<", "String", ",", "List", "<", "Relationship", ">", ">", "entry", ":", "parserData", ".", "getLevelRelationships", "(", ")", ".", "entrySet", "(", ")", ")", "{", "final", "String", "levelId", "=", "entry", ".", "getKey", "(", ")", ";", "final", "Level", "level", "=", "parserData", ".", "getLevels", "(", ")", ".", "get", "(", "levelId", ")", ";", "assert", "level", "!=", "null", ";", "for", "(", "final", "Relationship", "relationship", ":", "entry", ".", "getValue", "(", ")", ")", "{", "processRelationship", "(", "parserData", ",", "level", ",", "relationship", ")", ";", "}", "}", "// Process the topic relationships", "for", "(", "final", "Map", ".", "Entry", "<", "String", ",", "List", "<", "Relationship", ">", ">", "entry", ":", "parserData", ".", "getTopicRelationships", "(", ")", ".", "entrySet", "(", ")", ")", "{", "final", "String", "topicId", "=", "entry", ".", "getKey", "(", ")", ";", "final", "SpecTopic", "specTopic", "=", "parserData", ".", "getSpecTopics", "(", ")", ".", "get", "(", "topicId", ")", ";", "assert", "specTopic", "!=", "null", ";", "for", "(", "final", "Relationship", "relationship", ":", "entry", ".", "getValue", "(", ")", ")", "{", "processRelationship", "(", "parserData", ",", "specTopic", ",", "relationship", ")", ";", "}", "}", "}" ]
Process the relationships without logging any errors. @param parserData
[ "Process", "the", "relationships", "without", "logging", "any", "errors", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L1797-L1821
151,668
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java
ContentSpecParser.findVariableSets
protected List<VariableSet> findVariableSets(final ParserData parserData, final String input, final char startDelim, final char endDelim) { final StringBuilder varLine = new StringBuilder(input); final List<VariableSet> retValue = new ArrayList<VariableSet>(); int startPos = 0; VariableSet set = ProcessorUtilities.findVariableSet(input, startDelim, endDelim, startPos); while (set != null && set.getContents() != null) { /* * Check if we've found the end of a set. If we have add the set to the * list and try and see if another set exists. If not then get the next line * in the content spec and keep processing the set until the end of the set * is found or the end of the content spec. */ if (set.getEndPos() != null) { retValue.add(set); final String nextLine = parserData.getLines().peek(); startPos = set.getEndPos() + 1; set = ProcessorUtilities.findVariableSet(varLine.toString(), startDelim, endDelim, startPos); /* * If the next set and/or its contents are empty then it means we found all the sets * for the input line. However the next line in the content spec maybe a continuation * but we couldn't find it originally because of a missing separator. So peek at the next * line and see if it's a continuation (ie another relationship) and if it is then add the * line and continue to find sets. */ if ((set == null || set.getContents() == null) && (nextLine != null && nextLine.trim().toUpperCase(Locale.ENGLISH).matches( "^\\" + startDelim + "[ ]*(R|L|P|T|B).*"))) { final String line = parserData.getLines().poll(); parserData.setLineCount(parserData.getLineCount() + 1); if (line != null) { varLine.append("\n").append(line); set = ProcessorUtilities.findVariableSet(varLine.toString(), startDelim, endDelim, startPos); } } } else { final String line = parserData.getLines().poll(); parserData.setLineCount(parserData.getLineCount() + 1); if (line != null) { varLine.append("\n").append(line); set = ProcessorUtilities.findVariableSet(varLine.toString(), startDelim, endDelim, startPos); } else { retValue.add(set); break; } } } return retValue; }
java
protected List<VariableSet> findVariableSets(final ParserData parserData, final String input, final char startDelim, final char endDelim) { final StringBuilder varLine = new StringBuilder(input); final List<VariableSet> retValue = new ArrayList<VariableSet>(); int startPos = 0; VariableSet set = ProcessorUtilities.findVariableSet(input, startDelim, endDelim, startPos); while (set != null && set.getContents() != null) { /* * Check if we've found the end of a set. If we have add the set to the * list and try and see if another set exists. If not then get the next line * in the content spec and keep processing the set until the end of the set * is found or the end of the content spec. */ if (set.getEndPos() != null) { retValue.add(set); final String nextLine = parserData.getLines().peek(); startPos = set.getEndPos() + 1; set = ProcessorUtilities.findVariableSet(varLine.toString(), startDelim, endDelim, startPos); /* * If the next set and/or its contents are empty then it means we found all the sets * for the input line. However the next line in the content spec maybe a continuation * but we couldn't find it originally because of a missing separator. So peek at the next * line and see if it's a continuation (ie another relationship) and if it is then add the * line and continue to find sets. */ if ((set == null || set.getContents() == null) && (nextLine != null && nextLine.trim().toUpperCase(Locale.ENGLISH).matches( "^\\" + startDelim + "[ ]*(R|L|P|T|B).*"))) { final String line = parserData.getLines().poll(); parserData.setLineCount(parserData.getLineCount() + 1); if (line != null) { varLine.append("\n").append(line); set = ProcessorUtilities.findVariableSet(varLine.toString(), startDelim, endDelim, startPos); } } } else { final String line = parserData.getLines().poll(); parserData.setLineCount(parserData.getLineCount() + 1); if (line != null) { varLine.append("\n").append(line); set = ProcessorUtilities.findVariableSet(varLine.toString(), startDelim, endDelim, startPos); } else { retValue.add(set); break; } } } return retValue; }
[ "protected", "List", "<", "VariableSet", ">", "findVariableSets", "(", "final", "ParserData", "parserData", ",", "final", "String", "input", ",", "final", "char", "startDelim", ",", "final", "char", "endDelim", ")", "{", "final", "StringBuilder", "varLine", "=", "new", "StringBuilder", "(", "input", ")", ";", "final", "List", "<", "VariableSet", ">", "retValue", "=", "new", "ArrayList", "<", "VariableSet", ">", "(", ")", ";", "int", "startPos", "=", "0", ";", "VariableSet", "set", "=", "ProcessorUtilities", ".", "findVariableSet", "(", "input", ",", "startDelim", ",", "endDelim", ",", "startPos", ")", ";", "while", "(", "set", "!=", "null", "&&", "set", ".", "getContents", "(", ")", "!=", "null", ")", "{", "/*\n * Check if we've found the end of a set. If we have add the set to the\n * list and try and see if another set exists. If not then get the next line\n * in the content spec and keep processing the set until the end of the set\n * is found or the end of the content spec.\n */", "if", "(", "set", ".", "getEndPos", "(", ")", "!=", "null", ")", "{", "retValue", ".", "add", "(", "set", ")", ";", "final", "String", "nextLine", "=", "parserData", ".", "getLines", "(", ")", ".", "peek", "(", ")", ";", "startPos", "=", "set", ".", "getEndPos", "(", ")", "+", "1", ";", "set", "=", "ProcessorUtilities", ".", "findVariableSet", "(", "varLine", ".", "toString", "(", ")", ",", "startDelim", ",", "endDelim", ",", "startPos", ")", ";", "/*\n * If the next set and/or its contents are empty then it means we found all the sets\n * for the input line. However the next line in the content spec maybe a continuation\n * but we couldn't find it originally because of a missing separator. So peek at the next\n * line and see if it's a continuation (ie another relationship) and if it is then add the\n * line and continue to find sets.\n */", "if", "(", "(", "set", "==", "null", "||", "set", ".", "getContents", "(", ")", "==", "null", ")", "&&", "(", "nextLine", "!=", "null", "&&", "nextLine", ".", "trim", "(", ")", ".", "toUpperCase", "(", "Locale", ".", "ENGLISH", ")", ".", "matches", "(", "\"^\\\\\"", "+", "startDelim", "+", "\"[ ]*(R|L|P|T|B).*\"", ")", ")", ")", "{", "final", "String", "line", "=", "parserData", ".", "getLines", "(", ")", ".", "poll", "(", ")", ";", "parserData", ".", "setLineCount", "(", "parserData", ".", "getLineCount", "(", ")", "+", "1", ")", ";", "if", "(", "line", "!=", "null", ")", "{", "varLine", ".", "append", "(", "\"\\n\"", ")", ".", "append", "(", "line", ")", ";", "set", "=", "ProcessorUtilities", ".", "findVariableSet", "(", "varLine", ".", "toString", "(", ")", ",", "startDelim", ",", "endDelim", ",", "startPos", ")", ";", "}", "}", "}", "else", "{", "final", "String", "line", "=", "parserData", ".", "getLines", "(", ")", ".", "poll", "(", ")", ";", "parserData", ".", "setLineCount", "(", "parserData", ".", "getLineCount", "(", ")", "+", "1", ")", ";", "if", "(", "line", "!=", "null", ")", "{", "varLine", ".", "append", "(", "\"\\n\"", ")", ".", "append", "(", "line", ")", ";", "set", "=", "ProcessorUtilities", ".", "findVariableSet", "(", "varLine", ".", "toString", "(", ")", ",", "startDelim", ",", "endDelim", ",", "startPos", ")", ";", "}", "else", "{", "retValue", ".", "add", "(", "set", ")", ";", "break", ";", "}", "}", "}", "return", "retValue", ";", "}" ]
Finds a List of variable sets within a string. If the end of a set can't be determined then it will continue to parse the following lines until the end is found. @param parserData @param input The string to find the sets in. @param startDelim The starting character of the set. @param endDelim The ending character of the set. @return A list of VariableSets that contain the contents of each set and the start and end position of the set.
[ "Finds", "a", "List", "of", "variable", "sets", "within", "a", "string", ".", "If", "the", "end", "of", "a", "set", "can", "t", "be", "determined", "then", "it", "will", "continue", "to", "parse", "the", "following", "lines", "until", "the", "end", "is", "found", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L2012-L2066
151,669
tvesalainen/util
util/src/main/java/org/vesalainen/util/CollectionHelp.java
CollectionHelp.split
public static final <T> List<List<T>> split(List<T> list, Predicate<T> predicate) { if (list.isEmpty()) { return Collections.EMPTY_LIST; } List<List<T>> lists = new ArrayList<>(); boolean b = predicate.test(list.get(0)); int len = list.size(); int start = 0; for (int ii=1;ii<len;ii++) { boolean t = predicate.test(list.get(ii)); if (b != t) { lists.add(list.subList(start, ii)); start = ii; b = t; } } lists.add(list.subList(start, len)); return lists; }
java
public static final <T> List<List<T>> split(List<T> list, Predicate<T> predicate) { if (list.isEmpty()) { return Collections.EMPTY_LIST; } List<List<T>> lists = new ArrayList<>(); boolean b = predicate.test(list.get(0)); int len = list.size(); int start = 0; for (int ii=1;ii<len;ii++) { boolean t = predicate.test(list.get(ii)); if (b != t) { lists.add(list.subList(start, ii)); start = ii; b = t; } } lists.add(list.subList(start, len)); return lists; }
[ "public", "static", "final", "<", "T", ">", "List", "<", "List", "<", "T", ">", ">", "split", "(", "List", "<", "T", ">", "list", ",", "Predicate", "<", "T", ">", "predicate", ")", "{", "if", "(", "list", ".", "isEmpty", "(", ")", ")", "{", "return", "Collections", ".", "EMPTY_LIST", ";", "}", "List", "<", "List", "<", "T", ">", ">", "lists", "=", "new", "ArrayList", "<>", "(", ")", ";", "boolean", "b", "=", "predicate", ".", "test", "(", "list", ".", "get", "(", "0", ")", ")", ";", "int", "len", "=", "list", ".", "size", "(", ")", ";", "int", "start", "=", "0", ";", "for", "(", "int", "ii", "=", "1", ";", "ii", "<", "len", ";", "ii", "++", ")", "{", "boolean", "t", "=", "predicate", ".", "test", "(", "list", ".", "get", "(", "ii", ")", ")", ";", "if", "(", "b", "!=", "t", ")", "{", "lists", ".", "add", "(", "list", ".", "subList", "(", "start", ",", "ii", ")", ")", ";", "start", "=", "ii", ";", "b", "=", "t", ";", "}", "}", "lists", ".", "add", "(", "list", ".", "subList", "(", "start", ",", "len", ")", ")", ";", "return", "lists", ";", "}" ]
Splits list into several sub-lists according to predicate. @param <T> @param list @param predicate @return
[ "Splits", "list", "into", "several", "sub", "-", "lists", "according", "to", "predicate", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/CollectionHelp.java#L46-L68
151,670
tvesalainen/util
util/src/main/java/org/vesalainen/util/CollectionHelp.java
CollectionHelp.setFormat
public static final void setFormat(String format, Locale locale) { threadFormat.set(format); threadLocale.set(locale); }
java
public static final void setFormat(String format, Locale locale) { threadFormat.set(format); threadLocale.set(locale); }
[ "public", "static", "final", "void", "setFormat", "(", "String", "format", ",", "Locale", "locale", ")", "{", "threadFormat", ".", "set", "(", "format", ")", ";", "threadLocale", ".", "set", "(", "locale", ")", ";", "}" ]
Set Format string and locale for calling thread. List items are formatted using these. It is good practice to call removeFormat after use. @param locale @see #removeFormat() @see java.lang.String#format(java.util.Locale, java.lang.String, java.lang.Object...)
[ "Set", "Format", "string", "and", "locale", "for", "calling", "thread", ".", "List", "items", "are", "formatted", "using", "these", ".", "It", "is", "good", "practice", "to", "call", "removeFormat", "after", "use", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/CollectionHelp.java#L98-L102
151,671
tvesalainen/util
util/src/main/java/org/vesalainen/util/CollectionHelp.java
CollectionHelp.create
public static final <T> List<T> create(T... items) { List<T> list = new ArrayList<>(); Collections.addAll(list, items); return list; }
java
public static final <T> List<T> create(T... items) { List<T> list = new ArrayList<>(); Collections.addAll(list, items); return list; }
[ "public", "static", "final", "<", "T", ">", "List", "<", "T", ">", "create", "(", "T", "...", "items", ")", "{", "List", "<", "T", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "Collections", ".", "addAll", "(", "list", ",", "items", ")", ";", "return", "list", ";", "}" ]
Creates a list that is populated with items @param <T> @param items @return
[ "Creates", "a", "list", "that", "is", "populated", "with", "items" ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/CollectionHelp.java#L131-L136
151,672
tvesalainen/util
util/src/main/java/org/vesalainen/util/CollectionHelp.java
CollectionHelp.remove
public static final <T> void remove(Collection<T> collection, T... items) { for (T t : items) { collection.remove(t); } }
java
public static final <T> void remove(Collection<T> collection, T... items) { for (T t : items) { collection.remove(t); } }
[ "public", "static", "final", "<", "T", ">", "void", "remove", "(", "Collection", "<", "T", ">", "collection", ",", "T", "...", "items", ")", "{", "for", "(", "T", "t", ":", "items", ")", "{", "collection", ".", "remove", "(", "t", ")", ";", "}", "}" ]
Removes items from collection @param <T> @param collection @param items
[ "Removes", "items", "from", "collection" ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/CollectionHelp.java#L155-L161
151,673
tvesalainen/util
util/src/main/java/org/vesalainen/util/CollectionHelp.java
CollectionHelp.print
public static final String print(String delim, Collection<?> collection) { return print(null, delim, null, null, null, collection); }
java
public static final String print(String delim, Collection<?> collection) { return print(null, delim, null, null, null, collection); }
[ "public", "static", "final", "String", "print", "(", "String", "delim", ",", "Collection", "<", "?", ">", "collection", ")", "{", "return", "print", "(", "null", ",", "delim", ",", "null", ",", "null", ",", "null", ",", "collection", ")", ";", "}" ]
Returns collection items delimited @param delim @param collection @return @deprecated Use java.util.stream.Collectors.joining @see java.util.stream.Collectors#joining(java.lang.CharSequence)
[ "Returns", "collection", "items", "delimited" ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/CollectionHelp.java#L170-L173
151,674
tvesalainen/util
util/src/main/java/org/vesalainen/util/CollectionHelp.java
CollectionHelp.print
public static final String print(String start, String delim, String quotStart, String quotEnd, String end, Collection<?> collection) { try { StringBuilder out = new StringBuilder(); print(out, start, delim, quotStart, quotEnd, end, collection); return out.toString(); } catch (IOException ex) { throw new IllegalArgumentException(ex); } }
java
public static final String print(String start, String delim, String quotStart, String quotEnd, String end, Collection<?> collection) { try { StringBuilder out = new StringBuilder(); print(out, start, delim, quotStart, quotEnd, end, collection); return out.toString(); } catch (IOException ex) { throw new IllegalArgumentException(ex); } }
[ "public", "static", "final", "String", "print", "(", "String", "start", ",", "String", "delim", ",", "String", "quotStart", ",", "String", "quotEnd", ",", "String", "end", ",", "Collection", "<", "?", ">", "collection", ")", "{", "try", "{", "StringBuilder", "out", "=", "new", "StringBuilder", "(", ")", ";", "print", "(", "out", ",", "start", ",", "delim", ",", "quotStart", ",", "quotEnd", ",", "end", ",", "collection", ")", ";", "return", "out", ".", "toString", "(", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "throw", "new", "IllegalArgumentException", "(", "ex", ")", ";", "}", "}" ]
Returns collection items delimited with given strings. If any of delimiters is null, it is ignored. @param start Start @param delim Delimiter @param quotStart Start of quotation @param quotEnd End of quotation @param end End @param collection @return @deprecated Use java.util.stream.Collectors.joining @see java.util.stream.Collectors#joining(java.lang.CharSequence, java.lang.CharSequence, java.lang.CharSequence)
[ "Returns", "collection", "items", "delimited", "with", "given", "strings", ".", "If", "any", "of", "delimiters", "is", "null", "it", "is", "ignored", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/CollectionHelp.java#L187-L199
151,675
tvesalainen/util
util/src/main/java/org/vesalainen/util/CollectionHelp.java
CollectionHelp.print
public static final String print(String delim, Object... array) { return print(null, delim, null, null, null, array); }
java
public static final String print(String delim, Object... array) { return print(null, delim, null, null, null, array); }
[ "public", "static", "final", "String", "print", "(", "String", "delim", ",", "Object", "...", "array", ")", "{", "return", "print", "(", "null", ",", "delim", ",", "null", ",", "null", ",", "null", ",", "array", ")", ";", "}" ]
Returns array items delimited @param delim @param array @return
[ "Returns", "array", "items", "delimited" ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/CollectionHelp.java#L237-L240
151,676
tvesalainen/util
util/src/main/java/org/vesalainen/util/CollectionHelp.java
CollectionHelp.print
public static final String print(String start, String delim, String quotStart, String quotEnd, String end, Object... array) { try { StringBuilder out = new StringBuilder(); print(out, start, delim, quotStart, quotEnd, end, array); return out.toString(); } catch (IOException ex) { throw new IllegalArgumentException(ex); } }
java
public static final String print(String start, String delim, String quotStart, String quotEnd, String end, Object... array) { try { StringBuilder out = new StringBuilder(); print(out, start, delim, quotStart, quotEnd, end, array); return out.toString(); } catch (IOException ex) { throw new IllegalArgumentException(ex); } }
[ "public", "static", "final", "String", "print", "(", "String", "start", ",", "String", "delim", ",", "String", "quotStart", ",", "String", "quotEnd", ",", "String", "end", ",", "Object", "...", "array", ")", "{", "try", "{", "StringBuilder", "out", "=", "new", "StringBuilder", "(", ")", ";", "print", "(", "out", ",", "start", ",", "delim", ",", "quotStart", ",", "quotEnd", ",", "end", ",", "array", ")", ";", "return", "out", ".", "toString", "(", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "throw", "new", "IllegalArgumentException", "(", "ex", ")", ";", "}", "}" ]
Returns array items delimited with given strings. If any of delimiters is null, it is ignored. @param start @param delim @param quotStart @param quotEnd @param end @param array @return
[ "Returns", "array", "items", "delimited", "with", "given", "strings", ".", "If", "any", "of", "delimiters", "is", "null", "it", "is", "ignored", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/CollectionHelp.java#L252-L264
151,677
tvesalainen/util
util/src/main/java/org/vesalainen/util/CollectionHelp.java
CollectionHelp.addAll
public static <T> Collection<T> addAll(Collection<T> list, T... array) { for (T item : array) { list.add(item); } return list; }
java
public static <T> Collection<T> addAll(Collection<T> list, T... array) { for (T item : array) { list.add(item); } return list; }
[ "public", "static", "<", "T", ">", "Collection", "<", "T", ">", "addAll", "(", "Collection", "<", "T", ">", "list", ",", "T", "...", "array", ")", "{", "for", "(", "T", "item", ":", "array", ")", "{", "list", ".", "add", "(", "item", ")", ";", "}", "return", "list", ";", "}" ]
Adds array members to list @param <T> @param list @param array
[ "Adds", "array", "members", "to", "list" ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/CollectionHelp.java#L321-L328
151,678
tvesalainen/util
util/src/main/java/org/vesalainen/util/CollectionHelp.java
CollectionHelp.toArray
public static <T> T[] toArray(Collection<T> col, Class<T> cls) { T[] arr = (T[]) Array.newInstance(cls, col.size()); return col.toArray(arr); }
java
public static <T> T[] toArray(Collection<T> col, Class<T> cls) { T[] arr = (T[]) Array.newInstance(cls, col.size()); return col.toArray(arr); }
[ "public", "static", "<", "T", ">", "T", "[", "]", "toArray", "(", "Collection", "<", "T", ">", "col", ",", "Class", "<", "T", ">", "cls", ")", "{", "T", "[", "]", "arr", "=", "(", "T", "[", "]", ")", "Array", ".", "newInstance", "(", "cls", ",", "col", ".", "size", "(", ")", ")", ";", "return", "col", ".", "toArray", "(", "arr", ")", ";", "}" ]
Converts Collection to array. @param <T> @param col @param cls @return @see java.util.Collection#toArray(T[])
[ "Converts", "Collection", "to", "array", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/CollectionHelp.java#L355-L359
151,679
tvesalainen/util
util/src/main/java/org/vesalainen/nio/channels/vc/VirtualCircuitFactory.java
VirtualCircuitFactory.create
public static final VirtualCircuit create(ByteChannel ch1, ByteChannel ch2, int capacity, boolean direct) { if ( (ch1 instanceof SelectableChannel) && (ch2 instanceof SelectableChannel) ) { SelectableChannel sc1 = (SelectableChannel) ch1; SelectableChannel sc2 = (SelectableChannel) ch2; return new SelectableVirtualCircuit(sc1, sc2, capacity, direct); } else { if ( (ch1 instanceof SelectableBySelector) && (ch2 instanceof SelectableBySelector) ) { SelectableBySelector sbs1 = (SelectableBySelector) ch1; SelectableBySelector sbs2 = (SelectableBySelector) ch2; return new SelectableVirtualCircuit(sbs1.getSelector(), sbs2.getSelector(), ch1, ch2, capacity, direct); } else { return new ByteChannelVirtualCircuit(ch1, ch2, capacity, direct); } } }
java
public static final VirtualCircuit create(ByteChannel ch1, ByteChannel ch2, int capacity, boolean direct) { if ( (ch1 instanceof SelectableChannel) && (ch2 instanceof SelectableChannel) ) { SelectableChannel sc1 = (SelectableChannel) ch1; SelectableChannel sc2 = (SelectableChannel) ch2; return new SelectableVirtualCircuit(sc1, sc2, capacity, direct); } else { if ( (ch1 instanceof SelectableBySelector) && (ch2 instanceof SelectableBySelector) ) { SelectableBySelector sbs1 = (SelectableBySelector) ch1; SelectableBySelector sbs2 = (SelectableBySelector) ch2; return new SelectableVirtualCircuit(sbs1.getSelector(), sbs2.getSelector(), ch1, ch2, capacity, direct); } else { return new ByteChannelVirtualCircuit(ch1, ch2, capacity, direct); } } }
[ "public", "static", "final", "VirtualCircuit", "create", "(", "ByteChannel", "ch1", ",", "ByteChannel", "ch2", ",", "int", "capacity", ",", "boolean", "direct", ")", "{", "if", "(", "(", "ch1", "instanceof", "SelectableChannel", ")", "&&", "(", "ch2", "instanceof", "SelectableChannel", ")", ")", "{", "SelectableChannel", "sc1", "=", "(", "SelectableChannel", ")", "ch1", ";", "SelectableChannel", "sc2", "=", "(", "SelectableChannel", ")", "ch2", ";", "return", "new", "SelectableVirtualCircuit", "(", "sc1", ",", "sc2", ",", "capacity", ",", "direct", ")", ";", "}", "else", "{", "if", "(", "(", "ch1", "instanceof", "SelectableBySelector", ")", "&&", "(", "ch2", "instanceof", "SelectableBySelector", ")", ")", "{", "SelectableBySelector", "sbs1", "=", "(", "SelectableBySelector", ")", "ch1", ";", "SelectableBySelector", "sbs2", "=", "(", "SelectableBySelector", ")", "ch2", ";", "return", "new", "SelectableVirtualCircuit", "(", "sbs1", ".", "getSelector", "(", ")", ",", "sbs2", ".", "getSelector", "(", ")", ",", "ch1", ",", "ch2", ",", "capacity", ",", "direct", ")", ";", "}", "else", "{", "return", "new", "ByteChannelVirtualCircuit", "(", "ch1", ",", "ch2", ",", "capacity", ",", "direct", ")", ";", "}", "}", "}" ]
Creates either SelectableVirtualCircuit or ByteChannelVirtualCircuit depending on channel. @param ch1 @param ch2 @param capacity @param direct @return
[ "Creates", "either", "SelectableVirtualCircuit", "or", "ByteChannelVirtualCircuit", "depending", "on", "channel", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/nio/channels/vc/VirtualCircuitFactory.java#L40-L67
151,680
pressgang-ccms/PressGangCCMSContentSpec
src/main/java/org/jboss/pressgang/ccms/contentspec/utils/CustomTopicXMLValidator.java
CustomTopicXMLValidator.checkTopicRootElement
public static List<String> checkTopicRootElement(final ServerSettingsWrapper serverSettings, final BaseTopicWrapper<?> topic, final Document doc) { final List<String> xmlErrors = new ArrayList<String>(); final ServerEntitiesWrapper serverEntities = serverSettings.getEntities(); if (isTopicANormalTopic(topic, serverSettings)) { if (!doc.getDocumentElement().getNodeName().equals(DocBookUtilities.TOPIC_ROOT_NODE_NAME)) { xmlErrors.add("Topics must be a <" + DocBookUtilities.TOPIC_ROOT_NODE_NAME + ">."); } } else { if (topic.hasTag(serverEntities.getRevisionHistoryTagId())) { if (!doc.getDocumentElement().getNodeName().equals("appendix")) { xmlErrors.add("Revision History topics must be an <appendix>."); } // Check to make sure that a revhistory entry exists final NodeList revHistoryList = doc.getElementsByTagName("revhistory"); if (revHistoryList.getLength() == 0) { xmlErrors.add("No <revhistory> element found. A <revhistory> must exist for Revision Histories."); } } else if (topic.hasTag(serverEntities.getLegalNoticeTagId())) { if (!doc.getDocumentElement().getNodeName().equals("legalnotice")) { xmlErrors.add("Legal Notice topics must be a <legalnotice>."); } } else if (topic.hasTag(serverEntities.getAuthorGroupTagId())) { if (!doc.getDocumentElement().getNodeName().equals("authorgroup")) { xmlErrors.add("Author Group topics must be an <authorgroup>."); } } else if (topic.hasTag(serverEntities.getAbstractTagId())) { if (!doc.getDocumentElement().getNodeName().equals("abstract")) { xmlErrors.add("Abstract topics must be an <abstract>."); } } else if (topic.hasTag(serverEntities.getInfoTagId())) { if (DocBookVersion.DOCBOOK_50.getId().equals(topic.getXmlFormat())) { if (!doc.getDocumentElement().getNodeName().equals("info")) { xmlErrors.add("Info topics must be an <info>."); } } else { if (!doc.getDocumentElement().getNodeName().equals("sectioninfo")) { xmlErrors.add("Info topics must be a <sectioninfo>."); } } } } return xmlErrors; }
java
public static List<String> checkTopicRootElement(final ServerSettingsWrapper serverSettings, final BaseTopicWrapper<?> topic, final Document doc) { final List<String> xmlErrors = new ArrayList<String>(); final ServerEntitiesWrapper serverEntities = serverSettings.getEntities(); if (isTopicANormalTopic(topic, serverSettings)) { if (!doc.getDocumentElement().getNodeName().equals(DocBookUtilities.TOPIC_ROOT_NODE_NAME)) { xmlErrors.add("Topics must be a <" + DocBookUtilities.TOPIC_ROOT_NODE_NAME + ">."); } } else { if (topic.hasTag(serverEntities.getRevisionHistoryTagId())) { if (!doc.getDocumentElement().getNodeName().equals("appendix")) { xmlErrors.add("Revision History topics must be an <appendix>."); } // Check to make sure that a revhistory entry exists final NodeList revHistoryList = doc.getElementsByTagName("revhistory"); if (revHistoryList.getLength() == 0) { xmlErrors.add("No <revhistory> element found. A <revhistory> must exist for Revision Histories."); } } else if (topic.hasTag(serverEntities.getLegalNoticeTagId())) { if (!doc.getDocumentElement().getNodeName().equals("legalnotice")) { xmlErrors.add("Legal Notice topics must be a <legalnotice>."); } } else if (topic.hasTag(serverEntities.getAuthorGroupTagId())) { if (!doc.getDocumentElement().getNodeName().equals("authorgroup")) { xmlErrors.add("Author Group topics must be an <authorgroup>."); } } else if (topic.hasTag(serverEntities.getAbstractTagId())) { if (!doc.getDocumentElement().getNodeName().equals("abstract")) { xmlErrors.add("Abstract topics must be an <abstract>."); } } else if (topic.hasTag(serverEntities.getInfoTagId())) { if (DocBookVersion.DOCBOOK_50.getId().equals(topic.getXmlFormat())) { if (!doc.getDocumentElement().getNodeName().equals("info")) { xmlErrors.add("Info topics must be an <info>."); } } else { if (!doc.getDocumentElement().getNodeName().equals("sectioninfo")) { xmlErrors.add("Info topics must be a <sectioninfo>."); } } } } return xmlErrors; }
[ "public", "static", "List", "<", "String", ">", "checkTopicRootElement", "(", "final", "ServerSettingsWrapper", "serverSettings", ",", "final", "BaseTopicWrapper", "<", "?", ">", "topic", ",", "final", "Document", "doc", ")", "{", "final", "List", "<", "String", ">", "xmlErrors", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "final", "ServerEntitiesWrapper", "serverEntities", "=", "serverSettings", ".", "getEntities", "(", ")", ";", "if", "(", "isTopicANormalTopic", "(", "topic", ",", "serverSettings", ")", ")", "{", "if", "(", "!", "doc", ".", "getDocumentElement", "(", ")", ".", "getNodeName", "(", ")", ".", "equals", "(", "DocBookUtilities", ".", "TOPIC_ROOT_NODE_NAME", ")", ")", "{", "xmlErrors", ".", "add", "(", "\"Topics must be a <\"", "+", "DocBookUtilities", ".", "TOPIC_ROOT_NODE_NAME", "+", "\">.\"", ")", ";", "}", "}", "else", "{", "if", "(", "topic", ".", "hasTag", "(", "serverEntities", ".", "getRevisionHistoryTagId", "(", ")", ")", ")", "{", "if", "(", "!", "doc", ".", "getDocumentElement", "(", ")", ".", "getNodeName", "(", ")", ".", "equals", "(", "\"appendix\"", ")", ")", "{", "xmlErrors", ".", "add", "(", "\"Revision History topics must be an <appendix>.\"", ")", ";", "}", "// Check to make sure that a revhistory entry exists", "final", "NodeList", "revHistoryList", "=", "doc", ".", "getElementsByTagName", "(", "\"revhistory\"", ")", ";", "if", "(", "revHistoryList", ".", "getLength", "(", ")", "==", "0", ")", "{", "xmlErrors", ".", "add", "(", "\"No <revhistory> element found. A <revhistory> must exist for Revision Histories.\"", ")", ";", "}", "}", "else", "if", "(", "topic", ".", "hasTag", "(", "serverEntities", ".", "getLegalNoticeTagId", "(", ")", ")", ")", "{", "if", "(", "!", "doc", ".", "getDocumentElement", "(", ")", ".", "getNodeName", "(", ")", ".", "equals", "(", "\"legalnotice\"", ")", ")", "{", "xmlErrors", ".", "add", "(", "\"Legal Notice topics must be a <legalnotice>.\"", ")", ";", "}", "}", "else", "if", "(", "topic", ".", "hasTag", "(", "serverEntities", ".", "getAuthorGroupTagId", "(", ")", ")", ")", "{", "if", "(", "!", "doc", ".", "getDocumentElement", "(", ")", ".", "getNodeName", "(", ")", ".", "equals", "(", "\"authorgroup\"", ")", ")", "{", "xmlErrors", ".", "add", "(", "\"Author Group topics must be an <authorgroup>.\"", ")", ";", "}", "}", "else", "if", "(", "topic", ".", "hasTag", "(", "serverEntities", ".", "getAbstractTagId", "(", ")", ")", ")", "{", "if", "(", "!", "doc", ".", "getDocumentElement", "(", ")", ".", "getNodeName", "(", ")", ".", "equals", "(", "\"abstract\"", ")", ")", "{", "xmlErrors", ".", "add", "(", "\"Abstract topics must be an <abstract>.\"", ")", ";", "}", "}", "else", "if", "(", "topic", ".", "hasTag", "(", "serverEntities", ".", "getInfoTagId", "(", ")", ")", ")", "{", "if", "(", "DocBookVersion", ".", "DOCBOOK_50", ".", "getId", "(", ")", ".", "equals", "(", "topic", ".", "getXmlFormat", "(", ")", ")", ")", "{", "if", "(", "!", "doc", ".", "getDocumentElement", "(", ")", ".", "getNodeName", "(", ")", ".", "equals", "(", "\"info\"", ")", ")", "{", "xmlErrors", ".", "add", "(", "\"Info topics must be an <info>.\"", ")", ";", "}", "}", "else", "{", "if", "(", "!", "doc", ".", "getDocumentElement", "(", ")", ".", "getNodeName", "(", ")", ".", "equals", "(", "\"sectioninfo\"", ")", ")", "{", "xmlErrors", ".", "add", "(", "\"Info topics must be a <sectioninfo>.\"", ")", ";", "}", "}", "}", "}", "return", "xmlErrors", ";", "}" ]
Checks that the topics root element matches the topic type. @param topic The topic to validate the doc against. @param doc The topics XML DOM Document. @return A list of error messages for any invalid content found, otherwise an empty list.
[ "Checks", "that", "the", "topics", "root", "element", "matches", "the", "topic", "type", "." ]
2bc02e2971e4522b47a130fb7ae5a0f5ad377df1
https://github.com/pressgang-ccms/PressGangCCMSContentSpec/blob/2bc02e2971e4522b47a130fb7ae5a0f5ad377df1/src/main/java/org/jboss/pressgang/ccms/contentspec/utils/CustomTopicXMLValidator.java#L63-L109
151,681
pressgang-ccms/PressGangCCMSContentSpec
src/main/java/org/jboss/pressgang/ccms/contentspec/utils/CustomTopicXMLValidator.java
CustomTopicXMLValidator.checkTopicContentBasedOnType
public static List<String> checkTopicContentBasedOnType(final ServerSettingsWrapper serverSettings, final BaseTopicWrapper<?> topic, final Document doc, boolean skipNestedSectionValidation) { final ServerEntitiesWrapper serverEntities = serverSettings.getEntities(); final List<String> xmlErrors = new ArrayList<String>(); if (topic.hasTag(serverEntities.getRevisionHistoryTagId())) { // Check to make sure that a revhistory entry exists final String revHistoryErrors = DocBookUtilities.validateRevisionHistory(doc, DATE_FORMATS); if (revHistoryErrors != null) { xmlErrors.add(revHistoryErrors); } } else if (topic.hasTag(serverEntities.getInfoTagId())) { // Check that the info topic doesn't contain invalid fields if (DocBookUtilities.checkForInvalidInfoElements(doc)) { xmlErrors.add("Info topics cannot contain <title>, <subtitle> or <titleabbrev> elements."); } } else if (isTopicANormalTopic(topic, serverSettings)) { // Check that nested sections aren't used final List<Node> subSections = XMLUtilities.getDirectChildNodes(doc.getDocumentElement(), "section"); if (subSections.size() > 0 && !skipNestedSectionValidation) { xmlErrors.add("Nested sections cannot be used in topics. Please consider breaking the content into multiple topics."); } } return xmlErrors; }
java
public static List<String> checkTopicContentBasedOnType(final ServerSettingsWrapper serverSettings, final BaseTopicWrapper<?> topic, final Document doc, boolean skipNestedSectionValidation) { final ServerEntitiesWrapper serverEntities = serverSettings.getEntities(); final List<String> xmlErrors = new ArrayList<String>(); if (topic.hasTag(serverEntities.getRevisionHistoryTagId())) { // Check to make sure that a revhistory entry exists final String revHistoryErrors = DocBookUtilities.validateRevisionHistory(doc, DATE_FORMATS); if (revHistoryErrors != null) { xmlErrors.add(revHistoryErrors); } } else if (topic.hasTag(serverEntities.getInfoTagId())) { // Check that the info topic doesn't contain invalid fields if (DocBookUtilities.checkForInvalidInfoElements(doc)) { xmlErrors.add("Info topics cannot contain <title>, <subtitle> or <titleabbrev> elements."); } } else if (isTopicANormalTopic(topic, serverSettings)) { // Check that nested sections aren't used final List<Node> subSections = XMLUtilities.getDirectChildNodes(doc.getDocumentElement(), "section"); if (subSections.size() > 0 && !skipNestedSectionValidation) { xmlErrors.add("Nested sections cannot be used in topics. Please consider breaking the content into multiple topics."); } } return xmlErrors; }
[ "public", "static", "List", "<", "String", ">", "checkTopicContentBasedOnType", "(", "final", "ServerSettingsWrapper", "serverSettings", ",", "final", "BaseTopicWrapper", "<", "?", ">", "topic", ",", "final", "Document", "doc", ",", "boolean", "skipNestedSectionValidation", ")", "{", "final", "ServerEntitiesWrapper", "serverEntities", "=", "serverSettings", ".", "getEntities", "(", ")", ";", "final", "List", "<", "String", ">", "xmlErrors", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "if", "(", "topic", ".", "hasTag", "(", "serverEntities", ".", "getRevisionHistoryTagId", "(", ")", ")", ")", "{", "// Check to make sure that a revhistory entry exists", "final", "String", "revHistoryErrors", "=", "DocBookUtilities", ".", "validateRevisionHistory", "(", "doc", ",", "DATE_FORMATS", ")", ";", "if", "(", "revHistoryErrors", "!=", "null", ")", "{", "xmlErrors", ".", "add", "(", "revHistoryErrors", ")", ";", "}", "}", "else", "if", "(", "topic", ".", "hasTag", "(", "serverEntities", ".", "getInfoTagId", "(", ")", ")", ")", "{", "// Check that the info topic doesn't contain invalid fields", "if", "(", "DocBookUtilities", ".", "checkForInvalidInfoElements", "(", "doc", ")", ")", "{", "xmlErrors", ".", "add", "(", "\"Info topics cannot contain <title>, <subtitle> or <titleabbrev> elements.\"", ")", ";", "}", "}", "else", "if", "(", "isTopicANormalTopic", "(", "topic", ",", "serverSettings", ")", ")", "{", "// Check that nested sections aren't used", "final", "List", "<", "Node", ">", "subSections", "=", "XMLUtilities", ".", "getDirectChildNodes", "(", "doc", ".", "getDocumentElement", "(", ")", ",", "\"section\"", ")", ";", "if", "(", "subSections", ".", "size", "(", ")", ">", "0", "&&", "!", "skipNestedSectionValidation", ")", "{", "xmlErrors", ".", "add", "(", "\"Nested sections cannot be used in topics. Please consider breaking the content into multiple topics.\"", ")", ";", "}", "}", "return", "xmlErrors", ";", "}" ]
Check a topic and return an error messages if the content doesn't match the topic type. @param serverSettings The server settings. @param topic The topic to check the content for. @param doc The topics XML DOM Document. @param skipNestedSectionValidation Whether or not nested section validation should be performed. @return A list of error messages for any invalid content found, otherwise an empty list.
[ "Check", "a", "topic", "and", "return", "an", "error", "messages", "if", "the", "content", "doesn", "t", "match", "the", "topic", "type", "." ]
2bc02e2971e4522b47a130fb7ae5a0f5ad377df1
https://github.com/pressgang-ccms/PressGangCCMSContentSpec/blob/2bc02e2971e4522b47a130fb7ae5a0f5ad377df1/src/main/java/org/jboss/pressgang/ccms/contentspec/utils/CustomTopicXMLValidator.java#L120-L145
151,682
pressgang-ccms/PressGangCCMSContentSpec
src/main/java/org/jboss/pressgang/ccms/contentspec/utils/CustomTopicXMLValidator.java
CustomTopicXMLValidator.isTopicANormalTopic
public static boolean isTopicANormalTopic(final BaseTopicWrapper<?> topic, final ServerSettingsWrapper serverSettings) { return !(topic.hasTag(serverSettings.getEntities().getRevisionHistoryTagId()) || topic.hasTag( serverSettings.getEntities().getLegalNoticeTagId()) || topic.hasTag( serverSettings.getEntities().getAuthorGroupTagId()) || topic.hasTag( serverSettings.getEntities().getInfoTagId()) || topic.hasTag(serverSettings.getEntities().getAbstractTagId())); }
java
public static boolean isTopicANormalTopic(final BaseTopicWrapper<?> topic, final ServerSettingsWrapper serverSettings) { return !(topic.hasTag(serverSettings.getEntities().getRevisionHistoryTagId()) || topic.hasTag( serverSettings.getEntities().getLegalNoticeTagId()) || topic.hasTag( serverSettings.getEntities().getAuthorGroupTagId()) || topic.hasTag( serverSettings.getEntities().getInfoTagId()) || topic.hasTag(serverSettings.getEntities().getAbstractTagId())); }
[ "public", "static", "boolean", "isTopicANormalTopic", "(", "final", "BaseTopicWrapper", "<", "?", ">", "topic", ",", "final", "ServerSettingsWrapper", "serverSettings", ")", "{", "return", "!", "(", "topic", ".", "hasTag", "(", "serverSettings", ".", "getEntities", "(", ")", ".", "getRevisionHistoryTagId", "(", ")", ")", "||", "topic", ".", "hasTag", "(", "serverSettings", ".", "getEntities", "(", ")", ".", "getLegalNoticeTagId", "(", ")", ")", "||", "topic", ".", "hasTag", "(", "serverSettings", ".", "getEntities", "(", ")", ".", "getAuthorGroupTagId", "(", ")", ")", "||", "topic", ".", "hasTag", "(", "serverSettings", ".", "getEntities", "(", ")", ".", "getInfoTagId", "(", ")", ")", "||", "topic", ".", "hasTag", "(", "serverSettings", ".", "getEntities", "(", ")", ".", "getAbstractTagId", "(", ")", ")", ")", ";", "}" ]
Check to see if a Topic is a normal topic, instead of a Revision History or Legal Notice @param topic The topic to be checked. @return True if the topic is a normal topic, otherwise false.
[ "Check", "to", "see", "if", "a", "Topic", "is", "a", "normal", "topic", "instead", "of", "a", "Revision", "History", "or", "Legal", "Notice" ]
2bc02e2971e4522b47a130fb7ae5a0f5ad377df1
https://github.com/pressgang-ccms/PressGangCCMSContentSpec/blob/2bc02e2971e4522b47a130fb7ae5a0f5ad377df1/src/main/java/org/jboss/pressgang/ccms/contentspec/utils/CustomTopicXMLValidator.java#L153-L158
151,683
pressgang-ccms/PressGangCCMSContentSpec
src/main/java/org/jboss/pressgang/ccms/contentspec/utils/CustomTopicXMLValidator.java
CustomTopicXMLValidator.doesTopicHaveValidXMLForInitialContent
public static boolean doesTopicHaveValidXMLForInitialContent(final SpecTopic specTopic, final BaseTopicWrapper<?> topic) { boolean valid = true; final InitialContent initialContent = (InitialContent) specTopic.getParent(); final int numSpecTopics = initialContent.getNumberOfSpecTopics() + initialContent.getNumberOfCommonContents(); final boolean isOnlyChild = initialContent.getParent().getNumberOfChildLevels() == 1 && initialContent.getParent().getNumberOfSpecTopics() == 0 && initialContent.getParent().getNumberOfCommonContents() == 0 && numSpecTopics == 1; if (numSpecTopics >= 1) { final String condition = specTopic.getConditionStatement(true); try { final Document doc = XMLUtilities.convertStringToDocument(topic.getXml()); // Process the conditions to remove anything that isn't used DocBookUtilities.processConditions(condition, doc); /* * We need to make sure the following rules apply for initial text: * - Nested sections aren't used * - <simplesect> and <refentry> can only be used if the topic is an only child * - <info>/<sectioninfo> can only be used in the first child topic and the initial content doesn't have an info topic */ final List<org.w3c.dom.Node> invalidElements = XMLUtilities.getDirectChildNodes(doc.getDocumentElement(), "section"); final List<org.w3c.dom.Node> invalidElementsIfMultipleChildren = XMLUtilities.getDirectChildNodes(doc.getDocumentElement(), "refentry", "simplesect"); final List<org.w3c.dom.Node> invalidInfoElements = XMLUtilities.getDirectChildNodes(doc.getDocumentElement(), "info", "sectioninfo"); if (numSpecTopics > 1 && invalidElements.size() > 0) { valid = false; } else if (!isOnlyChild && invalidElementsIfMultipleChildren.size() > 0) { valid = false; } else if ((initialContent.getFirstSpecNode() != specTopic && invalidInfoElements.size() > 0) || (initialContent.getParent().getInfoTopic() != null && invalidInfoElements.size() > 0)) { valid = false; } } catch (Exception e) { log.debug(e.getMessage()); } } return valid; }
java
public static boolean doesTopicHaveValidXMLForInitialContent(final SpecTopic specTopic, final BaseTopicWrapper<?> topic) { boolean valid = true; final InitialContent initialContent = (InitialContent) specTopic.getParent(); final int numSpecTopics = initialContent.getNumberOfSpecTopics() + initialContent.getNumberOfCommonContents(); final boolean isOnlyChild = initialContent.getParent().getNumberOfChildLevels() == 1 && initialContent.getParent().getNumberOfSpecTopics() == 0 && initialContent.getParent().getNumberOfCommonContents() == 0 && numSpecTopics == 1; if (numSpecTopics >= 1) { final String condition = specTopic.getConditionStatement(true); try { final Document doc = XMLUtilities.convertStringToDocument(topic.getXml()); // Process the conditions to remove anything that isn't used DocBookUtilities.processConditions(condition, doc); /* * We need to make sure the following rules apply for initial text: * - Nested sections aren't used * - <simplesect> and <refentry> can only be used if the topic is an only child * - <info>/<sectioninfo> can only be used in the first child topic and the initial content doesn't have an info topic */ final List<org.w3c.dom.Node> invalidElements = XMLUtilities.getDirectChildNodes(doc.getDocumentElement(), "section"); final List<org.w3c.dom.Node> invalidElementsIfMultipleChildren = XMLUtilities.getDirectChildNodes(doc.getDocumentElement(), "refentry", "simplesect"); final List<org.w3c.dom.Node> invalidInfoElements = XMLUtilities.getDirectChildNodes(doc.getDocumentElement(), "info", "sectioninfo"); if (numSpecTopics > 1 && invalidElements.size() > 0) { valid = false; } else if (!isOnlyChild && invalidElementsIfMultipleChildren.size() > 0) { valid = false; } else if ((initialContent.getFirstSpecNode() != specTopic && invalidInfoElements.size() > 0) || (initialContent.getParent().getInfoTopic() != null && invalidInfoElements.size() > 0)) { valid = false; } } catch (Exception e) { log.debug(e.getMessage()); } } return valid; }
[ "public", "static", "boolean", "doesTopicHaveValidXMLForInitialContent", "(", "final", "SpecTopic", "specTopic", ",", "final", "BaseTopicWrapper", "<", "?", ">", "topic", ")", "{", "boolean", "valid", "=", "true", ";", "final", "InitialContent", "initialContent", "=", "(", "InitialContent", ")", "specTopic", ".", "getParent", "(", ")", ";", "final", "int", "numSpecTopics", "=", "initialContent", ".", "getNumberOfSpecTopics", "(", ")", "+", "initialContent", ".", "getNumberOfCommonContents", "(", ")", ";", "final", "boolean", "isOnlyChild", "=", "initialContent", ".", "getParent", "(", ")", ".", "getNumberOfChildLevels", "(", ")", "==", "1", "&&", "initialContent", ".", "getParent", "(", ")", ".", "getNumberOfSpecTopics", "(", ")", "==", "0", "&&", "initialContent", ".", "getParent", "(", ")", ".", "getNumberOfCommonContents", "(", ")", "==", "0", "&&", "numSpecTopics", "==", "1", ";", "if", "(", "numSpecTopics", ">=", "1", ")", "{", "final", "String", "condition", "=", "specTopic", ".", "getConditionStatement", "(", "true", ")", ";", "try", "{", "final", "Document", "doc", "=", "XMLUtilities", ".", "convertStringToDocument", "(", "topic", ".", "getXml", "(", ")", ")", ";", "// Process the conditions to remove anything that isn't used", "DocBookUtilities", ".", "processConditions", "(", "condition", ",", "doc", ")", ";", "/*\n * We need to make sure the following rules apply for initial text:\n * - Nested sections aren't used\n * - <simplesect> and <refentry> can only be used if the topic is an only child\n * - <info>/<sectioninfo> can only be used in the first child topic and the initial content doesn't have an info topic\n */", "final", "List", "<", "org", ".", "w3c", ".", "dom", ".", "Node", ">", "invalidElements", "=", "XMLUtilities", ".", "getDirectChildNodes", "(", "doc", ".", "getDocumentElement", "(", ")", ",", "\"section\"", ")", ";", "final", "List", "<", "org", ".", "w3c", ".", "dom", ".", "Node", ">", "invalidElementsIfMultipleChildren", "=", "XMLUtilities", ".", "getDirectChildNodes", "(", "doc", ".", "getDocumentElement", "(", ")", ",", "\"refentry\"", ",", "\"simplesect\"", ")", ";", "final", "List", "<", "org", ".", "w3c", ".", "dom", ".", "Node", ">", "invalidInfoElements", "=", "XMLUtilities", ".", "getDirectChildNodes", "(", "doc", ".", "getDocumentElement", "(", ")", ",", "\"info\"", ",", "\"sectioninfo\"", ")", ";", "if", "(", "numSpecTopics", ">", "1", "&&", "invalidElements", ".", "size", "(", ")", ">", "0", ")", "{", "valid", "=", "false", ";", "}", "else", "if", "(", "!", "isOnlyChild", "&&", "invalidElementsIfMultipleChildren", ".", "size", "(", ")", ">", "0", ")", "{", "valid", "=", "false", ";", "}", "else", "if", "(", "(", "initialContent", ".", "getFirstSpecNode", "(", ")", "!=", "specTopic", "&&", "invalidInfoElements", ".", "size", "(", ")", ">", "0", ")", "||", "(", "initialContent", ".", "getParent", "(", ")", ".", "getInfoTopic", "(", ")", "!=", "null", "&&", "invalidInfoElements", ".", "size", "(", ")", ">", "0", ")", ")", "{", "valid", "=", "false", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "debug", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "return", "valid", ";", "}" ]
Checks a topics XML to make sure it has content that can be used as front matter for a level. @param specTopic The SpecTopic of the topic to check the XML for. @param topic The actual topic to check the XML from. @return True if the XML can be used, otherwise false.
[ "Checks", "a", "topics", "XML", "to", "make", "sure", "it", "has", "content", "that", "can", "be", "used", "as", "front", "matter", "for", "a", "level", "." ]
2bc02e2971e4522b47a130fb7ae5a0f5ad377df1
https://github.com/pressgang-ccms/PressGangCCMSContentSpec/blob/2bc02e2971e4522b47a130fb7ae5a0f5ad377df1/src/main/java/org/jboss/pressgang/ccms/contentspec/utils/CustomTopicXMLValidator.java#L167-L208
151,684
nwillc/almost-functional
src/main/java/almost/functional/utils/Throwables.java
Throwables.propagate
public static RuntimeException propagate(final Exception exception) { if (RuntimeException.class.isAssignableFrom(exception.getClass())) { return (RuntimeException) exception; } return new RuntimeException("Repropagated " + exception.getMessage(), exception); //NOPMD }
java
public static RuntimeException propagate(final Exception exception) { if (RuntimeException.class.isAssignableFrom(exception.getClass())) { return (RuntimeException) exception; } return new RuntimeException("Repropagated " + exception.getMessage(), exception); //NOPMD }
[ "public", "static", "RuntimeException", "propagate", "(", "final", "Exception", "exception", ")", "{", "if", "(", "RuntimeException", ".", "class", ".", "isAssignableFrom", "(", "exception", ".", "getClass", "(", ")", ")", ")", "{", "return", "(", "RuntimeException", ")", "exception", ";", "}", "return", "new", "RuntimeException", "(", "\"Repropagated \"", "+", "exception", ".", "getMessage", "(", ")", ",", "exception", ")", ";", "//NOPMD", "}" ]
Propagate a Throwable as a RuntimeException. The Runtime exception bases it's message not the message of the Throwable, and the Throwable is set as it's cause. This can be used to deal with exceptions in lambdas etc. @param exception the Exception to repropagate. @return a RuntimeException
[ "Propagate", "a", "Throwable", "as", "a", "RuntimeException", ".", "The", "Runtime", "exception", "bases", "it", "s", "message", "not", "the", "message", "of", "the", "Throwable", "and", "the", "Throwable", "is", "set", "as", "it", "s", "cause", ".", "This", "can", "be", "used", "to", "deal", "with", "exceptions", "in", "lambdas", "etc", "." ]
a6cc7c73b2be475ed1bce5128c24b2eb9c27d666
https://github.com/nwillc/almost-functional/blob/a6cc7c73b2be475ed1bce5128c24b2eb9c27d666/src/main/java/almost/functional/utils/Throwables.java#L31-L37
151,685
NessComputing/components-ness-event
core/src/main/java/com/nesscomputing/event/InternalEventDispatcher.java
InternalEventDispatcher.dispatch
@Override public void dispatch(@Nonnull final NessEvent event) { if (event == null) { LOG.trace("Dropping null event"); } else { for (final NessEventReceiver receiver : eventReceivers) { try { if (receiver.accept(event)) { receiver.receive(event); } } catch (Exception e) { // don't reraise. We prefer to not disrupt event handling by other receievers LOG.error(e, "Exception during event handling by %s of event %s", receiver, event); } } } }
java
@Override public void dispatch(@Nonnull final NessEvent event) { if (event == null) { LOG.trace("Dropping null event"); } else { for (final NessEventReceiver receiver : eventReceivers) { try { if (receiver.accept(event)) { receiver.receive(event); } } catch (Exception e) { // don't reraise. We prefer to not disrupt event handling by other receievers LOG.error(e, "Exception during event handling by %s of event %s", receiver, event); } } } }
[ "@", "Override", "public", "void", "dispatch", "(", "@", "Nonnull", "final", "NessEvent", "event", ")", "{", "if", "(", "event", "==", "null", ")", "{", "LOG", ".", "trace", "(", "\"Dropping null event\"", ")", ";", "}", "else", "{", "for", "(", "final", "NessEventReceiver", "receiver", ":", "eventReceivers", ")", "{", "try", "{", "if", "(", "receiver", ".", "accept", "(", "event", ")", ")", "{", "receiver", ".", "receive", "(", "event", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "// don't reraise. We prefer to not disrupt event handling by other receievers", "LOG", ".", "error", "(", "e", ",", "\"Exception during event handling by %s of event %s\"", ",", "receiver", ",", "event", ")", ";", "}", "}", "}", "}" ]
Dispatch an event for distribution to the local Event receivers.
[ "Dispatch", "an", "event", "for", "distribution", "to", "the", "local", "Event", "receivers", "." ]
6d41f9e7c810c3ffa6bb79e19bb8cfb1d1c12c33
https://github.com/NessComputing/components-ness-event/blob/6d41f9e7c810c3ffa6bb79e19bb8cfb1d1c12c33/core/src/main/java/com/nesscomputing/event/InternalEventDispatcher.java#L50-L69
151,686
sworisbreathing/sfmf4j
sfmf4j-jpathwatch/src/main/java/com/github/sworisbreathing/sfmf4j/jpathwatch/SFMF4JWatchListener.java
SFMF4JWatchListener.onEvent
public void onEvent(final WatchEvent<Path> event) { Kind kind = event.kind(); if (StandardWatchEventKind.ENTRY_CREATE.equals(kind)) { File file = new File(event.context().toString()); listener.fileCreated(file); } else if (StandardWatchEventKind.ENTRY_DELETE.equals(kind)) { File file = new File(event.context().toString()); listener.fileDeleted(file); } else if (StandardWatchEventKind.ENTRY_MODIFY.equals(kind)) { File file = new File(event.context().toString()); listener.fileChanged(file); } }
java
public void onEvent(final WatchEvent<Path> event) { Kind kind = event.kind(); if (StandardWatchEventKind.ENTRY_CREATE.equals(kind)) { File file = new File(event.context().toString()); listener.fileCreated(file); } else if (StandardWatchEventKind.ENTRY_DELETE.equals(kind)) { File file = new File(event.context().toString()); listener.fileDeleted(file); } else if (StandardWatchEventKind.ENTRY_MODIFY.equals(kind)) { File file = new File(event.context().toString()); listener.fileChanged(file); } }
[ "public", "void", "onEvent", "(", "final", "WatchEvent", "<", "Path", ">", "event", ")", "{", "Kind", "kind", "=", "event", ".", "kind", "(", ")", ";", "if", "(", "StandardWatchEventKind", ".", "ENTRY_CREATE", ".", "equals", "(", "kind", ")", ")", "{", "File", "file", "=", "new", "File", "(", "event", ".", "context", "(", ")", ".", "toString", "(", ")", ")", ";", "listener", ".", "fileCreated", "(", "file", ")", ";", "}", "else", "if", "(", "StandardWatchEventKind", ".", "ENTRY_DELETE", ".", "equals", "(", "kind", ")", ")", "{", "File", "file", "=", "new", "File", "(", "event", ".", "context", "(", ")", ".", "toString", "(", ")", ")", ";", "listener", ".", "fileDeleted", "(", "file", ")", ";", "}", "else", "if", "(", "StandardWatchEventKind", ".", "ENTRY_MODIFY", ".", "equals", "(", "kind", ")", ")", "{", "File", "file", "=", "new", "File", "(", "event", ".", "context", "(", ")", ".", "toString", "(", ")", ")", ";", "listener", ".", "fileChanged", "(", "file", ")", ";", "}", "}" ]
Forwards watch events to the listener. @param event the event to forward @see StandardWatchEventKind @see DirectoryListener#fileCreated(File) @see DirectoryListener#fileDeleted(File) @see DirectoryListener#fileChanged(File)
[ "Forwards", "watch", "events", "to", "the", "listener", "." ]
826c2c02af69d55f98e64fbcfae23d0c7bac3f19
https://github.com/sworisbreathing/sfmf4j/blob/826c2c02af69d55f98e64fbcfae23d0c7bac3f19/sfmf4j-jpathwatch/src/main/java/com/github/sworisbreathing/sfmf4j/jpathwatch/SFMF4JWatchListener.java#L56-L68
151,687
jbundle/jbundle
app/program/db/src/main/java/org/jbundle/app/program/db/ProgramControl.java
ProgramControl.getBasePath
public String getBasePath() { String basePath = DBConstants.BLANK; basePath = this.getField(ProgramControl.BASE_DIRECTORY).toString(); PropertyOwner propertyOwner = null; if (this.getOwner() instanceof PropertyOwner) propertyOwner = (PropertyOwner)this.getOwner(); try { basePath = Utility.replaceResources(basePath, null, Utility.propertiesToMap(System.getProperties()), propertyOwner); } catch (SecurityException e) { basePath = Utility.replaceResources(basePath, null, null, propertyOwner); } return basePath; }
java
public String getBasePath() { String basePath = DBConstants.BLANK; basePath = this.getField(ProgramControl.BASE_DIRECTORY).toString(); PropertyOwner propertyOwner = null; if (this.getOwner() instanceof PropertyOwner) propertyOwner = (PropertyOwner)this.getOwner(); try { basePath = Utility.replaceResources(basePath, null, Utility.propertiesToMap(System.getProperties()), propertyOwner); } catch (SecurityException e) { basePath = Utility.replaceResources(basePath, null, null, propertyOwner); } return basePath; }
[ "public", "String", "getBasePath", "(", ")", "{", "String", "basePath", "=", "DBConstants", ".", "BLANK", ";", "basePath", "=", "this", ".", "getField", "(", "ProgramControl", ".", "BASE_DIRECTORY", ")", ".", "toString", "(", ")", ";", "PropertyOwner", "propertyOwner", "=", "null", ";", "if", "(", "this", ".", "getOwner", "(", ")", "instanceof", "PropertyOwner", ")", "propertyOwner", "=", "(", "PropertyOwner", ")", "this", ".", "getOwner", "(", ")", ";", "try", "{", "basePath", "=", "Utility", ".", "replaceResources", "(", "basePath", ",", "null", ",", "Utility", ".", "propertiesToMap", "(", "System", ".", "getProperties", "(", ")", ")", ",", "propertyOwner", ")", ";", "}", "catch", "(", "SecurityException", "e", ")", "{", "basePath", "=", "Utility", ".", "replaceResources", "(", "basePath", ",", "null", ",", "null", ",", "propertyOwner", ")", ";", "}", "return", "basePath", ";", "}" ]
Get the base path. Replace all the params first.
[ "Get", "the", "base", "path", ".", "Replace", "all", "the", "params", "first", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/db/src/main/java/org/jbundle/app/program/db/ProgramControl.java#L234-L247
151,688
carewebframework/carewebframework-vista
org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/Response.java
Response.getResponseType
private ResponseType getResponseType(int code) throws IOException { try { return ResponseType.values()[code]; } catch (Exception e) { throw new IOException("Unrecognized response code: " + code); } }
java
private ResponseType getResponseType(int code) throws IOException { try { return ResponseType.values()[code]; } catch (Exception e) { throw new IOException("Unrecognized response code: " + code); } }
[ "private", "ResponseType", "getResponseType", "(", "int", "code", ")", "throws", "IOException", "{", "try", "{", "return", "ResponseType", ".", "values", "(", ")", "[", "code", "]", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "IOException", "(", "\"Unrecognized response code: \"", "+", "code", ")", ";", "}", "}" ]
Returns the response type from the status value. @param code The response code. @return The response type.
[ "Returns", "the", "response", "type", "from", "the", "status", "value", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/Response.java#L91-L97
151,689
DDTH/ddth-tsc
ddth-tsc-core/src/main/java/com/github/ddth/tsc/DataPoint.java
DataPoint.add
public DataPoint add(DataPoint another) { if (type == Type.NONE) { _cloneFrom(another); } else { if (another.type != Type.NONE) { add(another.value()); } } return this; }
java
public DataPoint add(DataPoint another) { if (type == Type.NONE) { _cloneFrom(another); } else { if (another.type != Type.NONE) { add(another.value()); } } return this; }
[ "public", "DataPoint", "add", "(", "DataPoint", "another", ")", "{", "if", "(", "type", "==", "Type", ".", "NONE", ")", "{", "_cloneFrom", "(", "another", ")", ";", "}", "else", "{", "if", "(", "another", ".", "type", "!=", "Type", ".", "NONE", ")", "{", "add", "(", "another", ".", "value", "(", ")", ")", ";", "}", "}", "return", "this", ";", "}" ]
Adds value from another data point. @param another @return @since 0.3.0
[ "Adds", "value", "from", "another", "data", "point", "." ]
d233c304c8fed2f3c069de42a36b7bbd5c8be01b
https://github.com/DDTH/ddth-tsc/blob/d233c304c8fed2f3c069de42a36b7bbd5c8be01b/ddth-tsc-core/src/main/java/com/github/ddth/tsc/DataPoint.java#L170-L180
151,690
DDTH/ddth-tsc
ddth-tsc-core/src/main/java/com/github/ddth/tsc/DataPoint.java
DataPoint.add
public DataPoint add(long value) { switch (type) { case MINIMUM: this.value = Math.min(this.value, value); break; case MAXIMUM: this.value = Math.max(this.value, value); break; case AVERAGE: case SUM: this.value += value; this.numPoints++; break; default: throw new IllegalStateException("Unknown type [" + type + "]!"); } return this; }
java
public DataPoint add(long value) { switch (type) { case MINIMUM: this.value = Math.min(this.value, value); break; case MAXIMUM: this.value = Math.max(this.value, value); break; case AVERAGE: case SUM: this.value += value; this.numPoints++; break; default: throw new IllegalStateException("Unknown type [" + type + "]!"); } return this; }
[ "public", "DataPoint", "add", "(", "long", "value", ")", "{", "switch", "(", "type", ")", "{", "case", "MINIMUM", ":", "this", ".", "value", "=", "Math", ".", "min", "(", "this", ".", "value", ",", "value", ")", ";", "break", ";", "case", "MAXIMUM", ":", "this", ".", "value", "=", "Math", ".", "max", "(", "this", ".", "value", ",", "value", ")", ";", "break", ";", "case", "AVERAGE", ":", "case", "SUM", ":", "this", ".", "value", "+=", "value", ";", "this", ".", "numPoints", "++", ";", "break", ";", "default", ":", "throw", "new", "IllegalStateException", "(", "\"Unknown type [\"", "+", "type", "+", "\"]!\"", ")", ";", "}", "return", "this", ";", "}" ]
Adds a value to the data point. <p> How the value is actually added depends on type of the data point. See {@link Type}. </p> @param value @return
[ "Adds", "a", "value", "to", "the", "data", "point", "." ]
d233c304c8fed2f3c069de42a36b7bbd5c8be01b
https://github.com/DDTH/ddth-tsc/blob/d233c304c8fed2f3c069de42a36b7bbd5c8be01b/ddth-tsc-core/src/main/java/com/github/ddth/tsc/DataPoint.java#L193-L210
151,691
DDTH/ddth-tsc
ddth-tsc-core/src/main/java/com/github/ddth/tsc/DataPoint.java
DataPoint.set
public DataPoint set(DataPoint another) { if (type == Type.NONE) { _cloneFrom(another); } else { if (another.type != Type.NONE) { set(another.value()); } } return this; }
java
public DataPoint set(DataPoint another) { if (type == Type.NONE) { _cloneFrom(another); } else { if (another.type != Type.NONE) { set(another.value()); } } return this; }
[ "public", "DataPoint", "set", "(", "DataPoint", "another", ")", "{", "if", "(", "type", "==", "Type", ".", "NONE", ")", "{", "_cloneFrom", "(", "another", ")", ";", "}", "else", "{", "if", "(", "another", ".", "type", "!=", "Type", ".", "NONE", ")", "{", "set", "(", "another", ".", "value", "(", ")", ")", ";", "}", "}", "return", "this", ";", "}" ]
Sets data point's value using another data point. @param another @return @since 0.3.0
[ "Sets", "data", "point", "s", "value", "using", "another", "data", "point", "." ]
d233c304c8fed2f3c069de42a36b7bbd5c8be01b
https://github.com/DDTH/ddth-tsc/blob/d233c304c8fed2f3c069de42a36b7bbd5c8be01b/ddth-tsc-core/src/main/java/com/github/ddth/tsc/DataPoint.java#L219-L229
151,692
DDTH/ddth-tsc
ddth-tsc-core/src/main/java/com/github/ddth/tsc/DataPoint.java
DataPoint.value
public long value() { switch (type) { case AVERAGE: return numPoints != 0 ? value / numPoints : 0; case NONE: return 0; case MAXIMUM: case MINIMUM: case SUM: return value; default: throw new IllegalStateException("Unknown type [" + type + "]!"); } }
java
public long value() { switch (type) { case AVERAGE: return numPoints != 0 ? value / numPoints : 0; case NONE: return 0; case MAXIMUM: case MINIMUM: case SUM: return value; default: throw new IllegalStateException("Unknown type [" + type + "]!"); } }
[ "public", "long", "value", "(", ")", "{", "switch", "(", "type", ")", "{", "case", "AVERAGE", ":", "return", "numPoints", "!=", "0", "?", "value", "/", "numPoints", ":", "0", ";", "case", "NONE", ":", "return", "0", ";", "case", "MAXIMUM", ":", "case", "MINIMUM", ":", "case", "SUM", ":", "return", "value", ";", "default", ":", "throw", "new", "IllegalStateException", "(", "\"Unknown type [\"", "+", "type", "+", "\"]!\"", ")", ";", "}", "}" ]
Gets the data point value. <p> The returned value depends on type of data point's. See {@link Type}. </p> @return
[ "Gets", "the", "data", "point", "value", "." ]
d233c304c8fed2f3c069de42a36b7bbd5c8be01b
https://github.com/DDTH/ddth-tsc/blob/d233c304c8fed2f3c069de42a36b7bbd5c8be01b/ddth-tsc-core/src/main/java/com/github/ddth/tsc/DataPoint.java#L252-L265
151,693
jmeetsma/Iglu-Util
src/main/java/org/ijsberg/iglu/util/misc/KeyGenerator.java
KeyGenerator.generateKey
public static synchronized String generateKey() { String code = ""; long nr = System.currentTimeMillis(); if (nr <= lastnr) { nr = lastnr + 1; } lastnr = nr; String s = String.valueOf(nr); for (int i = 0; i < s.length(); i++) { code += codeArray[randomizer.nextInt(6)][s.charAt(i) - 48]; } return code; }
java
public static synchronized String generateKey() { String code = ""; long nr = System.currentTimeMillis(); if (nr <= lastnr) { nr = lastnr + 1; } lastnr = nr; String s = String.valueOf(nr); for (int i = 0; i < s.length(); i++) { code += codeArray[randomizer.nextInt(6)][s.charAt(i) - 48]; } return code; }
[ "public", "static", "synchronized", "String", "generateKey", "(", ")", "{", "String", "code", "=", "\"\"", ";", "long", "nr", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "if", "(", "nr", "<=", "lastnr", ")", "{", "nr", "=", "lastnr", "+", "1", ";", "}", "lastnr", "=", "nr", ";", "String", "s", "=", "String", ".", "valueOf", "(", "nr", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "s", ".", "length", "(", ")", ";", "i", "++", ")", "{", "code", "+=", "codeArray", "[", "randomizer", ".", "nextInt", "(", "6", ")", "]", "[", "s", ".", "charAt", "(", "i", ")", "-", "48", "]", ";", "}", "return", "code", ";", "}" ]
Generates a random key which is guaranteed to be unique within the application. @return
[ "Generates", "a", "random", "key", "which", "is", "guaranteed", "to", "be", "unique", "within", "the", "application", "." ]
971eb022115247b1e34dc26dd02e7e621e29e910
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/KeyGenerator.java#L45-L58
151,694
jbundle/jbundle
main/msg.wsdl/src/main/java/org/jbundle/main/msg/wsdl/CreateWSDL20.java
CreateWSDL20.addServiceType
public void addServiceType(DescriptionType descriptionType) { String interfacens; String interfacename; QName qname; String name; ServiceType serviceType = wsdlFactory.createServiceType(); descriptionType.getImportOrIncludeOrTypes().add(wsdlFactory.createService(serviceType)); name = this.getControlProperty(MessageControl.SERVICE_NAME); serviceType.setName(name); interfacens = this.getNamespace();; interfacename = this.getControlProperty(MessageControl.INTERFACE_NAME); qname = new QName(interfacens, interfacename); serviceType.setInterface(qname); EndpointType endpointType = wsdlFactory.createEndpointType(); serviceType.getEndpointOrFeatureOrProperty().add(wsdlFactory.createEndpoint(endpointType)); String address = this.getURIValue(this.getRecord(MessageControl.MESSAGE_CONTROL_FILE).getField(MessageControl.WEB_SERVICES_SERVER).toString()); // Important - This is the web services URL endpointType.setAddress(address); interfacens = this.getNamespace();; interfacename = this.getControlProperty(MessageControl.BINDING_NAME); qname = new QName(interfacens, interfacename); endpointType.setBinding(qname); name = this.getControlProperty(MessageControl.ENDPOINT_NAME); endpointType.setName(name); }
java
public void addServiceType(DescriptionType descriptionType) { String interfacens; String interfacename; QName qname; String name; ServiceType serviceType = wsdlFactory.createServiceType(); descriptionType.getImportOrIncludeOrTypes().add(wsdlFactory.createService(serviceType)); name = this.getControlProperty(MessageControl.SERVICE_NAME); serviceType.setName(name); interfacens = this.getNamespace();; interfacename = this.getControlProperty(MessageControl.INTERFACE_NAME); qname = new QName(interfacens, interfacename); serviceType.setInterface(qname); EndpointType endpointType = wsdlFactory.createEndpointType(); serviceType.getEndpointOrFeatureOrProperty().add(wsdlFactory.createEndpoint(endpointType)); String address = this.getURIValue(this.getRecord(MessageControl.MESSAGE_CONTROL_FILE).getField(MessageControl.WEB_SERVICES_SERVER).toString()); // Important - This is the web services URL endpointType.setAddress(address); interfacens = this.getNamespace();; interfacename = this.getControlProperty(MessageControl.BINDING_NAME); qname = new QName(interfacens, interfacename); endpointType.setBinding(qname); name = this.getControlProperty(MessageControl.ENDPOINT_NAME); endpointType.setName(name); }
[ "public", "void", "addServiceType", "(", "DescriptionType", "descriptionType", ")", "{", "String", "interfacens", ";", "String", "interfacename", ";", "QName", "qname", ";", "String", "name", ";", "ServiceType", "serviceType", "=", "wsdlFactory", ".", "createServiceType", "(", ")", ";", "descriptionType", ".", "getImportOrIncludeOrTypes", "(", ")", ".", "add", "(", "wsdlFactory", ".", "createService", "(", "serviceType", ")", ")", ";", "name", "=", "this", ".", "getControlProperty", "(", "MessageControl", ".", "SERVICE_NAME", ")", ";", "serviceType", ".", "setName", "(", "name", ")", ";", "interfacens", "=", "this", ".", "getNamespace", "(", ")", ";", ";", "interfacename", "=", "this", ".", "getControlProperty", "(", "MessageControl", ".", "INTERFACE_NAME", ")", ";", "qname", "=", "new", "QName", "(", "interfacens", ",", "interfacename", ")", ";", "serviceType", ".", "setInterface", "(", "qname", ")", ";", "EndpointType", "endpointType", "=", "wsdlFactory", ".", "createEndpointType", "(", ")", ";", "serviceType", ".", "getEndpointOrFeatureOrProperty", "(", ")", ".", "add", "(", "wsdlFactory", ".", "createEndpoint", "(", "endpointType", ")", ")", ";", "String", "address", "=", "this", ".", "getURIValue", "(", "this", ".", "getRecord", "(", "MessageControl", ".", "MESSAGE_CONTROL_FILE", ")", ".", "getField", "(", "MessageControl", ".", "WEB_SERVICES_SERVER", ")", ".", "toString", "(", ")", ")", ";", "// Important - This is the web services URL", "endpointType", ".", "setAddress", "(", "address", ")", ";", "interfacens", "=", "this", ".", "getNamespace", "(", ")", ";", ";", "interfacename", "=", "this", ".", "getControlProperty", "(", "MessageControl", ".", "BINDING_NAME", ")", ";", "qname", "=", "new", "QName", "(", "interfacens", ",", "interfacename", ")", ";", "endpointType", ".", "setBinding", "(", "qname", ")", ";", "name", "=", "this", ".", "getControlProperty", "(", "MessageControl", ".", "ENDPOINT_NAME", ")", ";", "endpointType", ".", "setName", "(", "name", ")", ";", "}" ]
AddServiceType Method.
[ "AddServiceType", "Method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/msg.wsdl/src/main/java/org/jbundle/main/msg/wsdl/CreateWSDL20.java#L112-L138
151,695
jbundle/jbundle
main/msg.wsdl/src/main/java/org/jbundle/main/msg/wsdl/CreateWSDL20.java
CreateWSDL20.addBindingType
public void addBindingType(DescriptionType descriptionType) { String interfacens; String interfacename; QName qname; String value; String name; // Create the bindings type BindingType bindingType = wsdlFactory.createBindingType(); descriptionType.getImportOrIncludeOrTypes().add(wsdlFactory.createBinding(bindingType)); name = this.getControlProperty(MessageControl.BINDING_NAME); bindingType.setName(name); interfacens = this.getNamespace(); interfacename = this.getControlProperty(MessageControl.INTERFACE_NAME); qname = new QName(interfacens, interfacename); bindingType.setInterface(qname); bindingType.setType(this.getControlProperty(WSOAP_BINDING_URI)); interfacens = this.getControlProperty(SOAP_SENDING_URI); interfacename = "protocol"; qname = new QName(interfacens, interfacename); value = this.getControlProperty(SOAP_URI); bindingType.getOtherAttributes().put(qname, value); this.addBindingOperationTypes(bindingType); }
java
public void addBindingType(DescriptionType descriptionType) { String interfacens; String interfacename; QName qname; String value; String name; // Create the bindings type BindingType bindingType = wsdlFactory.createBindingType(); descriptionType.getImportOrIncludeOrTypes().add(wsdlFactory.createBinding(bindingType)); name = this.getControlProperty(MessageControl.BINDING_NAME); bindingType.setName(name); interfacens = this.getNamespace(); interfacename = this.getControlProperty(MessageControl.INTERFACE_NAME); qname = new QName(interfacens, interfacename); bindingType.setInterface(qname); bindingType.setType(this.getControlProperty(WSOAP_BINDING_URI)); interfacens = this.getControlProperty(SOAP_SENDING_URI); interfacename = "protocol"; qname = new QName(interfacens, interfacename); value = this.getControlProperty(SOAP_URI); bindingType.getOtherAttributes().put(qname, value); this.addBindingOperationTypes(bindingType); }
[ "public", "void", "addBindingType", "(", "DescriptionType", "descriptionType", ")", "{", "String", "interfacens", ";", "String", "interfacename", ";", "QName", "qname", ";", "String", "value", ";", "String", "name", ";", "// Create the bindings type", "BindingType", "bindingType", "=", "wsdlFactory", ".", "createBindingType", "(", ")", ";", "descriptionType", ".", "getImportOrIncludeOrTypes", "(", ")", ".", "add", "(", "wsdlFactory", ".", "createBinding", "(", "bindingType", ")", ")", ";", "name", "=", "this", ".", "getControlProperty", "(", "MessageControl", ".", "BINDING_NAME", ")", ";", "bindingType", ".", "setName", "(", "name", ")", ";", "interfacens", "=", "this", ".", "getNamespace", "(", ")", ";", "interfacename", "=", "this", ".", "getControlProperty", "(", "MessageControl", ".", "INTERFACE_NAME", ")", ";", "qname", "=", "new", "QName", "(", "interfacens", ",", "interfacename", ")", ";", "bindingType", ".", "setInterface", "(", "qname", ")", ";", "bindingType", ".", "setType", "(", "this", ".", "getControlProperty", "(", "WSOAP_BINDING_URI", ")", ")", ";", "interfacens", "=", "this", ".", "getControlProperty", "(", "SOAP_SENDING_URI", ")", ";", "interfacename", "=", "\"protocol\"", ";", "qname", "=", "new", "QName", "(", "interfacens", ",", "interfacename", ")", ";", "value", "=", "this", ".", "getControlProperty", "(", "SOAP_URI", ")", ";", "bindingType", ".", "getOtherAttributes", "(", ")", ".", "put", "(", "qname", ",", "value", ")", ";", "this", ".", "addBindingOperationTypes", "(", "bindingType", ")", ";", "}" ]
AddBindingType Method.
[ "AddBindingType", "Method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/msg.wsdl/src/main/java/org/jbundle/main/msg/wsdl/CreateWSDL20.java#L142-L167
151,696
jbundle/jbundle
main/msg.wsdl/src/main/java/org/jbundle/main/msg/wsdl/CreateWSDL20.java
CreateWSDL20.addInterfaceType
public void addInterfaceType(DescriptionType descriptionType) { // Create the interfaces InterfaceType interfaceType = wsdlFactory.createInterfaceType(); descriptionType.getImportOrIncludeOrTypes().add(wsdlFactory.createInterface(interfaceType)); String interfaceName = this.getControlProperty(MessageControl.INTERFACE_NAME); interfaceType.setName(interfaceName); this.addInterfaceOperationTypes(interfaceType); }
java
public void addInterfaceType(DescriptionType descriptionType) { // Create the interfaces InterfaceType interfaceType = wsdlFactory.createInterfaceType(); descriptionType.getImportOrIncludeOrTypes().add(wsdlFactory.createInterface(interfaceType)); String interfaceName = this.getControlProperty(MessageControl.INTERFACE_NAME); interfaceType.setName(interfaceName); this.addInterfaceOperationTypes(interfaceType); }
[ "public", "void", "addInterfaceType", "(", "DescriptionType", "descriptionType", ")", "{", "// Create the interfaces", "InterfaceType", "interfaceType", "=", "wsdlFactory", ".", "createInterfaceType", "(", ")", ";", "descriptionType", ".", "getImportOrIncludeOrTypes", "(", ")", ".", "add", "(", "wsdlFactory", ".", "createInterface", "(", "interfaceType", ")", ")", ";", "String", "interfaceName", "=", "this", ".", "getControlProperty", "(", "MessageControl", ".", "INTERFACE_NAME", ")", ";", "interfaceType", ".", "setName", "(", "interfaceName", ")", ";", "this", ".", "addInterfaceOperationTypes", "(", "interfaceType", ")", ";", "}" ]
AddInterfaceType Method.
[ "AddInterfaceType", "Method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/msg.wsdl/src/main/java/org/jbundle/main/msg/wsdl/CreateWSDL20.java#L207-L216
151,697
js-lib-com/commons
src/main/java/js/format/FileSize.java
FileSize.format
private String format(double fileSize, Units units) { StringBuilder builder = new StringBuilder(); builder.append(numberFormat.format(fileSize)); builder.append(' '); builder.append(units.name()); return builder.toString(); }
java
private String format(double fileSize, Units units) { StringBuilder builder = new StringBuilder(); builder.append(numberFormat.format(fileSize)); builder.append(' '); builder.append(units.name()); return builder.toString(); }
[ "private", "String", "format", "(", "double", "fileSize", ",", "Units", "units", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "builder", ".", "append", "(", "numberFormat", ".", "format", "(", "fileSize", ")", ")", ";", "builder", ".", "append", "(", "'", "'", ")", ";", "builder", ".", "append", "(", "units", ".", "name", "(", ")", ")", ";", "return", "builder", ".", "toString", "(", ")", ";", "}" ]
Build file size representation for given numeric value and units. @param fileSize file size numeric part value, @param units file size units. @return formated file size.
[ "Build", "file", "size", "representation", "for", "given", "numeric", "value", "and", "units", "." ]
f8c64482142b163487745da74feb106f0765c16b
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/format/FileSize.java#L119-L126
151,698
jbundle/jbundle
app/program/script/src/main/java/org/jbundle/app/program/script/process/BaseProcessRecords.java
BaseProcessRecords.includeRecord
public boolean includeRecord(Record recFileHdr, Record recClassInfo, String strPackage) { String strProject = this.getProperty("project"); String strType = this.getProperty("type"); String[] classLists = null; String classList = this.getProperty("classList"); if (classList != null) classLists = classList.split(","); String database = this.getProperty("database"); if (recClassInfo.getField(ClassInfo.BASE_CLASS_NAME).toString().equalsIgnoreCase("QueryRecord")) return false; if (recClassInfo.getField(ClassInfo.BASE_CLASS_NAME).toString().indexOf("Query") != -1) return false; String strClassPackage = this.getFullPackageName(recClassInfo.getField(ClassInfo.CLASS_PROJECT_ID).toString(), recClassInfo.getField(ClassInfo.CLASS_PACKAGE).toString()); String strClassProject = classProjectIDs.get(recClassInfo.getField(ClassInfo.CLASS_PROJECT_ID).toString()); String strClassType = recFileHdr.getField(FileHdr.TYPE).toString(); if (strClassPackage != null) if (strPackage != null) if (!strClassPackage.matches(this.patternToRegex(strPackage))) return false; if (strClassType != null) if (strType != null) if (!strClassType.toUpperCase().contains(strType.toUpperCase())) return false; if (classLists != null) { String className = recClassInfo.getField(ClassInfo.CLASS_NAME).toString(); boolean match = false; for (String classMatch : classLists) { if (className.equalsIgnoreCase(classMatch)) match = true; } if (!match) return false; } if (strClassProject == null) return false; // Never if (strProject != null) return strClassProject.matches(this.patternToRegex(strProject)); // Does the project name pattern match? if (database != null) if (!database.equalsIgnoreCase(recFileHdr.getField(FileHdr.DATABASE_NAME).toString())) return false; return true; }
java
public boolean includeRecord(Record recFileHdr, Record recClassInfo, String strPackage) { String strProject = this.getProperty("project"); String strType = this.getProperty("type"); String[] classLists = null; String classList = this.getProperty("classList"); if (classList != null) classLists = classList.split(","); String database = this.getProperty("database"); if (recClassInfo.getField(ClassInfo.BASE_CLASS_NAME).toString().equalsIgnoreCase("QueryRecord")) return false; if (recClassInfo.getField(ClassInfo.BASE_CLASS_NAME).toString().indexOf("Query") != -1) return false; String strClassPackage = this.getFullPackageName(recClassInfo.getField(ClassInfo.CLASS_PROJECT_ID).toString(), recClassInfo.getField(ClassInfo.CLASS_PACKAGE).toString()); String strClassProject = classProjectIDs.get(recClassInfo.getField(ClassInfo.CLASS_PROJECT_ID).toString()); String strClassType = recFileHdr.getField(FileHdr.TYPE).toString(); if (strClassPackage != null) if (strPackage != null) if (!strClassPackage.matches(this.patternToRegex(strPackage))) return false; if (strClassType != null) if (strType != null) if (!strClassType.toUpperCase().contains(strType.toUpperCase())) return false; if (classLists != null) { String className = recClassInfo.getField(ClassInfo.CLASS_NAME).toString(); boolean match = false; for (String classMatch : classLists) { if (className.equalsIgnoreCase(classMatch)) match = true; } if (!match) return false; } if (strClassProject == null) return false; // Never if (strProject != null) return strClassProject.matches(this.patternToRegex(strProject)); // Does the project name pattern match? if (database != null) if (!database.equalsIgnoreCase(recFileHdr.getField(FileHdr.DATABASE_NAME).toString())) return false; return true; }
[ "public", "boolean", "includeRecord", "(", "Record", "recFileHdr", ",", "Record", "recClassInfo", ",", "String", "strPackage", ")", "{", "String", "strProject", "=", "this", ".", "getProperty", "(", "\"project\"", ")", ";", "String", "strType", "=", "this", ".", "getProperty", "(", "\"type\"", ")", ";", "String", "[", "]", "classLists", "=", "null", ";", "String", "classList", "=", "this", ".", "getProperty", "(", "\"classList\"", ")", ";", "if", "(", "classList", "!=", "null", ")", "classLists", "=", "classList", ".", "split", "(", "\",\"", ")", ";", "String", "database", "=", "this", ".", "getProperty", "(", "\"database\"", ")", ";", "if", "(", "recClassInfo", ".", "getField", "(", "ClassInfo", ".", "BASE_CLASS_NAME", ")", ".", "toString", "(", ")", ".", "equalsIgnoreCase", "(", "\"QueryRecord\"", ")", ")", "return", "false", ";", "if", "(", "recClassInfo", ".", "getField", "(", "ClassInfo", ".", "BASE_CLASS_NAME", ")", ".", "toString", "(", ")", ".", "indexOf", "(", "\"Query\"", ")", "!=", "-", "1", ")", "return", "false", ";", "String", "strClassPackage", "=", "this", ".", "getFullPackageName", "(", "recClassInfo", ".", "getField", "(", "ClassInfo", ".", "CLASS_PROJECT_ID", ")", ".", "toString", "(", ")", ",", "recClassInfo", ".", "getField", "(", "ClassInfo", ".", "CLASS_PACKAGE", ")", ".", "toString", "(", ")", ")", ";", "String", "strClassProject", "=", "classProjectIDs", ".", "get", "(", "recClassInfo", ".", "getField", "(", "ClassInfo", ".", "CLASS_PROJECT_ID", ")", ".", "toString", "(", ")", ")", ";", "String", "strClassType", "=", "recFileHdr", ".", "getField", "(", "FileHdr", ".", "TYPE", ")", ".", "toString", "(", ")", ";", "if", "(", "strClassPackage", "!=", "null", ")", "if", "(", "strPackage", "!=", "null", ")", "if", "(", "!", "strClassPackage", ".", "matches", "(", "this", ".", "patternToRegex", "(", "strPackage", ")", ")", ")", "return", "false", ";", "if", "(", "strClassType", "!=", "null", ")", "if", "(", "strType", "!=", "null", ")", "if", "(", "!", "strClassType", ".", "toUpperCase", "(", ")", ".", "contains", "(", "strType", ".", "toUpperCase", "(", ")", ")", ")", "return", "false", ";", "if", "(", "classLists", "!=", "null", ")", "{", "String", "className", "=", "recClassInfo", ".", "getField", "(", "ClassInfo", ".", "CLASS_NAME", ")", ".", "toString", "(", ")", ";", "boolean", "match", "=", "false", ";", "for", "(", "String", "classMatch", ":", "classLists", ")", "{", "if", "(", "className", ".", "equalsIgnoreCase", "(", "classMatch", ")", ")", "match", "=", "true", ";", "}", "if", "(", "!", "match", ")", "return", "false", ";", "}", "if", "(", "strClassProject", "==", "null", ")", "return", "false", ";", "// Never", "if", "(", "strProject", "!=", "null", ")", "return", "strClassProject", ".", "matches", "(", "this", ".", "patternToRegex", "(", "strProject", ")", ")", ";", "// Does the project name pattern match?", "if", "(", "database", "!=", "null", ")", "if", "(", "!", "database", ".", "equalsIgnoreCase", "(", "recFileHdr", ".", "getField", "(", "FileHdr", ".", "DATABASE_NAME", ")", ".", "toString", "(", ")", ")", ")", "return", "false", ";", "return", "true", ";", "}" ]
Include this record?.
[ "Include", "this", "record?", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/script/src/main/java/org/jbundle/app/program/script/process/BaseProcessRecords.java#L308-L360
151,699
jbundle/jbundle
app/program/script/src/main/java/org/jbundle/app/program/script/process/BaseProcessRecords.java
BaseProcessRecords.patternToRegex
public String patternToRegex(String string) { if (string != null) if (!string.contains("[")) if (!string.contains("{")) // If it has one of these, it probably is a regex already. if (!string.contains("\\.")) { string = string.replace(".", "\\."); string = string.replace("*", ".*"); } return string; }
java
public String patternToRegex(String string) { if (string != null) if (!string.contains("[")) if (!string.contains("{")) // If it has one of these, it probably is a regex already. if (!string.contains("\\.")) { string = string.replace(".", "\\."); string = string.replace("*", ".*"); } return string; }
[ "public", "String", "patternToRegex", "(", "String", "string", ")", "{", "if", "(", "string", "!=", "null", ")", "if", "(", "!", "string", ".", "contains", "(", "\"[\"", ")", ")", "if", "(", "!", "string", ".", "contains", "(", "\"{\"", ")", ")", "// If it has one of these, it probably is a regex already.", "if", "(", "!", "string", ".", "contains", "(", "\"\\\\.\"", ")", ")", "{", "string", "=", "string", ".", "replace", "(", "\".\"", ",", "\"\\\\.\"", ")", ";", "string", "=", "string", ".", "replace", "(", "\"*\"", ",", "\".*\"", ")", ";", "}", "return", "string", ";", "}" ]
Kind of convert file filter to regex.
[ "Kind", "of", "convert", "file", "filter", "to", "regex", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/script/src/main/java/org/jbundle/app/program/script/process/BaseProcessRecords.java#L364-L375