repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/cache/SiblingCounter.java
SiblingCounter.constant
public static SiblingCounter constant( final int count ) { assert count > -1; return new SiblingCounter() { @Override public int countSiblingsNamed( Name childName ) { return count; } }; }
java
public static SiblingCounter constant( final int count ) { assert count > -1; return new SiblingCounter() { @Override public int countSiblingsNamed( Name childName ) { return count; } }; }
[ "public", "static", "SiblingCounter", "constant", "(", "final", "int", "count", ")", "{", "assert", "count", ">", "-", "1", ";", "return", "new", "SiblingCounter", "(", ")", "{", "@", "Override", "public", "int", "countSiblingsNamed", "(", "Name", "childName...
Create a sibling counter that always return the supplied count, regardless of the name or node. @param count the count to be returned; may not be negative @return the counter that always returns {@code count}; never null
[ "Create", "a", "sibling", "counter", "that", "always", "return", "the", "supplied", "count", "regardless", "of", "the", "name", "or", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/SiblingCounter.java#L60-L68
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/cache/SiblingCounter.java
SiblingCounter.alter
public static SiblingCounter alter( final SiblingCounter counter, final int delta ) { assert counter != null; return new SiblingCounter() { @Override public int countSiblingsNamed( Name childName ) { int count = counter.countSiblingsNamed(childName) + delta; return count > 0 ? count : 0; // never negative } }; }
java
public static SiblingCounter alter( final SiblingCounter counter, final int delta ) { assert counter != null; return new SiblingCounter() { @Override public int countSiblingsNamed( Name childName ) { int count = counter.countSiblingsNamed(childName) + delta; return count > 0 ? count : 0; // never negative } }; }
[ "public", "static", "SiblingCounter", "alter", "(", "final", "SiblingCounter", "counter", ",", "final", "int", "delta", ")", "{", "assert", "counter", "!=", "null", ";", "return", "new", "SiblingCounter", "(", ")", "{", "@", "Override", "public", "int", "cou...
Creates a sibling counter that alters another counter by a constant value. @param counter the sibling counter; may not be null @param delta the positive or negative amount by which the {@code counter}'s value is altered @return the sibling counter; never null
[ "Creates", "a", "sibling", "counter", "that", "alters", "another", "counter", "by", "a", "constant", "value", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/SiblingCounter.java#L112-L122
train
ModeShape/modeshape
web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/handler/RestRepositoryHandler.java
RestRepositoryHandler.getWorkspaces
public RestWorkspaces getWorkspaces( HttpServletRequest request, String repositoryName ) throws RepositoryException { assert request != null; assert repositoryName != null; RestWorkspaces workspaces = new RestWorkspaces(); Session session = getSession(request, repositoryName, null); for (String workspaceName : session.getWorkspace().getAccessibleWorkspaceNames()) { String repositoryUrl = RestHelper.urlFrom(request); workspaces.addWorkspace(workspaceName, repositoryUrl); } return workspaces; }
java
public RestWorkspaces getWorkspaces( HttpServletRequest request, String repositoryName ) throws RepositoryException { assert request != null; assert repositoryName != null; RestWorkspaces workspaces = new RestWorkspaces(); Session session = getSession(request, repositoryName, null); for (String workspaceName : session.getWorkspace().getAccessibleWorkspaceNames()) { String repositoryUrl = RestHelper.urlFrom(request); workspaces.addWorkspace(workspaceName, repositoryUrl); } return workspaces; }
[ "public", "RestWorkspaces", "getWorkspaces", "(", "HttpServletRequest", "request", ",", "String", "repositoryName", ")", "throws", "RepositoryException", "{", "assert", "request", "!=", "null", ";", "assert", "repositoryName", "!=", "null", ";", "RestWorkspaces", "wor...
Returns the list of workspaces available to this user within the named repository. @param request the servlet request; may not be null @param repositoryName the name of the repository; may not be null @return the list of workspaces available to this user within the named repository, as a {@link RestWorkspaces} object @throws RepositoryException if there is any other error accessing the list of available workspaces for the repository
[ "Returns", "the", "list", "of", "workspaces", "available", "to", "this", "user", "within", "the", "named", "repository", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/handler/RestRepositoryHandler.java#L66-L78
train
ModeShape/modeshape
web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/handler/RestRepositoryHandler.java
RestRepositoryHandler.backupRepository
public Response backupRepository( ServletContext context, HttpServletRequest request, String repositoryName, BackupOptions options ) throws RepositoryException { final File backupLocation = resolveBackupLocation(context); Session session = getSession(request, repositoryName, null); String repositoryVersion = session.getRepository().getDescriptorValue(Repository.REP_VERSION_DESC).getString().replaceAll("\\.",""); final String backupName = "modeshape_" + repositoryVersion + "_" + repositoryName + "_backup_" + DATE_FORMAT.format(new Date()); final File backup = new File(backupLocation, backupName); if (!backup.mkdirs()) { throw new RuntimeException("Cannot create backup folder: " + backup); } logger.debug("Backing up repository '{0}' to '{1}', using '{2}'", repositoryName, backup, options); RepositoryManager repositoryManager = ((org.modeshape.jcr.api.Workspace)session.getWorkspace()).getRepositoryManager(); repositoryManager.backupRepository(backup, options); final String backupURL; try { backupURL = backup.toURI().toURL().toString(); } catch (MalformedURLException e) { //should never happen throw new RuntimeException(e); } JSONAble responseContent = new JSONAble() { @Override public JSONObject toJSON() throws JSONException { JSONObject object = new JSONObject(); object.put("name", backupName); object.put("url", backupURL); return object; } }; return Response.status(Response.Status.CREATED).entity(responseContent).build(); }
java
public Response backupRepository( ServletContext context, HttpServletRequest request, String repositoryName, BackupOptions options ) throws RepositoryException { final File backupLocation = resolveBackupLocation(context); Session session = getSession(request, repositoryName, null); String repositoryVersion = session.getRepository().getDescriptorValue(Repository.REP_VERSION_DESC).getString().replaceAll("\\.",""); final String backupName = "modeshape_" + repositoryVersion + "_" + repositoryName + "_backup_" + DATE_FORMAT.format(new Date()); final File backup = new File(backupLocation, backupName); if (!backup.mkdirs()) { throw new RuntimeException("Cannot create backup folder: " + backup); } logger.debug("Backing up repository '{0}' to '{1}', using '{2}'", repositoryName, backup, options); RepositoryManager repositoryManager = ((org.modeshape.jcr.api.Workspace)session.getWorkspace()).getRepositoryManager(); repositoryManager.backupRepository(backup, options); final String backupURL; try { backupURL = backup.toURI().toURL().toString(); } catch (MalformedURLException e) { //should never happen throw new RuntimeException(e); } JSONAble responseContent = new JSONAble() { @Override public JSONObject toJSON() throws JSONException { JSONObject object = new JSONObject(); object.put("name", backupName); object.put("url", backupURL); return object; } }; return Response.status(Response.Status.CREATED).entity(responseContent).build(); }
[ "public", "Response", "backupRepository", "(", "ServletContext", "context", ",", "HttpServletRequest", "request", ",", "String", "repositoryName", ",", "BackupOptions", "options", ")", "throws", "RepositoryException", "{", "final", "File", "backupLocation", "=", "resolv...
Performs a repository backup.
[ "Performs", "a", "repository", "backup", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/handler/RestRepositoryHandler.java#L83-L118
train
ModeShape/modeshape
web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/handler/RestRepositoryHandler.java
RestRepositoryHandler.restoreRepository
public Response restoreRepository( ServletContext context, HttpServletRequest request, String repositoryName, String backupName, RestoreOptions options ) throws RepositoryException { if (StringUtil.isBlank(backupName)) { throw new IllegalArgumentException("The name of the backup cannot be null"); } File backup = resolveBackup(context, backupName); logger.debug("Restoring repository '{0}' from backup '{1}' using '{2}'", repositoryName, backup, options); Session session = getSession(request, repositoryName, null); RepositoryManager repositoryManager = ((org.modeshape.jcr.api.Workspace)session.getWorkspace()).getRepositoryManager(); final Problems problems = repositoryManager.restoreRepository(backup, options); if (!problems.hasProblems()) { return Response.ok().build(); } List<JSONAble> response = new ArrayList<JSONAble>(problems.size()); for (Problem problem : problems) { RestException exception = problem.getThrowable() != null ? new RestException(problem.getMessage(), problem.getThrowable()) : new RestException(problem.getMessage()); response.add(exception); } return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(response).build(); }
java
public Response restoreRepository( ServletContext context, HttpServletRequest request, String repositoryName, String backupName, RestoreOptions options ) throws RepositoryException { if (StringUtil.isBlank(backupName)) { throw new IllegalArgumentException("The name of the backup cannot be null"); } File backup = resolveBackup(context, backupName); logger.debug("Restoring repository '{0}' from backup '{1}' using '{2}'", repositoryName, backup, options); Session session = getSession(request, repositoryName, null); RepositoryManager repositoryManager = ((org.modeshape.jcr.api.Workspace)session.getWorkspace()).getRepositoryManager(); final Problems problems = repositoryManager.restoreRepository(backup, options); if (!problems.hasProblems()) { return Response.ok().build(); } List<JSONAble> response = new ArrayList<JSONAble>(problems.size()); for (Problem problem : problems) { RestException exception = problem.getThrowable() != null ? new RestException(problem.getMessage(), problem.getThrowable()) : new RestException(problem.getMessage()); response.add(exception); } return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(response).build(); }
[ "public", "Response", "restoreRepository", "(", "ServletContext", "context", ",", "HttpServletRequest", "request", ",", "String", "repositoryName", ",", "String", "backupName", ",", "RestoreOptions", "options", ")", "throws", "RepositoryException", "{", "if", "(", "St...
Restores a repository using an existing backup.
[ "Restores", "a", "repository", "using", "an", "existing", "backup", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/handler/RestRepositoryHandler.java#L123-L147
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/statistic/SimpleStatistics.java
SimpleStatistics.add
public void add( T value ) { Lock lock = this.lock.writeLock(); try { lock.lock(); doAddValue(value); } finally { lock.unlock(); } }
java
public void add( T value ) { Lock lock = this.lock.writeLock(); try { lock.lock(); doAddValue(value); } finally { lock.unlock(); } }
[ "public", "void", "add", "(", "T", "value", ")", "{", "Lock", "lock", "=", "this", ".", "lock", ".", "writeLock", "(", ")", ";", "try", "{", "lock", ".", "lock", "(", ")", ";", "doAddValue", "(", "value", ")", ";", "}", "finally", "{", "lock", ...
Add a new value to these statistics. @param value the new value
[ "Add", "a", "new", "value", "to", "these", "statistics", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/statistic/SimpleStatistics.java#L64-L72
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/statistic/SimpleStatistics.java
SimpleStatistics.getTotal
public T getTotal() { Lock lock = this.lock.readLock(); lock.lock(); try { return this.total; } finally { lock.unlock(); } }
java
public T getTotal() { Lock lock = this.lock.readLock(); lock.lock(); try { return this.total; } finally { lock.unlock(); } }
[ "public", "T", "getTotal", "(", ")", "{", "Lock", "lock", "=", "this", ".", "lock", ".", "readLock", "(", ")", ";", "lock", ".", "lock", "(", ")", ";", "try", "{", "return", "this", ".", "total", ";", "}", "finally", "{", "lock", ".", "unlock", ...
Get the aggregate sum of the values in the series. @return the total of the values, or 0.0 if the {@link #getCount() count} is 0
[ "Get", "the", "aggregate", "sum", "of", "the", "values", "in", "the", "series", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/statistic/SimpleStatistics.java#L107-L115
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/statistic/SimpleStatistics.java
SimpleStatistics.getMaximum
public T getMaximum() { Lock lock = this.lock.readLock(); lock.lock(); try { return this.maximum; } finally { lock.unlock(); } }
java
public T getMaximum() { Lock lock = this.lock.readLock(); lock.lock(); try { return this.maximum; } finally { lock.unlock(); } }
[ "public", "T", "getMaximum", "(", ")", "{", "Lock", "lock", "=", "this", ".", "lock", ".", "readLock", "(", ")", ";", "lock", ".", "lock", "(", ")", ";", "try", "{", "return", "this", ".", "maximum", ";", "}", "finally", "{", "lock", ".", "unlock...
Get the maximum value in the series. @return the maximum value, or 0.0 if the {@link #getCount() count} is 0
[ "Get", "the", "maximum", "value", "in", "the", "series", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/statistic/SimpleStatistics.java#L122-L130
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/statistic/SimpleStatistics.java
SimpleStatistics.getMinimum
public T getMinimum() { Lock lock = this.lock.readLock(); lock.lock(); try { return this.minimum != null ? this.minimum : (T)this.math.createZeroValue(); } finally { lock.unlock(); } }
java
public T getMinimum() { Lock lock = this.lock.readLock(); lock.lock(); try { return this.minimum != null ? this.minimum : (T)this.math.createZeroValue(); } finally { lock.unlock(); } }
[ "public", "T", "getMinimum", "(", ")", "{", "Lock", "lock", "=", "this", ".", "lock", ".", "readLock", "(", ")", ";", "lock", ".", "lock", "(", ")", ";", "try", "{", "return", "this", ".", "minimum", "!=", "null", "?", "this", ".", "minimum", ":"...
Get the minimum value in the series. @return the minimum value, or 0.0 if the {@link #getCount() count} is 0
[ "Get", "the", "minimum", "value", "in", "the", "series", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/statistic/SimpleStatistics.java#L137-L145
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/statistic/SimpleStatistics.java
SimpleStatistics.getCount
public int getCount() { Lock lock = this.lock.readLock(); lock.lock(); try { return this.count; } finally { lock.unlock(); } }
java
public int getCount() { Lock lock = this.lock.readLock(); lock.lock(); try { return this.count; } finally { lock.unlock(); } }
[ "public", "int", "getCount", "(", ")", "{", "Lock", "lock", "=", "this", ".", "lock", ".", "readLock", "(", ")", ";", "lock", ".", "lock", "(", ")", ";", "try", "{", "return", "this", ".", "count", ";", "}", "finally", "{", "lock", ".", "unlock",...
Get the number of values that have been measured. @return the count
[ "Get", "the", "number", "of", "values", "that", "have", "been", "measured", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/statistic/SimpleStatistics.java#L152-L160
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/statistic/SimpleStatistics.java
SimpleStatistics.reset
public void reset() { Lock lock = this.lock.writeLock(); lock.lock(); try { doReset(); } finally { lock.unlock(); } }
java
public void reset() { Lock lock = this.lock.writeLock(); lock.lock(); try { doReset(); } finally { lock.unlock(); } }
[ "public", "void", "reset", "(", ")", "{", "Lock", "lock", "=", "this", ".", "lock", ".", "writeLock", "(", ")", ";", "lock", ".", "lock", "(", ")", ";", "try", "{", "doReset", "(", ")", ";", "}", "finally", "{", "lock", ".", "unlock", "(", ")",...
Reset the statistics in this object, and clear out any stored information.
[ "Reset", "the", "statistics", "in", "this", "object", "and", "clear", "out", "any", "stored", "information", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/statistic/SimpleStatistics.java#L197-L205
train
ModeShape/modeshape
modeshape-schematic/src/main/java/org/modeshape/schematic/internal/schema/DocumentTransformer.java
DocumentTransformer.getSubstitutedProperty
public static String getSubstitutedProperty( String value, PropertyAccessor propertyAccessor ) { if (value == null || value.trim().length() == 0) return value; StringBuilder sb = new StringBuilder(value); // Get the index of the first constant, if any int startName = sb.indexOf(CURLY_PREFIX); if (startName == -1) return value; // process as many different variable groupings that are defined, where one group will resolve to one property // substitution while (startName != -1) { String defaultValue = null; int endName = sb.indexOf(CURLY_SUFFIX, startName); if (endName == -1) { // if no suffix can be found, then this variable was probably defined incorrectly // but return what there is at this point return sb.toString(); } String varString = sb.substring(startName + 2, endName); if (varString.indexOf(DEFAULT_DELIM) > -1) { List<String> defaults = split(varString, DEFAULT_DELIM); // get the property(s) variables that are defined left of the default delimiter. varString = defaults.get(0); // if the default is defined, then capture in case none of the other properties are found if (defaults.size() == 2) { defaultValue = defaults.get(1); } } String constValue = null; // split the property(s) based VAR_DELIM, when multiple property options are defined List<String> vars = split(varString, VAR_DELIM); for (final String var : vars) { constValue = System.getenv(var); if (constValue == null) { constValue = propertyAccessor.getProperty(var); } // the first found property is the value to be substituted if (constValue != null) { break; } } // if no property is found to substitute, then use the default value, if defined if (constValue == null && defaultValue != null) { constValue = defaultValue; } if (constValue != null) { sb = sb.replace(startName, endName + 1, constValue); // Checking for another constants startName = sb.indexOf(CURLY_PREFIX); } else { // continue to try to substitute for other properties so that all defined variables // are tried to be substituted for startName = sb.indexOf(CURLY_PREFIX, endName); } } return sb.toString(); }
java
public static String getSubstitutedProperty( String value, PropertyAccessor propertyAccessor ) { if (value == null || value.trim().length() == 0) return value; StringBuilder sb = new StringBuilder(value); // Get the index of the first constant, if any int startName = sb.indexOf(CURLY_PREFIX); if (startName == -1) return value; // process as many different variable groupings that are defined, where one group will resolve to one property // substitution while (startName != -1) { String defaultValue = null; int endName = sb.indexOf(CURLY_SUFFIX, startName); if (endName == -1) { // if no suffix can be found, then this variable was probably defined incorrectly // but return what there is at this point return sb.toString(); } String varString = sb.substring(startName + 2, endName); if (varString.indexOf(DEFAULT_DELIM) > -1) { List<String> defaults = split(varString, DEFAULT_DELIM); // get the property(s) variables that are defined left of the default delimiter. varString = defaults.get(0); // if the default is defined, then capture in case none of the other properties are found if (defaults.size() == 2) { defaultValue = defaults.get(1); } } String constValue = null; // split the property(s) based VAR_DELIM, when multiple property options are defined List<String> vars = split(varString, VAR_DELIM); for (final String var : vars) { constValue = System.getenv(var); if (constValue == null) { constValue = propertyAccessor.getProperty(var); } // the first found property is the value to be substituted if (constValue != null) { break; } } // if no property is found to substitute, then use the default value, if defined if (constValue == null && defaultValue != null) { constValue = defaultValue; } if (constValue != null) { sb = sb.replace(startName, endName + 1, constValue); // Checking for another constants startName = sb.indexOf(CURLY_PREFIX); } else { // continue to try to substitute for other properties so that all defined variables // are tried to be substituted for startName = sb.indexOf(CURLY_PREFIX, endName); } } return sb.toString(); }
[ "public", "static", "String", "getSubstitutedProperty", "(", "String", "value", ",", "PropertyAccessor", "propertyAccessor", ")", "{", "if", "(", "value", "==", "null", "||", "value", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", "return"...
getSubstitutedProperty is called to perform the property substitution on the value. @param value @param propertyAccessor @return String
[ "getSubstitutedProperty", "is", "called", "to", "perform", "the", "property", "substitution", "on", "the", "value", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-schematic/src/main/java/org/modeshape/schematic/internal/schema/DocumentTransformer.java#L78-L151
train
ModeShape/modeshape
modeshape-schematic/src/main/java/org/modeshape/schematic/internal/schema/DocumentTransformer.java
DocumentTransformer.split
private static List<String> split( String str, String splitter ) { StringTokenizer tokens = new StringTokenizer(str, splitter); ArrayList<String> l = new ArrayList<>(tokens.countTokens()); while (tokens.hasMoreTokens()) { l.add(tokens.nextToken()); } return l; }
java
private static List<String> split( String str, String splitter ) { StringTokenizer tokens = new StringTokenizer(str, splitter); ArrayList<String> l = new ArrayList<>(tokens.countTokens()); while (tokens.hasMoreTokens()) { l.add(tokens.nextToken()); } return l; }
[ "private", "static", "List", "<", "String", ">", "split", "(", "String", "str", ",", "String", "splitter", ")", "{", "StringTokenizer", "tokens", "=", "new", "StringTokenizer", "(", "str", ",", "splitter", ")", ";", "ArrayList", "<", "String", ">", "l", ...
Split a string into pieces based on delimiters. Similar to the perl function of the same name. The delimiters are not included in the returned strings. @param str Full string @param splitter Characters to split on @return List of String pieces from full string
[ "Split", "a", "string", "into", "pieces", "based", "on", "delimiters", ".", "Similar", "to", "the", "perl", "function", "of", "the", "same", "name", ".", "The", "delimiters", "are", "not", "included", "in", "the", "returned", "strings", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-schematic/src/main/java/org/modeshape/schematic/internal/schema/DocumentTransformer.java#L161-L169
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/connector/filesystem/FileSystemConnector.java
FileSystemConnector.checkFileNotExcluded
protected void checkFileNotExcluded( String id, File file ) { if (isExcluded(file)) { String msg = JcrI18n.fileConnectorCannotStoreFileThatIsExcluded.text(getSourceName(), id, file.getAbsolutePath()); throw new DocumentStoreException(id, msg); } }
java
protected void checkFileNotExcluded( String id, File file ) { if (isExcluded(file)) { String msg = JcrI18n.fileConnectorCannotStoreFileThatIsExcluded.text(getSourceName(), id, file.getAbsolutePath()); throw new DocumentStoreException(id, msg); } }
[ "protected", "void", "checkFileNotExcluded", "(", "String", "id", ",", "File", "file", ")", "{", "if", "(", "isExcluded", "(", "file", ")", ")", "{", "String", "msg", "=", "JcrI18n", ".", "fileConnectorCannotStoreFileThatIsExcluded", ".", "text", "(", "getSour...
Utility method to ensure that the file is writable by this connector. @param id the identifier of the node @param file the file @throws DocumentStoreException if the file is expected to be writable but is not or is excluded, or if the connector is readonly
[ "Utility", "method", "to", "ensure", "that", "the", "file", "is", "writable", "by", "this", "connector", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/connector/filesystem/FileSystemConnector.java#L471-L477
train
ModeShape/modeshape
web/modeshape-webdav/src/main/java/org/modeshape/webdav/fromcatalina/RequestUtil.java
RequestUtil.filter
public static String filter( String message ) { if (message == null) { return (null); } char content[] = new char[message.length()]; message.getChars(0, message.length(), content, 0); StringBuilder result = new StringBuilder(content.length + 50); for (int i = 0; i < content.length; i++) { switch (content[i]) { case '<': result.append("&lt;"); break; case '>': result.append("&gt;"); break; case '&': result.append("&amp;"); break; case '"': result.append("&quot;"); break; default: result.append(content[i]); } } return (result.toString()); }
java
public static String filter( String message ) { if (message == null) { return (null); } char content[] = new char[message.length()]; message.getChars(0, message.length(), content, 0); StringBuilder result = new StringBuilder(content.length + 50); for (int i = 0; i < content.length; i++) { switch (content[i]) { case '<': result.append("&lt;"); break; case '>': result.append("&gt;"); break; case '&': result.append("&amp;"); break; case '"': result.append("&quot;"); break; default: result.append(content[i]); } } return (result.toString()); }
[ "public", "static", "String", "filter", "(", "String", "message", ")", "{", "if", "(", "message", "==", "null", ")", "{", "return", "(", "null", ")", ";", "}", "char", "content", "[", "]", "=", "new", "char", "[", "message", ".", "length", "(", ")"...
Filter the specified message string for characters that are sensitive in HTML. This avoids potential attacks caused by including JavaScript codes in the request URL that is often reported in error messages. @param message The message string to be filtered @return the filtered message
[ "Filter", "the", "specified", "message", "string", "for", "characters", "that", "are", "sensitive", "in", "HTML", ".", "This", "avoids", "potential", "attacks", "caused", "by", "including", "JavaScript", "codes", "in", "the", "request", "URL", "that", "is", "o...
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-webdav/src/main/java/org/modeshape/webdav/fromcatalina/RequestUtil.java#L97-L126
train
ModeShape/modeshape
web/modeshape-webdav/src/main/java/org/modeshape/webdav/fromcatalina/RequestUtil.java
RequestUtil.parseCookieHeader
public static Cookie[] parseCookieHeader( String header ) { if ((header == null) || (header.length() < 1)) { return (new Cookie[0]); } ArrayList<Cookie> cookies = new ArrayList<Cookie>(); while (header.length() > 0) { int semicolon = header.indexOf(';'); if (semicolon < 0) { semicolon = header.length(); } if (semicolon == 0) { break; } String token = header.substring(0, semicolon); if (semicolon < header.length()) { header = header.substring(semicolon + 1); } else { header = ""; } try { int equals = token.indexOf('='); if (equals > 0) { String name = token.substring(0, equals).trim(); String value = token.substring(equals + 1).trim(); cookies.add(new Cookie(name, value)); } } catch (Throwable e) { // do nothing ?! } } return cookies.toArray(new Cookie[cookies.size()]); }
java
public static Cookie[] parseCookieHeader( String header ) { if ((header == null) || (header.length() < 1)) { return (new Cookie[0]); } ArrayList<Cookie> cookies = new ArrayList<Cookie>(); while (header.length() > 0) { int semicolon = header.indexOf(';'); if (semicolon < 0) { semicolon = header.length(); } if (semicolon == 0) { break; } String token = header.substring(0, semicolon); if (semicolon < header.length()) { header = header.substring(semicolon + 1); } else { header = ""; } try { int equals = token.indexOf('='); if (equals > 0) { String name = token.substring(0, equals).trim(); String value = token.substring(equals + 1).trim(); cookies.add(new Cookie(name, value)); } } catch (Throwable e) { // do nothing ?! } } return cookies.toArray(new Cookie[cookies.size()]); }
[ "public", "static", "Cookie", "[", "]", "parseCookieHeader", "(", "String", "header", ")", "{", "if", "(", "(", "header", "==", "null", ")", "||", "(", "header", ".", "length", "(", ")", "<", "1", ")", ")", "{", "return", "(", "new", "Cookie", "[",...
Parse a cookie header into an array of cookies according to RFC 2109. @param header Value of an HTTP "Cookie" header @return the cookies
[ "Parse", "a", "cookie", "header", "into", "an", "array", "of", "cookies", "according", "to", "RFC", "2109", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-webdav/src/main/java/org/modeshape/webdav/fromcatalina/RequestUtil.java#L225-L259
train
ModeShape/modeshape
web/modeshape-webdav/src/main/java/org/modeshape/webdav/fromcatalina/RequestUtil.java
RequestUtil.URLDecode
public static String URLDecode( String str, String enc ) { if (str == null) { return (null); } // use the specified encoding to extract bytes out of the // given string so that the encoding is not lost. If an // encoding is not specified, let it use platform default byte[] bytes = null; try { if (enc == null) { bytes = str.getBytes(); } else { bytes = str.getBytes(enc); } } catch (UnsupportedEncodingException uee) { } return URLDecode(bytes, enc); }
java
public static String URLDecode( String str, String enc ) { if (str == null) { return (null); } // use the specified encoding to extract bytes out of the // given string so that the encoding is not lost. If an // encoding is not specified, let it use platform default byte[] bytes = null; try { if (enc == null) { bytes = str.getBytes(); } else { bytes = str.getBytes(enc); } } catch (UnsupportedEncodingException uee) { } return URLDecode(bytes, enc); }
[ "public", "static", "String", "URLDecode", "(", "String", "str", ",", "String", "enc", ")", "{", "if", "(", "str", "==", "null", ")", "{", "return", "(", "null", ")", ";", "}", "// use the specified encoding to extract bytes out of the", "// given string so that t...
Decode and return the specified URL-encoded String. @param str The url-encoded string @param enc The encoding to use; if null, the default encoding is used @return the decoded URL @throws IllegalArgumentException if a '%' character is not followed by a valid 2-digit hexadecimal number
[ "Decode", "and", "return", "the", "specified", "URL", "-", "encoded", "String", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-webdav/src/main/java/org/modeshape/webdav/fromcatalina/RequestUtil.java#L320-L342
train
ModeShape/modeshape
web/modeshape-webdav/src/main/java/org/modeshape/webdav/fromcatalina/RequestUtil.java
RequestUtil.URLDecode
public static String URLDecode( byte[] bytes, String enc ) { if (bytes == null) { return (null); } int len = bytes.length; int ix = 0; int ox = 0; while (ix < len) { byte b = bytes[ix++]; // Get byte to test if (b == '+') { b = (byte)' '; } else if (b == '%') { b = (byte)((convertHexDigit(bytes[ix++]) << 4) + convertHexDigit(bytes[ix++])); } bytes[ox++] = b; } if (enc != null) { try { return new String(bytes, 0, ox, enc); } catch (Exception e) { e.printStackTrace(); } } return new String(bytes, 0, ox); }
java
public static String URLDecode( byte[] bytes, String enc ) { if (bytes == null) { return (null); } int len = bytes.length; int ix = 0; int ox = 0; while (ix < len) { byte b = bytes[ix++]; // Get byte to test if (b == '+') { b = (byte)' '; } else if (b == '%') { b = (byte)((convertHexDigit(bytes[ix++]) << 4) + convertHexDigit(bytes[ix++])); } bytes[ox++] = b; } if (enc != null) { try { return new String(bytes, 0, ox, enc); } catch (Exception e) { e.printStackTrace(); } } return new String(bytes, 0, ox); }
[ "public", "static", "String", "URLDecode", "(", "byte", "[", "]", "bytes", ",", "String", "enc", ")", "{", "if", "(", "bytes", "==", "null", ")", "{", "return", "(", "null", ")", ";", "}", "int", "len", "=", "bytes", ".", "length", ";", "int", "i...
Decode and return the specified URL-encoded byte array. @param bytes The url-encoded byte array @param enc The encoding to use; if null, the default encoding is used @return the decoded URL @throws IllegalArgumentException if a '%' character is not followed by a valid 2-digit hexadecimal number
[ "Decode", "and", "return", "the", "specified", "URL", "-", "encoded", "byte", "array", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-webdav/src/main/java/org/modeshape/webdav/fromcatalina/RequestUtil.java#L363-L391
train
ModeShape/modeshape
web/modeshape-webdav/src/main/java/org/modeshape/webdav/fromcatalina/RequestUtil.java
RequestUtil.streamNotConsumed
public static boolean streamNotConsumed( HttpServletRequest request ) { try { ServletInputStream servletInputStream = request.getInputStream(); //in servlet >= 3.0, available will throw an exception (while previously it didn't) return request.getContentLength() != 0 && servletInputStream.available() > 0; } catch (IOException e) { return false; } }
java
public static boolean streamNotConsumed( HttpServletRequest request ) { try { ServletInputStream servletInputStream = request.getInputStream(); //in servlet >= 3.0, available will throw an exception (while previously it didn't) return request.getContentLength() != 0 && servletInputStream.available() > 0; } catch (IOException e) { return false; } }
[ "public", "static", "boolean", "streamNotConsumed", "(", "HttpServletRequest", "request", ")", "{", "try", "{", "ServletInputStream", "servletInputStream", "=", "request", ".", "getInputStream", "(", ")", ";", "//in servlet >= 3.0, available will throw an exception (while pre...
Checks if the input stream of the given request is nor isn't consumed. This method is backwards-compatible with Servlet 2.x, as in Servlet 3.x there is a "isFinished" method. @param request a {@code HttpServletRequest}, never {@code null} @return {@code true} if the request stream has been consumed, {@code false} otherwise.
[ "Checks", "if", "the", "input", "stream", "of", "the", "given", "request", "is", "nor", "isn", "t", "consumed", ".", "This", "method", "is", "backwards", "-", "compatible", "with", "Servlet", "2", ".", "x", "as", "in", "Servlet", "3", ".", "x", "there"...
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-webdav/src/main/java/org/modeshape/webdav/fromcatalina/RequestUtil.java#L503-L511
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/JcrAccessControlList.java
JcrAccessControlList.defaultAcl
public static JcrAccessControlList defaultAcl( AccessControlManagerImpl acm ) { JcrAccessControlList acl = new JcrAccessControlList("/"); try { acl.principals.put(SimplePrincipal.EVERYONE, new AccessControlEntryImpl(SimplePrincipal.EVERYONE, acm.privileges())); } catch (AccessControlException e) { // will never happen } return acl; }
java
public static JcrAccessControlList defaultAcl( AccessControlManagerImpl acm ) { JcrAccessControlList acl = new JcrAccessControlList("/"); try { acl.principals.put(SimplePrincipal.EVERYONE, new AccessControlEntryImpl(SimplePrincipal.EVERYONE, acm.privileges())); } catch (AccessControlException e) { // will never happen } return acl; }
[ "public", "static", "JcrAccessControlList", "defaultAcl", "(", "AccessControlManagerImpl", "acm", ")", "{", "JcrAccessControlList", "acl", "=", "new", "JcrAccessControlList", "(", "\"/\"", ")", ";", "try", "{", "acl", ".", "principals", ".", "put", "(", "SimplePri...
Creates default Access Control List. @param acm access control manager instance @return Access Control List with all permissions granted to everyone.
[ "Creates", "default", "Access", "Control", "List", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/JcrAccessControlList.java#L60-L68
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/JcrAccessControlList.java
JcrAccessControlList.hasPrivileges
public boolean hasPrivileges( SecurityContext sc, Privilege[] privileges ) { for (AccessControlEntryImpl ace : principals.values()) { // check access list for everyone if (ace.getPrincipal().getName().equals(SimplePrincipal.EVERYONE.getName())) { if (ace.hasPrivileges(privileges)) { return true; } } // check user principal if (ace.getPrincipal().getName().equals(username(sc.getUserName()))) { if (ace.hasPrivileges(privileges)) { return true; } } // check group/role principal if (sc.hasRole(ace.getPrincipal().getName())) { if (ace.hasPrivileges(privileges)) { return true; } } } return false; }
java
public boolean hasPrivileges( SecurityContext sc, Privilege[] privileges ) { for (AccessControlEntryImpl ace : principals.values()) { // check access list for everyone if (ace.getPrincipal().getName().equals(SimplePrincipal.EVERYONE.getName())) { if (ace.hasPrivileges(privileges)) { return true; } } // check user principal if (ace.getPrincipal().getName().equals(username(sc.getUserName()))) { if (ace.hasPrivileges(privileges)) { return true; } } // check group/role principal if (sc.hasRole(ace.getPrincipal().getName())) { if (ace.hasPrivileges(privileges)) { return true; } } } return false; }
[ "public", "boolean", "hasPrivileges", "(", "SecurityContext", "sc", ",", "Privilege", "[", "]", "privileges", ")", "{", "for", "(", "AccessControlEntryImpl", "ace", ":", "principals", ".", "values", "(", ")", ")", "{", "// check access list for everyone", "if", ...
Tests privileges relatively to the given security context. @param sc security context carrying information about principals @param privileges privileges for test @return true when access list grants all given privileges within given security context.
[ "Tests", "privileges", "relatively", "to", "the", "given", "security", "context", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/JcrAccessControlList.java#L130-L155
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/JcrAccessControlList.java
JcrAccessControlList.getPrivileges
public Privilege[] getPrivileges( SecurityContext context ) { ArrayList<Privilege> privs = new ArrayList<Privilege>(); for (AccessControlEntryImpl ace : principals.values()) { // add privileges granted for everyone if (ace.getPrincipal().equals(SimplePrincipal.EVERYONE)) { privs.addAll(Arrays.asList(ace.getPrivileges())); } // add privileges granted for given user if (ace.getPrincipal().getName().equals(username(context.getUserName()))) { privs.addAll(Arrays.asList(ace.getPrivileges())); } // add privileges granted for given role if (context.hasRole(ace.getPrincipal().getName())) { privs.addAll(Arrays.asList(ace.getPrivileges())); } } Privilege[] res = new Privilege[privs.size()]; privs.toArray(res); return res; }
java
public Privilege[] getPrivileges( SecurityContext context ) { ArrayList<Privilege> privs = new ArrayList<Privilege>(); for (AccessControlEntryImpl ace : principals.values()) { // add privileges granted for everyone if (ace.getPrincipal().equals(SimplePrincipal.EVERYONE)) { privs.addAll(Arrays.asList(ace.getPrivileges())); } // add privileges granted for given user if (ace.getPrincipal().getName().equals(username(context.getUserName()))) { privs.addAll(Arrays.asList(ace.getPrivileges())); } // add privileges granted for given role if (context.hasRole(ace.getPrincipal().getName())) { privs.addAll(Arrays.asList(ace.getPrivileges())); } } Privilege[] res = new Privilege[privs.size()]; privs.toArray(res); return res; }
[ "public", "Privilege", "[", "]", "getPrivileges", "(", "SecurityContext", "context", ")", "{", "ArrayList", "<", "Privilege", ">", "privs", "=", "new", "ArrayList", "<", "Privilege", ">", "(", ")", ";", "for", "(", "AccessControlEntryImpl", "ace", ":", "prin...
Lists all privileges defined by this access list for the given user. @param context the security context of the user; never null @return list of privilege objects.
[ "Lists", "all", "privileges", "defined", "by", "this", "access", "list", "for", "the", "given", "user", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/JcrAccessControlList.java#L163-L186
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/JcrAccessControlList.java
JcrAccessControlList.username
private String username( String username ) { return (username.startsWith("<") && username.endsWith(">")) ? username.substring(1, username.length() - 1) : username; }
java
private String username( String username ) { return (username.startsWith("<") && username.endsWith(">")) ? username.substring(1, username.length() - 1) : username; }
[ "private", "String", "username", "(", "String", "username", ")", "{", "return", "(", "username", ".", "startsWith", "(", "\"<\"", ")", "&&", "username", ".", "endsWith", "(", "\">\"", ")", ")", "?", "username", ".", "substring", "(", "1", ",", "username"...
Removes brackets enclosing given user name @param username the user name @return user name without brackets.
[ "Removes", "brackets", "enclosing", "given", "user", "name" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/JcrAccessControlList.java#L240-L242
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/QueryContext.java
QueryContext.getNodeCache
public NodeCache getNodeCache( String workspaceName ) throws WorkspaceNotFoundException { NodeCache cache = overriddenNodeCachesByWorkspaceName.get(workspaceName); if (cache == null) { cache = repositoryCache.getWorkspaceCache(workspaceName); } return cache; }
java
public NodeCache getNodeCache( String workspaceName ) throws WorkspaceNotFoundException { NodeCache cache = overriddenNodeCachesByWorkspaceName.get(workspaceName); if (cache == null) { cache = repositoryCache.getWorkspaceCache(workspaceName); } return cache; }
[ "public", "NodeCache", "getNodeCache", "(", "String", "workspaceName", ")", "throws", "WorkspaceNotFoundException", "{", "NodeCache", "cache", "=", "overriddenNodeCachesByWorkspaceName", ".", "get", "(", "workspaceName", ")", ";", "if", "(", "cache", "==", "null", "...
Get the NodeCache for the given workspace name. The result will either be the overridden value supplied in the constructor or the workspace cache from the referenced RepositoryCache. @param workspaceName the name of the workspace @return the node cache; never null @throws WorkspaceNotFoundException if there is no workspace with the supplied name
[ "Get", "the", "NodeCache", "for", "the", "given", "workspace", "name", ".", "The", "result", "will", "either", "be", "the", "overridden", "value", "supplied", "in", "the", "constructor", "or", "the", "workspace", "cache", "from", "the", "referenced", "Reposito...
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/QueryContext.java#L255-L261
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/QueryContext.java
QueryContext.with
public QueryContext with( Schemata schemata ) { CheckArg.isNotNull(schemata, "schemata"); return new QueryContext(context, repositoryCache, workspaceNames, overriddenNodeCachesByWorkspaceName, schemata, indexDefns, nodeTypes, bufferManager, hints, problems, variables); }
java
public QueryContext with( Schemata schemata ) { CheckArg.isNotNull(schemata, "schemata"); return new QueryContext(context, repositoryCache, workspaceNames, overriddenNodeCachesByWorkspaceName, schemata, indexDefns, nodeTypes, bufferManager, hints, problems, variables); }
[ "public", "QueryContext", "with", "(", "Schemata", "schemata", ")", "{", "CheckArg", ".", "isNotNull", "(", "schemata", ",", "\"schemata\"", ")", ";", "return", "new", "QueryContext", "(", "context", ",", "repositoryCache", ",", "workspaceNames", ",", "overridde...
Obtain a copy of this context, except that the copy uses the supplied schemata. @param schemata the schemata that should be used in the new context @return the new context; never null @throws IllegalArgumentException if the schemata reference is null
[ "Obtain", "a", "copy", "of", "this", "context", "except", "that", "the", "copy", "uses", "the", "supplied", "schemata", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/QueryContext.java#L398-L402
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/QueryContext.java
QueryContext.with
public QueryContext with( Problems problems ) { return new QueryContext(context, repositoryCache, workspaceNames, overriddenNodeCachesByWorkspaceName, schemata, indexDefns, nodeTypes, bufferManager, hints, problems, variables); }
java
public QueryContext with( Problems problems ) { return new QueryContext(context, repositoryCache, workspaceNames, overriddenNodeCachesByWorkspaceName, schemata, indexDefns, nodeTypes, bufferManager, hints, problems, variables); }
[ "public", "QueryContext", "with", "(", "Problems", "problems", ")", "{", "return", "new", "QueryContext", "(", "context", ",", "repositoryCache", ",", "workspaceNames", ",", "overriddenNodeCachesByWorkspaceName", ",", "schemata", ",", "indexDefns", ",", "nodeTypes", ...
Obtain a copy of this context, except that the copy uses the supplied problem container. @param problems the problems that should be used in the new context; may be null if a new problem container should be used @return the new context; never null
[ "Obtain", "a", "copy", "of", "this", "context", "except", "that", "the", "copy", "uses", "the", "supplied", "problem", "container", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/QueryContext.java#L423-L426
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/QueryContext.java
QueryContext.with
public QueryContext with( Map<String, Object> variables ) { return new QueryContext(context, repositoryCache, workspaceNames, overriddenNodeCachesByWorkspaceName, schemata, indexDefns, nodeTypes, bufferManager, hints, problems, variables); }
java
public QueryContext with( Map<String, Object> variables ) { return new QueryContext(context, repositoryCache, workspaceNames, overriddenNodeCachesByWorkspaceName, schemata, indexDefns, nodeTypes, bufferManager, hints, problems, variables); }
[ "public", "QueryContext", "with", "(", "Map", "<", "String", ",", "Object", ">", "variables", ")", "{", "return", "new", "QueryContext", "(", "context", ",", "repositoryCache", ",", "workspaceNames", ",", "overriddenNodeCachesByWorkspaceName", ",", "schemata", ","...
Obtain a copy of this context, except that the copy uses the supplied variables. @param variables the variables that should be used in the new context; may be null if there are no such variables @return the new context; never null
[ "Obtain", "a", "copy", "of", "this", "context", "except", "that", "the", "copy", "uses", "the", "supplied", "variables", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/QueryContext.java#L434-L437
train
ModeShape/modeshape
sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/DdlParserScorer.java
DdlParserScorer.scoreText
public void scoreText( String text, int factor, String... keywords ) { if (text != null && keywords != null) { // Increment the score once for each keyword that is found within the text ... String lowercaseText = text.toLowerCase(); for (String keyword : keywords) { if (keyword == null) continue; String lowercaseKeyword = keyword.toLowerCase(); int index = 0; while (true) { index = lowercaseText.indexOf(lowercaseKeyword, index); if (index == -1) break; score += factor; ++index; } } } }
java
public void scoreText( String text, int factor, String... keywords ) { if (text != null && keywords != null) { // Increment the score once for each keyword that is found within the text ... String lowercaseText = text.toLowerCase(); for (String keyword : keywords) { if (keyword == null) continue; String lowercaseKeyword = keyword.toLowerCase(); int index = 0; while (true) { index = lowercaseText.indexOf(lowercaseKeyword, index); if (index == -1) break; score += factor; ++index; } } } }
[ "public", "void", "scoreText", "(", "String", "text", ",", "int", "factor", ",", "String", "...", "keywords", ")", "{", "if", "(", "text", "!=", "null", "&&", "keywords", "!=", "null", ")", "{", "// Increment the score once for each keyword that is found within th...
Increment the score if the given text contains any of the supply keywords. @param text the text to evaluate; may be null @param factor the factor to use for each increment @param keywords the keywords to be found in the text
[ "Increment", "the", "score", "if", "the", "given", "text", "contains", "any", "of", "the", "supply", "keywords", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/DdlParserScorer.java#L51-L69
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/sequencer/PathExpression.java
PathExpression.removeUnusedPredicates
protected String removeUnusedPredicates( String expression ) { assert expression != null; java.util.regex.Matcher matcher = UNUSABLE_PREDICATE_PATTERN.matcher(expression); // CHECKSTYLE IGNORE check FOR NEXT 1 LINES StringBuffer sb = new StringBuffer(); if (matcher.find()) { do { // Remove those predicates that show up in group 1 ... String predicateStr = matcher.group(0); String unusablePredicateStr = matcher.group(1); if (unusablePredicateStr != null) { predicateStr = ""; } matcher.appendReplacement(sb, predicateStr); } while (matcher.find()); matcher.appendTail(sb); expression = sb.toString(); } return expression; }
java
protected String removeUnusedPredicates( String expression ) { assert expression != null; java.util.regex.Matcher matcher = UNUSABLE_PREDICATE_PATTERN.matcher(expression); // CHECKSTYLE IGNORE check FOR NEXT 1 LINES StringBuffer sb = new StringBuffer(); if (matcher.find()) { do { // Remove those predicates that show up in group 1 ... String predicateStr = matcher.group(0); String unusablePredicateStr = matcher.group(1); if (unusablePredicateStr != null) { predicateStr = ""; } matcher.appendReplacement(sb, predicateStr); } while (matcher.find()); matcher.appendTail(sb); expression = sb.toString(); } return expression; }
[ "protected", "String", "removeUnusedPredicates", "(", "String", "expression", ")", "{", "assert", "expression", "!=", "null", ";", "java", ".", "util", ".", "regex", ".", "Matcher", "matcher", "=", "UNUSABLE_PREDICATE_PATTERN", ".", "matcher", "(", "expression", ...
Replace certain XPath patterns that are not used or understood. @param expression the input regular expressions string; may not be null @return the regular expression with all unused XPath patterns removed; never null
[ "Replace", "certain", "XPath", "patterns", "that", "are", "not", "used", "or", "understood", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/sequencer/PathExpression.java#L265-L284
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/sequencer/PathExpression.java
PathExpression.replaceXPathPatterns
protected String replaceXPathPatterns( String expression ) { assert expression != null; // replace 2 or more sequential '|' characters in an OR expression expression = expression.replaceAll("[\\|]{2,}", "|"); // if there is an empty expression in an OR expression, make the whole segment optional ... // (e.g., "/a/b/(c|)/d" => "a/b(/(c))?/d" expression = expression.replaceAll("/(\\([^|]+)(\\|){2,}([^)]+\\))", "(/$1$2$3)?"); expression = expression.replaceAll("/\\(\\|+([^)]+)\\)", "(?:/($1))?"); expression = expression.replaceAll("/\\((([^|]+)(\\|[^|]+)*)\\|+\\)", "(?:/($1))?"); // // Allow any path (that doesn't contain an explicit counter) to contain a counter, // // done by replacing any '/' or '|' that isn't preceded by ']' or '*' or '/' or '(' with '(\[\d+\])?/'... // input = input.replaceAll("(?<=[^\\]\\*/(])([/|])", "(?:\\\\[\\\\d+\\\\])?$1"); // Does the path contain any '[]' or '[*]' or '[0]' or '[n]' (where n is any positive integers)... // '[*]/' => '(\[\d+\])?/' expression = expression.replaceAll("\\[\\]", "(?:\\\\[\\\\d+\\\\])?"); // index is optional // '[]/' => '(\[\d+\])?/' expression = expression.replaceAll("\\[[*]\\]", "(?:\\\\[\\\\d+\\\\])?"); // index is optional // '[0]/' => '(\[0\])?/' expression = expression.replaceAll("\\[0\\]", "(?:\\\\[0\\\\])?"); // index is optional // '[n]/' => '\[n\]/' expression = expression.replaceAll("\\[([1-9]\\d*)\\]", "\\\\[$1\\\\]"); // index is required // Change any other end predicates to not be wrapped by braces but to begin with a slash ... // ...'[x]' => ...'/x' expression = expression.replaceAll("(?<!\\\\)\\[([^\\]]*)\\]$", "/$1"); // Replace all '[n,m,o,p]' type sequences with '[(n|m|o|p)]' java.util.regex.Matcher matcher = SEQUENCE_PATTERN.matcher(expression); // CHECKSTYLE IGNORE check FOR NEXT 1 LINES StringBuffer sb = new StringBuffer(); boolean result = matcher.find(); if (result) { do { String sequenceStr = matcher.group(1); boolean optional = false; if (sequenceStr.startsWith("0,")) { sequenceStr = sequenceStr.replaceFirst("^0,", ""); optional = true; } if (sequenceStr.endsWith(",0")) { sequenceStr = sequenceStr.replaceFirst(",0$", ""); optional = true; } if (sequenceStr.contains(",0,")) { sequenceStr = sequenceStr.replaceAll(",0,", ","); optional = true; } sequenceStr = sequenceStr.replaceAll(",", "|"); String replacement = "\\\\[(?:" + sequenceStr + ")\\\\]"; if (optional) { replacement = "(?:" + replacement + ")?"; } matcher.appendReplacement(sb, replacement); result = matcher.find(); } while (result); matcher.appendTail(sb); expression = sb.toString(); } // Order is important here expression = expression.replaceAll("[*]([^/(\\\\])", "[^/]*$1"); // '*' not followed by '/', '\\', or '(' expression = expression.replaceAll("(?<!\\[\\^/\\])[*]", "[^/]*"); // '*' not preceded by '[^/]' expression = expression.replaceAll("[/]{2,}$", "(?:/[^/]*)*"); // ending '//' expression = expression.replaceAll("[/]{2,}", "(?:/[^/]*)*/"); // other '//' return expression; }
java
protected String replaceXPathPatterns( String expression ) { assert expression != null; // replace 2 or more sequential '|' characters in an OR expression expression = expression.replaceAll("[\\|]{2,}", "|"); // if there is an empty expression in an OR expression, make the whole segment optional ... // (e.g., "/a/b/(c|)/d" => "a/b(/(c))?/d" expression = expression.replaceAll("/(\\([^|]+)(\\|){2,}([^)]+\\))", "(/$1$2$3)?"); expression = expression.replaceAll("/\\(\\|+([^)]+)\\)", "(?:/($1))?"); expression = expression.replaceAll("/\\((([^|]+)(\\|[^|]+)*)\\|+\\)", "(?:/($1))?"); // // Allow any path (that doesn't contain an explicit counter) to contain a counter, // // done by replacing any '/' or '|' that isn't preceded by ']' or '*' or '/' or '(' with '(\[\d+\])?/'... // input = input.replaceAll("(?<=[^\\]\\*/(])([/|])", "(?:\\\\[\\\\d+\\\\])?$1"); // Does the path contain any '[]' or '[*]' or '[0]' or '[n]' (where n is any positive integers)... // '[*]/' => '(\[\d+\])?/' expression = expression.replaceAll("\\[\\]", "(?:\\\\[\\\\d+\\\\])?"); // index is optional // '[]/' => '(\[\d+\])?/' expression = expression.replaceAll("\\[[*]\\]", "(?:\\\\[\\\\d+\\\\])?"); // index is optional // '[0]/' => '(\[0\])?/' expression = expression.replaceAll("\\[0\\]", "(?:\\\\[0\\\\])?"); // index is optional // '[n]/' => '\[n\]/' expression = expression.replaceAll("\\[([1-9]\\d*)\\]", "\\\\[$1\\\\]"); // index is required // Change any other end predicates to not be wrapped by braces but to begin with a slash ... // ...'[x]' => ...'/x' expression = expression.replaceAll("(?<!\\\\)\\[([^\\]]*)\\]$", "/$1"); // Replace all '[n,m,o,p]' type sequences with '[(n|m|o|p)]' java.util.regex.Matcher matcher = SEQUENCE_PATTERN.matcher(expression); // CHECKSTYLE IGNORE check FOR NEXT 1 LINES StringBuffer sb = new StringBuffer(); boolean result = matcher.find(); if (result) { do { String sequenceStr = matcher.group(1); boolean optional = false; if (sequenceStr.startsWith("0,")) { sequenceStr = sequenceStr.replaceFirst("^0,", ""); optional = true; } if (sequenceStr.endsWith(",0")) { sequenceStr = sequenceStr.replaceFirst(",0$", ""); optional = true; } if (sequenceStr.contains(",0,")) { sequenceStr = sequenceStr.replaceAll(",0,", ","); optional = true; } sequenceStr = sequenceStr.replaceAll(",", "|"); String replacement = "\\\\[(?:" + sequenceStr + ")\\\\]"; if (optional) { replacement = "(?:" + replacement + ")?"; } matcher.appendReplacement(sb, replacement); result = matcher.find(); } while (result); matcher.appendTail(sb); expression = sb.toString(); } // Order is important here expression = expression.replaceAll("[*]([^/(\\\\])", "[^/]*$1"); // '*' not followed by '/', '\\', or '(' expression = expression.replaceAll("(?<!\\[\\^/\\])[*]", "[^/]*"); // '*' not preceded by '[^/]' expression = expression.replaceAll("[/]{2,}$", "(?:/[^/]*)*"); // ending '//' expression = expression.replaceAll("[/]{2,}", "(?:/[^/]*)*/"); // other '//' return expression; }
[ "protected", "String", "replaceXPathPatterns", "(", "String", "expression", ")", "{", "assert", "expression", "!=", "null", ";", "// replace 2 or more sequential '|' characters in an OR expression", "expression", "=", "expression", ".", "replaceAll", "(", "\"[\\\\|]{2,}\"", ...
Replace certain XPath patterns, including some predicates, with substrings that are compatible with regular expressions. @param expression the input regular expressions string; may not be null @return the regular expression with XPath patterns replaced with regular expression fragments; never null
[ "Replace", "certain", "XPath", "patterns", "including", "some", "predicates", "with", "substrings", "that", "are", "compatible", "with", "regular", "expressions", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/sequencer/PathExpression.java#L319-L386
train
ModeShape/modeshape
index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsResponse.java
EsResponse.get
public Object get(String name) { Object obj = document.get(name); return (obj instanceof BasicArray) ? ((BasicArray)obj).toArray() : obj; }
java
public Object get(String name) { Object obj = document.get(name); return (obj instanceof BasicArray) ? ((BasicArray)obj).toArray() : obj; }
[ "public", "Object", "get", "(", "String", "name", ")", "{", "Object", "obj", "=", "document", ".", "get", "(", "name", ")", ";", "return", "(", "obj", "instanceof", "BasicArray", ")", "?", "(", "(", "BasicArray", ")", "obj", ")", ".", "toArray", "(",...
Gets property value. @param name property name. @return property value.
[ "Gets", "property", "value", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsResponse.java#L51-L54
train
ModeShape/modeshape
index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsResponse.java
EsResponse.readFromStream
private void readFromStream(InputStream in) throws IOException { document = DocumentFactory.newDocument(Json.read(in)); }
java
private void readFromStream(InputStream in) throws IOException { document = DocumentFactory.newDocument(Json.read(in)); }
[ "private", "void", "readFromStream", "(", "InputStream", "in", ")", "throws", "IOException", "{", "document", "=", "DocumentFactory", ".", "newDocument", "(", "Json", ".", "read", "(", "in", ")", ")", ";", "}" ]
Reads document content from the stream. @param in input stream. @throws IOException
[ "Reads", "document", "content", "from", "the", "stream", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsResponse.java#L62-L64
train
ModeShape/modeshape
modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/sequencer/Sequencer.java
Sequencer.getPathExpressions
public final String[] getPathExpressions() { String pathExpression = this.pathExpression; Object[] pathExpressions = this.pathExpressions; if (pathExpression == null && (pathExpressions == null || pathExpressions.length == 0)) { // there's none ... return new String[] {}; } if (pathExpression != null && (pathExpressions == null || pathExpressions.length == 0)) { // There's just one ... return new String[] {pathExpression}; } List<String> expressions = new ArrayList<String>(pathExpressions.length + 1); addExpression(expressions, pathExpression); for (Object value : pathExpressions) { addExpression(expressions, value); } return expressions.toArray(new String[expressions.size()]); }
java
public final String[] getPathExpressions() { String pathExpression = this.pathExpression; Object[] pathExpressions = this.pathExpressions; if (pathExpression == null && (pathExpressions == null || pathExpressions.length == 0)) { // there's none ... return new String[] {}; } if (pathExpression != null && (pathExpressions == null || pathExpressions.length == 0)) { // There's just one ... return new String[] {pathExpression}; } List<String> expressions = new ArrayList<String>(pathExpressions.length + 1); addExpression(expressions, pathExpression); for (Object value : pathExpressions) { addExpression(expressions, value); } return expressions.toArray(new String[expressions.size()]); }
[ "public", "final", "String", "[", "]", "getPathExpressions", "(", ")", "{", "String", "pathExpression", "=", "this", ".", "pathExpression", ";", "Object", "[", "]", "pathExpressions", "=", "this", ".", "pathExpressions", ";", "if", "(", "pathExpression", "==",...
Obtain the path expressions as configured on the sequencer. This method always returns a copy to prevent modification of the values. @return the path expressions; never null but possibly empty
[ "Obtain", "the", "path", "expressions", "as", "configured", "on", "the", "sequencer", ".", "This", "method", "always", "returns", "a", "copy", "to", "prevent", "modification", "of", "the", "values", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/sequencer/Sequencer.java#L120-L137
train
ModeShape/modeshape
modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/sequencer/Sequencer.java
Sequencer.isAccepted
public final boolean isAccepted( String mimeType ) { if (mimeType != null && hasAcceptedMimeTypes()) { return getAcceptedMimeTypes().contains(mimeType.trim()); } return true; // accept all mime types }
java
public final boolean isAccepted( String mimeType ) { if (mimeType != null && hasAcceptedMimeTypes()) { return getAcceptedMimeTypes().contains(mimeType.trim()); } return true; // accept all mime types }
[ "public", "final", "boolean", "isAccepted", "(", "String", "mimeType", ")", "{", "if", "(", "mimeType", "!=", "null", "&&", "hasAcceptedMimeTypes", "(", ")", ")", "{", "return", "getAcceptedMimeTypes", "(", ")", ".", "contains", "(", "mimeType", ".", "trim",...
Determine if this sequencer has been configured to accept and process content with the supplied MIME type. @param mimeType the MIME type @return true if content with the supplied the MIME type is to be processed (or when <code>mimeType</code> is null and therefore not known), or false otherwise @see #hasAcceptedMimeTypes()
[ "Determine", "if", "this", "sequencer", "has", "been", "configured", "to", "accept", "and", "process", "content", "with", "the", "supplied", "MIME", "type", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/sequencer/Sequencer.java#L361-L366
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/cache/document/WritableSessionCache.java
WritableSessionCache.getChangedNodesAtOrBelowChildrenFirst
private List<SessionNode> getChangedNodesAtOrBelowChildrenFirst( Path nodePath ) { List<SessionNode> changedNodesChildrenFirst = new ArrayList<SessionNode>(); for (NodeKey key : changedNodes.keySet()) { SessionNode changedNode = changedNodes.get(key); boolean isAtOrBelow = false; try { isAtOrBelow = changedNode.isAtOrBelow(this, nodePath); } catch (NodeNotFoundException e) { isAtOrBelow = false; } if (!isAtOrBelow) { continue; } int insertIndex = changedNodesChildrenFirst.size(); Path changedNodePath = changedNode.getPath(this); for (int i = 0; i < changedNodesChildrenFirst.size(); i++) { if (changedNodesChildrenFirst.get(i).getPath(this).isAncestorOf(changedNodePath)) { insertIndex = i; break; } } changedNodesChildrenFirst.add(insertIndex, changedNode); } return changedNodesChildrenFirst; }
java
private List<SessionNode> getChangedNodesAtOrBelowChildrenFirst( Path nodePath ) { List<SessionNode> changedNodesChildrenFirst = new ArrayList<SessionNode>(); for (NodeKey key : changedNodes.keySet()) { SessionNode changedNode = changedNodes.get(key); boolean isAtOrBelow = false; try { isAtOrBelow = changedNode.isAtOrBelow(this, nodePath); } catch (NodeNotFoundException e) { isAtOrBelow = false; } if (!isAtOrBelow) { continue; } int insertIndex = changedNodesChildrenFirst.size(); Path changedNodePath = changedNode.getPath(this); for (int i = 0; i < changedNodesChildrenFirst.size(); i++) { if (changedNodesChildrenFirst.get(i).getPath(this).isAncestorOf(changedNodePath)) { insertIndex = i; break; } } changedNodesChildrenFirst.add(insertIndex, changedNode); } return changedNodesChildrenFirst; }
[ "private", "List", "<", "SessionNode", ">", "getChangedNodesAtOrBelowChildrenFirst", "(", "Path", "nodePath", ")", "{", "List", "<", "SessionNode", ">", "changedNodesChildrenFirst", "=", "new", "ArrayList", "<", "SessionNode", ">", "(", ")", ";", "for", "(", "No...
Returns the list of changed nodes at or below the given path, starting with the children. @param nodePath the path of the parent node @return the list of changed nodes
[ "Returns", "the", "list", "of", "changed", "nodes", "at", "or", "below", "the", "given", "path", "starting", "with", "the", "children", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/document/WritableSessionCache.java#L278-L304
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/cache/document/WritableSessionCache.java
WritableSessionCache.completeTransaction
private void completeTransaction(final String txId, String wsName) { getWorkspace().clear(); // reset the ws cache to the shared (global one) setWorkspaceCache(sharedWorkspaceCache()); // and clear some tx specific data COMPLETE_FUNCTION_BY_TX_AND_WS.compute(txId, (transactionId, funcsByWsName) -> { funcsByWsName.remove(wsName); if (funcsByWsName.isEmpty()) { // this is the last ws cache we are clearing for this tx so mark all the keys as unlocked LOCKED_KEYS_BY_TX_ID.remove(txId); // and remove the map return null; } // there are other ws caches which need clearing for this tx, so just return the updated map return funcsByWsName; }); }
java
private void completeTransaction(final String txId, String wsName) { getWorkspace().clear(); // reset the ws cache to the shared (global one) setWorkspaceCache(sharedWorkspaceCache()); // and clear some tx specific data COMPLETE_FUNCTION_BY_TX_AND_WS.compute(txId, (transactionId, funcsByWsName) -> { funcsByWsName.remove(wsName); if (funcsByWsName.isEmpty()) { // this is the last ws cache we are clearing for this tx so mark all the keys as unlocked LOCKED_KEYS_BY_TX_ID.remove(txId); // and remove the map return null; } // there are other ws caches which need clearing for this tx, so just return the updated map return funcsByWsName; }); }
[ "private", "void", "completeTransaction", "(", "final", "String", "txId", ",", "String", "wsName", ")", "{", "getWorkspace", "(", ")", ".", "clear", "(", ")", ";", "// reset the ws cache to the shared (global one)", "setWorkspaceCache", "(", "sharedWorkspaceCache", "(...
Signal that the transaction that was active and in which this session participated has completed and that this session should no longer use a transaction-specific workspace cache.
[ "Signal", "that", "the", "transaction", "that", "was", "active", "and", "in", "which", "this", "session", "participated", "has", "completed", "and", "that", "this", "session", "should", "no", "longer", "use", "a", "transaction", "-", "specific", "workspace", "...
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/document/WritableSessionCache.java#L440-L456
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/cache/document/WritableSessionCache.java
WritableSessionCache.rollback
private void rollback(Transaction txn, Exception cause) throws Exception { try { txn.rollback(); } catch (Exception e) { logger.debug(e, "Error while rolling back transaction " + txn); } finally { throw cause; } }
java
private void rollback(Transaction txn, Exception cause) throws Exception { try { txn.rollback(); } catch (Exception e) { logger.debug(e, "Error while rolling back transaction " + txn); } finally { throw cause; } }
[ "private", "void", "rollback", "(", "Transaction", "txn", ",", "Exception", "cause", ")", "throws", "Exception", "{", "try", "{", "txn", ".", "rollback", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "debug", "(", "e", ...
Rolling back given transaction caused by given cause. @param txn the transaction @param cause roll back cause @throws Exception roll back cause.
[ "Rolling", "back", "given", "transaction", "caused", "by", "given", "cause", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/document/WritableSessionCache.java#L872-L880
train
ModeShape/modeshape
modeshape-jdbc-local/src/main/java/org/modeshape/jdbc/util/TimestampWithTimezone.java
TimestampWithTimezone.createDate
public static Date createDate( Calendar target ) { return new java.sql.Date(target.getTime().getTime()); }
java
public static Date createDate( Calendar target ) { return new java.sql.Date(target.getTime().getTime()); }
[ "public", "static", "Date", "createDate", "(", "Calendar", "target", ")", "{", "return", "new", "java", ".", "sql", ".", "Date", "(", "target", ".", "getTime", "(", ")", ".", "getTime", "(", ")", ")", ";", "}" ]
Creates normalized SQL Date Object based on the target Calendar @param target Calendar @return Date
[ "Creates", "normalized", "SQL", "Date", "Object", "based", "on", "the", "target", "Calendar" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jdbc-local/src/main/java/org/modeshape/jdbc/util/TimestampWithTimezone.java#L126-L128
train
ModeShape/modeshape
sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java
StandardDdlParser.mergeNodes
public void mergeNodes( DdlTokenStream tokens, AstNode firstNode, AstNode secondNode ) { assert tokens != null; assert firstNode != null; assert secondNode != null; int firstStartIndex = (Integer)firstNode.getProperty(DDL_START_CHAR_INDEX); int secondStartIndex = (Integer)secondNode.getProperty(DDL_START_CHAR_INDEX); int deltaLength = ((String)secondNode.getProperty(DDL_EXPRESSION)).length(); Position startPosition = new Position(firstStartIndex, 1, 0); Position endPosition = new Position((secondStartIndex + deltaLength), 1, 0); String source = tokens.getContentBetween(startPosition, endPosition); firstNode.setProperty(DDL_EXPRESSION, source); firstNode.setProperty(DDL_LENGTH, source.length()); }
java
public void mergeNodes( DdlTokenStream tokens, AstNode firstNode, AstNode secondNode ) { assert tokens != null; assert firstNode != null; assert secondNode != null; int firstStartIndex = (Integer)firstNode.getProperty(DDL_START_CHAR_INDEX); int secondStartIndex = (Integer)secondNode.getProperty(DDL_START_CHAR_INDEX); int deltaLength = ((String)secondNode.getProperty(DDL_EXPRESSION)).length(); Position startPosition = new Position(firstStartIndex, 1, 0); Position endPosition = new Position((secondStartIndex + deltaLength), 1, 0); String source = tokens.getContentBetween(startPosition, endPosition); firstNode.setProperty(DDL_EXPRESSION, source); firstNode.setProperty(DDL_LENGTH, source.length()); }
[ "public", "void", "mergeNodes", "(", "DdlTokenStream", "tokens", ",", "AstNode", "firstNode", ",", "AstNode", "secondNode", ")", "{", "assert", "tokens", "!=", "null", ";", "assert", "firstNode", "!=", "null", ";", "assert", "secondNode", "!=", "null", ";", ...
Merges second node into first node by re-setting expression source and length. @param tokens the {@link DdlTokenStream} representing the tokenized DDL content; may not be null @param firstNode the node to merge into; may not be null @param secondNode the node to merge into first node; may not be null
[ "Merges", "second", "node", "into", "first", "node", "by", "re", "-", "setting", "expression", "source", "and", "length", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java#L500-L515
train
ModeShape/modeshape
sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java
StandardDdlParser.parseCreateStatement
protected AstNode parseCreateStatement( DdlTokenStream tokens, AstNode parentNode ) throws ParsingException { assert tokens != null; assert parentNode != null; AstNode stmtNode = null; // DEFAULT DOES NOTHING // Subclasses can implement additional parsing // System.out.println(" >>> FOUND [CREATE] STATEMENT: TOKEN = " + tokens.consume() + " " + tokens.consume() + " " + // tokens.consume()); // SQL 92 CREATE OPTIONS: // CREATE SCHEMA // CREATE DOMAIN // CREATE [ { GLOBAL | LOCAL } TEMPORARY ] TABLE // CREATE VIEW // CREATE ASSERTION // CREATE CHARACTER SET // CREATE COLLATION // CREATE TRANSLATION if (tokens.matches(STMT_CREATE_SCHEMA)) { stmtNode = parseCreateSchemaStatement(tokens, parentNode); } else if (tokens.matches(STMT_CREATE_TABLE) || tokens.matches(STMT_CREATE_GLOBAL_TEMPORARY_TABLE) || tokens.matches(STMT_CREATE_LOCAL_TEMPORARY_TABLE)) { stmtNode = parseCreateTableStatement(tokens, parentNode); } else if (tokens.matches(STMT_CREATE_VIEW) || tokens.matches(STMT_CREATE_OR_REPLACE_VIEW)) { stmtNode = parseCreateViewStatement(tokens, parentNode); } else if (tokens.matches(STMT_CREATE_ASSERTION)) { stmtNode = parseCreateAssertionStatement(tokens, parentNode); } else if (tokens.matches(STMT_CREATE_CHARACTER_SET)) { stmtNode = parseCreateCharacterSetStatement(tokens, parentNode); } else if (tokens.matches(STMT_CREATE_COLLATION)) { stmtNode = parseCreateCollationStatement(tokens, parentNode); } else if (tokens.matches(STMT_CREATE_TRANSLATION)) { stmtNode = parseCreateTranslationStatement(tokens, parentNode); } else if (tokens.matches(STMT_CREATE_DOMAIN)) { stmtNode = parseCreateDomainStatement(tokens, parentNode); } else { markStartOfStatement(tokens); stmtNode = parseIgnorableStatement(tokens, "CREATE UNKNOWN", parentNode); Position position = getCurrentMarkedPosition(); String msg = DdlSequencerI18n.unknownCreateStatement.text(position.getLine(), position.getColumn()); DdlParserProblem problem = new DdlParserProblem(DdlConstants.Problems.WARNING, position, msg); stmtNode.setProperty(DDL_PROBLEM, problem.toString()); markEndOfStatement(tokens, stmtNode); } return stmtNode; }
java
protected AstNode parseCreateStatement( DdlTokenStream tokens, AstNode parentNode ) throws ParsingException { assert tokens != null; assert parentNode != null; AstNode stmtNode = null; // DEFAULT DOES NOTHING // Subclasses can implement additional parsing // System.out.println(" >>> FOUND [CREATE] STATEMENT: TOKEN = " + tokens.consume() + " " + tokens.consume() + " " + // tokens.consume()); // SQL 92 CREATE OPTIONS: // CREATE SCHEMA // CREATE DOMAIN // CREATE [ { GLOBAL | LOCAL } TEMPORARY ] TABLE // CREATE VIEW // CREATE ASSERTION // CREATE CHARACTER SET // CREATE COLLATION // CREATE TRANSLATION if (tokens.matches(STMT_CREATE_SCHEMA)) { stmtNode = parseCreateSchemaStatement(tokens, parentNode); } else if (tokens.matches(STMT_CREATE_TABLE) || tokens.matches(STMT_CREATE_GLOBAL_TEMPORARY_TABLE) || tokens.matches(STMT_CREATE_LOCAL_TEMPORARY_TABLE)) { stmtNode = parseCreateTableStatement(tokens, parentNode); } else if (tokens.matches(STMT_CREATE_VIEW) || tokens.matches(STMT_CREATE_OR_REPLACE_VIEW)) { stmtNode = parseCreateViewStatement(tokens, parentNode); } else if (tokens.matches(STMT_CREATE_ASSERTION)) { stmtNode = parseCreateAssertionStatement(tokens, parentNode); } else if (tokens.matches(STMT_CREATE_CHARACTER_SET)) { stmtNode = parseCreateCharacterSetStatement(tokens, parentNode); } else if (tokens.matches(STMT_CREATE_COLLATION)) { stmtNode = parseCreateCollationStatement(tokens, parentNode); } else if (tokens.matches(STMT_CREATE_TRANSLATION)) { stmtNode = parseCreateTranslationStatement(tokens, parentNode); } else if (tokens.matches(STMT_CREATE_DOMAIN)) { stmtNode = parseCreateDomainStatement(tokens, parentNode); } else { markStartOfStatement(tokens); stmtNode = parseIgnorableStatement(tokens, "CREATE UNKNOWN", parentNode); Position position = getCurrentMarkedPosition(); String msg = DdlSequencerI18n.unknownCreateStatement.text(position.getLine(), position.getColumn()); DdlParserProblem problem = new DdlParserProblem(DdlConstants.Problems.WARNING, position, msg); stmtNode.setProperty(DDL_PROBLEM, problem.toString()); markEndOfStatement(tokens, stmtNode); } return stmtNode; }
[ "protected", "AstNode", "parseCreateStatement", "(", "DdlTokenStream", "tokens", ",", "AstNode", "parentNode", ")", "throws", "ParsingException", "{", "assert", "tokens", "!=", "null", ";", "assert", "parentNode", "!=", "null", ";", "AstNode", "stmtNode", "=", "nu...
Parses DDL CREATE statement based on SQL 92 specifications. @param tokens the {@link DdlTokenStream} representing the tokenized DDL content; may not be null @param parentNode the parent {@link AstNode} node; may not be null @return the parsed CREATE {@link AstNode} @throws ParsingException
[ "Parses", "DDL", "CREATE", "statement", "based", "on", "SQL", "92", "specifications", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java#L543-L595
train
ModeShape/modeshape
sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java
StandardDdlParser.parseAlterStatement
protected AstNode parseAlterStatement( DdlTokenStream tokens, AstNode parentNode ) throws ParsingException { assert tokens != null; assert parentNode != null; if (tokens.matches(ALTER, TABLE)) { return parseAlterTableStatement(tokens, parentNode); } else if (tokens.matches("ALTER", "DOMAIN")) { markStartOfStatement(tokens); tokens.consume("ALTER", "DOMAIN"); String domainName = parseName(tokens); AstNode alterNode = nodeFactory().node(domainName, parentNode, TYPE_ALTER_DOMAIN_STATEMENT); parseUntilTerminator(tokens); markEndOfStatement(tokens, alterNode); return alterNode; } return null; }
java
protected AstNode parseAlterStatement( DdlTokenStream tokens, AstNode parentNode ) throws ParsingException { assert tokens != null; assert parentNode != null; if (tokens.matches(ALTER, TABLE)) { return parseAlterTableStatement(tokens, parentNode); } else if (tokens.matches("ALTER", "DOMAIN")) { markStartOfStatement(tokens); tokens.consume("ALTER", "DOMAIN"); String domainName = parseName(tokens); AstNode alterNode = nodeFactory().node(domainName, parentNode, TYPE_ALTER_DOMAIN_STATEMENT); parseUntilTerminator(tokens); markEndOfStatement(tokens, alterNode); return alterNode; } return null; }
[ "protected", "AstNode", "parseAlterStatement", "(", "DdlTokenStream", "tokens", ",", "AstNode", "parentNode", ")", "throws", "ParsingException", "{", "assert", "tokens", "!=", "null", ";", "assert", "parentNode", "!=", "null", ";", "if", "(", "tokens", ".", "mat...
Parses DDL ALTER statement based on SQL 92 specifications. @param tokens the {@link DdlTokenStream} representing the tokenized DDL content; may not be null @param parentNode the parent {@link AstNode} node; may not be null @return the parsed ALTER {@link AstNode} @throws ParsingException
[ "Parses", "DDL", "ALTER", "statement", "based", "on", "SQL", "92", "specifications", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java#L605-L622
train
ModeShape/modeshape
sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java
StandardDdlParser.getTableElementsString
protected String getTableElementsString( DdlTokenStream tokens, boolean useTerminator ) throws ParsingException { assert tokens != null; StringBuilder sb = new StringBuilder(100); if (useTerminator) { while (!isTerminator(tokens)) { sb.append(SPACE).append(tokens.consume()); } } else { // Assume we start with open parenthesis '(', then we can count on walking through ALL tokens until we find the close // parenthesis ')'. If there are intermediate parenthesis, we can count on them being pairs. tokens.consume(L_PAREN); // EXPECTED int iParen = 0; while (tokens.hasNext()) { if (tokens.matches(L_PAREN)) { iParen++; } else if (tokens.matches(R_PAREN)) { if (iParen == 0) { tokens.consume(R_PAREN); break; } iParen--; } if (isComment(tokens)) { tokens.consume(); } else { sb.append(SPACE).append(tokens.consume()); } } } return sb.toString(); }
java
protected String getTableElementsString( DdlTokenStream tokens, boolean useTerminator ) throws ParsingException { assert tokens != null; StringBuilder sb = new StringBuilder(100); if (useTerminator) { while (!isTerminator(tokens)) { sb.append(SPACE).append(tokens.consume()); } } else { // Assume we start with open parenthesis '(', then we can count on walking through ALL tokens until we find the close // parenthesis ')'. If there are intermediate parenthesis, we can count on them being pairs. tokens.consume(L_PAREN); // EXPECTED int iParen = 0; while (tokens.hasNext()) { if (tokens.matches(L_PAREN)) { iParen++; } else if (tokens.matches(R_PAREN)) { if (iParen == 0) { tokens.consume(R_PAREN); break; } iParen--; } if (isComment(tokens)) { tokens.consume(); } else { sb.append(SPACE).append(tokens.consume()); } } } return sb.toString(); }
[ "protected", "String", "getTableElementsString", "(", "DdlTokenStream", "tokens", ",", "boolean", "useTerminator", ")", "throws", "ParsingException", "{", "assert", "tokens", "!=", "null", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "100", ")", "...
Method which extracts the table element string from a CREATE TABLE statement. @param tokens the {@link DdlTokenStream} representing the tokenized DDL content; may not be null @param useTerminator @return the parsed table elements String. @throws ParsingException
[ "Method", "which", "extracts", "the", "table", "element", "string", "from", "a", "CREATE", "TABLE", "statement", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java#L1472-L1508
train
ModeShape/modeshape
sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java
StandardDdlParser.parseConstraintAttributes
protected void parseConstraintAttributes( DdlTokenStream tokens, AstNode constraintNode ) throws ParsingException { assert tokens != null; assert constraintNode != null; // Now we need to check for constraint attributes: // <constraint attributes> ::= // <constraint check time> [ [ NOT ] DEFERRABLE ] // | [ NOT ] DEFERRABLE [ <constraint check time> ] // // <constraint check time> ::= // INITIALLY DEFERRED // | INITIALLY IMMEDIATE // EXAMPLE : foreign key (contact_id) references contact (contact_id) on delete cascade INITIALLY DEFERRED, if (tokens.canConsume("INITIALLY", "DEFERRED")) { AstNode attrNode = nodeFactory().node("CONSTRAINT_ATTRIBUTE", constraintNode, TYPE_CONSTRAINT_ATTRIBUTE); attrNode.setProperty(PROPERTY_VALUE, "INITIALLY DEFERRED"); } if (tokens.canConsume("INITIALLY", "IMMEDIATE")) { AstNode attrNode = nodeFactory().node("CONSTRAINT_ATTRIBUTE", constraintNode, TYPE_CONSTRAINT_ATTRIBUTE); attrNode.setProperty(PROPERTY_VALUE, "INITIALLY IMMEDIATE"); } if (tokens.canConsume("NOT", "DEFERRABLE")) { AstNode attrNode = nodeFactory().node("CONSTRAINT_ATTRIBUTE", constraintNode, TYPE_CONSTRAINT_ATTRIBUTE); attrNode.setProperty(PROPERTY_VALUE, "NOT DEFERRABLE"); } if (tokens.canConsume("DEFERRABLE")) { AstNode attrNode = nodeFactory().node("CONSTRAINT_ATTRIBUTE", constraintNode, TYPE_CONSTRAINT_ATTRIBUTE); attrNode.setProperty(PROPERTY_VALUE, "DEFERRABLE"); } if (tokens.canConsume("INITIALLY", "DEFERRED")) { AstNode attrNode = nodeFactory().node("CONSTRAINT_ATTRIBUTE", constraintNode, TYPE_CONSTRAINT_ATTRIBUTE); attrNode.setProperty(PROPERTY_VALUE, "INITIALLY DEFERRED"); } if (tokens.canConsume("INITIALLY", "IMMEDIATE")) { AstNode attrNode = nodeFactory().node("CONSTRAINT_ATTRIBUTE", constraintNode, TYPE_CONSTRAINT_ATTRIBUTE); attrNode.setProperty(PROPERTY_VALUE, "INITIALLY IMMEDIATE"); } }
java
protected void parseConstraintAttributes( DdlTokenStream tokens, AstNode constraintNode ) throws ParsingException { assert tokens != null; assert constraintNode != null; // Now we need to check for constraint attributes: // <constraint attributes> ::= // <constraint check time> [ [ NOT ] DEFERRABLE ] // | [ NOT ] DEFERRABLE [ <constraint check time> ] // // <constraint check time> ::= // INITIALLY DEFERRED // | INITIALLY IMMEDIATE // EXAMPLE : foreign key (contact_id) references contact (contact_id) on delete cascade INITIALLY DEFERRED, if (tokens.canConsume("INITIALLY", "DEFERRED")) { AstNode attrNode = nodeFactory().node("CONSTRAINT_ATTRIBUTE", constraintNode, TYPE_CONSTRAINT_ATTRIBUTE); attrNode.setProperty(PROPERTY_VALUE, "INITIALLY DEFERRED"); } if (tokens.canConsume("INITIALLY", "IMMEDIATE")) { AstNode attrNode = nodeFactory().node("CONSTRAINT_ATTRIBUTE", constraintNode, TYPE_CONSTRAINT_ATTRIBUTE); attrNode.setProperty(PROPERTY_VALUE, "INITIALLY IMMEDIATE"); } if (tokens.canConsume("NOT", "DEFERRABLE")) { AstNode attrNode = nodeFactory().node("CONSTRAINT_ATTRIBUTE", constraintNode, TYPE_CONSTRAINT_ATTRIBUTE); attrNode.setProperty(PROPERTY_VALUE, "NOT DEFERRABLE"); } if (tokens.canConsume("DEFERRABLE")) { AstNode attrNode = nodeFactory().node("CONSTRAINT_ATTRIBUTE", constraintNode, TYPE_CONSTRAINT_ATTRIBUTE); attrNode.setProperty(PROPERTY_VALUE, "DEFERRABLE"); } if (tokens.canConsume("INITIALLY", "DEFERRED")) { AstNode attrNode = nodeFactory().node("CONSTRAINT_ATTRIBUTE", constraintNode, TYPE_CONSTRAINT_ATTRIBUTE); attrNode.setProperty(PROPERTY_VALUE, "INITIALLY DEFERRED"); } if (tokens.canConsume("INITIALLY", "IMMEDIATE")) { AstNode attrNode = nodeFactory().node("CONSTRAINT_ATTRIBUTE", constraintNode, TYPE_CONSTRAINT_ATTRIBUTE); attrNode.setProperty(PROPERTY_VALUE, "INITIALLY IMMEDIATE"); } }
[ "protected", "void", "parseConstraintAttributes", "(", "DdlTokenStream", "tokens", ",", "AstNode", "constraintNode", ")", "throws", "ParsingException", "{", "assert", "tokens", "!=", "null", ";", "assert", "constraintNode", "!=", "null", ";", "// Now we need to check fo...
Parses the attributes associated with any in-line column constraint definition or a table constrain definition. @param tokens the {@link DdlTokenStream} representing the tokenized DDL content; may not be null @param constraintNode @throws ParsingException
[ "Parses", "the", "attributes", "associated", "with", "any", "in", "-", "line", "column", "constraint", "definition", "or", "a", "table", "constrain", "definition", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java#L1904-L1944
train
ModeShape/modeshape
sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java
StandardDdlParser.getDataTypeStartWords
protected List<String> getDataTypeStartWords() { if (allDataTypeStartWords == null) { allDataTypeStartWords = new ArrayList<String>(); allDataTypeStartWords.addAll(DataTypes.DATATYPE_START_WORDS); allDataTypeStartWords.addAll(getCustomDataTypeStartWords()); } return allDataTypeStartWords; }
java
protected List<String> getDataTypeStartWords() { if (allDataTypeStartWords == null) { allDataTypeStartWords = new ArrayList<String>(); allDataTypeStartWords.addAll(DataTypes.DATATYPE_START_WORDS); allDataTypeStartWords.addAll(getCustomDataTypeStartWords()); } return allDataTypeStartWords; }
[ "protected", "List", "<", "String", ">", "getDataTypeStartWords", "(", ")", "{", "if", "(", "allDataTypeStartWords", "==", "null", ")", "{", "allDataTypeStartWords", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "allDataTypeStartWords", ".", "add...
Returns a list of data type start words which can be used to help identify a column definition sub-statement. @return list of data type start words
[ "Returns", "a", "list", "of", "data", "type", "start", "words", "which", "can", "be", "used", "to", "help", "identify", "a", "column", "definition", "sub", "-", "statement", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java#L2403-L2410
train
ModeShape/modeshape
sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java
StandardDdlParser.consumeIdentifier
protected String consumeIdentifier( DdlTokenStream tokens ) throws ParsingException { String value = tokens.consume(); // This may surrounded by quotes, so remove them ... if (value.charAt(0) == '"') { int length = value.length(); // Check for the end quote ... value = value.substring(1, length - 1); // not complete!! } // TODO: Handle warnings elegantly // else { // // Not quoted, so check for reserved words ... // if (tokens.isKeyWord(value)) { // // Record warning ... // System.out.println(" WARNING: Identifier [" + value + "] is a SQL 92 Reserved Word"); // } // } return value; }
java
protected String consumeIdentifier( DdlTokenStream tokens ) throws ParsingException { String value = tokens.consume(); // This may surrounded by quotes, so remove them ... if (value.charAt(0) == '"') { int length = value.length(); // Check for the end quote ... value = value.substring(1, length - 1); // not complete!! } // TODO: Handle warnings elegantly // else { // // Not quoted, so check for reserved words ... // if (tokens.isKeyWord(value)) { // // Record warning ... // System.out.println(" WARNING: Identifier [" + value + "] is a SQL 92 Reserved Word"); // } // } return value; }
[ "protected", "String", "consumeIdentifier", "(", "DdlTokenStream", "tokens", ")", "throws", "ParsingException", "{", "String", "value", "=", "tokens", ".", "consume", "(", ")", ";", "// This may surrounded by quotes, so remove them ...", "if", "(", "value", ".", "char...
Consumes an token identifier which can be of the form of a simple string or a double-quoted string. @param tokens the {@link DdlTokenStream} representing the tokenized DDL content; may not be null @return the identifier @throws ParsingException
[ "Consumes", "an", "token", "identifier", "which", "can", "be", "of", "the", "form", "of", "a", "simple", "string", "or", "a", "double", "-", "quoted", "string", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java#L2474-L2491
train
ModeShape/modeshape
sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java
StandardDdlParser.parseColumnNameList
protected boolean parseColumnNameList( DdlTokenStream tokens, AstNode parentNode, String referenceType ) { boolean parsedColumns = false; // CONSUME COLUMNS List<String> columnNameList = new ArrayList<String>(); if (tokens.matches(L_PAREN)) { tokens.consume(L_PAREN); columnNameList = parseNameList(tokens); if (!columnNameList.isEmpty()) { parsedColumns = true; } tokens.consume(R_PAREN); } for (String columnName : columnNameList) { nodeFactory().node(columnName, parentNode, referenceType); } return parsedColumns; }
java
protected boolean parseColumnNameList( DdlTokenStream tokens, AstNode parentNode, String referenceType ) { boolean parsedColumns = false; // CONSUME COLUMNS List<String> columnNameList = new ArrayList<String>(); if (tokens.matches(L_PAREN)) { tokens.consume(L_PAREN); columnNameList = parseNameList(tokens); if (!columnNameList.isEmpty()) { parsedColumns = true; } tokens.consume(R_PAREN); } for (String columnName : columnNameList) { nodeFactory().node(columnName, parentNode, referenceType); } return parsedColumns; }
[ "protected", "boolean", "parseColumnNameList", "(", "DdlTokenStream", "tokens", ",", "AstNode", "parentNode", ",", "String", "referenceType", ")", "{", "boolean", "parsedColumns", "=", "false", ";", "// CONSUME COLUMNS", "List", "<", "String", ">", "columnNameList", ...
Adds column reference nodes to a parent node. Returns true if column references added, false if not. @param tokens the {@link DdlTokenStream} representing the tokenized DDL content; may not be null @param parentNode the parent node @param referenceType the type of the reference node to create @return true if the column references were found and added to the node, or false if there were no column references found in the stream
[ "Adds", "column", "reference", "nodes", "to", "a", "parent", "node", ".", "Returns", "true", "if", "column", "references", "added", "false", "if", "not", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java#L2515-L2537
train
ModeShape/modeshape
sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java
StandardDdlParser.parseNameList
protected List<String> parseNameList( DdlTokenStream tokens ) throws ParsingException { List<String> names = new LinkedList<String>(); while (true) { names.add(parseName(tokens)); if (!tokens.canConsume(COMMA)) { break; } } return names; }
java
protected List<String> parseNameList( DdlTokenStream tokens ) throws ParsingException { List<String> names = new LinkedList<String>(); while (true) { names.add(parseName(tokens)); if (!tokens.canConsume(COMMA)) { break; } } return names; }
[ "protected", "List", "<", "String", ">", "parseNameList", "(", "DdlTokenStream", "tokens", ")", "throws", "ParsingException", "{", "List", "<", "String", ">", "names", "=", "new", "LinkedList", "<", "String", ">", "(", ")", ";", "while", "(", "true", ")", ...
Parses a comma separated list of names. @param tokens the {@link DdlTokenStream} representing the tokenized DDL content; may not be null @return list of names (never <code>null</code>) @throws ParsingException
[ "Parses", "a", "comma", "separated", "list", "of", "names", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java#L2546-L2558
train
ModeShape/modeshape
sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java
StandardDdlParser.parseUntilTerminator
protected String parseUntilTerminator( DdlTokenStream tokens ) throws ParsingException { final StringBuilder sb = new StringBuilder(); boolean lastTokenWasPeriod = false; Position prevPosition = (tokens.hasNext() ? tokens.nextPosition() : Position.EMPTY_CONTENT_POSITION); String prevToken = ""; while (tokens.hasNext() && !tokens.matches(DdlTokenizer.STATEMENT_KEY) && ((doUseTerminator() && !isTerminator(tokens)) || !doUseTerminator())) { final Position currPosition = tokens.nextPosition(); final String thisToken = tokens.consume(); final boolean thisTokenIsPeriod = thisToken.equals(PERIOD); final boolean thisTokenIsComma = thisToken.equals(COMMA); if (lastTokenWasPeriod || thisTokenIsPeriod || thisTokenIsComma) { sb.append(thisToken); } else if ((currPosition.getIndexInContent() - prevPosition.getIndexInContent() - prevToken.length()) > 0) { sb.append(SPACE).append(thisToken); } else { sb.append(thisToken); } if (thisTokenIsPeriod) { lastTokenWasPeriod = true; } else { lastTokenWasPeriod = false; } prevToken = thisToken; prevPosition = currPosition; } return sb.toString(); }
java
protected String parseUntilTerminator( DdlTokenStream tokens ) throws ParsingException { final StringBuilder sb = new StringBuilder(); boolean lastTokenWasPeriod = false; Position prevPosition = (tokens.hasNext() ? tokens.nextPosition() : Position.EMPTY_CONTENT_POSITION); String prevToken = ""; while (tokens.hasNext() && !tokens.matches(DdlTokenizer.STATEMENT_KEY) && ((doUseTerminator() && !isTerminator(tokens)) || !doUseTerminator())) { final Position currPosition = tokens.nextPosition(); final String thisToken = tokens.consume(); final boolean thisTokenIsPeriod = thisToken.equals(PERIOD); final boolean thisTokenIsComma = thisToken.equals(COMMA); if (lastTokenWasPeriod || thisTokenIsPeriod || thisTokenIsComma) { sb.append(thisToken); } else if ((currPosition.getIndexInContent() - prevPosition.getIndexInContent() - prevToken.length()) > 0) { sb.append(SPACE).append(thisToken); } else { sb.append(thisToken); } if (thisTokenIsPeriod) { lastTokenWasPeriod = true; } else { lastTokenWasPeriod = false; } prevToken = thisToken; prevPosition = currPosition; } return sb.toString(); }
[ "protected", "String", "parseUntilTerminator", "(", "DdlTokenStream", "tokens", ")", "throws", "ParsingException", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "boolean", "lastTokenWasPeriod", "=", "false", ";", "Position", "prevP...
Utility method which parses tokens until a terminator is found, another statement is identified or there are no more tokens. @param tokens the {@link DdlTokenStream} representing the tokenized DDL content; may not be null @return the parsed string @throws ParsingException
[ "Utility", "method", "which", "parses", "tokens", "until", "a", "terminator", "is", "found", "another", "statement", "is", "identified", "or", "there", "are", "no", "more", "tokens", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java#L2568-L2600
train
ModeShape/modeshape
sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java
StandardDdlParser.parseUntilSemiColon
protected String parseUntilSemiColon( DdlTokenStream tokens ) throws ParsingException { StringBuilder sb = new StringBuilder(); boolean lastTokenWasPeriod = false; while (tokens.hasNext() && !tokens.matches(SEMICOLON)) { String thisToken = tokens.consume(); boolean thisTokenIsPeriod = thisToken.equals(PERIOD); boolean thisTokenIsComma = thisToken.equals(COMMA); if (lastTokenWasPeriod || thisTokenIsPeriod || thisTokenIsComma) { sb.append(thisToken); } else { sb.append(SPACE).append(thisToken); } if (thisTokenIsPeriod) { lastTokenWasPeriod = true; } else { lastTokenWasPeriod = false; } } return sb.toString(); }
java
protected String parseUntilSemiColon( DdlTokenStream tokens ) throws ParsingException { StringBuilder sb = new StringBuilder(); boolean lastTokenWasPeriod = false; while (tokens.hasNext() && !tokens.matches(SEMICOLON)) { String thisToken = tokens.consume(); boolean thisTokenIsPeriod = thisToken.equals(PERIOD); boolean thisTokenIsComma = thisToken.equals(COMMA); if (lastTokenWasPeriod || thisTokenIsPeriod || thisTokenIsComma) { sb.append(thisToken); } else { sb.append(SPACE).append(thisToken); } if (thisTokenIsPeriod) { lastTokenWasPeriod = true; } else { lastTokenWasPeriod = false; } } return sb.toString(); }
[ "protected", "String", "parseUntilSemiColon", "(", "DdlTokenStream", "tokens", ")", "throws", "ParsingException", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "boolean", "lastTokenWasPeriod", "=", "false", ";", "while", "(", "tokens", "....
Utility method which parses tokens until a semicolon is found or there are no more tokens. @param tokens the {@link DdlTokenStream} representing the tokenized DDL content; may not be null @return the parsed string @throws ParsingException
[ "Utility", "method", "which", "parses", "tokens", "until", "a", "semicolon", "is", "found", "or", "there", "are", "no", "more", "tokens", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/StandardDdlParser.java#L2651-L2672
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryNodeTypeManager.java
RepositoryNodeTypeManager.registerListener
final boolean registerListener( NodeTypes.Listener listener ) { return listener != null ? this.listeners.addIfAbsent(listener) : false; }
java
final boolean registerListener( NodeTypes.Listener listener ) { return listener != null ? this.listeners.addIfAbsent(listener) : false; }
[ "final", "boolean", "registerListener", "(", "NodeTypes", ".", "Listener", "listener", ")", "{", "return", "listener", "!=", "null", "?", "this", ".", "listeners", ".", "addIfAbsent", "(", "listener", ")", ":", "false", ";", "}" ]
Add a listener that will be notified when the NodeTypes changes. Listeners will be called in a single thread, and should do almost no work. @param listener the new listener @return true if the listener was registered, or false if {@code listener} is null or if it is already registered
[ "Add", "a", "listener", "that", "will", "be", "notified", "when", "the", "NodeTypes", "changes", ".", "Listeners", "will", "be", "called", "in", "a", "single", "thread", "and", "should", "do", "almost", "no", "work", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryNodeTypeManager.java#L152-L154
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryNodeTypeManager.java
RepositoryNodeTypeManager.isNodeTypeInUse
boolean isNodeTypeInUse( Name nodeTypeName ) throws InvalidQueryException { String nodeTypeString = nodeTypeName.getString(context.getNamespaceRegistry()); String expression = "SELECT * from [" + nodeTypeString + "] LIMIT 1"; TypeSystem typeSystem = context.getValueFactories().getTypeSystem(); // Parsing must be done now ... QueryCommand command = queryParser.parseQuery(expression, typeSystem); assert command != null : "Could not parse " + expression; Schemata schemata = getRepositorySchemata(); // Now query the entire repository for any nodes that use this node type ... RepositoryCache repoCache = repository.repositoryCache(); RepositoryQueryManager queryManager = repository.queryManager(); Set<String> workspaceNames = repoCache.getWorkspaceNames(); Map<String, NodeCache> overridden = null; NodeTypes nodeTypes = repository.nodeTypeManager().getNodeTypes(); RepositoryIndexes indexDefns = repository.queryManager().getIndexes(); CancellableQuery query = queryManager.query(context, repoCache, workspaceNames, overridden, command, schemata, indexDefns, nodeTypes, null, null); try { QueryResults result = query.execute(); if (result.isEmpty()) return false; if (result.getRowCount() < 0) { // Try to get the first row ... NodeSequence seq = result.getRows(); Batch batch = seq.nextBatch(); while (batch != null) { if (batch.hasNext()) return true; // It's not common for the first batch may be empty, but it's possible. So try the next batch ... batch = seq.nextBatch(); } return false; } return result.getRowCount() > 0; } catch (RepositoryException e) { logger.error(e, JcrI18n.errorCheckingNodeTypeUsage, nodeTypeName, e.getLocalizedMessage()); return true; } }
java
boolean isNodeTypeInUse( Name nodeTypeName ) throws InvalidQueryException { String nodeTypeString = nodeTypeName.getString(context.getNamespaceRegistry()); String expression = "SELECT * from [" + nodeTypeString + "] LIMIT 1"; TypeSystem typeSystem = context.getValueFactories().getTypeSystem(); // Parsing must be done now ... QueryCommand command = queryParser.parseQuery(expression, typeSystem); assert command != null : "Could not parse " + expression; Schemata schemata = getRepositorySchemata(); // Now query the entire repository for any nodes that use this node type ... RepositoryCache repoCache = repository.repositoryCache(); RepositoryQueryManager queryManager = repository.queryManager(); Set<String> workspaceNames = repoCache.getWorkspaceNames(); Map<String, NodeCache> overridden = null; NodeTypes nodeTypes = repository.nodeTypeManager().getNodeTypes(); RepositoryIndexes indexDefns = repository.queryManager().getIndexes(); CancellableQuery query = queryManager.query(context, repoCache, workspaceNames, overridden, command, schemata, indexDefns, nodeTypes, null, null); try { QueryResults result = query.execute(); if (result.isEmpty()) return false; if (result.getRowCount() < 0) { // Try to get the first row ... NodeSequence seq = result.getRows(); Batch batch = seq.nextBatch(); while (batch != null) { if (batch.hasNext()) return true; // It's not common for the first batch may be empty, but it's possible. So try the next batch ... batch = seq.nextBatch(); } return false; } return result.getRowCount() > 0; } catch (RepositoryException e) { logger.error(e, JcrI18n.errorCheckingNodeTypeUsage, nodeTypeName, e.getLocalizedMessage()); return true; } }
[ "boolean", "isNodeTypeInUse", "(", "Name", "nodeTypeName", ")", "throws", "InvalidQueryException", "{", "String", "nodeTypeString", "=", "nodeTypeName", ".", "getString", "(", "context", ".", "getNamespaceRegistry", "(", ")", ")", ";", "String", "expression", "=", ...
Check if the named node type is in use in any workspace in the repository @param nodeTypeName the name of the node type to check @return true if at least one node is using that type; false otherwise @throws InvalidQueryException if there is an error searching for uses of the named node type
[ "Check", "if", "the", "named", "node", "type", "is", "in", "use", "in", "any", "workspace", "in", "the", "repository" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryNodeTypeManager.java#L305-L344
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryIndexManager.java
RepositoryIndexManager.doInitialize
protected void doInitialize( IndexProvider provider ) throws RepositoryException { // Set the execution context instance ... Reflection.setValue(provider, "context", repository.context()); // Set the environment Reflection.setValue(provider, "environment", repository.environment()); provider.initialize(); // If successful, call the 'postInitialize' method reflectively (due to inability to call directly) ... Method postInitialize = Reflection.findMethod(IndexProvider.class, "postInitialize"); Reflection.invokeAccessibly(provider, postInitialize, new Object[] {}); if (logger.isDebugEnabled()) { logger.debug("Successfully initialized index provider '{0}' in repository '{1}'", provider.getName(), repository.name()); } }
java
protected void doInitialize( IndexProvider provider ) throws RepositoryException { // Set the execution context instance ... Reflection.setValue(provider, "context", repository.context()); // Set the environment Reflection.setValue(provider, "environment", repository.environment()); provider.initialize(); // If successful, call the 'postInitialize' method reflectively (due to inability to call directly) ... Method postInitialize = Reflection.findMethod(IndexProvider.class, "postInitialize"); Reflection.invokeAccessibly(provider, postInitialize, new Object[] {}); if (logger.isDebugEnabled()) { logger.debug("Successfully initialized index provider '{0}' in repository '{1}'", provider.getName(), repository.name()); } }
[ "protected", "void", "doInitialize", "(", "IndexProvider", "provider", ")", "throws", "RepositoryException", "{", "// Set the execution context instance ...", "Reflection", ".", "setValue", "(", "provider", ",", "\"context\"", ",", "repository", ".", "context", "(", ")"...
Initialize the supplied provider. @param provider the provider; may not be null @throws RepositoryException if there is a problem initializing the provider
[ "Initialize", "the", "supplied", "provider", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryIndexManager.java#L234-L252
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryIndexManager.java
RepositoryIndexManager.getIndexWriterForProviders
IndexWriter getIndexWriterForProviders( Set<String> providerNames ) { List<IndexProvider> reindexProviders = new LinkedList<>(); for (IndexProvider provider : providers.values()) { if (providerNames.contains(provider.getName())) { reindexProviders.add(provider); } } return CompositeIndexWriter.create(reindexProviders); }
java
IndexWriter getIndexWriterForProviders( Set<String> providerNames ) { List<IndexProvider> reindexProviders = new LinkedList<>(); for (IndexProvider provider : providers.values()) { if (providerNames.contains(provider.getName())) { reindexProviders.add(provider); } } return CompositeIndexWriter.create(reindexProviders); }
[ "IndexWriter", "getIndexWriterForProviders", "(", "Set", "<", "String", ">", "providerNames", ")", "{", "List", "<", "IndexProvider", ">", "reindexProviders", "=", "new", "LinkedList", "<>", "(", ")", ";", "for", "(", "IndexProvider", "provider", ":", "providers...
Get the query index writer that will delegate to only those registered providers with the given names. @param providerNames the names of the providers that require indexing @return a query index writer instance; never null
[ "Get", "the", "query", "index", "writer", "that", "will", "delegate", "to", "only", "those", "registered", "providers", "with", "the", "given", "names", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryIndexManager.java#L280-L288
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jmx/RepositoryStatisticsBean.java
RepositoryStatisticsBean.start
public void start() { ObjectName beanName = null; try { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); beanName = getObjectName(); server.registerMBean(this, beanName); } catch (InstanceAlreadyExistsException e) { LOGGER.warn(JcrI18n.mBeanAlreadyRegistered, beanName); } catch (Exception e) { LOGGER.error(e, JcrI18n.cannotRegisterMBean, beanName); } }
java
public void start() { ObjectName beanName = null; try { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); beanName = getObjectName(); server.registerMBean(this, beanName); } catch (InstanceAlreadyExistsException e) { LOGGER.warn(JcrI18n.mBeanAlreadyRegistered, beanName); } catch (Exception e) { LOGGER.error(e, JcrI18n.cannotRegisterMBean, beanName); } }
[ "public", "void", "start", "(", ")", "{", "ObjectName", "beanName", "=", "null", ";", "try", "{", "MBeanServer", "server", "=", "ManagementFactory", ".", "getPlatformMBeanServer", "(", ")", ";", "beanName", "=", "getObjectName", "(", ")", ";", "server", ".",...
Initializes & registers this MBean with the local MBean server.
[ "Initializes", "&", "registers", "this", "MBean", "with", "the", "local", "MBean", "server", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jmx/RepositoryStatisticsBean.java#L65-L76
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jmx/RepositoryStatisticsBean.java
RepositoryStatisticsBean.stop
public void stop() { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); ObjectName beanName = null; try { beanName = getObjectName(); server.unregisterMBean(beanName); } catch (InstanceNotFoundException e) { LOGGER.debug("JMX bean {0} not found", beanName); } catch (Exception e) { LOGGER.error(e, JcrI18n.cannotUnRegisterMBean, beanName); } }
java
public void stop() { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); ObjectName beanName = null; try { beanName = getObjectName(); server.unregisterMBean(beanName); } catch (InstanceNotFoundException e) { LOGGER.debug("JMX bean {0} not found", beanName); } catch (Exception e) { LOGGER.error(e, JcrI18n.cannotUnRegisterMBean, beanName); } }
[ "public", "void", "stop", "(", ")", "{", "MBeanServer", "server", "=", "ManagementFactory", ".", "getPlatformMBeanServer", "(", ")", ";", "ObjectName", "beanName", "=", "null", ";", "try", "{", "beanName", "=", "getObjectName", "(", ")", ";", "server", ".", ...
Un-registers the bean from the JMX server.
[ "Un", "-", "registers", "the", "bean", "from", "the", "JMX", "server", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jmx/RepositoryStatisticsBean.java#L81-L92
train
ModeShape/modeshape
web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/Contents.java
Contents.show
public void show(String repository, final boolean changeHistory) { this.repository = repository; refreshWorkspacesAndReloadNode(null, ROOT_PATH, changeHistory); }
java
public void show(String repository, final boolean changeHistory) { this.repository = repository; refreshWorkspacesAndReloadNode(null, ROOT_PATH, changeHistory); }
[ "public", "void", "show", "(", "String", "repository", ",", "final", "boolean", "changeHistory", ")", "{", "this", ".", "repository", "=", "repository", ";", "refreshWorkspacesAndReloadNode", "(", "null", ",", "ROOT_PATH", ",", "changeHistory", ")", ";", "}" ]
Shows content of the root node of the first reachable workspace of the given repository. @param repository the name of the given repository. @param changeHistory if true then this action of navigation will be reflected in the browser URL and will don't touch URL in case of false value.
[ "Shows", "content", "of", "the", "root", "node", "of", "the", "first", "reachable", "workspace", "of", "the", "given", "repository", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/Contents.java#L160-L163
train
ModeShape/modeshape
web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/Contents.java
Contents.show
public void show(final String repository, final String workspace, final String path, final boolean changeHistory) { this.repository = repository; this.refreshWorkspacesAndReloadNode(null, path, changeHistory); }
java
public void show(final String repository, final String workspace, final String path, final boolean changeHistory) { this.repository = repository; this.refreshWorkspacesAndReloadNode(null, path, changeHistory); }
[ "public", "void", "show", "(", "final", "String", "repository", ",", "final", "String", "workspace", ",", "final", "String", "path", ",", "final", "boolean", "changeHistory", ")", "{", "this", ".", "repository", "=", "repository", ";", "this", ".", "refreshW...
Shows nodes identified by repository, workspace and path to node. @param repository the name of the repository @param workspace the name of the workspace @param path the path to node @param changeHistory true if this action should be reflected in browser history.
[ "Shows", "nodes", "identified", "by", "repository", "workspace", "and", "path", "to", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/Contents.java#L174-L178
train
ModeShape/modeshape
web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/Contents.java
Contents.refreshWorkspacesAndReloadNode
private void refreshWorkspacesAndReloadNode(final String name, final String path, final boolean changeHistory) { showLoadIcon(); console.jcrService().getWorkspaces(repository, new AsyncCallback<String[]>() { @Override public void onFailure(Throwable caught) { hideLoadIcon(); RemoteException e = (RemoteException) caught; SC.say(caught.getMessage()); if (e.code() == RemoteException.SECURITY_ERROR) { console.loadRepositoriesList(); } } @Override public void onSuccess(String[] workspaces) { wsp.setWorkspaceNames(workspaces); getAndDisplayNode(path, changeHistory); hideLoadIcon(); } }); }
java
private void refreshWorkspacesAndReloadNode(final String name, final String path, final boolean changeHistory) { showLoadIcon(); console.jcrService().getWorkspaces(repository, new AsyncCallback<String[]>() { @Override public void onFailure(Throwable caught) { hideLoadIcon(); RemoteException e = (RemoteException) caught; SC.say(caught.getMessage()); if (e.code() == RemoteException.SECURITY_ERROR) { console.loadRepositoriesList(); } } @Override public void onSuccess(String[] workspaces) { wsp.setWorkspaceNames(workspaces); getAndDisplayNode(path, changeHistory); hideLoadIcon(); } }); }
[ "private", "void", "refreshWorkspacesAndReloadNode", "(", "final", "String", "name", ",", "final", "String", "path", ",", "final", "boolean", "changeHistory", ")", "{", "showLoadIcon", "(", ")", ";", "console", ".", "jcrService", "(", ")", ".", "getWorkspaces", ...
Reloads values of the combo box with workspace names. Gets values from server side, assigns to combo box and select given name. @param name the name to be selected. @param path the path @param changeHistory true if the history is to
[ "Reloads", "values", "of", "the", "combo", "box", "with", "workspace", "names", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/Contents.java#L189-L210
train
ModeShape/modeshape
web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/Contents.java
Contents.getAndDisplayNode
public void getAndDisplayNode(final String path, final boolean changeHistory) { showLoadIcon(); console.jcrService().node(repository(), workspace(), path, new AsyncCallback<JcrNode>() { @Override public void onFailure(Throwable caught) { hideLoadIcon(); SC.say(caught.getMessage()); } @Override public void onSuccess(JcrNode node) { displayNode(node); console.changeWorkspaceInURL(workspace(), changeHistory); console.changePathInURL(path, changeHistory); hideLoadIcon(); } }); }
java
public void getAndDisplayNode(final String path, final boolean changeHistory) { showLoadIcon(); console.jcrService().node(repository(), workspace(), path, new AsyncCallback<JcrNode>() { @Override public void onFailure(Throwable caught) { hideLoadIcon(); SC.say(caught.getMessage()); } @Override public void onSuccess(JcrNode node) { displayNode(node); console.changeWorkspaceInURL(workspace(), changeHistory); console.changePathInURL(path, changeHistory); hideLoadIcon(); } }); }
[ "public", "void", "getAndDisplayNode", "(", "final", "String", "path", ",", "final", "boolean", "changeHistory", ")", "{", "showLoadIcon", "(", ")", ";", "console", ".", "jcrService", "(", ")", ".", "node", "(", "repository", "(", ")", ",", "workspace", "(...
Reads node with given path and selected repository and workspace. @param path the path to the node. @param changeHistory if true then path will be reflected in browser history.
[ "Reads", "node", "with", "given", "path", "and", "selected", "repository", "and", "workspace", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/Contents.java#L219-L236
train
ModeShape/modeshape
web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/Contents.java
Contents.displayNode
private void displayNode(JcrNode node) { this.node = node; this.path = node.getPath(); pathLabel.display(node.getPath()); //display childs, properties and ACLs childrenEditor.show(node); propertiesEditor.show(node); permissionsEditor.show(node); displayBinaryContent(node); //bring this page on top // console.display(Contents.this); }
java
private void displayNode(JcrNode node) { this.node = node; this.path = node.getPath(); pathLabel.display(node.getPath()); //display childs, properties and ACLs childrenEditor.show(node); propertiesEditor.show(node); permissionsEditor.show(node); displayBinaryContent(node); //bring this page on top // console.display(Contents.this); }
[ "private", "void", "displayNode", "(", "JcrNode", "node", ")", "{", "this", ".", "node", "=", "node", ";", "this", ".", "path", "=", "node", ".", "getPath", "(", ")", ";", "pathLabel", ".", "display", "(", "node", ".", "getPath", "(", ")", ")", ";"...
Displays specified node. @param node the node being displayed.
[ "Displays", "specified", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/Contents.java#L243-L258
train
ModeShape/modeshape
web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/Contents.java
Contents.save
public void save() { SC.ask("Do you want to save changes", new BooleanCallback() { @Override public void execute(Boolean yesSelected) { if (yesSelected) { jcrService().save(repository(), workspace(), new BaseCallback<Object>() { @Override public void onSuccess(Object result) { session().setHasChanges(false); updateControls(); } }); } } }); }
java
public void save() { SC.ask("Do you want to save changes", new BooleanCallback() { @Override public void execute(Boolean yesSelected) { if (yesSelected) { jcrService().save(repository(), workspace(), new BaseCallback<Object>() { @Override public void onSuccess(Object result) { session().setHasChanges(false); updateControls(); } }); } } }); }
[ "public", "void", "save", "(", ")", "{", "SC", ".", "ask", "(", "\"Do you want to save changes\"", ",", "new", "BooleanCallback", "(", ")", "{", "@", "Override", "public", "void", "execute", "(", "Boolean", "yesSelected", ")", "{", "if", "(", "yesSelected", ...
Save session's changes.
[ "Save", "session", "s", "changes", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/Contents.java#L274-L289
train
ModeShape/modeshape
web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/Contents.java
Contents.showAddNodeDialog
public void showAddNodeDialog() { jcrService().getPrimaryTypes(node.getRepository(), node.getWorkspace(), null, false, new AsyncCallback<String[]>() { @Override public void onFailure(Throwable caught) { SC.say(caught.getMessage()); } @Override public void onSuccess(String[] result) { addNodeDialog.setPrimaryTypes(result); addNodeDialog.showModal(); } }); }
java
public void showAddNodeDialog() { jcrService().getPrimaryTypes(node.getRepository(), node.getWorkspace(), null, false, new AsyncCallback<String[]>() { @Override public void onFailure(Throwable caught) { SC.say(caught.getMessage()); } @Override public void onSuccess(String[] result) { addNodeDialog.setPrimaryTypes(result); addNodeDialog.showModal(); } }); }
[ "public", "void", "showAddNodeDialog", "(", ")", "{", "jcrService", "(", ")", ".", "getPrimaryTypes", "(", "node", ".", "getRepository", "(", ")", ",", "node", ".", "getWorkspace", "(", ")", ",", "null", ",", "false", ",", "new", "AsyncCallback", "<", "S...
Prepares dialog for creating new node.
[ "Prepares", "dialog", "for", "creating", "new", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/Contents.java#L310-L326
train
ModeShape/modeshape
web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/Contents.java
Contents.exportXML
public void exportXML(String name, boolean skipBinary, boolean noRecurse) { console.jcrService().export(repository, workspace(), path(), name, true, true, new AsyncCallback<Object>() { @Override public void onFailure(Throwable caught) { SC.say(caught.getMessage()); } @Override public void onSuccess(Object result) { SC.say("Complete"); } }); }
java
public void exportXML(String name, boolean skipBinary, boolean noRecurse) { console.jcrService().export(repository, workspace(), path(), name, true, true, new AsyncCallback<Object>() { @Override public void onFailure(Throwable caught) { SC.say(caught.getMessage()); } @Override public void onSuccess(Object result) { SC.say("Complete"); } }); }
[ "public", "void", "exportXML", "(", "String", "name", ",", "boolean", "skipBinary", ",", "boolean", "noRecurse", ")", "{", "console", ".", "jcrService", "(", ")", ".", "export", "(", "repository", ",", "workspace", "(", ")", ",", "path", "(", ")", ",", ...
Exports contents to the given file. @param name the name of the file. @param skipBinary @param noRecurse
[ "Exports", "contents", "to", "the", "given", "file", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/Contents.java#L349-L361
train
ModeShape/modeshape
web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/Contents.java
Contents.importXML
public void importXML(String name, int option) { console.jcrService().importXML(repository, workspace(), path(), name, option, new AsyncCallback<Object>() { @Override public void onFailure(Throwable caught) { SC.say(caught.getMessage()); } @Override public void onSuccess(Object result) { SC.say("Complete"); } }); }
java
public void importXML(String name, int option) { console.jcrService().importXML(repository, workspace(), path(), name, option, new AsyncCallback<Object>() { @Override public void onFailure(Throwable caught) { SC.say(caught.getMessage()); } @Override public void onSuccess(Object result) { SC.say("Complete"); } }); }
[ "public", "void", "importXML", "(", "String", "name", ",", "int", "option", ")", "{", "console", ".", "jcrService", "(", ")", ".", "importXML", "(", "repository", ",", "workspace", "(", ")", ",", "path", "(", ")", ",", "name", ",", "option", ",", "ne...
Imports contents from the given file. @param name @param option
[ "Imports", "contents", "from", "the", "given", "file", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/Contents.java#L369-L382
train
ModeShape/modeshape
connectors/modeshape-connector-git/src/main/java/org/modeshape/connector/git/GitFunction.java
GitFunction.branchRefForName
protected String branchRefForName( String branchName ) { String remoteName = connector.remoteName(); return remoteName != null ? remoteBranchPrefix(remoteName) + branchName : LOCAL_BRANCH_PREFIX + branchName; }
java
protected String branchRefForName( String branchName ) { String remoteName = connector.remoteName(); return remoteName != null ? remoteBranchPrefix(remoteName) + branchName : LOCAL_BRANCH_PREFIX + branchName; }
[ "protected", "String", "branchRefForName", "(", "String", "branchName", ")", "{", "String", "remoteName", "=", "connector", ".", "remoteName", "(", ")", ";", "return", "remoteName", "!=", "null", "?", "remoteBranchPrefix", "(", "remoteName", ")", "+", "branchNam...
Obtain the name of the branch reference @param branchName @return the branch ref name
[ "Obtain", "the", "name", "of", "the", "branch", "reference" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-git/src/main/java/org/modeshape/connector/git/GitFunction.java#L108-L111
train
ModeShape/modeshape
connectors/modeshape-connector-git/src/main/java/org/modeshape/connector/git/GitFunction.java
GitFunction.addBranchesAsChildren
protected void addBranchesAsChildren( Git git, CallSpecification spec, DocumentWriter writer ) throws GitAPIException { Set<String> remoteBranchPrefixes = remoteBranchPrefixes(); if (remoteBranchPrefixes.isEmpty()) { // Generate the child references to the LOCAL branches, which will be sorted by name ... ListBranchCommand command = git.branchList(); List<Ref> branches = command.call(); // Reverse the sort of the branch names, since they might be version numbers ... Collections.sort(branches, REVERSE_REF_COMPARATOR); for (Ref ref : branches) { String name = ref.getName(); name = name.replace(GitFunction.LOCAL_BRANCH_PREFIX, ""); writer.addChild(spec.childId(name), name); } return; } // There is at least one REMOTE branch, so generate the child references to the REMOTE branches, // which will be sorted by name (by the command)... ListBranchCommand command = git.branchList(); command.setListMode(ListMode.REMOTE); List<Ref> branches = command.call(); // Reverse the sort of the branch names, since they might be version numbers ... Collections.sort(branches, REVERSE_REF_COMPARATOR); Set<String> uniqueNames = new HashSet<String>(); for (Ref ref : branches) { String name = ref.getName(); if (uniqueNames.contains(name)) continue; // We only want the branch if it matches one of the listed remotes ... boolean skip = false; for (String remoteBranchPrefix : remoteBranchPrefixes) { if (name.startsWith(remoteBranchPrefix)) { // Remove the prefix ... name = name.replaceFirst(remoteBranchPrefix, ""); break; } // Otherwise, it's a remote branch from a different remote that we don't want ... skip = true; } if (skip) continue; if (uniqueNames.add(name)) writer.addChild(spec.childId(name), name); } }
java
protected void addBranchesAsChildren( Git git, CallSpecification spec, DocumentWriter writer ) throws GitAPIException { Set<String> remoteBranchPrefixes = remoteBranchPrefixes(); if (remoteBranchPrefixes.isEmpty()) { // Generate the child references to the LOCAL branches, which will be sorted by name ... ListBranchCommand command = git.branchList(); List<Ref> branches = command.call(); // Reverse the sort of the branch names, since they might be version numbers ... Collections.sort(branches, REVERSE_REF_COMPARATOR); for (Ref ref : branches) { String name = ref.getName(); name = name.replace(GitFunction.LOCAL_BRANCH_PREFIX, ""); writer.addChild(spec.childId(name), name); } return; } // There is at least one REMOTE branch, so generate the child references to the REMOTE branches, // which will be sorted by name (by the command)... ListBranchCommand command = git.branchList(); command.setListMode(ListMode.REMOTE); List<Ref> branches = command.call(); // Reverse the sort of the branch names, since they might be version numbers ... Collections.sort(branches, REVERSE_REF_COMPARATOR); Set<String> uniqueNames = new HashSet<String>(); for (Ref ref : branches) { String name = ref.getName(); if (uniqueNames.contains(name)) continue; // We only want the branch if it matches one of the listed remotes ... boolean skip = false; for (String remoteBranchPrefix : remoteBranchPrefixes) { if (name.startsWith(remoteBranchPrefix)) { // Remove the prefix ... name = name.replaceFirst(remoteBranchPrefix, ""); break; } // Otherwise, it's a remote branch from a different remote that we don't want ... skip = true; } if (skip) continue; if (uniqueNames.add(name)) writer.addChild(spec.childId(name), name); } }
[ "protected", "void", "addBranchesAsChildren", "(", "Git", "git", ",", "CallSpecification", "spec", ",", "DocumentWriter", "writer", ")", "throws", "GitAPIException", "{", "Set", "<", "String", ">", "remoteBranchPrefixes", "=", "remoteBranchPrefixes", "(", ")", ";", ...
Add the names of the branches as children of the current node. @param git the Git object; may not be null @param spec the call specification; may not be null @param writer the document writer for the current node; may not be null @throws GitAPIException if there is a problem accessing the Git repository
[ "Add", "the", "names", "of", "the", "branches", "as", "children", "of", "the", "current", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-git/src/main/java/org/modeshape/connector/git/GitFunction.java#L155-L197
train
ModeShape/modeshape
connectors/modeshape-connector-git/src/main/java/org/modeshape/connector/git/GitFunction.java
GitFunction.addTagsAsChildren
protected void addTagsAsChildren( Git git, CallSpecification spec, DocumentWriter writer ) throws GitAPIException { // Generate the child references to the branches, which will be sorted by name (by the command). ListTagCommand command = git.tagList(); List<Ref> tags = command.call(); // Reverse the sort of the branch names, since they might be version numbers ... Collections.sort(tags, REVERSE_REF_COMPARATOR); for (Ref ref : tags) { String fullName = ref.getName(); String name = fullName.replaceFirst(TAG_PREFIX, ""); writer.addChild(spec.childId(name), name); } }
java
protected void addTagsAsChildren( Git git, CallSpecification spec, DocumentWriter writer ) throws GitAPIException { // Generate the child references to the branches, which will be sorted by name (by the command). ListTagCommand command = git.tagList(); List<Ref> tags = command.call(); // Reverse the sort of the branch names, since they might be version numbers ... Collections.sort(tags, REVERSE_REF_COMPARATOR); for (Ref ref : tags) { String fullName = ref.getName(); String name = fullName.replaceFirst(TAG_PREFIX, ""); writer.addChild(spec.childId(name), name); } }
[ "protected", "void", "addTagsAsChildren", "(", "Git", "git", ",", "CallSpecification", "spec", ",", "DocumentWriter", "writer", ")", "throws", "GitAPIException", "{", "// Generate the child references to the branches, which will be sorted by name (by the command).", "ListTagCommand...
Add the names of the tags as children of the current node. @param git the Git object; may not be null @param spec the call specification; may not be null @param writer the document writer for the current node; may not be null @throws GitAPIException if there is a problem accessing the Git repository
[ "Add", "the", "names", "of", "the", "tags", "as", "children", "of", "the", "current", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-git/src/main/java/org/modeshape/connector/git/GitFunction.java#L207-L220
train
ModeShape/modeshape
connectors/modeshape-connector-git/src/main/java/org/modeshape/connector/git/GitFunction.java
GitFunction.addCommitsAsChildren
protected void addCommitsAsChildren( Git git, CallSpecification spec, DocumentWriter writer, int pageSize ) throws GitAPIException { // Add commits in the log ... LogCommand command = git.log(); command.setSkip(0); command.setMaxCount(pageSize); // Add the first set of commits ... int actual = 0; String commitId = null; for (RevCommit commit : command.call()) { commitId = commit.getName(); writer.addChild(spec.childId(commitId), commitId); ++actual; } if (actual == pageSize) { // We wrote the maximum number of commits, so there's (probably) another page ... writer.addPage(spec.getId(), commitId, pageSize, PageWriter.UNKNOWN_TOTAL_SIZE); } }
java
protected void addCommitsAsChildren( Git git, CallSpecification spec, DocumentWriter writer, int pageSize ) throws GitAPIException { // Add commits in the log ... LogCommand command = git.log(); command.setSkip(0); command.setMaxCount(pageSize); // Add the first set of commits ... int actual = 0; String commitId = null; for (RevCommit commit : command.call()) { commitId = commit.getName(); writer.addChild(spec.childId(commitId), commitId); ++actual; } if (actual == pageSize) { // We wrote the maximum number of commits, so there's (probably) another page ... writer.addPage(spec.getId(), commitId, pageSize, PageWriter.UNKNOWN_TOTAL_SIZE); } }
[ "protected", "void", "addCommitsAsChildren", "(", "Git", "git", ",", "CallSpecification", "spec", ",", "DocumentWriter", "writer", ",", "int", "pageSize", ")", "throws", "GitAPIException", "{", "// Add commits in the log ...", "LogCommand", "command", "=", "git", ".",...
Add the first page of commits in the history names of the tags as children of the current node. @param git the Git object; may not be null @param spec the call specification; may not be null @param writer the document writer for the current node; may not be null @param pageSize the number of commits to include, and the number of commits that will be in the next page (if there are more commits) @throws GitAPIException if there is a problem accessing the Git repository
[ "Add", "the", "first", "page", "of", "commits", "in", "the", "history", "names", "of", "the", "tags", "as", "children", "of", "the", "current", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-git/src/main/java/org/modeshape/connector/git/GitFunction.java#L232-L253
train
ModeShape/modeshape
connectors/modeshape-connector-git/src/main/java/org/modeshape/connector/git/GitFunction.java
GitFunction.addCommitsAsPageOfChildren
protected void addCommitsAsPageOfChildren( Git git, Repository repository, CallSpecification spec, PageWriter writer, PageKey pageKey ) throws GitAPIException, IOException { RevWalk walker = new RevWalk(repository); try { // The offset is the ID of the last commit we read, so we'll need to skip the first commit String lastCommitIdName = pageKey.getOffsetString(); ObjectId lastCommitId = repository.resolve(lastCommitIdName); int pageSize = (int)pageKey.getBlockSize(); LogCommand command = git.log(); command.add(lastCommitId); command.setMaxCount(pageSize + 1); // Add the first set of commits ... int actual = 0; String commitId = null; for (RevCommit commit : command.call()) { commitId = commit.getName(); if (commitId.equals(lastCommitIdName)) continue; writer.addChild(spec.childId(commitId), commitId); ++actual; } if (actual == pageSize) { assert commitId != null; // We wrote the maximum number of commits, so there's (probably) another page ... writer.addPage(pageKey.getParentId(), commitId, pageSize, PageWriter.UNKNOWN_TOTAL_SIZE); } } finally { walker.dispose(); } }
java
protected void addCommitsAsPageOfChildren( Git git, Repository repository, CallSpecification spec, PageWriter writer, PageKey pageKey ) throws GitAPIException, IOException { RevWalk walker = new RevWalk(repository); try { // The offset is the ID of the last commit we read, so we'll need to skip the first commit String lastCommitIdName = pageKey.getOffsetString(); ObjectId lastCommitId = repository.resolve(lastCommitIdName); int pageSize = (int)pageKey.getBlockSize(); LogCommand command = git.log(); command.add(lastCommitId); command.setMaxCount(pageSize + 1); // Add the first set of commits ... int actual = 0; String commitId = null; for (RevCommit commit : command.call()) { commitId = commit.getName(); if (commitId.equals(lastCommitIdName)) continue; writer.addChild(spec.childId(commitId), commitId); ++actual; } if (actual == pageSize) { assert commitId != null; // We wrote the maximum number of commits, so there's (probably) another page ... writer.addPage(pageKey.getParentId(), commitId, pageSize, PageWriter.UNKNOWN_TOTAL_SIZE); } } finally { walker.dispose(); } }
[ "protected", "void", "addCommitsAsPageOfChildren", "(", "Git", "git", ",", "Repository", "repository", ",", "CallSpecification", "spec", ",", "PageWriter", "writer", ",", "PageKey", "pageKey", ")", "throws", "GitAPIException", ",", "IOException", "{", "RevWalk", "wa...
Add an additional page of commits in the history names of the tags as children of the current node. @param git the Git object; may not be null @param repository the Repository object; may not be null @param spec the call specification; may not be null @param writer the page writer for the current node; may not be null @param pageKey the page key for this page; may not be null @throws GitAPIException if there is a problem accessing the Git repository @throws IOException if there is a problem reading the Git repository
[ "Add", "an", "additional", "page", "of", "commits", "in", "the", "history", "names", "of", "the", "tags", "as", "children", "of", "the", "current", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-git/src/main/java/org/modeshape/connector/git/GitFunction.java#L266-L298
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/JcrPropertyDefinition.java
JcrPropertyDefinition.isAsOrMoreConstrainedThan
boolean isAsOrMoreConstrainedThan( PropertyDefinition other, ExecutionContext context ) { String[] otherConstraints = other.getValueConstraints(); if (otherConstraints == null || otherConstraints.length == 0) { // The ancestor's definition is less constrained, so it's okay even if this definition has no constraints ... return true; } String[] constraints = this.getValueConstraints(); if (constraints == null || constraints.length == 0) { // This definition has no constraints, while the ancestor does have them ... return false; } // There are constraints on both, so make sure they have the same types ... int type = this.getRequiredType(); int otherType = other.getRequiredType(); if (type == otherType && type != PropertyType.UNDEFINED) { ConstraintChecker thisChecker = createChecker(context, type, constraints); ConstraintChecker thatChecker = createChecker(context, otherType, otherConstraints); return thisChecker.isAsOrMoreConstrainedThan(thatChecker); } // We can only compare constraint literals, and we can only expect that every constraint literal in this // definition can be found in the other defintion (which can have more than this one) ... Set<String> thatLiterals = new HashSet<String>(); for (String literal : otherConstraints) { thatLiterals.add(literal); } for (String literal : constraints) { if (!thatLiterals.contains(literal)) return false; } return true; }
java
boolean isAsOrMoreConstrainedThan( PropertyDefinition other, ExecutionContext context ) { String[] otherConstraints = other.getValueConstraints(); if (otherConstraints == null || otherConstraints.length == 0) { // The ancestor's definition is less constrained, so it's okay even if this definition has no constraints ... return true; } String[] constraints = this.getValueConstraints(); if (constraints == null || constraints.length == 0) { // This definition has no constraints, while the ancestor does have them ... return false; } // There are constraints on both, so make sure they have the same types ... int type = this.getRequiredType(); int otherType = other.getRequiredType(); if (type == otherType && type != PropertyType.UNDEFINED) { ConstraintChecker thisChecker = createChecker(context, type, constraints); ConstraintChecker thatChecker = createChecker(context, otherType, otherConstraints); return thisChecker.isAsOrMoreConstrainedThan(thatChecker); } // We can only compare constraint literals, and we can only expect that every constraint literal in this // definition can be found in the other defintion (which can have more than this one) ... Set<String> thatLiterals = new HashSet<String>(); for (String literal : otherConstraints) { thatLiterals.add(literal); } for (String literal : constraints) { if (!thatLiterals.contains(literal)) return false; } return true; }
[ "boolean", "isAsOrMoreConstrainedThan", "(", "PropertyDefinition", "other", ",", "ExecutionContext", "context", ")", "{", "String", "[", "]", "otherConstraints", "=", "other", ".", "getValueConstraints", "(", ")", ";", "if", "(", "otherConstraints", "==", "null", ...
Determine if the constraints on this definition are as-constrained or more-constrained than those on the supplied definition. @param other the property definition to compare; may not be null @param context the execution context used to parse any values within the constraints @return true if this property definition is as-constrained or more-constrained, or false otherwise
[ "Determine", "if", "the", "constraints", "on", "this", "definition", "are", "as", "-", "constrained", "or", "more", "-", "constrained", "than", "those", "on", "the", "supplied", "definition", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/JcrPropertyDefinition.java#L496-L526
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/TransientBinaryStore.java
TransientBinaryStore.initializeStorage
@Override protected void initializeStorage( File directory ) throws BinaryStoreException { // make sure the directory doesn't exist FileUtil.delete(directory); if (!directory.exists()) { logger.debug("Creating temporary directory for transient binary store: {0}", directory.getAbsolutePath()); directory.mkdirs(); } if (!directory.canRead()) { throw new BinaryStoreException(JcrI18n.unableToReadTemporaryDirectory.text(directory.getAbsolutePath(), JAVA_IO_TMPDIR)); } if (!directory.canWrite()) { throw new BinaryStoreException(JcrI18n.unableToWriteTemporaryDirectory.text(directory.getAbsolutePath(), JAVA_IO_TMPDIR)); } }
java
@Override protected void initializeStorage( File directory ) throws BinaryStoreException { // make sure the directory doesn't exist FileUtil.delete(directory); if (!directory.exists()) { logger.debug("Creating temporary directory for transient binary store: {0}", directory.getAbsolutePath()); directory.mkdirs(); } if (!directory.canRead()) { throw new BinaryStoreException(JcrI18n.unableToReadTemporaryDirectory.text(directory.getAbsolutePath(), JAVA_IO_TMPDIR)); } if (!directory.canWrite()) { throw new BinaryStoreException(JcrI18n.unableToWriteTemporaryDirectory.text(directory.getAbsolutePath(), JAVA_IO_TMPDIR)); } }
[ "@", "Override", "protected", "void", "initializeStorage", "(", "File", "directory", ")", "throws", "BinaryStoreException", "{", "// make sure the directory doesn't exist", "FileUtil", ".", "delete", "(", "directory", ")", ";", "if", "(", "!", "directory", ".", "exi...
Ensures that the directory used by this binary store exists and can be both read and written to. @throws BinaryStoreException if the directory cannot be written to, read, or (if needed) created
[ "Ensures", "that", "the", "directory", "used", "by", "this", "binary", "store", "exists", "and", "can", "be", "both", "read", "and", "written", "to", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/TransientBinaryStore.java#L88-L104
train
ModeShape/modeshape
web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/model/RestWorkspaces.java
RestWorkspaces.addWorkspace
public Workspace addWorkspace( String name, String repositoryUrl ) { Workspace workspace = new Workspace(name, repositoryUrl); workspaces.add(workspace); return workspace; }
java
public Workspace addWorkspace( String name, String repositoryUrl ) { Workspace workspace = new Workspace(name, repositoryUrl); workspaces.add(workspace); return workspace; }
[ "public", "Workspace", "addWorkspace", "(", "String", "name", ",", "String", "repositoryUrl", ")", "{", "Workspace", "workspace", "=", "new", "Workspace", "(", "name", ",", "repositoryUrl", ")", ";", "workspaces", ".", "add", "(", "workspace", ")", ";", "ret...
Adds a new workspace to the list of workspaces. @param name a {@code non-null} string, the name of a workspace. @param repositoryUrl a {@code non-null} string, the absolute url to the repository to which the workspace belongs. @return a {@link Workspace} instance
[ "Adds", "a", "new", "workspace", "to", "the", "list", "of", "workspaces", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/model/RestWorkspaces.java#L49-L54
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/cache/change/ChangeSetAdapter.java
ChangeSetAdapter.modifyProperties
protected void modifyProperties( NodeKey key, Name primaryType, Set<Name> mixinTypes, Map<Name, AbstractPropertyChange> propChanges ) { }
java
protected void modifyProperties( NodeKey key, Name primaryType, Set<Name> mixinTypes, Map<Name, AbstractPropertyChange> propChanges ) { }
[ "protected", "void", "modifyProperties", "(", "NodeKey", "key", ",", "Name", "primaryType", ",", "Set", "<", "Name", ">", "mixinTypes", ",", "Map", "<", "Name", ",", "AbstractPropertyChange", ">", "propChanges", ")", "{", "}" ]
Handle the addition, change, and removal of one or more properties of a single node. This method is called once for each existing node whose properties are modified. @param key the unique key for the node; may not be null @param primaryType the primary type of the node for which the modifications occurred; never null @param mixinTypes the mixin types of the node for which the modifications occurred; never null but possibly empty @param propChanges the map of property modification events, keyed by the names of the properties; never null and never
[ "Handle", "the", "addition", "change", "and", "removal", "of", "one", "or", "more", "properties", "of", "a", "single", "node", ".", "This", "method", "is", "called", "once", "for", "each", "existing", "node", "whose", "properties", "are", "modified", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/change/ChangeSetAdapter.java#L248-L252
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/cache/change/ChangeSetAdapter.java
ChangeSetAdapter.addNode
protected void addNode( String workspaceName, NodeKey key, Path path, Name primaryType, Set<Name> mixinTypes, Properties properties ) { }
java
protected void addNode( String workspaceName, NodeKey key, Path path, Name primaryType, Set<Name> mixinTypes, Properties properties ) { }
[ "protected", "void", "addNode", "(", "String", "workspaceName", ",", "NodeKey", "key", ",", "Path", "path", ",", "Name", "primaryType", ",", "Set", "<", "Name", ">", "mixinTypes", ",", "Properties", "properties", ")", "{", "}" ]
Handle the addition of a node. @param workspaceName the workspace in which the node information should be available; may not be null @param key the unique key for the node; may not be null @param path the path of the node; may not be null @param primaryType the primary type of the node; may not be null @param mixinTypes the mixin types for the node; may not be null but may be empty @param properties the properties of the node; may not be null but may be empty
[ "Handle", "the", "addition", "of", "a", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/change/ChangeSetAdapter.java#L289-L295
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/cache/change/ChangeSetAdapter.java
ChangeSetAdapter.removeNode
protected void removeNode( String workspaceName, NodeKey key, NodeKey parentKey, Path path, Name primaryType, Set<Name> mixinTypes ) { }
java
protected void removeNode( String workspaceName, NodeKey key, NodeKey parentKey, Path path, Name primaryType, Set<Name> mixinTypes ) { }
[ "protected", "void", "removeNode", "(", "String", "workspaceName", ",", "NodeKey", "key", ",", "NodeKey", "parentKey", ",", "Path", "path", ",", "Name", "primaryType", ",", "Set", "<", "Name", ">", "mixinTypes", ")", "{", "}" ]
Handle the removal of a node. @param workspaceName the workspace in which the node information should be available; may not be null @param key the unique key for the node; may not be null @param parentKey the unique key for the parent of the node; may not be null @param path the path of the node; may not be null @param primaryType the primary type of the node; may not be null @param mixinTypes the mixin types for the node; may not be null but may be empty
[ "Handle", "the", "removal", "of", "a", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/change/ChangeSetAdapter.java#L327-L334
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/cache/change/ChangeSetAdapter.java
ChangeSetAdapter.changeNode
protected void changeNode( String workspaceName, NodeKey key, Path path, Name primaryType, Set<Name> mixinTypes ) { }
java
protected void changeNode( String workspaceName, NodeKey key, Path path, Name primaryType, Set<Name> mixinTypes ) { }
[ "protected", "void", "changeNode", "(", "String", "workspaceName", ",", "NodeKey", "key", ",", "Path", "path", ",", "Name", "primaryType", ",", "Set", "<", "Name", ">", "mixinTypes", ")", "{", "}" ]
Handle the change of a node. @param workspaceName the workspace in which the node information should be available; may not be null @param key the unique key for the node; may not be null @param path the path of the node; may not be null @param primaryType the primary type of the node; may not be null @param mixinTypes the mixin types for the node; may not be null but may be empty
[ "Handle", "the", "change", "of", "a", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/change/ChangeSetAdapter.java#L345-L350
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/cache/change/ChangeSetAdapter.java
ChangeSetAdapter.moveNode
protected void moveNode( String workspaceName, NodeKey key, Name primaryType, Set<Name> mixinTypes, NodeKey oldParent, NodeKey newParent, Path newPath, Path oldPath ) { }
java
protected void moveNode( String workspaceName, NodeKey key, Name primaryType, Set<Name> mixinTypes, NodeKey oldParent, NodeKey newParent, Path newPath, Path oldPath ) { }
[ "protected", "void", "moveNode", "(", "String", "workspaceName", ",", "NodeKey", "key", ",", "Name", "primaryType", ",", "Set", "<", "Name", ">", "mixinTypes", ",", "NodeKey", "oldParent", ",", "NodeKey", "newParent", ",", "Path", "newPath", ",", "Path", "ol...
Handle the move of a node. @param workspaceName the workspace in which the node information should be available; may not be null @param key the unique key for the node; may not be null @param primaryType the primary type of the node; may not be null @param mixinTypes the mixin types for the node; may not be null but may be empty @param oldParent the key of the node's parent before it was moved; may not be null @param newParent the key of the node's parent after it was moved; may not be null @param newPath the new path of the node after it was moved; may not be null @param oldPath the old path of the node before it was moved; may not be null
[ "Handle", "the", "move", "of", "a", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/change/ChangeSetAdapter.java#L364-L373
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/cache/change/ChangeSetAdapter.java
ChangeSetAdapter.renameNode
protected void renameNode( String workspaceName, NodeKey key, Path newPath, Segment oldSegment, Name primaryType, Set<Name> mixinTypes ) { }
java
protected void renameNode( String workspaceName, NodeKey key, Path newPath, Segment oldSegment, Name primaryType, Set<Name> mixinTypes ) { }
[ "protected", "void", "renameNode", "(", "String", "workspaceName", ",", "NodeKey", "key", ",", "Path", "newPath", ",", "Segment", "oldSegment", ",", "Name", "primaryType", ",", "Set", "<", "Name", ">", "mixinTypes", ")", "{", "}" ]
Handle the renaming of a node. @param workspaceName the workspace in which the node information should be available; may not be null @param key the unique key for the node; may not be null @param newPath the new path of the node after it was moved; may not be null @param oldSegment the old segment of the node before it was moved; may not be null @param primaryType the primary type of the node; may not be null @param mixinTypes the mixin types for the node; may not be null but may be empty
[ "Handle", "the", "renaming", "of", "a", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/change/ChangeSetAdapter.java#L385-L392
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/cache/change/ChangeSetAdapter.java
ChangeSetAdapter.reorderNode
protected void reorderNode( String workspaceName, NodeKey key, Name primaryType, Set<Name> mixinTypes, NodeKey parent, Path newPath, Path oldPath, Path reorderedBeforePath, Map<NodeKey, Map<Path, Path>> snsPathChangesByNodeKey ) { }
java
protected void reorderNode( String workspaceName, NodeKey key, Name primaryType, Set<Name> mixinTypes, NodeKey parent, Path newPath, Path oldPath, Path reorderedBeforePath, Map<NodeKey, Map<Path, Path>> snsPathChangesByNodeKey ) { }
[ "protected", "void", "reorderNode", "(", "String", "workspaceName", ",", "NodeKey", "key", ",", "Name", "primaryType", ",", "Set", "<", "Name", ">", "mixinTypes", ",", "NodeKey", "parent", ",", "Path", "newPath", ",", "Path", "oldPath", ",", "Path", "reorder...
Handle the reordering of a node. @param workspaceName the workspace in which the node information should be available; may not be null @param key the unique key for the node; may not be null @param primaryType the primary type of the node; may not be null @param mixinTypes the mixin types for the node; may not be null but may be empty @param parent the key of the node's parent; may not be null @param newPath the new path of the node after it was moved; may not be null @param oldPath the old path of the node before it was moved; may not be null @param reorderedBeforePath the path of the node before which the node was placed; null if it was moved to the end @param snsPathChangesByNodeKey a map which may contain additional path changes if the reordering was performed on a SNS
[ "Handle", "the", "reordering", "of", "a", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/change/ChangeSetAdapter.java#L407-L417
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/Tuples.java
Tuples.typeFactory
public static <T1, T2> TypeFactory<Tuple2<T1, T2>> typeFactory( TypeFactory<T1> type1, TypeFactory<T2> type2 ) { return new Tuple2TypeFactory<>(type1, type2); }
java
public static <T1, T2> TypeFactory<Tuple2<T1, T2>> typeFactory( TypeFactory<T1> type1, TypeFactory<T2> type2 ) { return new Tuple2TypeFactory<>(type1, type2); }
[ "public", "static", "<", "T1", ",", "T2", ">", "TypeFactory", "<", "Tuple2", "<", "T1", ",", "T2", ">", ">", "typeFactory", "(", "TypeFactory", "<", "T1", ">", "type1", ",", "TypeFactory", "<", "T2", ">", "type2", ")", "{", "return", "new", "Tuple2Ty...
Create a type factory for tuples of size 2. @param type1 the first type; may not be null @param type2 the second type; may not be null @return the type factory; never null
[ "Create", "a", "type", "factory", "for", "tuples", "of", "size", "2", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/Tuples.java#L103-L106
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/Tuples.java
Tuples.typeFactory
public static <T1, T2, T3> TypeFactory<Tuple3<T1, T2, T3>> typeFactory( TypeFactory<T1> type1, TypeFactory<T2> type2, TypeFactory<T3> type3 ) { return new Tuple3TypeFactory<>(type1, type2, type3); }
java
public static <T1, T2, T3> TypeFactory<Tuple3<T1, T2, T3>> typeFactory( TypeFactory<T1> type1, TypeFactory<T2> type2, TypeFactory<T3> type3 ) { return new Tuple3TypeFactory<>(type1, type2, type3); }
[ "public", "static", "<", "T1", ",", "T2", ",", "T3", ">", "TypeFactory", "<", "Tuple3", "<", "T1", ",", "T2", ",", "T3", ">", ">", "typeFactory", "(", "TypeFactory", "<", "T1", ">", "type1", ",", "TypeFactory", "<", "T2", ">", "type2", ",", "TypeFa...
Create a type factory for tuples of size 3. @param type1 the first type; may not be null @param type2 the second type; may not be null @param type3 the third type; may not be null @return the type factory; never null
[ "Create", "a", "type", "factory", "for", "tuples", "of", "size", "3", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/Tuples.java#L116-L120
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/Tuples.java
Tuples.typeFactory
public static <T1, T2, T3, T4> TypeFactory<Tuple4<T1, T2, T3, T4>> typeFactory( TypeFactory<T1> type1, TypeFactory<T2> type2, TypeFactory<T3> type3, TypeFactory<T4> type4 ) { return new Tuple4TypeFactory<>(type1, type2, type3, type4); }
java
public static <T1, T2, T3, T4> TypeFactory<Tuple4<T1, T2, T3, T4>> typeFactory( TypeFactory<T1> type1, TypeFactory<T2> type2, TypeFactory<T3> type3, TypeFactory<T4> type4 ) { return new Tuple4TypeFactory<>(type1, type2, type3, type4); }
[ "public", "static", "<", "T1", ",", "T2", ",", "T3", ",", "T4", ">", "TypeFactory", "<", "Tuple4", "<", "T1", ",", "T2", ",", "T3", ",", "T4", ">", ">", "typeFactory", "(", "TypeFactory", "<", "T1", ">", "type1", ",", "TypeFactory", "<", "T2", ">...
Create a type factory for tuples of size 4. @param type1 the first type; may not be null @param type2 the second type; may not be null @param type3 the third type; may not be null @param type4 the fourth type; may not be null @return the type factory; never null
[ "Create", "a", "type", "factory", "for", "tuples", "of", "size", "4", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/Tuples.java#L131-L136
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/Tuples.java
Tuples.typeFactory
public static TypeFactory<?> typeFactory( TypeFactory<?> type, int tupleSize ) { if (tupleSize <= 1) return type; if (tupleSize == 2) return typeFactory(type, type); if (tupleSize == 3) return typeFactory(type, type, type); if (tupleSize == 4) return typeFactory(type, type, type, type); Collection<TypeFactory<?>> types = new ArrayList<>(tupleSize); for (int i = 0; i != tupleSize; ++i) { types.add(type); } return new TupleNTypeFactory(types); }
java
public static TypeFactory<?> typeFactory( TypeFactory<?> type, int tupleSize ) { if (tupleSize <= 1) return type; if (tupleSize == 2) return typeFactory(type, type); if (tupleSize == 3) return typeFactory(type, type, type); if (tupleSize == 4) return typeFactory(type, type, type, type); Collection<TypeFactory<?>> types = new ArrayList<>(tupleSize); for (int i = 0; i != tupleSize; ++i) { types.add(type); } return new TupleNTypeFactory(types); }
[ "public", "static", "TypeFactory", "<", "?", ">", "typeFactory", "(", "TypeFactory", "<", "?", ">", "type", ",", "int", "tupleSize", ")", "{", "if", "(", "tupleSize", "<=", "1", ")", "return", "type", ";", "if", "(", "tupleSize", "==", "2", ")", "ret...
Create a type factory for uniform tuples. @param type the type of each/every slot in the tuples @param tupleSize the size of the tuples @return the type factory; never null
[ "Create", "a", "type", "factory", "for", "uniform", "tuples", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/Tuples.java#L155-L166
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/AccessControlManagerImpl.java
AccessControlManagerImpl.privileges
private Privilege[] privileges( Set<String> names ) throws ValueFormatException, AccessControlException, RepositoryException { Privilege[] privileges = new Privilege[names.size()]; int i = 0; for (String name : names) { privileges[i++] = privilegeFromName(name); } return privileges; }
java
private Privilege[] privileges( Set<String> names ) throws ValueFormatException, AccessControlException, RepositoryException { Privilege[] privileges = new Privilege[names.size()]; int i = 0; for (String name : names) { privileges[i++] = privilegeFromName(name); } return privileges; }
[ "private", "Privilege", "[", "]", "privileges", "(", "Set", "<", "String", ">", "names", ")", "throws", "ValueFormatException", ",", "AccessControlException", ",", "RepositoryException", "{", "Privilege", "[", "]", "privileges", "=", "new", "Privilege", "[", "na...
Constructs list of Privilege objects using privilege's name. @param names names of privileges @return Privilege objects. @throws ValueFormatException @throws AccessControlException @throws RepositoryException
[ "Constructs", "list", "of", "Privilege", "objects", "using", "privilege", "s", "name", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/AccessControlManagerImpl.java#L303-L310
train
ModeShape/modeshape
web/modeshape-webdav/src/main/java/org/modeshape/webdav/methods/DeterminableMethod.java
DeterminableMethod.determineMethodsAllowed
protected static String determineMethodsAllowed( StoredObject so ) { try { if (so != null) { if (so.isNullResource()) { return NULL_RESOURCE_METHODS_ALLOWED; } else if (so.isFolder()) { return RESOURCE_METHODS_ALLOWED + FOLDER_METHOD_ALLOWED; } // else resource return RESOURCE_METHODS_ALLOWED; } } catch (Exception e) { // we do nothing, just return less allowed methods } return LESS_ALLOWED_METHODS; }
java
protected static String determineMethodsAllowed( StoredObject so ) { try { if (so != null) { if (so.isNullResource()) { return NULL_RESOURCE_METHODS_ALLOWED; } else if (so.isFolder()) { return RESOURCE_METHODS_ALLOWED + FOLDER_METHOD_ALLOWED; } // else resource return RESOURCE_METHODS_ALLOWED; } } catch (Exception e) { // we do nothing, just return less allowed methods } return LESS_ALLOWED_METHODS; }
[ "protected", "static", "String", "determineMethodsAllowed", "(", "StoredObject", "so", ")", "{", "try", "{", "if", "(", "so", "!=", "null", ")", "{", "if", "(", "so", ".", "isNullResource", "(", ")", ")", "{", "return", "NULL_RESOURCE_METHODS_ALLOWED", ";", ...
Determines the methods normally allowed for the resource. @param so StoredObject representing the resource @return all allowed methods, separated by commas
[ "Determines", "the", "methods", "normally", "allowed", "for", "the", "resource", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-webdav/src/main/java/org/modeshape/webdav/methods/DeterminableMethod.java#L37-L56
train
ModeShape/modeshape
sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/dialect/derby/DerbyDdlParser.java
DerbyDdlParser.parseCreateIndex
protected AstNode parseCreateIndex( DdlTokenStream tokens, AstNode parentNode ) throws ParsingException { assert tokens != null; assert parentNode != null; markStartOfStatement(tokens); // CREATE [UNIQUE] INDEX index-Name // ON table-Name ( Simple-column-Name [ ASC | DESC ] [ , Simple-column-Name [ ASC | DESC ]] * ) tokens.consume(CREATE); // CREATE boolean isUnique = tokens.canConsume("UNIQUE"); tokens.consume("INDEX"); String indexName = parseName(tokens); tokens.consume("ON"); String tableName = parseName(tokens); AstNode indexNode = nodeFactory().node(indexName, parentNode, TYPE_CREATE_INDEX_STATEMENT); indexNode.setProperty(UNIQUE_INDEX, isUnique); indexNode.setProperty(TABLE_NAME, tableName); parseIndexTableColumns(tokens, indexNode); parseUntilTerminator(tokens); markEndOfStatement(tokens, indexNode); return indexNode; }
java
protected AstNode parseCreateIndex( DdlTokenStream tokens, AstNode parentNode ) throws ParsingException { assert tokens != null; assert parentNode != null; markStartOfStatement(tokens); // CREATE [UNIQUE] INDEX index-Name // ON table-Name ( Simple-column-Name [ ASC | DESC ] [ , Simple-column-Name [ ASC | DESC ]] * ) tokens.consume(CREATE); // CREATE boolean isUnique = tokens.canConsume("UNIQUE"); tokens.consume("INDEX"); String indexName = parseName(tokens); tokens.consume("ON"); String tableName = parseName(tokens); AstNode indexNode = nodeFactory().node(indexName, parentNode, TYPE_CREATE_INDEX_STATEMENT); indexNode.setProperty(UNIQUE_INDEX, isUnique); indexNode.setProperty(TABLE_NAME, tableName); parseIndexTableColumns(tokens, indexNode); parseUntilTerminator(tokens); markEndOfStatement(tokens, indexNode); return indexNode; }
[ "protected", "AstNode", "parseCreateIndex", "(", "DdlTokenStream", "tokens", ",", "AstNode", "parentNode", ")", "throws", "ParsingException", "{", "assert", "tokens", "!=", "null", ";", "assert", "parentNode", "!=", "null", ";", "markStartOfStatement", "(", "tokens"...
Parses DDL CREATE INDEX @param tokens the tokenized {@link DdlTokenStream} of the DDL input content; may not be null @param parentNode the parent {@link AstNode} node; may not be null @return the parsed CREATE INDEX @throws ParsingException
[ "Parses", "DDL", "CREATE", "INDEX" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/dialect/derby/DerbyDdlParser.java#L205-L234
train
ModeShape/modeshape
sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/dialect/derby/DerbyDdlParser.java
DerbyDdlParser.parseCreateRole
protected AstNode parseCreateRole( DdlTokenStream tokens, AstNode parentNode ) throws ParsingException { assert tokens != null; assert parentNode != null; markStartOfStatement(tokens); tokens.consume(CREATE, "ROLE"); String functionName = parseName(tokens); AstNode functionNode = nodeFactory().node(functionName, parentNode, TYPE_CREATE_ROLE_STATEMENT); markEndOfStatement(tokens, functionNode); return functionNode; }
java
protected AstNode parseCreateRole( DdlTokenStream tokens, AstNode parentNode ) throws ParsingException { assert tokens != null; assert parentNode != null; markStartOfStatement(tokens); tokens.consume(CREATE, "ROLE"); String functionName = parseName(tokens); AstNode functionNode = nodeFactory().node(functionName, parentNode, TYPE_CREATE_ROLE_STATEMENT); markEndOfStatement(tokens, functionNode); return functionNode; }
[ "protected", "AstNode", "parseCreateRole", "(", "DdlTokenStream", "tokens", ",", "AstNode", "parentNode", ")", "throws", "ParsingException", "{", "assert", "tokens", "!=", "null", ";", "assert", "parentNode", "!=", "null", ";", "markStartOfStatement", "(", "tokens",...
Parses DDL CREATE ROLE statement @param tokens the tokenized {@link DdlTokenStream} of the DDL input content; may not be null @param parentNode the parent {@link AstNode} node; may not be null @return the parsed CREATE ROLE statement node @throws ParsingException
[ "Parses", "DDL", "CREATE", "ROLE", "statement" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/dialect/derby/DerbyDdlParser.java#L433-L449
train
ModeShape/modeshape
sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/dialect/derby/DerbyDdlParser.java
DerbyDdlParser.parseColumns
protected void parseColumns( DdlTokenStream tokens, AstNode tableNode, boolean isAlterTable ) throws ParsingException { String tableElementString = getTableElementsString(tokens, false); DdlTokenStream localTokens = new DdlTokenStream(tableElementString, DdlTokenStream.ddlTokenizer(false), false); localTokens.start(); StringBuilder unusedTokensSB = new StringBuilder(); do { if (isColumnDefinitionStart(localTokens)) { parseColumnDefinition(localTokens, tableNode, isAlterTable); } else { // THIS IS AN ERROR. NOTHING FOUND. // NEED TO absorb tokens unusedTokensSB.append(SPACE).append(localTokens.consume()); } } while (localTokens.canConsume(COMMA)); if (unusedTokensSB.length() > 0) { String msg = DdlSequencerI18n.unusedTokensParsingColumnDefinition.text(tableNode.getName()); DdlParserProblem problem = new DdlParserProblem(Problems.WARNING, getCurrentMarkedPosition(), msg); problem.setUnusedSource(unusedTokensSB.toString()); addProblem(problem, tableNode); } }
java
protected void parseColumns( DdlTokenStream tokens, AstNode tableNode, boolean isAlterTable ) throws ParsingException { String tableElementString = getTableElementsString(tokens, false); DdlTokenStream localTokens = new DdlTokenStream(tableElementString, DdlTokenStream.ddlTokenizer(false), false); localTokens.start(); StringBuilder unusedTokensSB = new StringBuilder(); do { if (isColumnDefinitionStart(localTokens)) { parseColumnDefinition(localTokens, tableNode, isAlterTable); } else { // THIS IS AN ERROR. NOTHING FOUND. // NEED TO absorb tokens unusedTokensSB.append(SPACE).append(localTokens.consume()); } } while (localTokens.canConsume(COMMA)); if (unusedTokensSB.length() > 0) { String msg = DdlSequencerI18n.unusedTokensParsingColumnDefinition.text(tableNode.getName()); DdlParserProblem problem = new DdlParserProblem(Problems.WARNING, getCurrentMarkedPosition(), msg); problem.setUnusedSource(unusedTokensSB.toString()); addProblem(problem, tableNode); } }
[ "protected", "void", "parseColumns", "(", "DdlTokenStream", "tokens", ",", "AstNode", "tableNode", ",", "boolean", "isAlterTable", ")", "throws", "ParsingException", "{", "String", "tableElementString", "=", "getTableElementsString", "(", "tokens", ",", "false", ")", ...
Utility method designed to parse columns within an ALTER TABLE ADD statement. @param tokens the tokenized {@link DdlTokenStream} of the DDL input content; may not be null @param tableNode @param isAlterTable @throws ParsingException
[ "Utility", "method", "designed", "to", "parse", "columns", "within", "an", "ALTER", "TABLE", "ADD", "statement", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/dialect/derby/DerbyDdlParser.java#L887-L914
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/optimize/CopyCriteria.java
CopyCriteria.getColumnsReferencedBy
public static Set<Column> getColumnsReferencedBy( Visitable visitable ) { if (visitable == null) return Collections.emptySet(); final Set<Column> symbols = new HashSet<Column>(); // Walk the entire structure, so only supply a StrategyVisitor (that does no navigation) ... Visitors.visitAll(visitable, new AbstractVisitor() { protected void addColumnFor( SelectorName selectorName, String property ) { symbols.add(new Column(selectorName, property, property)); } @Override public void visit( Column column ) { symbols.add(column); } @Override public void visit( EquiJoinCondition joinCondition ) { addColumnFor(joinCondition.selector1Name(), joinCondition.getProperty1Name()); addColumnFor(joinCondition.selector2Name(), joinCondition.getProperty2Name()); } @Override public void visit( PropertyExistence prop ) { addColumnFor(prop.selectorName(), prop.getPropertyName()); } @Override public void visit( PropertyValue prop ) { addColumnFor(prop.selectorName(), prop.getPropertyName()); } @Override public void visit( ReferenceValue ref ) { String propertyName = ref.getPropertyName(); if (propertyName != null) { addColumnFor(ref.selectorName(), propertyName); } } }); return symbols; }
java
public static Set<Column> getColumnsReferencedBy( Visitable visitable ) { if (visitable == null) return Collections.emptySet(); final Set<Column> symbols = new HashSet<Column>(); // Walk the entire structure, so only supply a StrategyVisitor (that does no navigation) ... Visitors.visitAll(visitable, new AbstractVisitor() { protected void addColumnFor( SelectorName selectorName, String property ) { symbols.add(new Column(selectorName, property, property)); } @Override public void visit( Column column ) { symbols.add(column); } @Override public void visit( EquiJoinCondition joinCondition ) { addColumnFor(joinCondition.selector1Name(), joinCondition.getProperty1Name()); addColumnFor(joinCondition.selector2Name(), joinCondition.getProperty2Name()); } @Override public void visit( PropertyExistence prop ) { addColumnFor(prop.selectorName(), prop.getPropertyName()); } @Override public void visit( PropertyValue prop ) { addColumnFor(prop.selectorName(), prop.getPropertyName()); } @Override public void visit( ReferenceValue ref ) { String propertyName = ref.getPropertyName(); if (propertyName != null) { addColumnFor(ref.selectorName(), propertyName); } } }); return symbols; }
[ "public", "static", "Set", "<", "Column", ">", "getColumnsReferencedBy", "(", "Visitable", "visitable", ")", "{", "if", "(", "visitable", "==", "null", ")", "return", "Collections", ".", "emptySet", "(", ")", ";", "final", "Set", "<", "Column", ">", "symbo...
Get the set of Column objects that represent those columns referenced by the visitable object. @param visitable the object to be visited @return the set of Column objects, with column names that always are the string-form of the {@link Column#getPropertyName() property name}; never null
[ "Get", "the", "set", "of", "Column", "objects", "that", "represent", "those", "columns", "referenced", "by", "the", "visitable", "object", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/optimize/CopyCriteria.java#L173-L213
train
ModeShape/modeshape
index-providers/modeshape-lucene-index-provider/src/main/java/org/modeshape/jcr/index/lucene/FieldUtil.java
FieldUtil.removeTralingZeros
protected static void removeTralingZeros( StringBuilder sb ) { int endIndex = sb.length(); if (endIndex > 0) { --endIndex; int index = endIndex; while (sb.charAt(index) == '0') { --index; } if (index < endIndex) sb.delete(index + 1, endIndex + 1); } }
java
protected static void removeTralingZeros( StringBuilder sb ) { int endIndex = sb.length(); if (endIndex > 0) { --endIndex; int index = endIndex; while (sb.charAt(index) == '0') { --index; } if (index < endIndex) sb.delete(index + 1, endIndex + 1); } }
[ "protected", "static", "void", "removeTralingZeros", "(", "StringBuilder", "sb", ")", "{", "int", "endIndex", "=", "sb", ".", "length", "(", ")", ";", "if", "(", "endIndex", ">", "0", ")", "{", "--", "endIndex", ";", "int", "index", "=", "endIndex", ";...
Utility to remove the trailing 0's. @param sb the input string builder; may not be null
[ "Utility", "to", "remove", "the", "trailing", "0", "s", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-lucene-index-provider/src/main/java/org/modeshape/jcr/index/lucene/FieldUtil.java#L310-L320
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/IoUtil.java
IoUtil.write
public static void write( String content, File file ) throws IOException { CheckArg.isNotNull(file, "destination file"); if (content != null) { write(content, new FileOutputStream(file)); } }
java
public static void write( String content, File file ) throws IOException { CheckArg.isNotNull(file, "destination file"); if (content != null) { write(content, new FileOutputStream(file)); } }
[ "public", "static", "void", "write", "(", "String", "content", ",", "File", "file", ")", "throws", "IOException", "{", "CheckArg", ".", "isNotNull", "(", "file", ",", "\"destination file\"", ")", ";", "if", "(", "content", "!=", "null", ")", "{", "write", ...
Write the entire contents of the supplied string to the given file. @param content the content to write to the stream; may be null @param file the file to which the content is to be written @throws IOException @throws IllegalArgumentException if the stream is null
[ "Write", "the", "entire", "contents", "of", "the", "supplied", "string", "to", "the", "given", "file", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/IoUtil.java#L211-L217
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/IoUtil.java
IoUtil.closeQuietly
public static void closeQuietly( Closeable closeable ) { if (closeable == null) { return; } try { closeable.close(); } catch (Throwable t) { LOGGER.debug(t, "Ignored error at closing stream"); } }
java
public static void closeQuietly( Closeable closeable ) { if (closeable == null) { return; } try { closeable.close(); } catch (Throwable t) { LOGGER.debug(t, "Ignored error at closing stream"); } }
[ "public", "static", "void", "closeQuietly", "(", "Closeable", "closeable", ")", "{", "if", "(", "closeable", "==", "null", ")", "{", "return", ";", "}", "try", "{", "closeable", ".", "close", "(", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "...
Closes the closable silently. Any exceptions are ignored. @param closeable the closeable instance; may be null
[ "Closes", "the", "closable", "silently", ".", "Any", "exceptions", "are", "ignored", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/IoUtil.java#L521-L530
train
ModeShape/modeshape
web/modeshape-webdav/src/main/java/org/modeshape/webdav/StoredObject.java
StoredObject.setNullResource
public void setNullResource( boolean f ) { this.isNullRessource = f; this.isFolder = false; this.creationDate = null; this.lastModified = null; // this.content = null; this.contentLength = 0; this.mimeType = null; }
java
public void setNullResource( boolean f ) { this.isNullRessource = f; this.isFolder = false; this.creationDate = null; this.lastModified = null; // this.content = null; this.contentLength = 0; this.mimeType = null; }
[ "public", "void", "setNullResource", "(", "boolean", "f", ")", "{", "this", ".", "isNullRessource", "=", "f", ";", "this", ".", "isFolder", "=", "false", ";", "this", ".", "creationDate", "=", "null", ";", "this", ".", "lastModified", "=", "null", ";", ...
Sets a StoredObject as a lock-null resource @param f true to set the resource as lock-null resource
[ "Sets", "a", "StoredObject", "as", "a", "lock", "-", "null", "resource" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-webdav/src/main/java/org/modeshape/webdav/StoredObject.java#L126-L134
train
ModeShape/modeshape
sequencers/modeshape-sequencer-xml/src/main/java/org/modeshape/sequencer/xml/XmlSequencerHandler.java
XmlSequencerHandler.endContent
protected void endContent() throws RepositoryException { // Process the content of the element ... String content = StringUtil.normalize(contentBuilder.toString()); // Null-out builder to setup for subsequent content. // Must be done before call to startElement below to prevent infinite loop. contentBuilder = null; // Skip if nothing in content but whitespace if (content.length() > 0) { // Create separate node for each content entry since entries can be interspersed amongst child elements startNode(XmlLexicon.ELEMENT_CONTENT, XmlLexicon.ELEMENT_CONTENT); currentNode.setProperty(XmlLexicon.ELEMENT_CONTENT, content); endNode(); } }
java
protected void endContent() throws RepositoryException { // Process the content of the element ... String content = StringUtil.normalize(contentBuilder.toString()); // Null-out builder to setup for subsequent content. // Must be done before call to startElement below to prevent infinite loop. contentBuilder = null; // Skip if nothing in content but whitespace if (content.length() > 0) { // Create separate node for each content entry since entries can be interspersed amongst child elements startNode(XmlLexicon.ELEMENT_CONTENT, XmlLexicon.ELEMENT_CONTENT); currentNode.setProperty(XmlLexicon.ELEMENT_CONTENT, content); endNode(); } }
[ "protected", "void", "endContent", "(", ")", "throws", "RepositoryException", "{", "// Process the content of the element ...", "String", "content", "=", "StringUtil", ".", "normalize", "(", "contentBuilder", ".", "toString", "(", ")", ")", ";", "// Null-out builder to ...
See if there is any element content that needs to be completed. @throws RepositoryException if there is a problem writing the content to the repository session
[ "See", "if", "there", "is", "any", "element", "content", "that", "needs", "to", "be", "completed", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-xml/src/main/java/org/modeshape/sequencer/xml/XmlSequencerHandler.java#L104-L117
train
ModeShape/modeshape
web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/LoadingIcon.java
LoadingIcon.show
public void show(int x, int y) { disabledHLayout.setSize("100%", "100%"); disabledHLayout.setStyleName("disabledBackgroundStyle"); disabledHLayout.show(); loadingImg.setSize("100px", "100px"); loadingImg.setTop(y); //loading image height is 50px loadingImg.setLeft(x); //loading image width is 50px loadingImg.show(); loadingImg.bringToFront(); }
java
public void show(int x, int y) { disabledHLayout.setSize("100%", "100%"); disabledHLayout.setStyleName("disabledBackgroundStyle"); disabledHLayout.show(); loadingImg.setSize("100px", "100px"); loadingImg.setTop(y); //loading image height is 50px loadingImg.setLeft(x); //loading image width is 50px loadingImg.show(); loadingImg.bringToFront(); }
[ "public", "void", "show", "(", "int", "x", ",", "int", "y", ")", "{", "disabledHLayout", ".", "setSize", "(", "\"100%\"", ",", "\"100%\"", ")", ";", "disabledHLayout", ".", "setStyleName", "(", "\"disabledBackgroundStyle\"", ")", ";", "disabledHLayout", ".", ...
Shows loading indicator at the given place of screen. @param x horizontal coordinate (from left corner). @param y vertical coordinate (from right corner).
[ "Shows", "loading", "indicator", "at", "the", "given", "place", "of", "screen", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/LoadingIcon.java#L36-L46
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/JcrVersionManager.java
JcrVersionManager.checkout
void checkout( AbstractJcrNode node ) throws LockException, RepositoryException { checkVersionable(node); // Check this separately since it throws a different type of exception if (node.isLocked() && !node.holdsLock()) { throw new LockException(JcrI18n.lockTokenNotHeld.text(node.getPath())); } if (!node.hasProperty(JcrLexicon.BASE_VERSION)) { // This happens when we've added mix:versionable, but not saved it to create the base // version (and the rest of the version storage graph). See MODE-704. return; } // Checking out an already checked-out node is supposed to return silently if (node.getProperty(JcrLexicon.IS_CHECKED_OUT).getBoolean()) { return; } // Create a session that we'll used to change the node ... SessionCache versionSession = session.spawnSessionCache(false); MutableCachedNode versionable = versionSession.mutable(node.key()); NodeKey baseVersionKey = node.getBaseVersion().key(); PropertyFactory props = propertyFactory(); Reference baseVersionRef = session.referenceFactory().create(baseVersionKey, true); versionable.setProperty(versionSession, props.create(JcrLexicon.PREDECESSORS, new Object[] {baseVersionRef})); versionable.setProperty(versionSession, props.create(JcrLexicon.IS_CHECKED_OUT, Boolean.TRUE)); versionSession.save(); }
java
void checkout( AbstractJcrNode node ) throws LockException, RepositoryException { checkVersionable(node); // Check this separately since it throws a different type of exception if (node.isLocked() && !node.holdsLock()) { throw new LockException(JcrI18n.lockTokenNotHeld.text(node.getPath())); } if (!node.hasProperty(JcrLexicon.BASE_VERSION)) { // This happens when we've added mix:versionable, but not saved it to create the base // version (and the rest of the version storage graph). See MODE-704. return; } // Checking out an already checked-out node is supposed to return silently if (node.getProperty(JcrLexicon.IS_CHECKED_OUT).getBoolean()) { return; } // Create a session that we'll used to change the node ... SessionCache versionSession = session.spawnSessionCache(false); MutableCachedNode versionable = versionSession.mutable(node.key()); NodeKey baseVersionKey = node.getBaseVersion().key(); PropertyFactory props = propertyFactory(); Reference baseVersionRef = session.referenceFactory().create(baseVersionKey, true); versionable.setProperty(versionSession, props.create(JcrLexicon.PREDECESSORS, new Object[] {baseVersionRef})); versionable.setProperty(versionSession, props.create(JcrLexicon.IS_CHECKED_OUT, Boolean.TRUE)); versionSession.save(); }
[ "void", "checkout", "(", "AbstractJcrNode", "node", ")", "throws", "LockException", ",", "RepositoryException", "{", "checkVersionable", "(", "node", ")", ";", "// Check this separately since it throws a different type of exception", "if", "(", "node", ".", "isLocked", "(...
Checks out the given node, updating version-related properties on the node as needed. @param node the node to be checked out @throws LockException if a lock prevents the node from being checked out @throws RepositoryException if an error occurs during the checkout. See {@link javax.jcr.Node#checkout()} for a full description of the possible error conditions.
[ "Checks", "out", "the", "given", "node", "updating", "version", "-", "related", "properties", "on", "the", "node", "as", "needed", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/JcrVersionManager.java#L535-L563
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/ExecutionContext.java
ExecutionContext.with
public ExecutionContext with( Map<String, String> data ) { Map<String, String> newData = data; if (newData == null) { if (this.data.isEmpty()) return this; } else { // Copy the data in the map ... newData = Collections.unmodifiableMap(new HashMap<String, String>(data)); } return new ExecutionContext(securityContext, namespaceRegistry, propertyFactory, threadPools, binaryStore, newData, processId, decoder, encoder, stringFactory, binaryFactory, booleanFactory, dateFactory, decimalFactory, doubleFactory, longFactory, nameFactory, pathFactory, referenceFactory, weakReferenceFactory, simpleReferenceFactory, uriFactory, objectFactory, locale); }
java
public ExecutionContext with( Map<String, String> data ) { Map<String, String> newData = data; if (newData == null) { if (this.data.isEmpty()) return this; } else { // Copy the data in the map ... newData = Collections.unmodifiableMap(new HashMap<String, String>(data)); } return new ExecutionContext(securityContext, namespaceRegistry, propertyFactory, threadPools, binaryStore, newData, processId, decoder, encoder, stringFactory, binaryFactory, booleanFactory, dateFactory, decimalFactory, doubleFactory, longFactory, nameFactory, pathFactory, referenceFactory, weakReferenceFactory, simpleReferenceFactory, uriFactory, objectFactory, locale); }
[ "public", "ExecutionContext", "with", "(", "Map", "<", "String", ",", "String", ">", "data", ")", "{", "Map", "<", "String", ",", "String", ">", "newData", "=", "data", ";", "if", "(", "newData", "==", "null", ")", "{", "if", "(", "this", ".", "dat...
Create a new execution context that mirrors this context but that contains the supplied data. Note that the supplied map is always copied to ensure that it is immutable. @param data the data that is to be affiliated with the resulting context or null if the resulting context should have no data @return the execution context that is identical with this execution context, but which uses the supplied data; never null @since 2.0
[ "Create", "a", "new", "execution", "context", "that", "mirrors", "this", "context", "but", "that", "contains", "the", "supplied", "data", ".", "Note", "that", "the", "supplied", "map", "is", "always", "copied", "to", "ensure", "that", "it", "is", "immutable"...
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/ExecutionContext.java#L537-L549
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/ExecutionContext.java
ExecutionContext.with
public ExecutionContext with( String key, String value ) { Map<String, String> newData = data; if (value == null) { // Remove the value with the key ... if (this.data.isEmpty() || !this.data.containsKey(key)) { // nothing to remove return this; } newData = new HashMap<String, String>(data); newData.remove(key); newData = Collections.unmodifiableMap(newData); } else { // We are to add the value ... newData = new HashMap<String, String>(data); newData.put(key, value); newData = Collections.unmodifiableMap(newData); } return new ExecutionContext(securityContext, namespaceRegistry, propertyFactory, threadPools, binaryStore, newData, processId, decoder, encoder, stringFactory, binaryFactory, booleanFactory, dateFactory, decimalFactory, doubleFactory, longFactory, nameFactory, pathFactory, referenceFactory, weakReferenceFactory, simpleReferenceFactory, uriFactory, objectFactory, locale); }
java
public ExecutionContext with( String key, String value ) { Map<String, String> newData = data; if (value == null) { // Remove the value with the key ... if (this.data.isEmpty() || !this.data.containsKey(key)) { // nothing to remove return this; } newData = new HashMap<String, String>(data); newData.remove(key); newData = Collections.unmodifiableMap(newData); } else { // We are to add the value ... newData = new HashMap<String, String>(data); newData.put(key, value); newData = Collections.unmodifiableMap(newData); } return new ExecutionContext(securityContext, namespaceRegistry, propertyFactory, threadPools, binaryStore, newData, processId, decoder, encoder, stringFactory, binaryFactory, booleanFactory, dateFactory, decimalFactory, doubleFactory, longFactory, nameFactory, pathFactory, referenceFactory, weakReferenceFactory, simpleReferenceFactory, uriFactory, objectFactory, locale); }
[ "public", "ExecutionContext", "with", "(", "String", "key", ",", "String", "value", ")", "{", "Map", "<", "String", ",", "String", ">", "newData", "=", "data", ";", "if", "(", "value", "==", "null", ")", "{", "// Remove the value with the key ...", "if", "...
Create a new execution context that mirrors this context but that contains the supplied key-value pair in the new context's data. @param key the key for the new data that is to be affiliated with the resulting context @param value the data value to be affiliated with the supplied key in the resulting context, or null if an existing data affiliated with the key should be removed in the resulting context @return the execution context that is identical with this execution context, but which uses the supplied data; never null @since 2.0
[ "Create", "a", "new", "execution", "context", "that", "mirrors", "this", "context", "but", "that", "contains", "the", "supplied", "key", "-", "value", "pair", "in", "the", "new", "context", "s", "data", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/ExecutionContext.java#L578-L600
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/ExecutionContext.java
ExecutionContext.with
public ExecutionContext with(Locale locale) { return new ExecutionContext(securityContext, namespaceRegistry, propertyFactory, threadPools, binaryStore, data, processId, decoder, encoder, stringFactory, binaryFactory, booleanFactory, dateFactory, decimalFactory, doubleFactory, longFactory, nameFactory, pathFactory, referenceFactory, weakReferenceFactory, simpleReferenceFactory, uriFactory, objectFactory, locale); }
java
public ExecutionContext with(Locale locale) { return new ExecutionContext(securityContext, namespaceRegistry, propertyFactory, threadPools, binaryStore, data, processId, decoder, encoder, stringFactory, binaryFactory, booleanFactory, dateFactory, decimalFactory, doubleFactory, longFactory, nameFactory, pathFactory, referenceFactory, weakReferenceFactory, simpleReferenceFactory, uriFactory, objectFactory, locale); }
[ "public", "ExecutionContext", "with", "(", "Locale", "locale", ")", "{", "return", "new", "ExecutionContext", "(", "securityContext", ",", "namespaceRegistry", ",", "propertyFactory", ",", "threadPools", ",", "binaryStore", ",", "data", ",", "processId", ",", "dec...
Create a new execution context that mirrors this context but that contains the supplied locale. @param locale a {@code Locale} instance @return the execution context that is identical with this execution context, but which uses the supplied locale; never null @since 4.5
[ "Create", "a", "new", "execution", "context", "that", "mirrors", "this", "context", "but", "that", "contains", "the", "supplied", "locale", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/ExecutionContext.java#L624-L629
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/ExecutionContext.java
ExecutionContext.initializeDefaultNamespaces
protected void initializeDefaultNamespaces( NamespaceRegistry namespaceRegistry ) { if (namespaceRegistry == null) return; namespaceRegistry.register(JcrLexicon.Namespace.PREFIX, JcrLexicon.Namespace.URI); namespaceRegistry.register(JcrMixLexicon.Namespace.PREFIX, JcrMixLexicon.Namespace.URI); namespaceRegistry.register(JcrNtLexicon.Namespace.PREFIX, JcrNtLexicon.Namespace.URI); namespaceRegistry.register(ModeShapeLexicon.Namespace.PREFIX, ModeShapeLexicon.Namespace.URI); }
java
protected void initializeDefaultNamespaces( NamespaceRegistry namespaceRegistry ) { if (namespaceRegistry == null) return; namespaceRegistry.register(JcrLexicon.Namespace.PREFIX, JcrLexicon.Namespace.URI); namespaceRegistry.register(JcrMixLexicon.Namespace.PREFIX, JcrMixLexicon.Namespace.URI); namespaceRegistry.register(JcrNtLexicon.Namespace.PREFIX, JcrNtLexicon.Namespace.URI); namespaceRegistry.register(ModeShapeLexicon.Namespace.PREFIX, ModeShapeLexicon.Namespace.URI); }
[ "protected", "void", "initializeDefaultNamespaces", "(", "NamespaceRegistry", "namespaceRegistry", ")", "{", "if", "(", "namespaceRegistry", "==", "null", ")", "return", ";", "namespaceRegistry", ".", "register", "(", "JcrLexicon", ".", "Namespace", ".", "PREFIX", "...
Method that initializes the default namespaces for namespace registries. @param namespaceRegistry the namespace registry
[ "Method", "that", "initializes", "the", "default", "namespaces", "for", "namespace", "registries", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/ExecutionContext.java#L650-L656
train