code
stringlengths
73
34.1k
label
stringclasses
1 value
public Term parse( String fullTextSearchExpression ) { CheckArg.isNotNull(fullTextSearchExpression, "fullTextSearchExpression"); Tokenizer tokenizer = new TermTokenizer(); TokenStream stream = new TokenStream(fullTextSearchExpression, tokenizer, false); return parse(stream.start()); ...
java
public Term parse( TokenStream tokens ) { CheckArg.isNotNull(tokens, "tokens"); List<Term> terms = new ArrayList<Term>(); do { Term term = parseDisjunctedTerms(tokens); if (term == null) break; terms.add(term); } while (tokens.canConsume("OR")); ...
java
protected static String requireActiveTransaction() { return Optional.ofNullable(ACTIVE_TX_ID.get()).orElseThrow(() -> new RelationalProviderException( RelationalProviderI18n.threadNotAssociatedWithTransaction, Thread.currentThread().getName())); }
java
public static NodeSequence emptySequence( final int width ) { assert width >= 0; return new NodeSequence() { @Override public int width() { return width; } @Override public Batch nextBatch() { return null; ...
java
public static Batch emptyBatch( final String workspaceName, final int width ) { assert width > 0; return new Batch() { @Override public boolean hasNext() { return false; } @Override public St...
java
public static NodeSequence withBatch( final Batch sequence ) { if (sequence == null) return emptySequence(1); return new NodeSequence() { private boolean done = false; @Override public int width() { return sequence.width(); } ...
java
public static NodeSequence limit( NodeSequence sequence, Limit limitAndOffset ) { if (sequence == null) return emptySequence(0); if (limitAndOffset != null && !limitAndOffset.isUnlimited()) { final int limit = limitAndOffset.getRowLimit(); //...
java
public static NodeSequence limit( final NodeSequence sequence, final long maxRows ) { if (sequence == null) return emptySequence(0); if (maxRows <= 0) return emptySequence(sequence.width()); if (sequence.isEmpty()) return sequence; return new NodeSeq...
java
public static NodeSequence skip( final NodeSequence sequence, final int skip ) { if (sequence == null) return emptySequence(0); if (skip <= 0 || sequence.isEmpty()) return sequence; return new NodeSequence() { private int rowsToSkip = skip; ...
java
public static NodeSequence filter( final NodeSequence sequence, final RowFilter filter ) { if (sequence == null) return emptySequence(0); if (filter == null || sequence.isEmpty()) return sequence; return new NodeSequence() { @Override ...
java
public static NodeSequence append( final NodeSequence first, final NodeSequence second ) { if (first == null) { return second != null ? second : emptySequence(0); } if (second == null) return first; int firstWidth = first.width(); ...
java
public static NodeSequence slice( final NodeSequence original, Columns columns ) { final int newWidth = columns.getSelectorNames().size(); if (original.width() == newWidth) { return original; } // We need to return a NodeSequence that inc...
java
public static NodeSequence merging( final NodeSequence first, final NodeSequence second, final int totalWidth ) { if (first == null) { if (second == null) return emptySequence(totalWidth); final int firstWidt...
java
public synchronized final void initialize() throws RepositoryException { if (!initialized) { try { doInitialize(); initialized = true; } catch (RuntimeException e) { throw new RepositoryException(e); } } }
java
public synchronized final void shutdown() throws RepositoryException { preShutdown(); delegateWriter = NoOpQueryIndexWriter.INSTANCE; try { // Shutdown each of the provided indexes ... for (Map<String, AtomicIndex> byWorkspaceName : providedIndexesByWorkspaceNameByIndexN...
java
public void validateDefaultColumnTypes( ExecutionContext context, IndexDefinition defn, Problems problems ) { assert defn != null; for (int i = 0; i < defn.size(); i++) { validateDefaultColumnDefinitionTy...
java
public final Index getIndex( String indexName, String workspaceName ) { logger().trace("Looking for index '{0}' in '{1}' provider for query in workspace '{2}'", indexName, getName(), workspaceName); Map<String, AtomicIndex> byWorkspaceNames = provi...
java
public final ManagedIndex getManagedIndex( String indexName, String workspaceName ) { logger().trace("Looking for managed index '{0}' in '{1}' provider in workspace '{2}'", indexName, getName(), workspaceName); Map<String, AtomicIndex...
java
private final void onEachIndex( ProvidedIndexOperation op ) { for (String workspaceName : workspaceNames()) { Collection<AtomicIndex> indexes = providedIndexesFor(workspaceName); if (indexes != null) { for (AtomicIndex atomicIndex : indexes) { assert a...
java
public final void onEachIndexInWorkspace( String workspaceName, ManagedIndexOperation op ) { assert workspaceName != null; Collection<AtomicIndex> indexes = providedIndexesFor(workspaceName); if (indexes != null) { for (AtomicIndex atomic...
java
protected ManagedIndex updateIndex( IndexDefinition oldDefn, IndexDefinition updatedDefn, ManagedIndex existingIndex, String workspaceName, NodeTypes.Supplier n...
java
public List<NodeTypeDefinition> readAllNodeTypes() { CachedNode nodeTypes = nodeTypesNode(); List<NodeTypeDefinition> defns = new ArrayList<NodeTypeDefinition>(); for (ChildReference ref : nodeTypes.getChildReferences(system)) { CachedNode nodeType = system.getNode(ref); ...
java
public Position add( Position position ) { if (this.getIndexInContent() < 0) { return position.getIndexInContent() < 0 ? EMPTY_CONTENT_POSITION : position; } if (position.getIndexInContent() < 0) { return this; } int index = this.getIndexInContent() + po...
java
public static ObjectId valueOf( String uuid ) { int p = uuid.indexOf("/"); if (p < 0) { return new ObjectId(Type.OBJECT, uuid); } int p1 = p; while (p > 0) { p1 = p; p = uuid.indexOf("/", p + 1); } p = p1; ...
java
protected static Document replaceSystemPropertyVariables( Document doc ) { if (doc.isEmpty()) return doc; Document modified = doc.withVariablesReplacedWithSystemProperties(); if (modified == doc) return doc; // Otherwise, we changed some values. Note that the system properties can only ...
java
public static RepositoryConfiguration read( String resourcePathOrJsonContentString ) throws ParsingException, FileNotFoundException { CheckArg.isNotNull(resourcePathOrJsonContentString, "resourcePathOrJsonContentString"); InputStream stream = ResourceLookup.read(resourcePathOrJsonContentString, ...
java
public List<String> getNodeTypes() { List<String> result = new ArrayList<String>(); List<?> configuredNodeTypes = doc.getArray(FieldName.NODE_TYPES); if (configuredNodeTypes != null) { for (Object configuredNodeType : configuredNodeTypes) { result.add(configuredNodeT...
java
public String getDefaultWorkspaceName() { Document workspaces = doc.getDocument(FieldName.WORKSPACES); if (workspaces != null) { return workspaces.getString(FieldName.DEFAULT, Default.DEFAULT); } return Default.DEFAULT; }
java
public List<Component> getIndexProviders() { Problems problems = new SimpleProblems(); List<Component> components = readComponents(doc, FieldName.INDEX_PROVIDERS, FieldName.CLASSNAME, INDEX_PROVIDER_ALIASES, problems); assert !problems.hasError...
java
public DocumentOptimization getDocumentOptimization() { Document storage = doc.getDocument(FieldName.STORAGE); if (storage == null) { storage = Schematic.newDocument(); } return new DocumentOptimization(storage.getDocument(FieldName.DOCUMENT_OPTIMIZATION)); }
java
public void writeTo( WritableByteChannel channel ) throws IOException { int numberOfBytesToWrite = size; for (ByteBuffer buffer : buffers) { if (buffer == null) { // already flushed continue; } int numBytesInBuffer = Math.min(numberOfBy...
java
public final int applyUpgradesSince( int lastId, Context resources ) { int lastUpgradeId = lastId; for (UpgradeOperation op : operations) { if (op.getId() <= lastId) continue; LOGGER.debug("Upgrade {0}: starting", op); op.apply...
java
public static org.modeshape.jcr.api.Logger getLogger(Class<?> clazz) { return new ExtensionLogger(Logger.getLogger(clazz)); }
java
private void createIndex() { try { client.createIndex(name(), workspace, columns.mappings(workspace)); client.flush(name()); } catch (IOException e) { throw new EsIndexException(e); } }
java
private EsRequest find(String nodeKey) throws IOException { return client.getDocument(name(), workspace, nodeKey); }
java
private EsRequest findOrCreateDoc(String nodeKey) throws IOException { EsRequest doc = client.getDocument(name(), workspace, nodeKey); return doc != null ? doc : new EsRequest(); }
java
private void putValue(EsRequest doc, EsIndexColumn column, Object value) { Object columnValue = column.columnValue(value); String stringValue = column.stringValue(value); doc.put(column.getName(), columnValue); if (!(value instanceof ModeShapeDateTime || value instanceof Long || value in...
java
private void putValues(EsRequest doc, EsIndexColumn column, Object[] value) { Object[] columnValue = column.columnValues(value); int[] ln = new int[columnValue.length]; String[] lc = new String[columnValue.length]; String[] uc = new String[columnValue.length]; for (int i = 0; i ...
java
protected void processIdent( DetailAST aAST ) { final int parentType = aAST.getParent().getType(); if (((parentType != TokenTypes.DOT) && (parentType != TokenTypes.METHOD_DEF)) || ((parentType == TokenTypes.DOT) && (aAST.getNextSibling() != null))) { referenced.add(aAST.getText()...
java
private void processImport( DetailAST aAST ) { final FullIdent name = FullIdent.createFullIdentBelow(aAST); if ((name != null) && !name.getText().endsWith(".*")) { imports.add(name); } }
java
private void processStaticImport( DetailAST aAST ) { final FullIdent name = FullIdent.createFullIdent(aAST.getFirstChild().getNextSibling()); if ((name != null) && !name.getText().endsWith(".*")) { imports.add(name); } }
java
public PrivilegeImpl forName(String name) { if (name.contains("}")) { String localName = name.substring(name.indexOf('}') + 1); return privileges.get(localName); } if (name.contains(":")) { String localName = name.substring(name.indexOf(':') + 1); ...
java
public void setChangedNodes( Set<NodeKey> keys ) { if (keys != null) { this.nodeKeys = Collections.unmodifiableSet(new HashSet<NodeKey>(keys)); } }
java
public static boolean hasWildcardCharacters( String expression ) { Objects.requireNonNull(expression); CharacterIterator iter = new StringCharacterIterator(expression); boolean skipNext = false; for (char c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) { if (s...
java
public static String toRegularExpression( String likeExpression ) { // Replace all '\x' with 'x' ... String result = likeExpression.replaceAll("\\\\(.)", "$1"); // Escape characters used as metacharacters in regular expressions, including // '[', '^', '\', '$', '.', '|', '+', '(', and ')...
java
public String[] getAttributeNames() { synchronized (attributes) { return attributes.keySet().toArray(new String[attributes.keySet().size()]); } }
java
protected boolean appliesToPathConstraint( List<Component> predicates ) { if (predicates.isEmpty()) return true; if (predicates.size() > 1) return false; assert predicates.size() == 1; Component predicate = predicates.get(0); if (predicate instanceof Literal && ((Literal)predicat...
java
static BinaryStorage defaultConfig() { // By default binaries are not stored on disk EditableDocument binaries = Schematic.newDocument(); binaries.set(RepositoryConfiguration.FieldName.TYPE, RepositoryConfiguration.FieldValue.BINARY_STORAGE_TYPE_TRANSIENT); return new BinaryStorage(binar...
java
private static void localize( final Class<?> i18nClass, final Locale locale ) { assert i18nClass != null; assert locale != null; // Create a class-to-problem map for this locale if one doesn't exist, else get the existing one. Map<Class<?>, Set<String>> ...
java
@Override public String text( Locale locale, Object... arguments ) { try { String rawText = rawText(locale == null ? Locale.getDefault() : locale); return StringUtil.createString(rawText, arguments); } catch (IllegalArgumentException err) { ...
java
protected DocumentBuilder getDocumentBuilder() throws ServletException { DocumentBuilder documentBuilder = null; DocumentBuilderFactory documentBuilderFactory = null; try { documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceA...
java
public boolean indexAppliesTo( JoinCondition condition ) { if (condition instanceof ChildNodeJoinCondition) { return indexAppliesTo((ChildNodeJoinCondition)condition); } if (condition instanceof DescendantNodeJoinCondition) { return indexAppliesTo((DescendantNodeJoinCondi...
java
public boolean indexAppliesTo( Constraint constraint ) { if (constraint instanceof Comparison) { return indexAppliesTo((Comparison)constraint); } if (constraint instanceof And) { return indexAppliesTo((And)constraint); } if (constraint instanceof Or) { ...
java
private void aggregate(ArrayList<Privilege> list, Privilege p) { list.add(p); if (p.isAggregate()) { for (Privilege ap : p.getDeclaredAggregatePrivileges()) { aggregate(list, ap); } } }
java
public boolean contains(Privilege p) { if (p.getName().equalsIgnoreCase(this.getName())) { return true; } Privilege[] list = getAggregatePrivileges(); for (Privilege privilege : list) { if (privilege.getName().equalsIgnoreCase(p.getName())) { ...
java
void save( AbstractJcrNode node ) throws RepositoryException { // first check the node is valid from a cache perspective Set<NodeKey> keysToBeSaved = null; try { if (node.isNew()) { // expected by TCK throw new RepositoryException(JcrI18n.unableToSaveN...
java
static boolean hasRole( SecurityContext context, String roleName, String repositoryName, String workspaceName ) { if (context.hasRole(roleName)) return true; roleName = roleName + "." + repositoryName; if (contex...
java
public static boolean isForeignKey( NodeKey key, NodeKey rootKey ) { if (key == null) { return false; } String nodeWorkspaceKey = key.getWorkspaceKey(); boolean sameWorkspace = rootKey.getWorkspaceKey().equals(nodeWorkspaceKey); ...
java
public static String nodeIdentifier( NodeKey key, NodeKey rootKey ) { return isForeignKey(key, rootKey) ? key.toString() : key.getIdentifier(); }
java
public int computeNextStatementStartKeywordCount() { int result = 0; if (isNextKeyWord()) { for (String[] nextStmtStart : registeredStatementStartPhrases) { if (this.matches(nextStmtStart)) { return nextStmtStart.length; } } ...
java
protected void parse( String content ) { Tokenizer tokenizer = new CndTokenizer(false, true); TokenStream tokens = new TokenStream(content, tokenizer, false); tokens.start(); while (tokens.hasNext()) { // Keep reading while we can recognize one of the two types of statements ...
java
protected void parseNamespaceMapping( TokenStream tokens ) { tokens.consume('<'); String prefix = removeQuotes(tokens.consume()); tokens.consume('='); String uri = removeQuotes(tokens.consume()); tokens.consume('>'); // Register the namespace ... context.getNamesp...
java
protected void parseNodeTypeDefinition( TokenStream tokens ) { // Parse the name, and create the path and a property for the name ... Name name = parseNodeTypeName(tokens); JcrNodeTypeTemplate nodeType = new JcrNodeTypeTemplate(context); try { nodeType.setName(string(name)); ...
java
protected Name parseNodeTypeName( TokenStream tokens ) { tokens.consume('['); Name name = parseName(tokens); tokens.consume(']'); return name; }
java
protected List<Name> parseSupertypes( TokenStream tokens ) { if (tokens.canConsume('>')) { // There is at least one supertype ... return parseNameList(tokens); } return Collections.emptyList(); }
java
protected List<String> parseStringList( TokenStream tokens ) { List<String> strings = new ArrayList<String>(); if (tokens.canConsume('?')) { // This list is variant ... strings.add("?"); } else { // Read names until we see a ',' do { ...
java
protected List<Name> parseNameList( TokenStream tokens ) { List<Name> names = new ArrayList<Name>(); if (!tokens.canConsume('?')) { // Read names until we see a ',' do { names.add(parseName(tokens)); } while (tokens.canConsume(',')); } ...
java
protected void parsePropertyOrChildNodeDefinitions( TokenStream tokens, JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException { while (true) { // Keep reading while we see a property definition or child node definition ... ...
java
protected void parsePropertyDefinition( TokenStream tokens, JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException { tokens.consume('-'); Name name = parseName(tokens); JcrPropertyDefinitionTemplate propDefn = new JcrPropertyDefinitionTempl...
java
protected void parsePropertyType( TokenStream tokens, JcrPropertyDefinitionTemplate propDefn, String defaultPropertyType ) { if (tokens.canConsume('(')) { // Parse the (optional) property type ... String property...
java
protected void parseDefaultValues( TokenStream tokens, JcrPropertyDefinitionTemplate propDefn ) { if (tokens.canConsume('=')) { List<String> defaultValues = parseStringList(tokens); if (!defaultValues.isEmpty()) { propDefn.setDefault...
java
protected void parseValueConstraints( TokenStream tokens, JcrPropertyDefinitionTemplate propDefn ) { if (tokens.canConsume('<')) { List<String> defaultValues = parseStringList(tokens); if (!defaultValues.isEmpty()) { propDefn.setV...
java
protected void parsePropertyAttributes( TokenStream tokens, JcrPropertyDefinitionTemplate propDefn, JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException { boolean autoCreated = false; boolean mandatory ...
java
protected void parseQueryOperators( TokenStream tokens, JcrPropertyDefinitionTemplate propDefn ) { if (tokens.canConsume('?')) { return; } // The query operators are expected to be enclosed in a single quote, so therefore will be a single token...
java
protected void parseChildNodeDefinition( TokenStream tokens, JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException { tokens.consume('+'); Name name = parseName(tokens); JcrNodeDefinitionTemplate childDefn = new JcrNodeDefinitionTemplate(...
java
protected void parseRequiredPrimaryTypes( TokenStream tokens, JcrNodeDefinitionTemplate childDefn ) throws ConstraintViolationException { if (tokens.canConsume('(')) { List<Name> requiredTypes = parseNameList(tokens); if (requiredTypes.isEmpt...
java
protected void parseDefaultType( TokenStream tokens, JcrNodeDefinitionTemplate childDefn ) throws ConstraintViolationException { if (tokens.canConsume('=')) { if (!tokens.canConsume('?')) { Name defaultType = parseName(tokens); chi...
java
protected void parseNodeAttributes( TokenStream tokens, JcrNodeDefinitionTemplate childDefn, JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException { boolean autoCreated = false; boolean mandatory = false; ...
java
protected Name parseName( TokenStream tokens ) { String value = tokens.consume(); try { return nameFactory.create(removeQuotes(value)); } catch (ValueFormatException e) { if (e.getCause() instanceof NamespaceException) { throw (NamespaceException)e.getCaus...
java
protected final void parseVendorExtensions( TokenStream tokens, List<Property> properties ) { while (tokens.matches(CndTokenizer.VENDOR_EXTENSION)) { Property extension = parseVendorExtension(tokens.consume()); if (extension != null) proper...
java
protected final Property parseVendorExtension( String vendorExtension ) { if (vendorExtension == null) return null; // Remove the curly braces ... String extension = vendorExtension.replaceFirst("^[{]", "").replaceAll("[}]$", ""); if (extension.trim().length() == 0) return null; ...
java
protected final Property parseVendorExtensionContent( String vendorExtension ) { Matcher matcher = VENDOR_PATTERN.matcher(vendorExtension); if (!matcher.find()) return null; String vendorName = removeQuotes(matcher.group(1)); String vendorValue = removeQuotes(matcher.group(3)); a...
java
public WorkspaceCache createWorkspace( String name ) { if (!workspaceNames.contains(name)) { if (!configuration.isCreatingWorkspacesAllowed()) { throw new UnsupportedOperationException(JcrI18n.creatingWorkspacesIsNotAllowedInRepository.text(getName())); } // O...
java
public WorkspaceCache createExternalWorkspace(String name, Connectors connectors) { String[] tokens = name.split(":"); String sourceName = tokens[0]; String workspaceName = tokens[1]; this.workspaceNames.add(workspaceName); refreshRepositoryMetadata(true); ...
java
public SessionCache createSession(ExecutionContext context, String workspaceName, boolean readOnly) { WorkspaceCache workspaceCache = workspace(workspaceName); if (readOnly) { return new ReadOnlySessionCache(context, workspaceCache); } return new Writa...
java
public void setColumnStartPositions( String commaDelimitedColumnStartPositions ) { CheckArg.isNotNull(commaDelimitedColumnStartPositions, "commaDelimitedColumnStartPositions"); String[] stringStartPositions = commaDelimitedColumnStartPositions.split(","); int[] columnStartPositions = new int[st...
java
private static Set<String> setFor( String... elements ) { Set<String> set = new HashSet<String>(elements.length); set.addAll(Arrays.asList(elements)); return set; }
java
public void changeField( MappedAttributeDefinition defn, ModelNode newValue ) throws RepositoryException, OperationFailedException { ModeShapeEngine engine = getEngine(); String repositoryName = repositoryName(); // Get a snapshot of the current configuration ... ...
java
public void changeIndexProviderField( MappedAttributeDefinition defn, ModelNode newValue, String indexProviderName ) throws RepositoryException, OperationFailedException { ModeShapeEngine engine = getEngine(); String rep...
java
public void changeSequencerField( MappedAttributeDefinition defn, ModelNode newValue, String sequencerName ) throws RepositoryException, OperationFailedException { ModeShapeEngine engine = getEngine(); String repositoryName = re...
java
public void changePersistenceField(MappedAttributeDefinition defn, ModelNode newValue) throws RepositoryException, OperationFailedException { ModeShapeEngine engine = getEngine(); String repositoryName = repositoryName(); // Get a snapshot of the current c...
java
public void changeSourceField( MappedAttributeDefinition defn, ModelNode newValue, String sourceName ) throws RepositoryException, OperationFailedException { ModeShapeEngine engine = getEngine(); String repositoryName = repositoryName...
java
public void changeTextExtractorField( MappedAttributeDefinition defn, ModelNode newValue, String extractorName ) throws RepositoryException, OperationFailedException { ModeShapeEngine engine = getEngine(); String reposit...
java
public void changeAuthenticatorField( MappedAttributeDefinition defn, ModelNode newValue, String authenticatorName ) throws RepositoryException, OperationFailedException { ModeShapeEngine engine = getEngine(); String rep...
java
public boolean checkLocks( boolean exclusive, int depth ) { if (checkParents(exclusive) && checkChildren(exclusive, depth)) { return true; } return false; }
java
public Predicate<T> and( final Predicate<T> other ) { if (other == null || other == this) return this; return new Predicate<T>() { @Override public boolean test( T input ) { return Predicate.this.test(input) && other.test(input); } }; }
java
public Predicate<T> or( final Predicate<T> other ) { if (other == null || other == this) return this; return new Predicate<T>() { @Override public boolean test( T input ) { return Predicate.this.test(input) || other.test(input); } }; }
java
public Predicate<T> negate() { return new Predicate<T>() { @Override public boolean test( T input ) { return !Predicate.this.test(input); } @Override public Predicate<T> negate() { return Predicate.this; } ...
java
public static <T> Predicate<T> never() { return new Predicate<T>() { @Override public boolean test( T input ) { return false; } }; }
java
public static <T> Predicate<T> always() { return new Predicate<T>() { @Override public boolean test( T input ) { return true; } }; }
java