code
stringlengths
73
34.1k
label
stringclasses
1 value
public static List<Class<?>> convertArgumentClassesToPrimitives( Class<?>... arguments ) { if (arguments == null || arguments.length == 0) return Collections.emptyList(); List<Class<?>> result = new ArrayList<Class<?>>(arguments.length); for (Class<?> clazz : arguments) { if (clazz =...
java
public static String getClassName( final Class<?> clazz ) { final String fullName = clazz.getName(); final int fullNameLength = fullName.length(); // Check for array ('[') or the class/interface marker ('L') ... int numArrayDimensions = 0; while (numArrayDimensions < fullNameLen...
java
public static void setValue(Object instance, String fieldName, Object value) { try { Field f = findFieldRecursively(instance.getClass(), fieldName); if (f == null) throw new NoSuchMethodException("Cannot find field " + fieldName + " on " + instance.getClass() + " or super...
java
public static Method findMethod(Class<?> type, String methodName) { try { return type.getDeclaredMethod(methodName); } catch (NoSuchMethodException e) { if (type.equals(Object.class) || type.isInterface()) { throw new RuntimeException(e); } ...
java
public Method[] findMethods( Pattern methodNamePattern ) { final Method[] allMethods = this.targetClass.getMethods(); final List<Method> result = new ArrayList<Method>(); for (int i = 0; i < allMethods.length; i++) { final Method m = allMethods[i]; if (methodNamePattern.m...
java
public Object invokeGetterMethodOnTarget( String javaPropertyName, Object target ) throws NoSuchMethodException, SecurityException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { String[] methodNamesArray = findMethodNa...
java
public void setProperty( Object target, Property property, Object value ) throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { CheckArg.isNotNull(target, "target");...
java
public Object getProperty( Object target, Property property ) throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { CheckArg.isNotNull(target, "target"); CheckArg.isNotNull(property, "...
java
public String getPropertyAsString( Object target, Property property ) throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { Object value = getProperty(target, property); String...
java
public String getSourceKey() { if (sourceKey == null) { // Value is idempotent, so it's okay to do this without synchronizing ... sourceKey = key.substring(SOURCE_START_INDEX, SOURCE_END_INDEX); } return sourceKey; }
java
public String getWorkspaceKey() { if (workspaceKey == null) { // Value is idempotent, so it's okay to do this without synchronizing ... workspaceKey = key.substring(WORKSPACE_START_INDEX, WORKSPACE_END_INDEX); } return workspaceKey; }
java
public QueryBuilder union() { this.firstQuery = query(); this.firstQuerySetOperation = Operation.UNION; this.firstQueryAll = false; clear(false); return this; }
java
public QueryBuilder unionAll() { this.firstQuery = query(); this.firstQuerySetOperation = Operation.UNION; this.firstQueryAll = true; clear(false); return this; }
java
public QueryBuilder intersect() { this.firstQuery = query(); this.firstQuerySetOperation = Operation.INTERSECT; this.firstQueryAll = false; clear(false); return this; }
java
public QueryBuilder intersectAll() { this.firstQuery = query(); this.firstQuerySetOperation = Operation.INTERSECT; this.firstQueryAll = true; clear(false); return this; }
java
public QueryBuilder except() { this.firstQuery = query(); this.firstQuerySetOperation = Operation.EXCEPT; this.firstQueryAll = false; clear(false); return this; }
java
public QueryBuilder exceptAll() { this.firstQuery = query(); this.firstQuerySetOperation = Operation.EXCEPT; this.firstQueryAll = true; clear(false); return this; }
java
public static IndexChangeAdapter forMultipleColumns( ExecutionContext context, NodeTypePredicate matcher, String workspaceName, ProvidedIndex<?> inde...
java
private boolean checkSupportedAudio() { AudioHeader header = audioFile.getAudioHeader(); bitrate = header.getBitRateAsNumber(); sampleRate = header.getSampleRateAsNumber(); channels = header.getChannels(); if (header.getChannels().toLowerCase().contains("stereo")) { c...
java
static <T> LocalUniqueIndex<T> create( String name, String workspaceName, DB db, Converter<T> converter, BTreeKeySerializer<T> valueSerializer, ...
java
protected Object columnValue(Object value) { switch (type) { case PATH: case NAME: case STRING: case REFERENCE: case SIMPLEREFERENCE: case WEAKREFERENCE: case URI: return valueFactories.getStringFactory().create(...
java
protected Object cast(Object value) { switch (type) { case STRING : return valueFactories.getStringFactory().create(value); case LONG : return valueFactories.getLongFactory().create(value); case NAME : return valueFactories.getNa...
java
public boolean indexExists(String name) throws IOException { CloseableHttpClient client = HttpClients.createDefault(); HttpHead head = new HttpHead(String.format("http://%s:%d/%s", host, port, name)); try { CloseableHttpResponse response = client.execute(head); return res...
java
public boolean createIndex(String name, String type, EsRequest mappings) throws IOException { if (indexExists(name)) { return true; } CloseableHttpClient client = HttpClients.createDefault(); HttpPost method = new HttpPost(String.format("http://%s:%d/%s", host, port, name));...
java
public boolean deleteIndex(String name) throws IOException { CloseableHttpClient client = HttpClients.createDefault(); HttpDelete delete = new HttpDelete(String.format("http://%s:%d/%s", host, port, name)); try { CloseableHttpResponse resp = client.execute(delete); return...
java
public boolean storeDocument(String name, String type, String id, EsRequest doc) throws IOException { CloseableHttpClient client = HttpClients.createDefault(); HttpPost method = new HttpPost(String.format("http://%s:%d/%s/%s/%s", host, port, name, type, id)); try { String...
java
public EsRequest getDocument(String name, String type, String id) throws IOException { CloseableHttpClient client = HttpClients.createDefault(); HttpGet method = new HttpGet(String.format("http://%s:%d/%s/%s/%s", host, port, name, type, id)); try { CloseableHttpResponse resp = client...
java
public boolean deleteDocument(String name, String type, String id) throws IOException { CloseableHttpClient client = HttpClients.createDefault(); HttpDelete delete = new HttpDelete(String.format("http://%s:%d/%s/%s/%s", host, port, name, type, id)); try { return client.execute(delete...
java
public void deleteAll(String name, String type) throws IOException { CloseableHttpClient client = HttpClients.createDefault(); HttpPost method = new HttpPost(String.format("http://%s:%d/%s/%s", host, port, name, type)); try { EsRequest query = new EsRequest(); query.put("...
java
public void flush(String name) throws IOException { CloseableHttpClient client = HttpClients.createDefault(); HttpPost method = new HttpPost(String.format("http://%s:%d/%s/_flush", host, port, name)); try { CloseableHttpResponse resp = client.execute(method); int status =...
java
public EsResponse search(String name, String type, EsRequest query) throws IOException { CloseableHttpClient client = HttpClients.createDefault(); HttpPost method = new HttpPost(String.format("http://%s:%d/%s/%s/_search", host, port, name, type)); try { StringEntity requestEntity = n...
java
protected String doGetString( NamespaceRegistry namespaceRegistry, TextEncoder encoder, TextEncoder delimiterEncoder ) { if (encoder == null) encoder = DEFAULT_ENCODER; final String delimiter = delimiterEncoder != null ? delimiterEncode...
java
public Lock lock( AbstractJcrNode node, boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerInfo ) throws LockException, AccessDeniedException, InvalidItemStateException, RepositoryException { if (...
java
protected String removeQuotes( String text ) { assert text != null; if (text.length() > 2) { char first = text.charAt(0); // Need to remove these only if they are paired ... if (first == '"' || first == '\'') { int indexOfLast = text.length() - 1; ...
java
public void write( Document document ) { assert document != null; ++count; ++totalCount; if (count > maxDocumentsPerFile) { // Close the stream (we'll open a new one later in the method) ... close(); count = 1; } try { if (s...
java
public Query constrainedBy( Constraint constraint ) { return new Query(source, constraint, orderings(), columns, getLimits(), distinct); }
java
public Query orderedBy( List<Ordering> orderings ) { return new Query(source, constraint, orderings, columns, getLimits(), distinct); }
java
public Query returning( List<Column> columns ) { return new Query(source, constraint, orderings(), columns, getLimits(), distinct); }
java
public Query adding( Column... columns ) { List<Column> newColumns = null; if (this.columns != null) { newColumns = new ArrayList<Column>(this.columns); for (Column column : columns) { newColumns.add(column); } } else { newColumns =...
java
private void getCredentials() { jcrService.getUserName(new BaseCallback<String>() { @Override public void onSuccess(String name) { showMainForm(name); } }); }
java
public void loadNodeSpecifiedByURL() { repositoriesList.select(jcrURL.getRepository(), jcrURL.getWorkspace(), jcrURL.getPath(), true); }
java
public void showMainForm(String userName) { align(); changeUserName(userName); mainForm.addMember(header); mainForm.addMember(repositoryHeader); mainForm.addMember(viewPort); mainForm.addMember(strut(30)); mainForm.addMember(footer); setLayou...
java
public void changeRepositoryInURL(String name, boolean changeHistory) { jcrURL.setRepository(name); if (changeHistory) { htmlHistory.newItem(jcrURL.toString(), false); } }
java
public void changeWorkspaceInURL(String name, boolean changeHistory) { jcrURL.setWorkspace(name); if (changeHistory) { htmlHistory.newItem(jcrURL.toString(), false); } }
java
public void changePathInURL(String path, boolean changeHistory) { jcrURL.setPath(path); if (changeHistory) { htmlHistory.newItem(jcrURL.toString(), false); } }
java
public void showRepositories(Collection<RepositoryName> names) { repositoriesList.show(names); display(repositoriesList); this.hideRepository(); }
java
public void displayContent(String repository, String workspace, String path, boolean changeHistory) { contents.show(repository, workspace, path, changeHistory); displayRepository(repository); display(contents); changeRepositoryInURL(repository, changeHistory); }
java
public int removeAllChildren( Node node ) throws RepositoryException { isNotNull(node, "node"); int childrenRemoved = 0; NodeIterator iter = node.getNodes(); while (iter.hasNext()) { Node child = iter.nextNode(); child.remove(); ++childrenRemoved; ...
java
public Node getNode( Node node, String relativePath, boolean required ) throws RepositoryException { isNotNull(node, "node"); isNotNull(relativePath, "relativePath"); Node result = null; try { result = node.getNode(relativePat...
java
public String getReadable( Node node ) { if (node == null) return ""; try { return node.getPath(); } catch (RepositoryException err) { return node.toString(); } }
java
public Node findOrCreateNode( Session session, String path, String nodeType ) throws RepositoryException { return findOrCreateNode(session, path, nodeType, nodeType); }
java
public Node findOrCreateChild( Node parent, String name ) throws RepositoryException { return findOrCreateChild(parent, name, null); }
java
public Node findOrCreateChild( Node parent, String name, String nodeType ) throws RepositoryException { return findOrCreateNode(parent, name, nodeType, nodeType); }
java
public void onEachNode( Session session, boolean includeSystemNodes, NodeOperation operation ) throws Exception { Node node = session.getRootNode(); operation.run(node); NodeIterator iter = node.getNodes(); while (iter.hasNext()) { ...
java
public List<AstNode> getChildrenForType( AstNode astNode, String nodeType ) { CheckArg.isNotNull(astNode, "astNode"); CheckArg.isNotNull(nodeType, "nodeType"); List<AstNode> childrenOfType = new ArrayList<AstNode>(); for (AstNode child : astN...
java
private List<AbstractJcrNode> findOutputNodes( AbstractJcrNode rootOutputNode ) throws RepositoryException { if (rootOutputNode.isNew()) { return Arrays.asList(rootOutputNode); } // if the node was not new, we need to find the new sequenced nodes List<AbstractJcrNode> nodes ...
java
private void removeExistingOutputNodes( AbstractJcrNode parentOfOutput, String outputNodeName, String selectedPath, String logMsg ) throws RepositoryException { // Determine if the...
java
private boolean contentExists( BinaryKey key, boolean alive ) throws BinaryStoreException { try { String query = "SELECT payload from modeshape.binary where cid='" + key.toString() + "'"; query = alive ? query + " and usage=1;" : query + " and usage = 0...
java
private ByteBuffer buffer( InputStream stream ) throws IOException { stream.reset(); ByteArrayOutputStream bout = new ByteArrayOutputStream(); IoUtil.write(stream, bout); return ByteBuffer.wrap(bout.toByteArray()); }
java
public static Map<SelectorName, SelectorName> getSelectorAliasesByName( Visitable visitable ) { // Find all of the selectors that have aliases ... final Map<SelectorName, SelectorName> result = new HashMap<SelectorName, SelectorName>(); Visitors.visitAll(visitable, new Visitors.AbstractVisitor()...
java
public String getComment( int index ) { if (comments == null || index < 0 || index >= comments.size()) { throw new IllegalArgumentException("Not a valid comment index: " + index); } return comments.elementAt(index); }
java
protected boolean hasPrivileges( Privilege[] privileges ) { for (Privilege p : privileges) { if (!contains(this.privileges, p)) { return false; } } return true; }
java
protected boolean addIfNotPresent( Privilege[] privileges ) { ArrayList<Privilege> list = new ArrayList<Privilege>(); Collections.addAll(list, privileges); boolean res = combineRecursively(list, privileges); this.privileges.addAll(list); return res; }
java
protected boolean combineRecursively( List<Privilege> list, Privilege[] privileges ) { boolean res = false; for (Privilege p : privileges) { if (p.isAggregate()) { res = combineRecursively(list, p.getAggregatePrivileges()); ...
java
protected NodeSequence createNodeSequenceForSource( QueryCommand originalQuery, QueryContext context, PlanNode sourceNode, Columns columns, ...
java
protected NodeSequence createNodeSequenceForSource( QueryCommand originalQuery, QueryContext context, PlanNode sourceNode, IndexPlan index, ...
java
private String getHash() { try { Node contentNode = getContextNode(); Property data = contentNode.getProperty(Property.JCR_DATA); Binary bin = (Binary) data.getBinary(); return String.format("{%s}%s", HASH_ALGORITHM, bin.getHexHash()); } catch (RepositoryE...
java
public void setWorkspaceNames(String[] values) { col2.combo.setValueMap(values); if (values.length > 0) { col2.combo.setValue(values[0]); } }
java
private Set<String> versionLabelsFor( Version version ) throws RepositoryException { if (!version.getParent().equals(this)) { throw new VersionException(JcrI18n.invalidVersion.text(version.getPath(), getPath())); } String versionId = version.getIdentifier(); PropertyIterator...
java
private int computeCredsHashCode( Credentials c ) { if (c instanceof SimpleCredentials) { return computeSimpleCredsHashCode((SimpleCredentials)c); } return c.hashCode(); }
java
public int getSameNameSiblingIndex() { int snsIndex = 1; if (this.parent == null) { return snsIndex; } // Go through all the children ... for (AstNode sibling : this.parent.getChildren()) { if (sibling == this) { break; } ...
java
public String getAbsolutePath() { StringBuilder pathBuilder = new StringBuilder("/").append(this.getName()); AstNode parent = this.getParent(); while (parent != null) { pathBuilder.insert(0, "/" + parent.getName()); parent = parent.getParent(); } return pa...
java
public AstNode setProperty( String name, Object value ) { CheckArg.isNotNull(name, "name"); CheckArg.isNotNull(value, "value"); properties.put(name, value); return this; }
java
public AstNode setProperty( String name, Object... values ) { CheckArg.isNotNull(name, "name"); CheckArg.isNotNull(values, "value"); if (values.length != 0) { properties.put(name, Arrays.asList(values)); } return this; }
java
protected String removeBracketsAndQuotes( String text, Position position ) { return removeBracketsAndQuotes(text, true, position); }
java
protected String removeBracketsAndQuotes( String text, boolean recursive, Position position ) { if (text.length() > 0) { char firstChar = text.charAt(0); switch (firstChar) { case ...
java
private String[] propertyDefs( Node node ) throws RepositoryException { ArrayList<String> list = new ArrayList<>(); NodeType primaryType = node.getPrimaryNodeType(); PropertyDefinition[] defs = primaryType.getPropertyDefinitions(); for (PropertyDefinition def : defs) { if (...
java
private AccessControlList findAccessList( AccessControlManager acm, String path ) throws RepositoryException { AccessControlPolicy[] policy = acm.getPolicies(path); if (policy != null && policy.length > 0) { return (AccessControlList)policy[0]; ...
java
private Collection<JcrProperty> getProperties( String repository, String workspace, String path, Node node ) throws RepositoryException { ArrayList<PropertyDefinition> names = new ArrayList<>(); NodeType primaryType = node.getPrimaryNodeType(); PropertyDefinition[] defs = primaryType.ge...
java
private String values( PropertyDefinition pd, Property p ) throws RepositoryException { if (p == null) { return "N/A"; } if (pd.getRequiredType() == PropertyType.BINARY) { return "BINARY"; } if (!p.isMultiple()) { return p.get...
java
private AccessControlEntry pick( AccessControlList acl, String principal ) throws RepositoryException { for (AccessControlEntry entry : acl.getAccessControlEntries()) { if (entry.getPrincipal().getName().equals(principal)) { return entry; ...
java
private Privilege[] excludePrivilege( Privilege[] privileges, JcrPermission permission ) { ArrayList<Privilege> list = new ArrayList<>(); for (Privilege privilege : privileges) { if (!privilege.getName().equalsIgnoreCase(permission.getName())) { ...
java
private Privilege[] includePrivilege( AccessControlManager acm, Privilege[] privileges, JcrPermission permission ) throws RepositoryException { ArrayList<Privilege> list = new ArrayList<>(); for (Privilege privilege : p...
java
public static FileSystemBinaryStore create( File directory, File trash ) { String key = directory.getAbsolutePath(); FileSystemBinaryStore store = INSTANCES.get(key); if (store == null) { store = trash != null ? new FileSystemBinaryStore(directory, trash) : new FileSystemBinaryStore(...
java
protected void loadRemaining() { if (!loadedAll) { // Put all of the batches from the sequence into the buffer assert targetNumRowsInMemory >= 0L; assert batchSize != null; Batch batch = original.nextBatch(); boolean loadIntoMemory = inMemoryBatches !=...
java
public BinaryKey moveValue( BinaryKey key, String source, String destination ) throws BinaryStoreException { final BinaryStore sourceStore; if (source == null) { sourceStore = findBinaryStoreContainingKey(key); } else {...
java
public void moveValue( BinaryKey key, String destination ) throws BinaryStoreException { moveValue(key, null, destination); }
java
public BinaryStore findBinaryStoreContainingKey( BinaryKey key ) { Iterator<Map.Entry<String, BinaryStore>> binaryStoreIterator = getNamedStoreIterator(); while (binaryStoreIterator.hasNext()) { BinaryStore bs = binaryStoreIterator.next().getValue(); if (bs.hasBinary(key)) { ...
java
private BinaryStore selectBinaryStore( String hint ) { BinaryStore namedBinaryStore = null; if (hint != null) { logger.trace("Selecting named binary store for hint: " + hint); namedBinaryStore = namedStores.get(hint); } if (namedBinaryStore == null) { ...
java
public void start() { if (state == State.RUNNING) return; final Lock lock = this.lock.writeLock(); try { lock.lock(); this.state = State.STARTING; // Create an executor service that we'll use to start the repositories ... ThreadFactory threadFacto...
java
public Future<Boolean> shutdown( boolean forceShutdownOfAllRepositories ) { if (!forceShutdownOfAllRepositories) { // Check to see if there are any still running ... final Lock lock = this.lock.readLock(); try { lock.lock(); for (JcrRepository ...
java
protected boolean doShutdown() { if (state == State.NOT_RUNNING) { LOGGER.debug("Engine already shut down."); return true; } LOGGER.debug("Shutting down engine..."); final Lock lock = this.lock.writeLock(); try { lock.lock(); state ...
java
public Map<String, State> getRepositories() { checkRunning(); Map<String, State> results = new HashMap<String, State>(); final Lock lock = this.lock.readLock(); try { lock.lock(); for (JcrRepository repository : repositories.values()) { results.put...
java
protected Collection<JcrRepository> repositories() { if (this.state == State.RUNNING) { final Lock lock = this.lock.readLock(); try { lock.lock(); return new ArrayList<JcrRepository>(repositories.values()); } finally { lock.unlo...
java
protected JcrRepository deploy( final RepositoryConfiguration repositoryConfiguration, final String repositoryKey ) throws ConfigurationException, RepositoryException { CheckArg.isNotNull(repositoryConfiguration, "repositoryConfiguration"); checkRunning(); fi...
java
public Status validateRequest(final NormalisedPath requestPath, HttpServerExchange exchange, OpenApiOperation openApiOperation) { requireNonNull(requestPath, "A request path is required"); requireNonNull(exchange, "An exchange is required"); requireNonNull(openApiOperation, "An OpenAPI operation...
java
public Status validateResponse(final HttpServerExchange exchange, final SwaggerOperation swaggerOperation) { requireNonNull(exchange, "An exchange is required"); requireNonNull(swaggerOperation, "A swagger operation is required"); io.swagger.models.Response swaggerResponse = swaggerOperation.ge...
java
public Status validate(final Object value, final Property schema) { return doValidate(value, schema, null); }
java
public Status validate(final Object value, final Model schema, SchemaValidatorsConfig config) { return doValidate(value, schema, config); }
java
public Status validateResponseContent(Object responseContent, OpenApiOperation openApiOperation, String statusCode, String mediaTypeName) { //try to convert json string to structured object if(responseContent instanceof String) { responseContent = convertStrToObjTree((String)responseContent)...
java