id
stringlengths
7
14
text
stringlengths
1
106k
774658_0
public String encode(String text) { try { Cipher cipher = createCipher(Cipher.ENCRYPT_MODE, MasterPasswordStore.getMasterPassword(), SALT); byte[] encrypted = cipher.doFinal(text.getBytes("UTF-8")); return DatatypeConverter.printBase64Binary(encrypted); } catch (Exception e) { throw new RuntimeException(e); } }
774658_1
public static Config<String, String> get(String name, boolean readSystemPropertiesOnNull) { if (configurations.containsKey(name)) { return configurations.get(name); } for (PropertiesProvider propertyProvider : propertyProviders) { Map<String, String> props = propertyProvider.lookupProperties(name); if (props != null) { log.info("Loaded configuration for: " + name + " using " + propertyProvider.getClass().getName()); Config<String, String> conf; if (readSystemPropertiesOnNull) { conf = new SystemPropertiesMapWrapper(props); } else { conf = new MapWrapper(props); } configurations.put(name, conf); return conf; } } throw new RuntimeException("No configuration found for: " + name); }
774658_2
public static Config<String, String> get(String name, boolean readSystemPropertiesOnNull) { if (configurations.containsKey(name)) { return configurations.get(name); } for (PropertiesProvider propertyProvider : propertyProviders) { Map<String, String> props = propertyProvider.lookupProperties(name); if (props != null) { log.info("Loaded configuration for: " + name + " using " + propertyProvider.getClass().getName()); Config<String, String> conf; if (readSystemPropertiesOnNull) { conf = new SystemPropertiesMapWrapper(props); } else { conf = new MapWrapper(props); } configurations.put(name, conf); return conf; } } throw new RuntimeException("No configuration found for: " + name); }
774658_3
public static Config<String, String> get(String name, boolean readSystemPropertiesOnNull) { if (configurations.containsKey(name)) { return configurations.get(name); } for (PropertiesProvider propertyProvider : propertyProviders) { Map<String, String> props = propertyProvider.lookupProperties(name); if (props != null) { log.info("Loaded configuration for: " + name + " using " + propertyProvider.getClass().getName()); Config<String, String> conf; if (readSystemPropertiesOnNull) { conf = new SystemPropertiesMapWrapper(props); } else { conf = new MapWrapper(props); } configurations.put(name, conf); return conf; } } throw new RuntimeException("No configuration found for: " + name); }
774658_4
public static Config<String, String> get(String name, boolean readSystemPropertiesOnNull) { if (configurations.containsKey(name)) { return configurations.get(name); } for (PropertiesProvider propertyProvider : propertyProviders) { Map<String, String> props = propertyProvider.lookupProperties(name); if (props != null) { log.info("Loaded configuration for: " + name + " using " + propertyProvider.getClass().getName()); Config<String, String> conf; if (readSystemPropertiesOnNull) { conf = new SystemPropertiesMapWrapper(props); } else { conf = new MapWrapper(props); } configurations.put(name, conf); return conf; } } throw new RuntimeException("No configuration found for: " + name); }
774658_5
public static Config<String, String> get(String name, boolean readSystemPropertiesOnNull) { if (configurations.containsKey(name)) { return configurations.get(name); } for (PropertiesProvider propertyProvider : propertyProviders) { Map<String, String> props = propertyProvider.lookupProperties(name); if (props != null) { log.info("Loaded configuration for: " + name + " using " + propertyProvider.getClass().getName()); Config<String, String> conf; if (readSystemPropertiesOnNull) { conf = new SystemPropertiesMapWrapper(props); } else { conf = new MapWrapper(props); } configurations.put(name, conf); return conf; } } throw new RuntimeException("No configuration found for: " + name); }
774658_6
public static Config<String, String> get(String name, boolean readSystemPropertiesOnNull) { if (configurations.containsKey(name)) { return configurations.get(name); } for (PropertiesProvider propertyProvider : propertyProviders) { Map<String, String> props = propertyProvider.lookupProperties(name); if (props != null) { log.info("Loaded configuration for: " + name + " using " + propertyProvider.getClass().getName()); Config<String, String> conf; if (readSystemPropertiesOnNull) { conf = new SystemPropertiesMapWrapper(props); } else { conf = new MapWrapper(props); } configurations.put(name, conf); return conf; } } throw new RuntimeException("No configuration found for: " + name); }
774658_7
public static Config<String, String> get(String name, boolean readSystemPropertiesOnNull) { if (configurations.containsKey(name)) { return configurations.get(name); } for (PropertiesProvider propertyProvider : propertyProviders) { Map<String, String> props = propertyProvider.lookupProperties(name); if (props != null) { log.info("Loaded configuration for: " + name + " using " + propertyProvider.getClass().getName()); Config<String, String> conf; if (readSystemPropertiesOnNull) { conf = new SystemPropertiesMapWrapper(props); } else { conf = new MapWrapper(props); } configurations.put(name, conf); return conf; } } throw new RuntimeException("No configuration found for: " + name); }
774658_8
public static Config<String, String> get(String name, boolean readSystemPropertiesOnNull) { if (configurations.containsKey(name)) { return configurations.get(name); } for (PropertiesProvider propertyProvider : propertyProviders) { Map<String, String> props = propertyProvider.lookupProperties(name); if (props != null) { log.info("Loaded configuration for: " + name + " using " + propertyProvider.getClass().getName()); Config<String, String> conf; if (readSystemPropertiesOnNull) { conf = new SystemPropertiesMapWrapper(props); } else { conf = new MapWrapper(props); } configurations.put(name, conf); return conf; } } throw new RuntimeException("No configuration found for: " + name); }
774658_9
public static Config<String, String> get(String name, boolean readSystemPropertiesOnNull) { if (configurations.containsKey(name)) { return configurations.get(name); } for (PropertiesProvider propertyProvider : propertyProviders) { Map<String, String> props = propertyProvider.lookupProperties(name); if (props != null) { log.info("Loaded configuration for: " + name + " using " + propertyProvider.getClass().getName()); Config<String, String> conf; if (readSystemPropertiesOnNull) { conf = new SystemPropertiesMapWrapper(props); } else { conf = new MapWrapper(props); } configurations.put(name, conf); return conf; } } throw new RuntimeException("No configuration found for: " + name); }
782257_0
public static String[] tokenize( final String aInput, final String aDelimiters ) { if ( aInput == null ) { return null; } final List<String> result = new ArrayList<String>(); final StringTokenizer tokenizer = new StringTokenizer( aInput, aDelimiters, false /* returnDelims */); while ( tokenizer.hasMoreTokens() ) { String token = tokenizer.nextToken(); result.add( token.trim() ); } return result.toArray( new String[result.size()] ); }
782257_1
public static String[] tokenizeQuotedStrings( final String aInput, final String aDelimiters ) { if ( aInput == null ) { return null; } final List<String> result = new ArrayList<String>(); String lookback = ""; boolean inQuotedString = false; final StringTokenizer tokenizer = new StringTokenizer( aInput, aDelimiters, true /* returnDelims */); while ( tokenizer.hasMoreTokens() ) { String token = tokenizer.nextToken(); if ( !inQuotedString && token.startsWith( "\"" ) && !token.endsWith( "\"" ) ) { inQuotedString = true; lookback = token; } else if ( inQuotedString ) { lookback = lookback.concat( token ); if ( token.endsWith( "\"" ) ) { inQuotedString = false; token = lookback; } } if ( !inQuotedString && !isDelimiter( token, aDelimiters ) ) { result.add( token ); } } // Last step is to unquote all results... final ListIterator<String> iter = result.listIterator(); while ( iter.hasNext() ) { final String token = iter.next(); iter.set( unquote( token ) ); } return result.toArray( new String[result.size()] ); }
782257_2
public static String unquote( final String aInput ) { return unquote( aInput, '"' ); }
782257_3
public static HtmlExporter createHtmlExporter() { return new HtmlExporterImpl( true /* aIncludeDTD */); }
782257_4
public long getCount( final TYPE aValue ) { if ( aValue == null ) { throw new IllegalArgumentException( "Value cannot be null!" ); } long result = 0L; Long count = this.distribution.get( aValue ); if ( count != null ) { result = count.longValue(); } return result; }
782257_5
public TYPE getHighestRanked() { TYPE result = null; Long rank = null; for ( final Map.Entry<TYPE, Long> entry : this.distribution.entrySet() ) { if ( ( rank == null ) || ( rank.compareTo( entry.getValue() ) < 0 ) ) { rank = entry.getValue(); result = entry.getKey(); } } return result; }
782257_6
public TYPE getLowestRanked() { TYPE result = null; Long rank = null; for ( final Map.Entry<TYPE, Long> entry : this.distribution.entrySet() ) { if ( ( rank == null ) || ( rank.compareTo( entry.getValue() ) > 0 ) ) { rank = entry.getValue(); result = entry.getKey(); } } return result; }
782257_7
public static int convertByteOrder( final int aValue, final int aByteCount, final ByteOrder aByteOrder ) { if ( ( aByteCount <= 0 ) || ( aByteCount > 32 ) ) { throw new IllegalArgumentException( "Bit count cannot be zero, negative or beyond 32-bits!" ); } final ByteBuffer buf = ByteBuffer.allocate( aByteCount ); buf.putInt( aValue ); buf.order( aByteOrder ); buf.position( 0 ); final int result = buf.getInt(); return result; }
782257_8
public static int getBitIndex( final int aMaskValue ) { return ( int )Math.floor( Math.log( aMaskValue ) / Math.log( 2 ) ); }
782257_9
public static int getPercentage( final int aValue, final int aRange ) { double value = 0.0; if ( aRange != 0 ) { value = aValue * 100.0 / aRange; } return ( int )Math.max( 0.0, Math.min( 100.0, value ) ); }
790859_0
@Override public ExchangeDispatcher createDispatcher(final ServiceReference reference) { if (_logger.isDebugEnabled()) { _logger.debug("Creating Camel dispatcher for " + reference.getName()); } String endpoint = "direct:" + reference.getName(); RouteBuilder rb = new CamelExchangeBusRouteBuilder(endpoint, reference); try { // TODO - remove this logic once the test framework is able // to hot-replace a service endpoint. if (_camelContext.getRoute(endpoint) != null) { _camelContext.removeRoute(endpoint); if (_logger.isInfoEnabled()) { BusLogger.ROOT_LOGGER.removeRoute(endpoint); } } _camelContext.addRoutes(rb); if (_logger.isDebugEnabled()) { _logger.debug("Created route for " + endpoint + ", definition is: " + ModelHelper.dumpModelAsXml(rb.getRouteCollection())); } } catch (Exception ex) { throw BusMessages.MESSAGES.failedToCreateRoute(reference.getName(), ex); } ExchangeDispatcher dispatcher = new ExchangeDispatcher(_camelContext, reference); _dispatchers.put(reference.getName(), dispatcher); return dispatcher; }
790859_1
@Override public Dispatcher getDispatcher(ServiceReference reference) { return _dispatchers.get(reference.getName()); }
790859_2
@Override public Exchange createExchange(ExchangeHandler replyHandler, ExchangePattern pattern) { DefaultExchange exchange = new DefaultExchange(_context, translate(pattern)); exchange.setIn(new CamelMessage(exchange)); return new CamelExchange(this, exchange, replyHandler); }
790859_3
@Override public Exchange createExchange(ExchangeHandler replyHandler, ExchangePattern pattern) { DefaultExchange exchange = new DefaultExchange(_context, translate(pattern)); exchange.setIn(new CamelMessage(exchange)); return new CamelExchange(this, exchange, replyHandler); }
790859_4
@Override public Exchange createExchange(ExchangeHandler replyHandler, ExchangePattern pattern) { DefaultExchange exchange = new DefaultExchange(_context, translate(pattern)); exchange.setIn(new CamelMessage(exchange)); return new CamelExchange(this, exchange, replyHandler); }
790859_5
@Override public Message transform(Message message) { javax.xml.transform.Transformer transformer = null; try { DOMSource source = message.getContent(DOMSource.class); DOMResult result = new DOMResult(); if (_transformerPool != null) { transformer = _transformerPool.take(); } else { // if no pool is configured, then just create a new transformer for each request transformer = _templates.newTransformer(); transformer.setErrorListener(new XsltTransformerErrorListener(_failOnWarning)); } transformer.transform(source, result); message.setContent(((Document)result.getNode()).getDocumentElement()); } catch (Exception e) { throw TransformMessages.MESSAGES.errorDuringXsltTransformation(e); } finally { if (_transformerPool != null && transformer != null) { _transformerPool.give(transformer); } } return message; }
790859_6
@Override public Message transform(Message message) { javax.xml.transform.Transformer transformer = null; try { DOMSource source = message.getContent(DOMSource.class); DOMResult result = new DOMResult(); if (_transformerPool != null) { transformer = _transformerPool.take(); } else { // if no pool is configured, then just create a new transformer for each request transformer = _templates.newTransformer(); transformer.setErrorListener(new XsltTransformerErrorListener(_failOnWarning)); } transformer.transform(source, result); message.setContent(((Document)result.getNode()).getDocumentElement()); } catch (Exception e) { throw TransformMessages.MESSAGES.errorDuringXsltTransformation(e); } finally { if (_transformerPool != null && transformer != null) { _transformerPool.give(transformer); } } return message; }
790859_7
@Override public Message transform(Message message) { javax.xml.transform.Transformer transformer = null; try { DOMSource source = message.getContent(DOMSource.class); DOMResult result = new DOMResult(); if (_transformerPool != null) { transformer = _transformerPool.take(); } else { // if no pool is configured, then just create a new transformer for each request transformer = _templates.newTransformer(); transformer.setErrorListener(new XsltTransformerErrorListener(_failOnWarning)); } transformer.transform(source, result); message.setContent(((Document)result.getNode()).getDocumentElement()); } catch (Exception e) { throw TransformMessages.MESSAGES.errorDuringXsltTransformation(e); } finally { if (_transformerPool != null && transformer != null) { _transformerPool.give(transformer); } } return message; }
790859_8
TransformerPool getTransformerPool() { return _transformerPool; }
790859_9
@Override public Object transform(Object message) { return _dozerBeanMapper.map(message, QNameUtil.toJavaMessageType(getTo())); }
806019_0
@Override public DateTime getEventDateTime() { return eventDateTime; }
806019_1
@Override public String getName() { return eventName; }
806019_2
public Collection<String> getPathsForInterval(final ReadableInterval interval) { final Collection<String> paths = new ArrayList<String>(); granularity.stepThroughInterval(interval, new Granularity.Callback<RuntimeException>() { public void step(final ReadableInterval stepInterval) throws RuntimeException { paths.add(getPathForDateTime(stepInterval.getStart())); } }); return paths; }
806019_3
@Override public Integer getInteger() { return value; }
806019_4
@Override public Integer getInteger() { return value; }
806019_5
@Override public Boolean getBoolean() { return !value.equals(0); }
806019_6
@Override public Byte getByte() { return value.byteValue(); }
806019_7
@Override public Short getShort() { return value.shortValue(); }
806019_8
@Override public Integer getInteger() { return value; }
806019_9
@Override public Long getLong() { return value.longValue(); }
811072_0
public String sayHelloEJB(String name) { return "Hello " + name; }
812511_0
public void encrypt(String password) throws GeneralSecurityException { encrypt(password.getBytes()); }
812511_1
public void encrypt(String password) throws GeneralSecurityException { encrypt(password.getBytes()); }
812511_2
public static String toGlobusID(String dn) { return toGlobusID(dn, true); }
812511_3
public static String toGlobusID(String dn) { return toGlobusID(dn, true); }
812511_4
public static String toGlobusID(String dn) { return toGlobusID(dn, true); }
812511_5
public static X500Principal toPrincipal(String globusID) { if (globusID == null) { return null; } String id = globusID.trim(); StringBuilder buf = new StringBuilder(id.length()); if (!id.isEmpty()) { final int IDLE = 0; final int VALUE = 1; final int KEY = 2; int state = IDLE; int cEnd = 0; char[] asChars = id.toCharArray(); /* * walk in reverse order and split into RDN */ for (int i = asChars.length - 1; i >= 0; i--) { char c = asChars[i]; switch (state) { case KEY: if (c == '/' || c == ' ') { /* handle names with comma according rfc1779 */ String s = id.substring(i + 1, cEnd + 1); int commaIndex = s.indexOf(','); if (commaIndex != -1) { s = s.substring(0, commaIndex) + "\\" + s.substring(commaIndex); } buf.append(s).append(','); state = IDLE; } break; case VALUE: if (c == '=') { state = KEY; } break; case IDLE: default: // idle if (c == '/' || c == ' ') { continue; } else { cEnd = i; state = VALUE; } } } // delete last extra comma buf.deleteCharAt(buf.length() - 1); } String dn = buf.toString(); return new X500Principal(dn, KEYWORD_MAP); }
812511_6
public static X500Principal toPrincipal(String globusID) { if (globusID == null) { return null; } String id = globusID.trim(); StringBuilder buf = new StringBuilder(id.length()); if (!id.isEmpty()) { final int IDLE = 0; final int VALUE = 1; final int KEY = 2; int state = IDLE; int cEnd = 0; char[] asChars = id.toCharArray(); /* * walk in reverse order and split into RDN */ for (int i = asChars.length - 1; i >= 0; i--) { char c = asChars[i]; switch (state) { case KEY: if (c == '/' || c == ' ') { /* handle names with comma according rfc1779 */ String s = id.substring(i + 1, cEnd + 1); int commaIndex = s.indexOf(','); if (commaIndex != -1) { s = s.substring(0, commaIndex) + "\\" + s.substring(commaIndex); } buf.append(s).append(','); state = IDLE; } break; case VALUE: if (c == '=') { state = KEY; } break; case IDLE: default: // idle if (c == '/' || c == ' ') { continue; } else { cEnd = i; state = VALUE; } } } // delete last extra comma buf.deleteCharAt(buf.length() - 1); } String dn = buf.toString(); return new X500Principal(dn, KEYWORD_MAP); }
812511_7
public static X500Principal toPrincipal(String globusID) { if (globusID == null) { return null; } String id = globusID.trim(); StringBuilder buf = new StringBuilder(id.length()); if (!id.isEmpty()) { final int IDLE = 0; final int VALUE = 1; final int KEY = 2; int state = IDLE; int cEnd = 0; char[] asChars = id.toCharArray(); /* * walk in reverse order and split into RDN */ for (int i = asChars.length - 1; i >= 0; i--) { char c = asChars[i]; switch (state) { case KEY: if (c == '/' || c == ' ') { /* handle names with comma according rfc1779 */ String s = id.substring(i + 1, cEnd + 1); int commaIndex = s.indexOf(','); if (commaIndex != -1) { s = s.substring(0, commaIndex) + "\\" + s.substring(commaIndex); } buf.append(s).append(','); state = IDLE; } break; case VALUE: if (c == '=') { state = KEY; } break; case IDLE: default: // idle if (c == '/' || c == ' ') { continue; } else { cEnd = i; state = VALUE; } } } // delete last extra comma buf.deleteCharAt(buf.length() - 1); } String dn = buf.toString(); return new X500Principal(dn, KEYWORD_MAP); }
812511_8
public static X500Principal toPrincipal(String globusID) { if (globusID == null) { return null; } String id = globusID.trim(); StringBuilder buf = new StringBuilder(id.length()); if (!id.isEmpty()) { final int IDLE = 0; final int VALUE = 1; final int KEY = 2; int state = IDLE; int cEnd = 0; char[] asChars = id.toCharArray(); /* * walk in reverse order and split into RDN */ for (int i = asChars.length - 1; i >= 0; i--) { char c = asChars[i]; switch (state) { case KEY: if (c == '/' || c == ' ') { /* handle names with comma according rfc1779 */ String s = id.substring(i + 1, cEnd + 1); int commaIndex = s.indexOf(','); if (commaIndex != -1) { s = s.substring(0, commaIndex) + "\\" + s.substring(commaIndex); } buf.append(s).append(','); state = IDLE; } break; case VALUE: if (c == '=') { state = KEY; } break; case IDLE: default: // idle if (c == '/' || c == ' ') { continue; } else { cEnd = i; state = VALUE; } } } // delete last extra comma buf.deleteCharAt(buf.length() - 1); } String dn = buf.toString(); return new X500Principal(dn, KEYWORD_MAP); }
812511_9
public static X500Principal toPrincipal(String globusID) { if (globusID == null) { return null; } String id = globusID.trim(); StringBuilder buf = new StringBuilder(id.length()); if (!id.isEmpty()) { final int IDLE = 0; final int VALUE = 1; final int KEY = 2; int state = IDLE; int cEnd = 0; char[] asChars = id.toCharArray(); /* * walk in reverse order and split into RDN */ for (int i = asChars.length - 1; i >= 0; i--) { char c = asChars[i]; switch (state) { case KEY: if (c == '/' || c == ' ') { /* handle names with comma according rfc1779 */ String s = id.substring(i + 1, cEnd + 1); int commaIndex = s.indexOf(','); if (commaIndex != -1) { s = s.substring(0, commaIndex) + "\\" + s.substring(commaIndex); } buf.append(s).append(','); state = IDLE; } break; case VALUE: if (c == '=') { state = KEY; } break; case IDLE: default: // idle if (c == '/' || c == ' ') { continue; } else { cEnd = i; state = VALUE; } } } // delete last extra comma buf.deleteCharAt(buf.length() - 1); } String dn = buf.toString(); return new X500Principal(dn, KEYWORD_MAP); }
816192_0
public PluginManager() { init(); }
816192_1
public Collection<Plugin> list() { Collection<Plugin> list = new ArrayList<Plugin>(); BundleContext context = felix.getBundleContext(); Bundle[] bundles = context.getBundles(); for (Bundle b : bundles) { ServiceReference[] refs = b.getRegisteredServices(); if (refs != null) { for (ServiceReference sr : refs) { LogUtil.debug(PluginManager.class.getName(), " bundle service: " + sr); Object obj = context.getService(sr); if (obj instanceof Plugin) { list.add((Plugin) obj); } context.ungetService(sr); } } } return list; }
816192_2
public void testPlugin(String name, String location, Map properties, boolean override) { LogUtil.info(PluginManager.class.getName(), "====testPlugin===="); // check for existing plugin Plugin plugin = getPlugin(name); boolean existing = (plugin != null); boolean install = (location != null && location.trim().length() > 0); // install plugin if (install && (!existing || override)) { InputStream in = null; try { LogUtil.info(PluginManager.class.getName(), " ===install=== "); File file = new File(location); if (file.exists()) { in = new FileInputStream(file); upload(file.getName(), in); } } catch (Exception ex) { LogUtil.error(PluginManager.class.getName(), ex, ""); } finally { try { if (in != null) { in.close(); } } catch (IOException ex) { LogUtil.error(PluginManager.class.getName(), ex, ""); } } } // execute plugin LogUtil.info(PluginManager.class.getName(), " ===execute=== "); Object result = execute(name, properties); LogUtil.info(PluginManager.class.getName(), " result: " + result); // uninstall plugin if (install && (!existing || override)) { LogUtil.info(PluginManager.class.getName(), " ===uninstall=== "); uninstall(name); } LogUtil.info(PluginManager.class.getName(), "====testPlugin end===="); }
816192_3
public String getName() { return "DepartmentVariablePlugin"; }
816192_4
public String getName() { return "BeanShell Plugin"; }
819907_0
private void handleResourcePath(String rootPath, String resourcePath, BeanArchiveBuilder builder) { WeldServletLogger.LOG.debugv("Handle resource path: {0}", resourcePath); Set<String> subpaths = servletContext.getResourcePaths(resourcePath); if (subpaths != null && !subpaths.isEmpty()) { for (String subpath : subpaths) { if (subpath.endsWith(SLASH)) { // Paths indicating subdirectory end with a '/' handleResourcePath(rootPath, subpath, builder); } else if (subpath.endsWith(Files.CLASS_FILE_EXTENSION)) { add(rootPath, subpath, builder); } } } }
819907_1
public static <B extends BeanDeploymentArchive> Multimap<String, BeanDeploymentArchive> findBeanClassesDeployedInMultipleBeanArchives(Set<B> beanArchives) { if (beanArchives.size() == 1) { return Multimaps.emptyMultimap(); } SetMultimap<String, BeanDeploymentArchive> problems = SetMultimap.newSetMultimap(); if (beanArchives.size() == 2) { // Find the set that contains all bean classes of the first bean // archive that also belong to the second bean archive Iterator<B> iterator = beanArchives.iterator(); BeanDeploymentArchive first = iterator.next(); BeanDeploymentArchive second = iterator.next(); Set<String> intersection = new HashSet<String>(first.getBeanClasses()); intersection.retainAll(second.getBeanClasses()); if (!intersection.isEmpty()) { List<BeanDeploymentArchive> bdas = ImmutableList.of(first, second); for (String beanClass : intersection) { problems.putAll(beanClass, bdas); } } } else if (beanArchives.size() > 2) { // First collect the data SetMultimap<String, BeanDeploymentArchive> beanClassOccurrences = SetMultimap.newSetMultimap(); for (BeanDeploymentArchive beanArchive : beanArchives) { for (String beanClass : beanArchive.getBeanClasses()) { beanClassOccurrences.put(beanClass, beanArchive); } } // Then identify problematic bean classes for (Entry<String, Collection<BeanDeploymentArchive>> entry : beanClassOccurrences.entrySet()) { if (entry.getValue().size() > 1) { problems.putAll(entry.getKey(), entry.getValue()); } } } return problems; }
819907_2
public static String extractBeanArchiveId(String beanArchiveRef, String base, String separator) { beanArchiveRef = beanArchiveRef.replace('\\', '/'); StringBuilder id = new StringBuilder(); id.append(base); id.append(BeanArchives.BEAN_ARCHIVE_ID_BASE_DELIMITER); if (beanArchiveRef.contains(separator)) { id.append(beanArchiveRef.substring(beanArchiveRef.indexOf(separator), beanArchiveRef.length())); } else { id.append(beanArchiveRef); } return id.toString(); }
819907_3
public static boolean hasBeanDefiningMetaAnnotationSpecified(Annotation[] annotations, Class<? extends Annotation> metaAnnotationType) { for (Annotation annotation : annotations) { if (annotation.annotationType().isAnnotationPresent(metaAnnotationType)) { return true; } } return false; }
819907_4
static String annotatedMethodToString(AnnotatedMethod<?> method, Class<?> beanClass) { StringBuilder builder = new StringBuilder(); builder.append(Formats.addSpaceIfNeeded(Formats.formatAnnotations(method.getAnnotations()))); builder.append(Formats.formatModifiers(method.getJavaMember().getModifiers())); TypeVariable<Method>[] typeParams = method.getJavaMember().getTypeParameters(); builder.append(' '); if (typeParams.length > 0) { builder.append(Formats.formatTypeParameters(typeParams)); builder.append(' '); } builder.append(Formats.formatType(method.getJavaMember().getGenericReturnType())); builder.append(' '); if (!beanClass.getName().equals(method.getDeclaringType().getJavaClass().getName())) { builder.append(Formats.formatType(method.getDeclaringType().getJavaClass())); builder.append('.'); } builder.append(method.getJavaMember().getName()); builder.append(Formats.formatAsFormalParameterList(method.getParameters())); return builder.toString(); }
819907_5
static String annotationToString(Annotation annotation) { StringBuilder string = new StringBuilder(); string.append('@').append(annotation.annotationType().getName()).append('('); String classAffix = ".class"; String quotationMark = "\""; try { List<Method> methods = Arrays.asList(annotation.annotationType().getDeclaredMethods()); methods.sort(new Comparator<Method>() { @Override public int compare(Method o1, Method o2) { return o1.toGenericString().compareTo(o2.toGenericString()); } }); for (int i = 0; i < methods.size(); i++) { string.append(methods.get(i).getName()).append('='); Object value = methods.get(i).invoke(annotation); if (value instanceof boolean[]) { appendInBraces(string, Arrays.toString((boolean[]) value)); } else if (value instanceof byte[]) { appendInBraces(string, Arrays.toString((byte[]) value)); } else if (value instanceof short[]) { appendInBraces(string, Arrays.toString((short[]) value)); } else if (value instanceof int[]) { appendInBraces(string, Arrays.toString((int[]) value)); } else if (value instanceof long[]) { appendInBraces(string, Arrays.toString((long[]) value)); } else if (value instanceof float[]) { appendInBraces(string, Arrays.toString((float[]) value)); } else if (value instanceof double[]) { appendInBraces(string, Arrays.toString((double[]) value)); } else if (value instanceof char[]) { appendInBraces(string, Arrays.toString((char[]) value)); } else if (value instanceof String[]) { String[] strings = (String[]) value; String[] quoted = new String[strings.length]; for (int j = 0; j < strings.length; j++) { quoted[j] = quotationMark + strings[j] + quotationMark; } appendInBraces(string, Arrays.toString(quoted)); } else if (value instanceof Class<?>[]) { Class<?>[] classes = (Class<?>[]) value; String[] names = new String[classes.length]; for (int j = 0; j < classes.length; j++) { names[j] = classes[j].getName() + classAffix; } appendInBraces(string, Arrays.toString(names)); } else if (value instanceof Object[]) { appendInBraces(string, Arrays.toString((Object[]) value)); } else if (value instanceof String) { string.append('"').append(value).append('"'); } else if (value instanceof Class<?>) { string.append(((Class<?>) value).getName()).append(classAffix); } else { string.append(value); } if (i < methods.size() - 1) { string.append(", "); } } } catch (IllegalAccessException | IllegalArgumentException | SecurityException | InvocationTargetException ex) { // we cannot do it our way, revert to default Annotation.toString() ProbeLogger.LOG.cannotUseUnifiedAnnotationToStringConversion(ex); return annotation.toString(); } return string.append(')').toString(); }
819907_6
static String abbreviate(String value, int limit) { if (limit < ABR_MIN_LIMIT) { throw new IllegalArgumentException("Minimum limit is 4"); } if (value == null || value.length() <= limit) { return value; } return value.substring(0, limit - ABR_MARKER.length()) + ABR_MARKER; }
819907_7
static String[] getResourcePathParts(String requestUri, String contextPath) { final String path = requestUri.substring(contextPath.length(), requestUri.length()); if (path.startsWith(REST_URL_PATTERN_BASE)) { return Resource.splitPath(path.substring(REST_URL_PATTERN_BASE.length(), path.length())); } return null; }
819907_8
static Type parseType(String value, ResourceLoader resourceLoader) { value = value.trim(); // Wildcards if (value.equals(WILDCARD)) { return WildcardTypeImpl.defaultInstance(); } if (value.startsWith(WILDCARD_EXTENDS)) { Type upperBound = parseType(value.substring(WILDCARD_EXTENDS.length(), value.length()), resourceLoader); if (upperBound == null) { return null; } return WildcardTypeImpl.withUpperBound(upperBound); } if (value.startsWith(WILDCARD_SUPER)) { Type lowerBound = parseType(value.substring(WILDCARD_SUPER.length(), value.length()), resourceLoader); if (lowerBound == null) { return null; } return WildcardTypeImpl.withLowerBound(lowerBound); } // Array if (value.contains(ARRAY)) { Type componentType = parseType(value.substring(0, value.indexOf(ARRAY)), resourceLoader); if (componentType == null) { return null; } return new GenericArrayTypeImpl(componentType); } int chevLeft = value.indexOf(CHEVRONS_LEFT); String rawValue = chevLeft < 0 ? value : value.substring(0, chevLeft); Class<?> rawRequiredType = tryLoadClass(rawValue, resourceLoader); if (rawRequiredType == null) { return null; } if (rawRequiredType.getTypeParameters().length == 0) { return rawRequiredType; } // Parameterized type int chevRight = value.lastIndexOf(CHEVRONS_RIGHT); if (chevRight < 0) { return null; } List<String> parts = split(value.substring(chevLeft + 1, chevRight), ',', CHEVRONS_LEFT.charAt(0), CHEVRONS_RIGHT.charAt(0)); Type[] typeParameters = new Type[parts.size()]; for (int i = 0; i < typeParameters.length; i++) { Type typeParam = parseType(parts.get(i), resourceLoader); if (typeParam == null) { return null; } typeParameters[i] = typeParam; } return new ParameterizedTypeImpl(rawRequiredType, typeParameters); }
819907_9
static List<QualifierInstance> parseQualifiers(String qualifiers, ResourceLoader resourceLoader, BeanManager beanManager) { List<QualifierInstance> qualifierInstances = new ArrayList<>(); for (String qualifier : splitQualifiers(qualifiers)) { qualifierInstances.add(createQualifierInstance(qualifier, resourceLoader, beanManager)); } return qualifierInstances; }
828909_0
@Override public void preCreateTable(ObserverContext<MasterCoprocessorEnvironment> c, HTableDescriptor desc, HRegionInfo[] regions) throws IOException { requirePermission(Permission.Action.CREATE); }
828909_1
@Override public void preModifyTable(ObserverContext<MasterCoprocessorEnvironment> c, byte[] tableName, HTableDescriptor htd) throws IOException { requirePermission(tableName, null, null, Action.ADMIN, Action.CREATE); }
828909_2
@Override public void preDeleteTable(ObserverContext<MasterCoprocessorEnvironment> c, byte[] tableName) throws IOException { requirePermission(tableName, null, null, Action.ADMIN, Action.CREATE); }
828909_3
@Override public void preAddColumn(ObserverContext<MasterCoprocessorEnvironment> c, byte[] tableName, HColumnDescriptor column) throws IOException { requirePermission(tableName, null, null, Action.ADMIN, Action.CREATE); }
828909_4
@Override public void preModifyColumn(ObserverContext<MasterCoprocessorEnvironment> c, byte[] tableName, HColumnDescriptor descriptor) throws IOException { requirePermission(tableName, null, null, Action.ADMIN, Action.CREATE); }
828909_5
@Override public void preDeleteColumn(ObserverContext<MasterCoprocessorEnvironment> c, byte[] tableName, byte[] col) throws IOException { requirePermission(tableName, null, null, Action.ADMIN, Action.CREATE); }
828909_6
@Override public void preDisableTable(ObserverContext<MasterCoprocessorEnvironment> c, byte[] tableName) throws IOException { if (Bytes.equals(tableName, AccessControlLists.ACL_GLOBAL_NAME)) { throw new AccessDeniedException("Not allowed to disable " + AccessControlLists.ACL_TABLE_NAME_STR + " table."); } requirePermission(tableName, null, null, Action.ADMIN, Action.CREATE); }
828909_7
@Override public void preEnableTable(ObserverContext<MasterCoprocessorEnvironment> c, byte[] tableName) throws IOException { requirePermission(tableName, null, null, Action.ADMIN, Action.CREATE); }
828909_8
@Override public void preMove(ObserverContext<MasterCoprocessorEnvironment> c, HRegionInfo region, ServerName srcServer, ServerName destServer) throws IOException { requirePermission(region.getTableName(), null, null, Action.ADMIN); }
828909_9
@Override public void preAssign(ObserverContext<MasterCoprocessorEnvironment> c, HRegionInfo regionInfo) throws IOException { requirePermission(regionInfo.getTableName(), null, null, Action.ADMIN); }
832025_0
public POICategories getPOICategories() throws IOException { Response<PoiTypesDto> response = v2Api.getPOICategories().execute(); return response.body().toPOICategories(context); }
832025_1
public List<POI> getPOIs(final String type, final double lonW, final double latS, final double lonE, final double latN) throws IOException { String bbox = toBboxString(lonW, latS, lonE, latN); Response<FeatureCollection> response = v2Api.getPOIs(type, bbox).execute(); return PoiFactory.toPoiList(response.body()); }
832025_2
public List<POI> getPOIs(final String type, final double lonW, final double latS, final double lonE, final double latN) throws IOException { String bbox = toBboxString(lonW, latS, lonE, latN); Response<FeatureCollection> response = v2Api.getPOIs(type, bbox).execute(); return PoiFactory.toPoiList(response.body()); }
832025_3
public UserJourneys getUserJourneys(final String username) throws IOException { Response<UserJourneysDto> response = v2Api.getUserJourneys(username).execute(); return response.body().toUserJourneys(); }
832025_4
public Photos getPhotos(final double lonW, final double latS, final double lonE, final double latN) throws IOException { String bbox = toBboxString(lonW, latS, lonE, latN); Response<FeatureCollection> response = v2Api.getPhotos(bbox).execute(); return PhotosFactory.toPhotos(response.body()); }
832025_5
public GeoPlaces geoCoder(final String search, final double lonW, final double latS, final double lonE, final double latN) throws IOException { String bbox = toBboxString(lonW, latS, lonE, latN); Response<FeatureCollection> response = v2Api.geoCoder(search, bbox).execute(); return GeoPlacesFactory.toGeoPlaces(response.body()); }
832025_6
public Result register(final String username, final String password, final String name, final String email) throws IOException { Response<UserCreateResponseDto> response = v2Api.register(username, password, name, email).execute(); return response.body().toRegistrationResult(); }
832025_7
public Result register(final String username, final String password, final String name, final String email) throws IOException { Response<UserCreateResponseDto> response = v2Api.register(username, password, name, email).execute(); return response.body().toRegistrationResult(); }
832025_8
public Signin.Result authenticate(final String identifier, final String password) throws IOException { Response<UserAuthenticateResponseDto> response = v2Api.authenticate(identifier, password).execute(); return response.body().toSigninResult(); }
832025_9
public Result sendFeedback(final int itinerary, final String comments, final String name, final String email) throws IOException { Response<SendFeedbackResponseDto> response = v2Api.sendFeedback("routing", itinerary, comments, name, email).execute(); return response.body().toFeedbackResult(); }
832676_0
public static <T> Class<T> locate(Class<T> factoryId) { return locate(factoryId, factoryId.getName()); }
832676_1
public static <T> Class<T> locate(Class<T> factoryId) { return locate(factoryId, factoryId.getName()); }
832676_2
public static <T> Class<T> locate(Class<T> factoryId) { return locate(factoryId, factoryId.getName()); }
832676_3
public static <T> Class<T> locate(Class<T> factoryId) { return locate(factoryId, factoryId.getName()); }
832676_4
public void parse(Reader reader) throws IOException { BufferedReader br = new BufferedReader(reader); String line; while ((line = br.readLine()) != null) { if (!line.startsWith("#")) { parse(line); } } }
832676_5
public void parse(Reader reader) throws IOException { BufferedReader br = new BufferedReader(reader); String line; while ((line = br.readLine()) != null) { if (!line.startsWith("#")) { parse(line); } } }
832676_6
public static String getValueString(Object obj) { if (obj == null) { return "null"; } else if (obj instanceof boolean[]) { return Arrays.toString((boolean[]) obj); } else if (obj instanceof byte[]) { return Arrays.toString((byte[]) obj); } else if (obj instanceof char[]) { return Arrays.toString((char[]) obj); } else if (obj instanceof double[]) { return Arrays.toString((double[]) obj); } else if (obj instanceof float[]) { return Arrays.toString((float[]) obj); } else if (obj instanceof int[]) { return Arrays.toString((int[]) obj); } else if (obj instanceof long[]) { return Arrays.toString((long[]) obj); } else if (obj instanceof short[]) { return Arrays.toString((short[]) obj); } else if (obj instanceof Collection<?>) { Object[] array = ((Collection<?>) obj).toArray(); return getValueString(array); } else if (obj.getClass().isArray()) { Object[] array = (Object[]) obj; StringBuilder sb = new StringBuilder(); sb.append("["); for (int i = 0; i < array.length; i++) { if (i != 0) { sb.append(", "); } sb.append(getValueString(array[i])); } sb.append("]"); return sb.toString(); } else { return obj.toString(); } }
832676_7
public static String getValueString(Object obj) { if (obj == null) { return "null"; } else if (obj instanceof boolean[]) { return Arrays.toString((boolean[]) obj); } else if (obj instanceof byte[]) { return Arrays.toString((byte[]) obj); } else if (obj instanceof char[]) { return Arrays.toString((char[]) obj); } else if (obj instanceof double[]) { return Arrays.toString((double[]) obj); } else if (obj instanceof float[]) { return Arrays.toString((float[]) obj); } else if (obj instanceof int[]) { return Arrays.toString((int[]) obj); } else if (obj instanceof long[]) { return Arrays.toString((long[]) obj); } else if (obj instanceof short[]) { return Arrays.toString((short[]) obj); } else if (obj instanceof Collection<?>) { Object[] array = ((Collection<?>) obj).toArray(); return getValueString(array); } else if (obj.getClass().isArray()) { Object[] array = (Object[]) obj; StringBuilder sb = new StringBuilder(); sb.append("["); for (int i = 0; i < array.length; i++) { if (i != 0) { sb.append(", "); } sb.append(getValueString(array[i])); } sb.append("]"); return sb.toString(); } else { return obj.toString(); } }
832676_8
public static AnsiBufferedReader window(InputStream is, int begin, int end, int tabs) throws IOException { AnsiBufferedReader reader = new AnsiBufferedReader(is, begin, end, Integer.MAX_VALUE); reader.setTabs(tabs); return reader; }
832676_9
@Override public boolean verifyServerKey(ClientSession sshClientSession, SocketAddress remoteAddress, PublicKey serverKey) { PublicKey knownKey; try { knownKey = knownHostsManager.getKnownKey(remoteAddress, serverKey.getAlgorithm()); } catch (InvalidKeySpecException e) { System.err.println("Invalid key stored for host " + remoteAddress + ". Terminating session."); return false; } if (knownKey == null) { boolean confirm; if (!quiet) { System.out.println("Connecting to unknown server. Add this server to known hosts ? (y/n)"); confirm = getConfirmation(); } else { System.out.println("Connecting to unknown server. Automatically adding to known hosts."); confirm = true; } if (confirm) { knownHostsManager.storeKeyForHost(remoteAddress, serverKey); System.out.println("Storing the server key in known_hosts."); } else { System.out.println("Aborting connection"); } return confirm; } boolean verifed = (knownKey.equals(serverKey)); if (!verifed) { System.err.println("Server key for host " + remoteAddress + " does not match the stored key !! Terminating session."); System.err.println(keyChangedMessage); } return verifed; }
832679_0
public String toString() { StringBuilder resource = new StringBuilder(); for (String s : toStringList()) { if (resource.length() > 0) resource.append("\n"); resource.append(s); } return resource.toString(); }
832679_1
public String toString() { StringBuilder resource = new StringBuilder(); for (String s : toStringList()) { if (resource.length() > 0) resource.append("\n"); resource.append(s); } return resource.toString(); }
832679_2
public String toString() { StringBuilder resource = new StringBuilder(); for (String s : toStringList()) { if (resource.length() > 0) resource.append("\n"); resource.append(s); } return resource.toString(); }
832679_3
public String getHiera() { String name = getName(); StringBuilder result = new StringBuilder(); for (Map.Entry<String, String> entry : attribs.entrySet()) { result.append("\n" + name + "::" + entry.getKey() + ": " + entry.getValue()); } return result.toString(); }