code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public static String urlFrom( String baseUrl,
String... pathSegments ) {
StringBuilder urlBuilder = new StringBuilder(baseUrl);
if (urlBuilder.charAt(urlBuilder.length() - 1) == '/') {
urlBuilder.deleteCharAt(urlBuilder.length() - 1);
}
for (... | java |
public static Value jsonValueToJCRValue( Object value,
ValueFactory valueFactory ) {
if (value == null) {
return null;
}
// try the datatypes that can be handled by Jettison
if (value instanceof Integer || value instanceof Long) {... | java |
public static boolean isProperlyFormattedKey( String hexadecimalStr ) {
if (hexadecimalStr == null) return false;
// Length is expected to be the same as the digest ...
final int length = hexadecimalStr.length();
if (length != ALGORITHM.getHexadecimalStringLength()) return false;
... | java |
Future<Boolean> shutdown() {
// Create a simple executor that will do the backgrounding for us ...
final ExecutorService executor = Executors.newSingleThreadExecutor(new NamedThreadFactory("modeshape-repository-stop"));
try {
// Submit a runnable to terminate all sessions ...
... | java |
private String getParameter(List<FileItem> items, String name) {
for (FileItem i : items) {
if (i.isFormField() && i.getFieldName().equals(name)) {
return i.getString();
}
}
return null;
} | java |
private InputStream getStream(List<FileItem> items) throws IOException {
for (FileItem i : items) {
if (!i.isFormField() && i.getFieldName().equals(CONTENT_PARAMETER)) {
return i.getInputStream();
}
}
return null;
} | java |
public static void isNotLessThan( int argument,
int notLessThanValue,
String name ) {
if (argument < notLessThanValue) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBeLessThan.text(name, argument, notLessThan... | java |
public static void isNotGreaterThan( int argument,
int notGreaterThanValue,
String name ) {
if (argument > notGreaterThanValue) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBeGreaterThan.text(name, arg... | java |
public static void isGreaterThan( int argument,
int greaterThanValue,
String name ) {
if (argument <= greaterThanValue) {
throw new IllegalArgumentException(CommonI18n.argumentMustBeGreaterThan.text(name, argument, greaterTh... | java |
public static void isLessThan( int argument,
int lessThanValue,
String name ) {
if (argument >= lessThanValue) {
throw new IllegalArgumentException(CommonI18n.argumentMustBeLessThan.text(name, argument, lessThanValue));
}
... | java |
public static void isGreaterThanOrEqualTo( int argument,
int greaterThanOrEqualToValue,
String name ) {
if (argument < greaterThanOrEqualToValue) {
throw new IllegalArgumentException(CommonI18n.argumentMust... | java |
public static void isLessThanOrEqualTo( int argument,
int lessThanOrEqualToValue,
String name ) {
if (argument > lessThanOrEqualToValue) {
throw new IllegalArgumentException(CommonI18n.argumentMustBeLessThanOrEqu... | java |
public static void isPowerOfTwo( int argument,
String name ) {
if (Integer.bitCount(argument) != 1) {
throw new IllegalArgumentException(CommonI18n.argumentMustBePowerOfTwo.text(name, argument));
}
} | java |
public static void isNotNan( double argument,
String name ) {
if (Double.isNaN(argument)) {
throw new IllegalArgumentException(CommonI18n.argumentMustBeNumber.text(name));
}
} | java |
public static void isNotZeroLength( String argument,
String name ) {
isNotNull(argument, name);
if (argument.length() <= 0) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBeNullOrZeroLength.text(name));
}
} | java |
public static void isNotEmpty( String argument,
String name ) {
isNotZeroLength(argument, name);
if (argument != null && argument.trim().length() == 0) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBeNullOrZeroLengthOrEmpty.text(name));
... | java |
public static void isNotNull( Object argument,
String name ) {
if (argument == null) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBeNull.text(name));
}
} | java |
public static void isNull( Object argument,
String name ) {
if (argument != null) {
throw new IllegalArgumentException(CommonI18n.argumentMustBeNull.text(name));
}
} | java |
public static void isInstanceOf( Object argument,
Class<?> expectedClass,
String name ) {
isNotNull(argument, name);
if (!expectedClass.isInstance(argument)) {
throw new IllegalArgumentException(CommonI18n.argumentMust... | java |
public static <C> C getInstanceOf( Object argument,
Class<C> expectedClass,
String name ) {
isInstanceOf(argument, expectedClass, name);
return expectedClass.cast(argument);
} | java |
public static void isNotEmpty( Iterator<?> argument,
String name ) {
isNotNull(argument, name);
if (!argument.hasNext()) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBeEmpty.text(name));
}
} | java |
public static void isNotEmpty( Collection<?> argument,
String name ) {
isNotNull(argument, name);
if (argument.isEmpty()) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBeEmpty.text(name));
}
} | java |
public static void isEmpty( Object[] argument,
String name ) {
isNotNull(argument, name);
if (argument.length > 0) {
throw new IllegalArgumentException(CommonI18n.argumentMustBeEmpty.text(name));
}
} | java |
public static void isNotEmpty( Object[] argument,
String name ) {
isNotNull(argument, name);
if (argument.length == 0) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBeEmpty.text(name));
}
} | java |
public static void contains( Collection<?> argument,
Object value,
String name ) {
isNotNull(argument, name);
if (!argument.contains(value)) {
throw new IllegalArgumentException(CommonI18n.argumentDidNotContainObject.text(name... | java |
public static void containsKey( Map<?, ?> argument,
Object key,
String name ) {
isNotNull(argument, name);
if (!argument.containsKey(key)) {
throw new IllegalArgumentException(CommonI18n.argumentDidNotContainKey.text(nam... | java |
public static void containsNoNulls( Iterable<?> argument,
String name ) {
isNotNull(argument, name);
int i = 0;
for (Object object : argument) {
if (object == null) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotC... | java |
public static void hasSizeOfAtLeast( Collection<?> argument,
int minimumSize,
String name ) {
isNotNull(argument, name);
if (argument.size() < minimumSize) {
throw new IllegalArgumentException(CommonI18n.argume... | java |
public static void hasSizeOfAtMost( Collection<?> argument,
int maximumSize,
String name ) {
isNotNull(argument, name);
if (argument.size() > maximumSize) {
throw new IllegalArgumentException(CommonI18n.argumentM... | java |
public static void hasSizeOfAtLeast( Object[] argument,
int minimumSize,
String name ) {
isNotNull(argument, name);
if (argument.length < minimumSize) {
throw new IllegalArgumentException(CommonI18n.argumentMus... | java |
public static void hasSizeOfAtMost( Object[] argument,
int maximumSize,
String name ) {
isNotNull(argument, name);
if (argument.length > maximumSize) {
throw new IllegalArgumentException(CommonI18n.argumentMustBe... | java |
public static String jodaFormat( ZonedDateTime dateTime ) {
CheckArg.isNotNull(dateTime, "dateTime");
return dateTime.format(JODA_ISO8601_FORMATTER);
} | java |
protected final <T> T processStream( Binary binary,
BinaryOperation<T> operation ) throws Exception {
InputStream stream = binary.getStream();
if (stream == null) {
throw new IllegalArgumentException("The binary value is empty");
}
tr... | java |
public void addLanguage( QueryParser languageParser ) {
CheckArg.isNotNull(languageParser, "languageParser");
this.parsers.put(languageParser.getLanguage().trim().toLowerCase(), languageParser);
} | java |
public Set<String> getLanguages() {
Set<String> result = new HashSet<String>();
for (QueryParser parser : parsers.values()) {
result.add(parser.getLanguage());
}
return Collections.unmodifiableSet(result);
} | java |
public QueryParser getParserFor( String language ) {
CheckArg.isNotNull(language, "language");
return parsers.get(language.trim().toLowerCase());
} | java |
public static Builder createBuilder( ExecutionContext context,
NodeTypes nodeTypes ) {
CheckArg.isNotNull(context, "context");
CheckArg.isNotNull(nodeTypes, "nodeTypes");
return new Builder(context, nodeTypes);
} | java |
public void show(JcrNode node) {
this.node = node;
if (node.getAcl() == null) {
this.displayDisabledEditor();
} else if (this.isAclDefined(node)) {
this.selectFirstPrincipalAndDisplayPermissions(node);
} else {
this.displayEveryonePermissions();
... | java |
protected AstNode parseMaterializedViewStatement( DdlTokenStream tokens,
AstNode parentNode ) throws ParsingException {
assert tokens != null;
assert parentNode != null;
markStartOfStatement(tokens);
/* -----------------------------... | java |
private String parseContentBetweenParens( final DdlTokenStream tokens ) throws ParsingException {
tokens.consume(L_PAREN); // don't include first paren in expression
int numLeft = 1;
int numRight = 0;
final StringBuilder text = new StringBuilder();
while (tokens.hasNext()) {
... | java |
protected boolean isColumnDefinitionStart( DdlTokenStream tokens,
String columnMixinType ) throws ParsingException {
boolean result = isColumnDefinitionStart(tokens);
if (!result && TYPE_ALTER_COLUMN_DEFINITION.equals(columnMixinType)) {
for (St... | java |
public static ExtractFromRow extractPath( final int indexInRow,
final NodeCache cache,
TypeSystem types ) {
final TypeFactory<Path> type = types.getPathFactory();
final boolean trace = NodeSequence.LOGGER.isTrace... | java |
public static ExtractFromRow extractParentPath( final int indexInRow,
final NodeCache cache,
TypeSystem types ) {
final TypeFactory<Path> type = types.getPathFactory();
final boolean trace = NodeSeque... | java |
public static ExtractFromRow extractRelativePath( final int indexInRow,
final Path relativePath,
final NodeCache cache,
TypeSystem types ) {
CheckArg.... | java |
public static ExtractFromRow extractPropertyValue( final Name propertyName,
final int indexInRow,
final NodeCache cache,
final TypeFactory<?> desiredType )... | java |
protected final boolean reindex( String workspaceName,
NodeKey key,
Path path,
Name primaryType,
Set<Name> mixinTypes,
Properties prope... | java |
protected NodeCacheIterator nodes( String workspaceName,
Path path ) {
// Determine which filter we should use based upon the workspace name. For the system workspace,
// all queryable nodes are included. For all other workspaces, all queryable nodes are included e... | java |
public RestNode addCustomProperty( String name,
String value ) {
customProperties.put(name, value);
return this;
} | java |
protected final void checkForCheckedOut() throws VersionException, RepositoryException {
if (!node.isCheckedOut()) {
// Node is not checked out, so changing property is only allowed if OPV of property is 'ignore' ...
JcrPropertyDefinition defn = getDefinition();
if (defn.getO... | java |
protected final CachedNode node() throws ItemNotFoundException, InvalidItemStateException {
CachedNode node = sessionCache().getNode(key);
if (node == null) {
if (sessionCache().isDestroyed(key)) {
throw new InvalidItemStateException("The node with key " + key + " has been re... | java |
final JcrPropertyDefinition propertyDefinitionFor( org.modeshape.jcr.value.Property property,
Name primaryType,
Set<Name> mixinTypes,
NodeTypes nodeTypes )... | java |
final JcrPropertyDefinition findBestPropertyDefinition( Name primaryTypeNameOfParent,
Collection<Name> mixinTypeNamesOfParent,
org.modeshape.jcr.value.Property property,
... | java |
protected final AbstractJcrNode childNode( Name name,
Type expectedType )
throws PathNotFoundException, ItemNotFoundException, InvalidItemStateException {
ChildReference ref = node().getChildReferences(sessionCache()).getChild(name);
if (ref == null... | java |
protected LinkedList<Property> autoCreatePropertiesFor( Name nodeName,
Name primaryType,
PropertyFactory propertyFactory,
NodeTypes capabili... | java |
protected void autoCreateChildren( Name primaryType,
NodeTypes capabilities )
throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException,
RepositoryException {
Collection<JcrNodeDefinition> autoChildDefn... | java |
final AbstractJcrProperty removeExistingProperty( Name name ) throws VersionException, LockException, RepositoryException {
AbstractJcrProperty existing = getProperty(name);
if (existing != null) {
existing.remove();
return existing;
}
// Return without throwing a... | java |
final AbstractJcrProperty setProperty( Name name,
Value[] values,
int jcrPropertyType,
boolean skipReferenceValidation )
throws VersionException, LockException, ConstraintViolationExc... | java |
protected final NodeIterator referringNodes( ReferenceType referenceType ) throws RepositoryException {
if (!this.isReferenceable()) {
return JcrEmptyNodeIterator.INSTANCE;
}
// Get all of the nodes that are referring to this node ...
Set<NodeKey> keys = node().getReferrers(... | java |
protected boolean containsChangesWithExternalDependencies( AtomicReference<Set<NodeKey>> affectedNodeKeys )
throws RepositoryException {
Set<NodeKey> allChanges = sessionCache().getChangedNodeKeys();
Set<NodeKey> changesAtOrBelowThis = sessionCache().getChangedNodeKeysAtOrBelow(this.node());
... | java |
private void removeReferrerChanges( Set<NodeKey> allChanges,
Set<NodeKey> changesAtOrBelowThis ) throws RepositoryException {
// check if there are any nodes in the overall list of changes (and outside the branch) due to reference changes
for (Iterator<NodeKey> al... | java |
public char[] getPassword() {
String result = properties.getProperty(LocalJcrDriver.PASSWORD_PROPERTY_NAME);
return result != null ? result.toCharArray() : null;
} | java |
public boolean isTeiidSupport() {
String result = properties.getProperty(LocalJcrDriver.TEIID_SUPPORT_PROPERTY_NAME);
if (result == null) {
return false;
}
return result.equalsIgnoreCase(Boolean.TRUE.toString());
} | java |
public Credentials getCredentials() {
String username = getUsername();
char[] password = getPassword();
if (username != null) {
return new SimpleCredentials(username, password);
}
return null;
} | java |
public static byte[] getHash( String digestName,
InputStream stream ) throws NoSuchAlgorithmException, IOException {
CheckArg.isNotNull(stream, "stream");
MessageDigest digest = MessageDigest.getInstance(digestName);
assert digest != null;
int bufSize = ... | java |
public static String sha1( String string ) {
try {
byte[] sha1 = SecureHash.getHash(SecureHash.Algorithm.SHA_1, string.getBytes());
return SecureHash.asHexString(sha1);
} catch (NoSuchAlgorithmException e) {
throw new SystemFailureException(e);
}
} | java |
public RepositoryDelegate createRepositoryDelegate( String url,
Properties info,
JcrContextFactory contextFactory ) throws SQLException {
if (!acceptUrl(url)) {
throw new SQLException(Jdbc... | java |
public static Set<SelectorName> nameSetFrom( Set<SelectorName> firstSet,
Set<SelectorName> secondSet ) {
if ((firstSet == null || firstSet.isEmpty()) && (secondSet == null || secondSet.isEmpty())) {
return Collections.emptySet();
}
Set... | java |
public void setSplitPattern( String regularExpression ) throws PatternSyntaxException {
CheckArg.isNotNull(regularExpression, "regularExpression");
Pattern.compile(splitPattern);
splitPattern = regularExpression;
} | java |
public Document read() {
try {
do {
if (stream == null) {
// Open the stream to the next file ...
stream = openNextFile();
if (stream == null) {
// No more files to read ...
re... | java |
public Duration add( long duration,
TimeUnit unit ) {
long durationInNanos = TimeUnit.NANOSECONDS.convert(duration, unit);
return new Duration(this.durationInNanos + durationInNanos);
} | java |
public Duration subtract( long duration,
TimeUnit unit ) {
long durationInNanos = TimeUnit.NANOSECONDS.convert(duration, unit);
return new Duration(this.durationInNanos - durationInNanos);
} | java |
public Duration add( Duration duration ) {
return new Duration(this.durationInNanos + (duration == null ? 0l : duration.longValue()));
} | java |
public Duration subtract( Duration duration ) {
return new Duration(this.durationInNanos - (duration == null ? 0l : duration.longValue()));
} | java |
public Components getComponents() {
if (this.components == null) {
// This is idempotent, so no need to synchronize ...
// Calculate how many seconds, and don't lose any information ...
BigDecimal bigSeconds = new BigDecimal(this.durationInNanos).divide(new BigDecimal(100000... | java |
public long getDuration( TimeUnit unit ) {
if (unit == null) throw new IllegalArgumentException();
return unit.convert(durationInNanos, TimeUnit.NANOSECONDS);
} | java |
public void changed( ChangeSet changes ) {
checkNotClosed();
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Cache for workspace '{0}' received {1} changes from local sessions: {2}", workspaceName,
changes.size(), changes);
}
// Clear this workspace's ca... | java |
private static synchronized JcrRepository getRepository( String configFileName,
String repositoryName,
final Context nameCtx,
final Name ... | java |
public static TimeBasedKeys create( int bitsUsedInCounter ) {
CheckArg.isPositive(bitsUsedInCounter, "bitsUsedInCounter");
int maxAvailableBitsToShift = Long.numberOfLeadingZeros(System.currentTimeMillis());
CheckArg.isLessThan(bitsUsedInCounter, maxAvailableBitsToShift, "bitsUsedInCounter");
... | java |
public long nextKey() {
// Note that per Oracle the currentTimeMillis is the current number of seconds past the epoch
// in UTC (not in local time). Therefore, processes with exactly synchronized clocks will
// always get the same value regardless of their timezone ...
final long timesta... | java |
protected void nullReference( List<Comparison> comparisons,
Comparison comparisonToNull ) {
if (comparisonToNull != null) {
for (int i = 0; i != comparisons.size(); ++i) {
if (comparisons.get(i) == comparisonToNull) comparisons.set(i, null);
... | java |
protected void nullReference( List<Comparison> comparisons,
Iterable<Comparison> comparisonsToNull ) {
for (Comparison comparisonToNull : comparisonsToNull) {
nullReference(comparisons, comparisonToNull);
}
} | java |
protected int compareStaticOperands( QueryContext context,
Comparison comparison1,
Comparison comparison2 ) {
Object value1 = getValue(context, comparison1.getOperand2());
Object value2 = getValue(context, comparison2.getO... | java |
private String getContentType(List<FileItem> items) {
for (FileItem i : items) {
if (!i.isFormField() && i.getFieldName().equals(CONTENT_PARAMETER)) {
return i.getContentType();
}
}
return null;
} | java |
protected long claimUpTo( int number ) {
assert number > 0;
long nextPosition = this.nextPosition;
long maxPosition = nextPosition + number;
long wrapPoint = maxPosition - bufferSize;
long cachedSlowestConsumerPosition = this.slowestConsumerPosition;
if (wrapPoint > cach... | java |
private List<String> getRootfiles( ZipInputStream zipStream ) throws Exception {
List<String> rootfiles = new ArrayList<>();
ZipEntry entry = null;
while ((entry = zipStream.getNextEntry()) != null) {
String entryName = entry.getName();
if (entryName.endsWith("META-INF/co... | java |
private ByteArrayOutputStream getZipEntryContent(
ZipInputStream zipStream,
ZipEntry entry ) throws IOException {
try (ByteArrayOutputStream content =
new ByteArrayOutputStream()) {
byte[] bytes = new byte[(int) entry.getSize()];
int read;
... | java |
protected void incrementBinaryReferenceCount( BinaryKey binaryKey,
Set<BinaryKey> unusedBinaryKeys,
Set<BinaryKey> usedBinaryKeys ) {
// Find the document metadata and increment the usage count ...
String... | java |
protected void decrementBinaryReferenceCount( Object fieldValue,
Set<BinaryKey> unusedBinaryKeys,
Set<BinaryKey> usedBinaryKeys) {
if (fieldValue instanceof List<?>) {
for (Object value : (List<?>)fie... | java |
protected boolean isLocked( EditableDocument doc ) {
return hasProperty(doc, JcrLexicon.LOCK_OWNER) || hasProperty(doc, JcrLexicon.LOCK_IS_DEEP);
} | java |
public static InputStream read( String path, ClassLoader classLoader, boolean useTLCL ) {
if (useTLCL) {
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(path);
if (stream != null) {
return stream;
}
}
ret... | java |
public static InputStream read( String path, Class<?> clazz, boolean useTLCL ) {
return read(path, clazz.getClassLoader(), useTLCL);
} | java |
private void setS3ObjectTag(String objectKey, String tagKey, String tagValue) throws BinaryStoreException {
try {
GetObjectTaggingRequest getTaggingRequest = new GetObjectTaggingRequest(bucketName, objectKey);
GetObjectTaggingResult getTaggingResult = s3Client.getObjectTagging(getTagging... | java |
private List<Tag> mergeS3TagSet(List<Tag> initialTags, Tag changeTag) {
Map<String, String> mergedTags = initialTags.stream().collect(Collectors.toMap(Tag::getKey, Tag::getValue));
mergedTags.put(changeTag.getKey(), changeTag.getValue());
return mergedTags.entrySet().stream().map(
... | java |
protected long parseLong( DdlTokenStream tokens,
DataType dataType ) {
String value = consume(tokens, dataType, false);
return parseLong(value);
} | java |
protected long parseBracketedLong( DdlTokenStream tokens,
DataType dataType ) {
consume(tokens, dataType, false, L_PAREN);
String value = consume(tokens, dataType, false);
consume(tokens, dataType, false, R_PAREN);
return parseLong(value);
} | java |
public static final SequencerPathExpression compile( String expression ) throws InvalidSequencerPathExpression {
CheckArg.isNotNull(expression, "sequencer path expression");
expression = expression.trim();
if (expression.length() == 0) {
throw new InvalidSequencerPathExpression(Repos... | java |
public Matcher matcher( String absolutePath ) {
PathExpression.Matcher inputMatcher = selectExpression.matcher(absolutePath);
String outputPath = null;
WorkspacePath wsPath = null;
if (inputMatcher.matches()) {
// Grab the named groups ...
Map<Integer, String> rep... | java |
public static EditableDocument newDocument( Document original ) {
BasicDocument newDoc = new BasicDocument();
newDoc.putAll(original);
return new DocumentEditor(newDoc, DEFAULT_FACTORY);
} | java |
public static EditableDocument newDocument( String name,
Object value ) {
return new DocumentEditor(new BasicDocument(name, value), DEFAULT_FACTORY);
} | java |
public static EditableDocument newDocument( String name1,
Object value1,
String name2,
Object value2 ) {
return new DocumentEditor(new BasicDocument(name1, value1, name... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.