code
stringlengths
73
34.1k
label
stringclasses
1 value
public void setStrategy( T minimum, T maximum ) { this.bucketingStrategy = new ExplicitBucketingStrategy(minimum, maximum); this.bucketWidth = null; }
java
public Histogram<T> setSignificantFigures( int significantFigures ) { if (significantFigures != this.significantFigures) { this.significantFigures = significantFigures; this.bucketWidth = null; this.buckets.clear(); } return this; }
java
public Histogram<T> setBucketCount( int count ) { if (count != this.bucketCount) { this.bucketCount = count; this.bucketWidth = null; this.buckets.clear(); } return this; }
java
@Override public synchronized void start( BootstrapContext ctx ) throws ResourceAdapterInternalException { if (engine == null) { engine = new ModeShapeEngine(); engine.start(); } }
java
@Override public synchronized void stop() { if (engine != null) { Future<Boolean> shutdown = engine.shutdown(); final int SHUTDOWN_TIMEOUT = 30; try { LOGGER.debug("Shutting down engine to stop resource adapter"); if ( ! shutdown.get(SHUTDO...
java
public Serializer<?> serializerFor( TypeFactory<?> type ) { if (type instanceof TupleFactory) { return ((TupleFactory<?>)type).getSerializer(this); } return serializers.serializerFor(type.getType()); }
java
public BTreeKeySerializer<?> bTreeKeySerializerFor( TypeFactory<?> type, boolean pack ) { return serializers.bTreeKeySerializerFor(type.getType(), type.getComparator(), pack); }
java
JcrNodeDefinition getNodeDefinition( NodeDefinitionId definitionId ) { if (definitionId == null) return null; return nodeTypes().getChildNodeDefinition(definitionId); }
java
JcrPropertyDefinition getPropertyDefinition( PropertyDefinitionId definitionId ) { if (definitionId == null) return null; return nodeTypes().getPropertyDefinition(definitionId); }
java
public boolean isDerivedFrom( String[] testTypeNames, String primaryTypeName, String[] mixinNames ) throws RepositoryException { CheckArg.isNotEmpty(testTypeNames, "testTypeNames"); CheckArg.isNotEmpty(primaryTypeName, "primaryTypeName"...
java
public static int valueFromName(String name) { if (name.equals(TYPENAME_SIMPLE_REFERENCE)) { return SIMPLE_REFERENCE; } return javax.jcr.PropertyType.valueFromName(name); }
java
protected CachedNode nodeInWorkspace( AbstractSessionCache session ) { return isNew() ? null : session.getWorkspace().getNode(key); }
java
protected final Segment getSegment( NodeCache cache, CachedNode parent ) { if (parent != null) { ChildReference ref = parent.getChildReferences(cache).getChild(key); if (ref == null) { // This node doesn't exist in the parent ...
java
private void emitValue( Value value, ContentHandler contentHandler, int propertyType, boolean skipBinary ) throws RepositoryException, SAXException { if (PropertyType.BINARY == propertyType) { startElement(contentHa...
java
private Node nodeFor( ITransaction transaction, ResolvedRequest request ) throws RepositoryException { return ((JcrSessionTransaction)transaction).nodeFor(request); }
java
private String[] childrenFor( ITransaction transaction, ResolvedRequest request ) throws RepositoryException { return ((JcrSessionTransaction)transaction).childrenFor(request); }
java
public RestQueryResult addColumn( String name, String type ) { if (!StringUtil.isBlank(name)) { columns.put(name, type); } return this; }
java
static <T> LocalDuplicateIndex<T> create( String name, String workspaceName, DB db, Converter<T> converter, Serializer<T> valueSerialize...
java
public String currentTransactionId() { try { javax.transaction.Transaction txn = txnMgr.getTransaction(); return txn != null ? txn.toString() : null; } catch (SystemException e) { return null; } }
java
public Transaction begin() throws NotSupportedException, SystemException, RollbackException { // check if there isn't an active transaction already NestableThreadLocalTransaction localTx = LOCAL_TRANSACTION.get(); if (localTx != null) { // we have an existing local transaction so we ...
java
public void commit() throws HeuristicRollbackException, RollbackException, HeuristicMixedException, SystemException { Transaction transaction = currentTransaction(); if (transaction == null) { throw new IllegalStateException("No active transaction"); } transaction.commit(); ...
java
public void rollback() throws SystemException { Transaction transaction = currentTransaction(); if (transaction == null) { throw new IllegalStateException("No active transaction"); } transaction.rollback(); }
java
protected NodeTypes without( Collection<JcrNodeType> removedNodeTypes ) { if (removedNodeTypes.isEmpty()) return this; Collection<JcrNodeType> nodeTypes = new HashSet<JcrNodeType>(this.nodeTypes.values()); nodeTypes.removeAll(removedNodeTypes); return new NodeTypes(this.context, nodeType...
java
protected NodeTypes with( Collection<JcrNodeType> addedNodeTypes ) { if (addedNodeTypes.isEmpty()) return this; Collection<JcrNodeType> nodeTypes = new HashSet<JcrNodeType>(this.nodeTypes.values()); // if there are updated node types, remove them first (hashcode is based on name alone), ...
java
public boolean isTypeOrSubtype( Name nodeTypeName, Name candidateSupertypeName ) { if (JcrNtLexicon.BASE.equals(candidateSupertypeName)) { // If the candidate is 'nt:base', then every node type is a subtype ... return true; } if (nodeTy...
java
public boolean isTypeOrSubtype( Set<Name> nodeTypeNames, Name candidateSupertypeName ) { for (Name nodeTypeName : nodeTypeNames) { if (isTypeOrSubtype(nodeTypeName, candidateSupertypeName)) return true; } return false; }
java
public boolean allowsNameSiblings( Name primaryType, Set<Name> mixinTypes ) { if (isUnorderedCollection(primaryType, mixinTypes)) { // regardless of the actual types, if at least one of them is an unordered collection, SNS are not allowed return fal...
java
public int getBucketIdLengthForUnorderedCollection( Name nodeTypeName, Set<Name> mixinTypes ) { Set<Name> allTypes = new LinkedHashSet<>(); allTypes.add(nodeTypeName); if (mixinTypes != null && !mixinTypes.isEmpty()) { allTypes.addAll(mixinTypes); } for (Name typeName...
java
public boolean isReferenceProperty( Name nodeTypeName, Name propertyName ) { JcrNodeType type = getNodeType(nodeTypeName); if (type != null) { for (JcrPropertyDefinition propDefn : type.allPropertyDefinitions(propertyName)) { int requir...
java
public boolean hasMandatoryPropertyDefinitions( Name primaryType, Set<Name> mixinTypes ) { if (mandatoryPropertiesNodeTypes.containsKey(primaryType)) return true; for (Name mixinType : mixinTypes) { if (mandatoryPropertiesNodeTypes.contains...
java
public boolean hasMandatoryChildNodeDefinitions( Name primaryType, Set<Name> mixinTypes ) { if (mandatoryChildrenNodeTypes.containsKey(primaryType)) return true; for (Name mixinType : mixinTypes) { if (mandatoryChildrenNodeTypes.containsKe...
java
public boolean isQueryable(Name nodeTypeName, Set<Name> mixinTypes) { if (nonQueryableNodeTypes.contains(nodeTypeName)) { return false; } if (!mixinTypes.isEmpty()) { for (Name mixinType : mixinTypes) { if (nonQueryableNodeTypes.contains(mixinType)) { ...
java
boolean canRemoveItem( Name primaryTypeNameOfParent, List<Name> mixinTypeNamesOfParent, Name itemName, boolean skipProtected ) { // First look in the primary type for a matching property definition... JcrNodeType primaryTyp...
java
protected JcrNodeType findTypeInMapOrList( Name typeName, Collection<JcrNodeType> pendingList ) { for (JcrNodeType pendingNodeType : pendingList) { if (pendingNodeType.getInternalName().equals(typeName)) { return pendingNodeType; ...
java
protected List<JcrNodeType> supertypesFor( NodeTypeDefinition nodeType, Collection<JcrNodeType> pendingTypes ) throws RepositoryException { assert nodeType != null; List<JcrNodeType> supertypes = new LinkedList<JcrNodeType>(); boolean isMixin = no...
java
final Collection<JcrNodeType> subtypesFor( JcrNodeType nodeType ) { List<JcrNodeType> subtypes = new LinkedList<JcrNodeType>(); for (JcrNodeType type : this.nodeTypes.values()) { if (type.supertypes().contains(nodeType)) { subtypes.add(type); } } r...
java
final Collection<JcrNodeType> declaredSubtypesFor( JcrNodeType nodeType ) { CheckArg.isNotNull(nodeType, "nodeType"); String nodeTypeName = nodeType.getName(); List<JcrNodeType> subtypes = new LinkedList<JcrNodeType>(); for (JcrNodeType type : this.nodeTypes.values()) { if (A...
java
protected void validate( JcrNodeType nodeType, List<JcrNodeType> supertypes, List<JcrNodeType> pendingTypes ) throws RepositoryException { validateSupertypes(supertypes); List<Name> supertypeNames = new ArrayList<Name>(supertypes.size()); ...
java
public boolean isCaseSensitive() { switch (getJcrType()) { case PropertyType.DOUBLE: case PropertyType.LONG: case PropertyType.DECIMAL: case PropertyType.WEAKREFERENCE: case PropertyType.REFERENCE: // conversion is case-insensitive case Pro...
java
public boolean isSigned() { switch (getJcrType()) { case PropertyType.DOUBLE: case PropertyType.LONG: case PropertyType.DECIMAL: case PropertyType.DATE: return true; } return false; }
java
public static <T> Iterable<T> concat( final Iterable<T> a, final Iterable<T> b ) { assert (a != null); assert (b != null); return () -> Collections.concat(a.iterator(), b.iterator()); }
java
public static <T> Iterator<T> concat( final Iterator<T> a, final Iterator<T> b ) { assert (a != null); assert (b != null); return new Iterator<T>() { @Override public boolean hasNext() { return a.hasNext() || b.h...
java
public EsIndexColumn column(String name) { return columns.get(noprefix(name, EsIndexColumn.LENGTH_PREFIX, EsIndexColumn.LOWERCASE_PREFIX, EsIndexColumn.UPPERCASE_PREFIX)); }
java
private String noprefix(String name, String... prefix) { for (int i = 0; i < prefix.length; i++) { if (name.startsWith(prefix[i])) { name = name.replaceAll(prefix[i], ""); } } return name; }
java
public EsRequest mappings( String type ) { EsRequest mappings = new EsRequest(); EsRequest mappingsValue = new EsRequest(); EsRequest mtype = new EsRequest(); EsRequest properties = new EsRequest(); for (EsIndexColumn col : columns()) { ...
java
private EsRequest fieldMapping( PropertyType type ) { EsRequest mappings = new EsRequest(); switch (type) { case BINARY: mappings.put("type", "binary"); break; case BOOLEAN: mappings.put("type", "boolean"); break; ...
java
public void setControls(FormItem... items) { FormItem[] controls = new FormItem[items.length + 3]; int i = 0; for (FormItem item : items) { controls[i++] = item; } controls[i++] = new SpacerItem(); controls[i++] = confirmButton; controls[i++]...
java
public static void unzip(InputStream zipFile, String dest) throws IOException { byte[] buffer = new byte[1024]; //create output directory is not exists File folder = new File(dest); if (folder.exists()) { FileUtil.delete(folder); } folder.mkdir(); ...
java
public static void zipDir(String dirName, String nameZipFile) throws IOException { try (FileOutputStream fW = new FileOutputStream(nameZipFile); ZipOutputStream zip = new ZipOutputStream(fW)) { addFolderToZip("", dirName, zip); } }
java
public static void addFolderToZip(String path, String srcFolder, ZipOutputStream zip) throws IOException { File folder = new File(srcFolder); if (folder.list().length == 0) { addFileToZip(path, srcFolder, zip, true); } else { for (String fileName : folder.list()) { ...
java
public static void addFileToZip(String path, String srcFile, ZipOutputStream zip, boolean flag) throws IOException { File folder = new File(srcFile); if (flag) { zip.putNextEntry(new ZipEntry(path + "/" + folder.getName() + "/")); } else { if (folder.isDirectory()) { ...
java
public static String getExtension(final String filename) { Objects.requireNonNull(filename, "filename cannot be null"); int lastDotIdx = filename.lastIndexOf("."); return lastDotIdx >= 0 ? filename.substring(lastDotIdx) : ""; }
java
public void read( InputStream stream, Node outputNode ) throws Exception { read(new InputSource(stream), outputNode); }
java
private JcrSession openSession() throws ResourceException { try { Repository repo = mcf.getRepository(); Session s = repo.login(cri.getCredentials(), cri.getWorkspace()); return (JcrSession) s; } catch (RepositoryException e) { throw new ResourceException(...
java
@Override public void destroy() throws ResourceException { LOGGER.debug("Shutting down connection to repo '{0}'", mcf.getRepositoryURL()); this.session.logout(); this.handles.clear(); }
java
@Override public ManagedConnectionMetaData getMetaData() throws ResourceException { try { return new JcrManagedConnectionMetaData(mcf.getRepository(), session); } catch (Exception e) { throw new ResourceException(e); } }
java
public Session getSession( JcrSessionHandle handle ) { if ((handles.size() > 0) && (handles.get(0) == handle)) { return session; } throw new java.lang.IllegalStateException("Inactive logical session handle called"); }
java
public static String combineLines( String[] lines, char separator ) { if (lines == null || lines.length == 0) return ""; StringBuilder sb = new StringBuilder(); for (int i = 0; i != lines.length; ++i) { String line = lines[i]; if (i ...
java
public static List<String> splitLines( final String content ) { if (content == null || content.length() == 0) return Collections.emptyList(); String[] lines = content.split("[\\r]?\\n"); return Arrays.asList(lines); }
java
public static String createString( final char charToRepeat, int numberOfRepeats ) { assert numberOfRepeats >= 0; StringBuilder sb = new StringBuilder(); for (int i = 0; i < numberOfRepeats; ++i) { sb.append(charToRepeat); } retur...
java
public static String justify( Justify justify, String str, final int width, char padWithChar ) { switch (justify) { case LEFT: return justifyLeft(str, width, padWithChar); ...
java
public static String justifyRight( String str, final int width, char padWithChar ) { assert width > 0; // Trim the leading and trailing whitespace ... str = str != null ? str.trim() : ""; final int length = st...
java
public static String justifyLeft( String str, final int width, char padWithChar ) { return justifyLeft(str, width, padWithChar, true); }
java
public static String justifyCenter( String str, final int width, char padWithChar ) { // Trim the leading and trailing whitespace ... str = str != null ? str.trim() : ""; int addChars = width - str.length(); ...
java
public static String truncate( Object obj, int maxLength, String suffix ) { CheckArg.isNonNegative(maxLength, "maxLength"); if (obj == null || maxLength == 0) { return ""; } String str = obj.toString(); ...
java
public static String getStackTrace( Throwable throwable ) { if (throwable == null) return null; final ByteArrayOutputStream bas = new ByteArrayOutputStream(); final PrintWriter pw = new PrintWriter(bas); throwable.printStackTrace(pw); pw.close(); return bas.toString(); ...
java
public static String normalize( String text ) { CheckArg.isNotNull(text, "text"); // This could be much more efficient. return NORMALIZE_PATTERN.matcher(text).replaceAll(" ").trim(); }
java
public static String getHexString( byte[] bytes ) { try { byte[] hex = new byte[2 * bytes.length]; int index = 0; for (byte b : bytes) { int v = b & 0xFF; hex[index++] = HEX_CHAR_TABLE[v >>> 4]; hex[index++] = HEX_CHAR_TABLE[v ...
java
public static boolean containsAnyOf( String str, char... chars ) { CharacterIterator iter = new StringCharacterIterator(str); for (char c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) { for (char match : chars) { if (c ...
java
protected void refreshFromSystem() { try { // Re-read and re-register all of the namespaces ... SessionCache systemCache = repository.createSystemSession(repository.context(), false); SystemContent system = new SystemContent(systemCache); CachedNode locks = system...
java
protected void record( final Sequencer.Context context, final char[] sourceCode, final Node outputNode ) throws Exception { if ((sourceCode == null) || (sourceCode.length == 0)) { LOGGER.debug("No source code was found for output node {0}", outpu...
java
private String getTypeName( Type type ) { CheckArg.isNotNull(type, "type"); if (type.isPrimitiveType()) { PrimitiveType primitiveType = (PrimitiveType)type; return primitiveType.getPrimitiveTypeCode().toString(); } if (type.isSimpleType()) { SimpleType...
java
public static DatabaseType determineType(DatabaseMetaData metaData) throws SQLException { metaData = Objects.requireNonNull(metaData, "metaData cannot be null"); int majorVersion = metaData.getDatabaseMajorVersion(); int minorVersion = metaData.getDatabaseMinorVersion(); String name = me...
java
@SuppressWarnings( "unchecked" ) public synchronized void addConsumer( MessageConsumer<? extends Serializable> consumer ) { consumers.add((MessageConsumer<Serializable>)consumer); }
java
public synchronized boolean shutdown() { if (channel == null) { return false; } Address address = channel.getAddress(); LOGGER.debug("{0} shutting down clustering service...", address); consumers.clear(); // Mark this as not accepting any more ... isO...
java
public boolean sendMessage( Serializable payload ) { if (!isOpen() || !multipleMembersInCluster()) { return false; } if (LOGGER.isDebugEnabled()) { LOGGER.debug("{0} SENDING {1} ", toString(), payload); } try { byte[] messageData = toByteArray...
java
public static ClusteringService startStandalone( String clusterName, String jgroupsConfig ) { ClusteringService clusteringService = new StandaloneClusteringService(clusterName, jgroupsConfig); clusteringService.init(); return clusteringService...
java
public static ClusteringService startStandalone(String clusterName, Channel channel) { ClusteringService clusteringService = new StandaloneClusteringService(clusterName, channel); clusteringService.init(); return clusteringService; }
java
public static ClusteringService startForked( Channel mainChannel ) { if (!mainChannel.isConnected()) { throw new IllegalStateException(ClusteringI18n.channelNotConnected.text()); } ClusteringService clusteringService = new ForkedClusteringService(mainChannel);...
java
public boolean isNotOneOf( Type first, Type... rest ) { return isNotOneOf(EnumSet.of(first, rest)); }
java
public boolean isOneOf( Type first, Type... rest ) { return isOneOf(EnumSet.of(first, rest)); }
java
public boolean isBelow( PlanNode possibleAncestor ) { PlanNode node = this; while (node != null) { if (node == possibleAncestor) return true; node = node.getParent(); } return false; }
java
public boolean replaceChild( PlanNode child, PlanNode replacement ) { assert child != null; assert replacement != null; if (child.parent == this) { int i = this.children.indexOf(child); if (replacement.parent == this) { // ...
java
public Set<Property> getPropertyKeys() { return nodeProperties != null ? nodeProperties.keySet() : Collections.<Property>emptySet(); }
java
public Object getProperty( Property propertyId ) { return nodeProperties != null ? nodeProperties.get(propertyId) : null; }
java
public <ValueType> ValueType getProperty( Property propertyId, Class<ValueType> type ) { return nodeProperties != null ? type.cast(nodeProperties.get(propertyId)) : null; }
java
public Object setProperty( Property propertyId, Object value ) { if (value == null) { // Removing this property ... return nodeProperties != null ? nodeProperties.remove(propertyId) : null; } // Otherwise, we're adding the property i...
java
public Object removeProperty( Object propertyId ) { return nodeProperties != null ? nodeProperties.remove(propertyId) : null; }
java
public boolean hasCollectionProperty( Property propertyId ) { Object value = getProperty(propertyId); return (value instanceof Collection<?> && !((Collection<?>)value).isEmpty()); }
java
public boolean replaceSelector( SelectorName original, SelectorName replacement ) { if (original != null && replacement != null) { if (selectors.remove(original)) { selectors.add(replacement); return true; } } ...
java
public List<PlanNode> findAllFirstNodesAtOrBelow( Type typeToFind ) { List<PlanNode> results = new LinkedList<PlanNode>(); LinkedList<PlanNode> queue = new LinkedList<PlanNode>(); queue.add(this); while (!queue.isEmpty()) { PlanNode aNode = queue.poll(); if (aNode...
java
public void apply( Traversal order, final Operation operation, final Type type ) { apply(order, new Operation() { @Override public void apply( PlanNode node ) { if (node.getType() == type) operation.apply(node); } ...
java
public void apply( Traversal order, Operation operation ) { assert order != null; switch (order) { case LEVEL_ORDER: operation.apply(this); applyLevelOrder(order, operation); break; case PRE_ORDER: ...
java
public void applyToAncestorsUpTo( Type stopType, Operation operation ) { PlanNode ancestor = getParent(); while (ancestor != null) { if (ancestor.getType() == stopType) return; operation.apply(ancestor); ancestor = ancestor.getPar...
java
public void applyToAncestors( Operation operation ) { PlanNode ancestor = getParent(); while (ancestor != null) { operation.apply(ancestor); ancestor = ancestor.getParent(); } }
java
public List<PlanNode> findAllAtOrBelow( Traversal order ) { assert order != null; LinkedList<PlanNode> results = new LinkedList<PlanNode>(); LinkedList<PlanNode> queue = new LinkedList<PlanNode>(); queue.add(this); while (!queue.isEmpty()) { PlanNode aNode = queue.pol...
java
public List<PlanNode> findAllAtOrBelow( Traversal order, Type typeToFind ) { return findAllAtOrBelow(order, EnumSet.of(typeToFind)); }
java
public PlanNode findAtOrBelow( Traversal order, Type typeToFind ) { return findAtOrBelow(order, EnumSet.of(typeToFind)); }
java
public String findJcrName( String cmisName ) { for (Relation aList : list) { if (aList.cmisName.equals(cmisName)) { return aList.jcrName; } } return cmisName; }
java
public String findCmisName( String jcrName ) { for (Relation aList : list) { if (aList.jcrName.equals(jcrName)) { return aList.cmisName; } } return jcrName; }
java