id
stringlengths
7
14
text
stringlengths
1
106k
1421692_3
public static Class<?>[] getClasses(String packageName) throws ClassNotFoundException, IOException { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); assert classLoader != null; String path = packageName.replace('.', '/'); Enumeration<URL> resources = classLoader.getResources(path); List<File> dirs = new ArrayList<File>(); ArrayList<Class<?>> classes = new ArrayList<Class<?>>(); while (resources.hasMoreElements()) { URL resource = resources.nextElement(); String p = ""; if (resource.getFile().indexOf("!") >= 0) {// 在其他的jar文件中 p = resource.getFile().substring(0, resource.getFile().indexOf("!")).replaceAll("%20", ""); } else {// 在classes目录中 p = resource.getFile(); } if (p.startsWith("file:/")) p = p.substring(5); if (p.toLowerCase().endsWith(".jar")) { JarFile jarFile = new JarFile(p); Enumeration<JarEntry> enums = jarFile.entries(); while (enums.hasMoreElements()) { JarEntry entry = (JarEntry) enums.nextElement(); String n = entry.getName(); if (n.endsWith(".class")) { n = n.replaceAll("/", ".").substring(0, n.length() - 6); if (n.startsWith(packageName)) { classes.add(Class.forName(n)); } } } jarFile.close(); } else { dirs.add(new File(p)); } } for (File directory : dirs) { classes.addAll(findClasses(directory, packageName)); } return classes.toArray(new Class[classes.size()]); }
1421692_4
public boolean matches(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); for (int i = 0; i < 7; i++) { Field field = fields[i]; if (null != field && !field.isBlank() && !field.matches(calendar)) { return false; } } return true; }
1421692_5
public Date next(Date date) { Calendar calendar = new GregorianCalendar(); calendar.setTime(date); calendar.add(Calendar.SECOND, 1); calendar.set(Calendar.MILLISECOND, 0); next0(calendar); return calendar.getTime(); }
1421692_6
public boolean matches(Map<String, String> targets, BWResult result) throws IllegalStateException { return this.data.matches(targets, result); }
1421692_7
public static boolean containsKey(Map<?, ?> map, Object key) { if (null == map) { return false; } return map.containsKey(key); }
1421692_8
@SuppressWarnings("unchecked") public static Set<String> getKeys(Map<String, Object> map, Set<String> keys) { if (org.apache.commons.collections4.MapUtils.isEmpty(map)) { throw new IllegalArgumentException("map can not be null"); } if (org.apache.commons.collections4.CollectionUtils.isEmpty(keys)) { keys = new HashSet<String>(); } for (String key : map.keySet()) { if (!keys.contains(key)) { keys.add(key); } Object o = map.get(key); if (o instanceof Map) { getKeys((Map<String, Object>) o, keys); } else if (o instanceof List) { for (Object obj : (List<Object>) o) { if (obj instanceof Map) { getKeys((Map<String, Object>) obj, keys); } } } else if (o instanceof Object[]) { for (Object obj : (Object[]) o) { if (obj instanceof Map) { getKeys((Map<String, Object>) obj, keys); } } } } return keys; }
1421692_9
@SuppressWarnings("unchecked") public static Set<String> getKeys(Map<String, Object> map, Set<String> keys) { if (org.apache.commons.collections4.MapUtils.isEmpty(map)) { throw new IllegalArgumentException("map can not be null"); } if (org.apache.commons.collections4.CollectionUtils.isEmpty(keys)) { keys = new HashSet<String>(); } for (String key : map.keySet()) { if (!keys.contains(key)) { keys.add(key); } Object o = map.get(key); if (o instanceof Map) { getKeys((Map<String, Object>) o, keys); } else if (o instanceof List) { for (Object obj : (List<Object>) o) { if (obj instanceof Map) { getKeys((Map<String, Object>) obj, keys); } } } else if (o instanceof Object[]) { for (Object obj : (Object[]) o) { if (obj instanceof Map) { getKeys((Map<String, Object>) obj, keys); } } } } return keys; }
1443269_0
@Override public List<String> getClusterList(boolean useCache) { if (useCache) { return new ArrayList<String>(_clusters.get()); } long s = System.nanoTime(); try { checkIfOpen(); return _zk.getChildren(ZookeeperPathConstants.getClustersPath(), false); } catch (KeeperException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); } finally { long e = System.nanoTime(); LOG.debug("trace getClusterList [" + (e - s) / 1000000.0 + " ms]"); } }
1443269_1
@Override public boolean isInSafeMode(boolean useCache, String cluster) { if (useCache) { Long safeModeTimestamp = _safeModeMap.get(cluster); if (safeModeTimestamp != null && safeModeTimestamp != Long.MIN_VALUE) { return safeModeTimestamp < System.currentTimeMillis() ? false : true; } } long s = System.nanoTime(); try { checkIfOpen(); String blurSafemodePath = ZookeeperPathConstants.getSafemodePath(cluster); Stat stat = _zk.exists(blurSafemodePath, false); if (stat == null) { return false; } byte[] data = _zk.getData(blurSafemodePath, false, stat); if (data == null) { return false; } long timestamp = Long.parseLong(new String(data)); long waitTime = timestamp - System.currentTimeMillis(); if (waitTime > 0) { return true; } return false; } catch (KeeperException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); } finally { long e = System.nanoTime(); LOG.debug("trace isInSafeMode took [" + (e - s) / 1000000.0 + " ms]"); } }
1443269_2
@Override public boolean isInSafeMode(boolean useCache, String cluster) { if (useCache) { Long safeModeTimestamp = _safeModeMap.get(cluster); if (safeModeTimestamp != null && safeModeTimestamp != Long.MIN_VALUE) { return safeModeTimestamp < System.currentTimeMillis() ? false : true; } } long s = System.nanoTime(); try { checkIfOpen(); String blurSafemodePath = ZookeeperPathConstants.getSafemodePath(cluster); Stat stat = _zk.exists(blurSafemodePath, false); if (stat == null) { return false; } byte[] data = _zk.getData(blurSafemodePath, false, stat); if (data == null) { return false; } long timestamp = Long.parseLong(new String(data)); long waitTime = timestamp - System.currentTimeMillis(); if (waitTime > 0) { return true; } return false; } catch (KeeperException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); } finally { long e = System.nanoTime(); LOG.debug("trace isInSafeMode took [" + (e - s) / 1000000.0 + " ms]"); } }
1443269_3
@Override public boolean isInSafeMode(boolean useCache, String cluster) { if (useCache) { Long safeModeTimestamp = _safeModeMap.get(cluster); if (safeModeTimestamp != null && safeModeTimestamp != Long.MIN_VALUE) { return safeModeTimestamp < System.currentTimeMillis() ? false : true; } } long s = System.nanoTime(); try { checkIfOpen(); String blurSafemodePath = ZookeeperPathConstants.getSafemodePath(cluster); Stat stat = _zk.exists(blurSafemodePath, false); if (stat == null) { return false; } byte[] data = _zk.getData(blurSafemodePath, false, stat); if (data == null) { return false; } long timestamp = Long.parseLong(new String(data)); long waitTime = timestamp - System.currentTimeMillis(); if (waitTime > 0) { return true; } return false; } catch (KeeperException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); } finally { long e = System.nanoTime(); LOG.debug("trace isInSafeMode took [" + (e - s) / 1000000.0 + " ms]"); } }
1443269_4
@Override public String getCluster(boolean useCache, String table) { if (useCache) { for (Entry<String, Set<String>> entry : _tablesPerCluster.entrySet()) { if (entry.getValue().contains(table)) { return entry.getKey(); } } } List<String> clusterList = getClusterList(useCache); for (String cluster : clusterList) { long s = System.nanoTime(); try { checkIfOpen(); Stat stat = _zk.exists(ZookeeperPathConstants.getTablePath(cluster, table), false); if (stat != null) { // _tableToClusterCache.put(table, cluster); return cluster; } } catch (KeeperException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); } finally { long e = System.nanoTime(); LOG.debug("trace getCluster took [" + (e - s) / 1000000.0 + " ms]"); } } return null; }
1443269_5
@Override public List<String> getTableList(boolean useCache, String cluster) { if (useCache) { Set<String> tables = _tablesPerCluster.get(cluster); if (tables != null) { return new ArrayList<String>(tables); } } long s = System.nanoTime(); try { checkIfOpen(); return _zk.getChildren(ZookeeperPathConstants.getTablesPath(cluster), false); } catch (KeeperException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); } finally { long e = System.nanoTime(); LOG.debug("trace getTableList took [" + (e - s) / 1000000.0 + " ms]"); } }
1443269_6
@Override public boolean isEnabled(boolean useCache, String cluster, String table) { if (useCache) { Boolean e = _enabled.get(getClusterTableKey(cluster, table)); if (e != null) { return e; } } long s = System.nanoTime(); String tablePathIsEnabled = ZookeeperPathConstants.getTableEnabledPath(cluster, table); try { checkIfOpen(); if (_zk.exists(tablePathIsEnabled, false) == null) { return false; } } catch (KeeperException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); } finally { long e = System.nanoTime(); LOG.debug("trace isEnabled took [" + (e - s) / 1000000.0 + " ms]"); } return true; }
1443269_7
public void fetchRow(String table, Selector selector, FetchResult fetchResult) throws BlurException { validSelector(selector); BlurIndex index; try { if (selector.getLocationId() == null) { populateSelector(table, selector); } String locationId = selector.getLocationId(); if (locationId.equals(NOT_FOUND)) { fetchResult.setDeleted(false); fetchResult.setExists(false); return; } String shard = getShard(locationId); Map<String, BlurIndex> blurIndexes = _indexServer.getIndexes(table); if (blurIndexes == null) { LOG.error("Table [{0}] not found", table); throw new BlurException("Table [" + table + "] not found", null); } index = blurIndexes.get(shard); if (index == null) { if (index == null) { LOG.error("Shard [{0}] not found in table [{1}]", shard, table); throw new BlurException("Shard [" + shard + "] not found in table [" + table + "]", null); } } } catch (BlurException e) { throw e; } catch (Exception e) { LOG.error("Unknown error while trying to get the correct index reader for selector [{0}].", e, selector); throw new BException(e.getMessage(), e); } IndexReader reader = null; try { reader = index.getIndexReader(); fetchRow(reader, table, selector, fetchResult); if (_blurMetrics != null) { if (fetchResult.rowResult != null) { if (fetchResult.rowResult.row != null && fetchResult.rowResult.row.records != null) { _blurMetrics.recordReads.addAndGet(fetchResult.rowResult.row.records.size()); } _blurMetrics.rowReads.incrementAndGet(); } else if (fetchResult.recordResult != null) { _blurMetrics.recordReads.incrementAndGet(); } } } catch (Exception e) { LOG.error("Unknown error while trying to fetch row.", e); throw new BException(e.getMessage(), e); } finally { if (reader != null) { // this will allow for closing of index try { reader.decRef(); } catch (IOException e) { LOG.error("Unknown error trying to call decRef on reader [{0}]", e, reader); } } } }
1443269_8
public void fetchRow(String table, Selector selector, FetchResult fetchResult) throws BlurException { validSelector(selector); BlurIndex index; try { if (selector.getLocationId() == null) { populateSelector(table, selector); } String locationId = selector.getLocationId(); if (locationId.equals(NOT_FOUND)) { fetchResult.setDeleted(false); fetchResult.setExists(false); return; } String shard = getShard(locationId); Map<String, BlurIndex> blurIndexes = _indexServer.getIndexes(table); if (blurIndexes == null) { LOG.error("Table [{0}] not found", table); throw new BlurException("Table [" + table + "] not found", null); } index = blurIndexes.get(shard); if (index == null) { if (index == null) { LOG.error("Shard [{0}] not found in table [{1}]", shard, table); throw new BlurException("Shard [" + shard + "] not found in table [" + table + "]", null); } } } catch (BlurException e) { throw e; } catch (Exception e) { LOG.error("Unknown error while trying to get the correct index reader for selector [{0}].", e, selector); throw new BException(e.getMessage(), e); } IndexReader reader = null; try { reader = index.getIndexReader(); fetchRow(reader, table, selector, fetchResult); if (_blurMetrics != null) { if (fetchResult.rowResult != null) { if (fetchResult.rowResult.row != null && fetchResult.rowResult.row.records != null) { _blurMetrics.recordReads.addAndGet(fetchResult.rowResult.row.records.size()); } _blurMetrics.rowReads.incrementAndGet(); } else if (fetchResult.recordResult != null) { _blurMetrics.recordReads.incrementAndGet(); } } } catch (Exception e) { LOG.error("Unknown error while trying to fetch row.", e); throw new BException(e.getMessage(), e); } finally { if (reader != null) { // this will allow for closing of index try { reader.decRef(); } catch (IOException e) { LOG.error("Unknown error trying to call decRef on reader [{0}]", e, reader); } } } }
1443269_9
public void fetchRow(String table, Selector selector, FetchResult fetchResult) throws BlurException { validSelector(selector); BlurIndex index; try { if (selector.getLocationId() == null) { populateSelector(table, selector); } String locationId = selector.getLocationId(); if (locationId.equals(NOT_FOUND)) { fetchResult.setDeleted(false); fetchResult.setExists(false); return; } String shard = getShard(locationId); Map<String, BlurIndex> blurIndexes = _indexServer.getIndexes(table); if (blurIndexes == null) { LOG.error("Table [{0}] not found", table); throw new BlurException("Table [" + table + "] not found", null); } index = blurIndexes.get(shard); if (index == null) { if (index == null) { LOG.error("Shard [{0}] not found in table [{1}]", shard, table); throw new BlurException("Shard [" + shard + "] not found in table [" + table + "]", null); } } } catch (BlurException e) { throw e; } catch (Exception e) { LOG.error("Unknown error while trying to get the correct index reader for selector [{0}].", e, selector); throw new BException(e.getMessage(), e); } IndexReader reader = null; try { reader = index.getIndexReader(); fetchRow(reader, table, selector, fetchResult); if (_blurMetrics != null) { if (fetchResult.rowResult != null) { if (fetchResult.rowResult.row != null && fetchResult.rowResult.row.records != null) { _blurMetrics.recordReads.addAndGet(fetchResult.rowResult.row.records.size()); } _blurMetrics.rowReads.incrementAndGet(); } else if (fetchResult.recordResult != null) { _blurMetrics.recordReads.incrementAndGet(); } } } catch (Exception e) { LOG.error("Unknown error while trying to fetch row.", e); throw new BException(e.getMessage(), e); } finally { if (reader != null) { // this will allow for closing of index try { reader.decRef(); } catch (IOException e) { LOG.error("Unknown error trying to call decRef on reader [{0}]", e, reader); } } } }
1446919_0
public void process( int number ) { /* The same as above */ for ( int i = 0; i < number; i++) { everyTime( i ); if ( i % blockSize == blockSize - 1 || i == number - 1 ) { everyBlock( i ); } } blocksComplete(); }
1446919_1
public void process( int number ) { /* The same as above */ for ( int i = 0; i < number; i++) { everyTime( i ); if ( i % blockSize == blockSize - 1 || i == number - 1 ) { everyBlock( i ); } } blocksComplete(); }
1446919_2
public void process( int number ) { /* The same as above */ for ( int i = 0; i < number; i++) { everyTime( i ); if ( i % blockSize == blockSize - 1 || i == number - 1 ) { everyBlock( i ); } } blocksComplete(); }
1446919_3
public void process( int number ) { /* The same as above */ for ( int i = 0; i < number; i++) { everyTime( i ); if ( i % blockSize == blockSize - 1 || i == number - 1 ) { everyBlock( i ); } } blocksComplete(); }
1446919_4
public String get() throws DataFormatException { return decode(encodedData); }
1446919_5
public float getScore(float scoreFactor) { assert inverseValueAtBoundary >= 1f : "value at boundary must be <= 1, so inverse must be >= 1"; // scoreFactor: 1.0 -> -infinity (any negative value) // turn into range of zero -> infinity float x = 1.0f - scoreFactor; // Power up our scoreFactor to give our squareness. // pow() ensures that 0.0 and 1.0 points stay same. float result = getValue( Math.pow(x, squareness) ); return result; }
1446919_6
public String checkName(String name) { build(); String rval = checkName(name, malesDB); if (rval == null) { rval = checkName(name, femalesDB); } return rval; }
1446919_7
public String checkName(String name) { build(); String rval = checkName(name, malesDB); if (rval == null) { rval = checkName(name, femalesDB); } return rval; }
1446919_8
public String checkName(String name) { build(); String rval = checkName(name, malesDB); if (rval == null) { rval = checkName(name, femalesDB); } return rval; }
1446919_9
public String checkName(String name) { build(); String rval = checkName(name, malesDB); if (rval == null) { rval = checkName(name, femalesDB); } return rval; }
1450115_0
public DerivedBuilder derive() { return new Builder(this); }
1450115_1
@Override public final Void onCompleted() { if (delegateTerminated.getAndSet(true)) { return null; } final T result; try { result = delegate().onCompleted(); } catch (final Throwable t) { emitOnError(t); return null; } if (!emitter.isDisposed()) { if (result == null) { emitter.onComplete(); } else { emitter.onSuccess(result); } } return null; }
1450115_2
@Override public final void onThrowable(Throwable t) { if (delegateTerminated.getAndSet(true)) { return; } Throwable error = t; try { delegate().onThrowable(t); } catch (final Throwable x) { error = new CompositeException(Arrays.asList(t, x)); } emitOnError(error); }
1450115_3
@Override public final Void onCompleted() { if (delegateTerminated.getAndSet(true)) { return null; } final T result; try { result = delegate().onCompleted(); } catch (final Throwable t) { emitOnError(t); return null; } if (!emitter.isDisposed()) { if (result == null) { emitter.onComplete(); } else { emitter.onSuccess(result); } } return null; }
1450115_4
@Override public final void onThrowable(Throwable t) { if (delegateTerminated.getAndSet(true)) { return; } Throwable error = t; try { delegate().onThrowable(t); } catch (final Throwable x) { error = new CompositeException(Arrays.asList(t, x)); } emitOnError(error); }
1450115_5
@Override public final Void onCompleted() { if (delegateTerminated.getAndSet(true)) { return null; } final T result; try { result = delegate().onCompleted(); } catch (final Throwable t) { emitOnError(t); return null; } if (!emitter.isDisposed()) { if (result == null) { emitter.onComplete(); } else { emitter.onSuccess(result); } } return null; }
1450115_6
@Override public final void onThrowable(Throwable t) { if (delegateTerminated.getAndSet(true)) { return; } Throwable error = t; try { delegate().onThrowable(t); } catch (final Throwable x) { error = new CompositeException(Arrays.asList(t, x)); } emitOnError(error); }
1450115_7
@Override public final void onThrowable(Throwable t) { if (delegateTerminated.getAndSet(true)) { return; } Throwable error = t; try { delegate().onThrowable(t); } catch (final Throwable x) { error = new CompositeException(Arrays.asList(t, x)); } emitOnError(error); }
1450115_8
@Override public final void onThrowable(Throwable t) { if (delegateTerminated.getAndSet(true)) { return; } Throwable error = t; try { delegate().onThrowable(t); } catch (final Throwable x) { error = new CompositeException(Arrays.asList(t, x)); } emitOnError(error); }
1450115_9
@Override public <T> Maybe<T> prepare(Request request, Supplier<? extends AsyncHandler<T>> handlerSupplier) { requireNonNull(request); requireNonNull(handlerSupplier); return Maybe.create(emitter -> { final AsyncHandler<?> bridge = createBridge(emitter, handlerSupplier.get()); final Future<?> responseFuture = asyncHttpClient.executeRequest(request, bridge); emitter.setDisposable(Disposables.fromFuture(responseFuture)); }); }
1452945_0
public AbstractPE getPE(String keyValue) { AbstractPE pe = null; try { pe = (AbstractPE) lookupTable.get(keyValue); if (pe == null) { pe = (AbstractPE) prototype.clone(); pe.initInstance(); } // update the last update time on the entry lookupTable.set(keyValue, pe, prototype.getTtl()); } catch (Exception e) { logger.error("exception when looking up pe for key:" + keyValue, e); } return pe; }
1458461_0
public void setPersistenceUnit(String pU) { this.persistenceUnit = pU; }
1458461_1
public void setPropertyFile(File file) { this.propertyFile = file; }
1458461_2
public void setConfigFile(File file) { this.configFile = file; }
1458461_3
public void setType(String type) { this.type = Type.valueOf(type.toUpperCase()); }
1458461_4
public void addConfiguredFileSet(FileSet fileSet) { fileSets.add(fileSet); }
1458461_5
public MetadataTask createMetadata() { this.metadataTask = new MetadataTask(); return this.metadataTask; }
1458461_6
public ExportDdlTask createExportDdl() { return new ExportDdlTask(); }
1458461_7
public ExportCfgTask createExportCfg() { this.exportCfgTask = new ExportCfgTask(this); return this.exportCfgTask; }
1458461_8
public void execute() { if (exportCfgTask != null) { exportCfgTask.getProperties().put( ExporterConstants.METADATA_DESCRIPTOR, metadataTask.createMetadataDescriptor()); exportCfgTask.execute(); } }
1458461_9
public ExportCfgTask(HibernateToolTask parent) { this.parent = parent; }
1459400_0
public void clear() throws IOException { rewound = false; diskObjectCount = 0; list.clear(); if (raFile != null) { raFile.seek(0); raFile.setLength(0); } }
1459953_0
@Override public JndiDTO[] getData() throws NamingException { return list(""); }
1459953_1
@Override public JndiDTO[] list(final String name) throws NamingException { return execute(new ContextCallback<JndiDTO[]>() { @Override public JndiDTO[] doInJndi(Context context) throws NamingException { NamingEnumeration<NameClassPair> namingEnum=null; try { namingEnum=context.list(fixName(name)); String prefix=name==null||name.isEmpty()?"":name+"/"; List<JndiDTO> namingDatas=new ArrayList<JndiDTO>(); while(namingEnum.hasMore()) { NameClassPair nameClassPair=namingEnum.next(); String simpleName=nameClassPair.getName(); String fullName=prefix+simpleName; if (nameClassPair instanceof Binding) { Binding binding=(Binding) nameClassPair; namingDatas.add(createData(context, fullName, simpleName, nameClassPair.getClassName(), binding.getObject())); } else { namingDatas.add(createData(context, fullName, simpleName, nameClassPair.getClassName(), null)); } } return namingDatas.toArray(new JndiDTO[namingDatas.size()]); } finally { if (namingEnum!=null) { namingEnum.close(); } } } }); }
1459953_2
@Override public JndiDTO lookup(final String name) throws NamingException { return execute(new ContextCallback<JndiDTO>() { @Override public JndiDTO doInJndi(Context context) throws NamingException { String fullName=fixName(name); String simpleName; Object object; if (fullName.isEmpty()) { object = context; simpleName = ""; } else { object=context.lookup(fullName); simpleName=null; } if (object==null) { return null; } return createData(context, fullName, simpleName, object.getClass().getName(), object); } }); }
1459953_3
public Contact createContact(String firstname, String lastname) { Contact contact = new Contact(); contact.setFirstname(firstname); contact.setLastname(lastname); contactDao.createContact(contact); return contact; }
1459953_4
public static <I, O> Function<I, Try<O>> of(ThrowingFunction<I, O> function) { return input -> { try { O result = function.apply(input); return new Success<>(result); } catch (RuntimeException e) { throw e; // we don't want to wrap runtime exceptions } catch (Exception e) { return new Failure<>(e); } }; }
1459953_5
public <F> Try<F> map(Function<E, F> mapper) { return flatMap(of(result -> mapper.apply(result))); }
1459953_6
public Optional<E> toOption() { return isSuccess() ? Optional.ofNullable(asSuccess().getResult()) : Optional.<E>empty(); }
1459953_7
public Optional<E> toOption() { return isSuccess() ? Optional.ofNullable(asSuccess().getResult()) : Optional.<E>empty(); }
1459953_8
public static <I, O> Function<I, Try<O>> of(ThrowingFunction<I, O> function) { return input -> { try { O result = function.apply(input); return new Success<>(result); } catch (RuntimeException e) { throw e; // we don't want to wrap runtime exceptions } catch (Exception e) { return new Failure<>(e); } }; }
1459953_9
public static <E> Collector<Try<E>, ?, Map<Type, List<Try<E>>>> groupingBySuccess() { return Collectors.groupingBy(t -> t.getType()); }
1463490_0
@Override public void execute() throws MojoExecutionException, MojoFailureException { try { JAXBContext context = JAXBContext.newInstance("org.xwiki.rest.model.jaxb"); Unmarshaller unmarshaller = context.createUnmarshaller(); Marshaller marshaller = context.createMarshaller(); HttpClient httpClient = new HttpClient(); httpClient.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(this.username, this.password)); httpClient.getParams().setAuthenticationPreemptive(true); installExtensions(marshaller, unmarshaller, httpClient); } catch (Exception e) { throw new MojoExecutionException("Failed to install Extension(s) into XWiki", e); } }
1463490_1
@Override protected void validate(Document document) { // RPD 1 validateRpd1s1(); validateRpd1s2(); validateRpd1s3(); // RPD 2 validateRpd2s1(); validateRpd2s2(); validateRpd2s3(); validateRpd2s4(); validateRpd2s5(); validateRpd2s6(); validateRpd2s7(); validateRpd2s8(); validateRpd2s9(); // RPD 3 validateRpd3s1(); validateRpd3s2(); validateRpd3s3(); validateRpd3s4(); validateRpd3s5(); validateRpd3s6(); validateRpd3s7(); validateRpd3s8(); validateRpd3s9(); validateRpd3s10(); validateRpd3s11(); validateRpd3s12(); validateRpd3s13(); validateRpd3s14(); validateRpd3s15(); // RPD 4 validateRpd4s1(); validateRpd4s2(); validateRpd4s3(); validateRpd4s4(); validateRpd4s5(); validateRpd4s6(); validateRpd4s7(); // RPD 5 validateRpd5s1(); // RPD 6 validateRpd6s1(); validateRpd6s2(); // RPD 7 validateRpd7s1(); validateRpd7s2(); validateRpd7s3(); validateRpd7s4(); validateRpd7s5(); validateRpd7s6(); validateRpd7s7(); // RPD 8 validateRpd8s1(); validateRpd8s2(); validateRpd8s3(); validateRpd8s4(); validateRpd8s5(); validateRpd8s6(); validateRpd8s7(); validateRpd8s8(); validateRpd8s9(); validateRpd8s10(); validateRpd8s11(); validateRpd8s12(); validateRpd8s13(); validateRpd8s14(); validateRpd8s15(); validateRpd8s16(); validateRpd8s17(); validateRpd8s18(); validateRpd8s19(); validateRpd8s20(); validateRpd8s21(); validateRpd8s22(); validateRpd8s23(); // RPD 9 validateRpd9s1(); validateRpd9s2(); // RPD 10 validateRpd10s1(); validateRpd10s2(); validateRpd10s3(); // RPD 11 validateRpd11s1(); validateRpd11s2(); validateRpd11s3(); validateRpd11s4(); validateRpd11s5(); validateRpd11s6(); validateRpd11s7(); validateRpd11s8(); validateRpd11s9(); validateRpd11s10(); // RPD 12 validateRpd12s1(); // RPD 13 validateRpd13s1(); validateRpd13s2(); validateRpd13s3(); validateRpd13s4(); validateRpd13s5(); validateRpd13s6(); validateRpd13s7(); validateRpd13s8(); validateRpd13s9(); validateRpd13s10(); validateRpd13s11(); validateRpd13s12(); validateRpd13s13(); validateRpd13s14(); validateRpd13s15(); validateRpd13s16(); validateRpd13s17(); validateRpd13s18(); // RPD 14 validateRpd14s1(); // RPD 15 validateRpd15s1(); validateRpd15s2(); validateRpd15s3(); validateRpd15s4(); validateRpd15s5(); validateRpd15s6(); validateRpd15s7(); // RPD 16 validateRpd16s1(); validateRpd16s2(); validateRpd16s3(); validateRpd16s4(); // RPD 18 validateRpd18s1(); validateRpd18s2(); // RPD 22 validateRpd22s1(); validateRpd22s2(); validateRpd22s3(); validateRpd22s4(); validateRpd22s5(); validateRpd22s6(); validateRpd22s7(); validateRpd22s8(); validateRpd22s9(); validateRpd22s10(); }
1463490_2
@Override protected void validate(Document document) { // RPD 1 validateRpd1s1(); validateRpd1s2(); validateRpd1s3(); // RPD 2 validateRpd2s1(); validateRpd2s2(); validateRpd2s3(); validateRpd2s4(); validateRpd2s5(); validateRpd2s6(); validateRpd2s7(); validateRpd2s8(); validateRpd2s9(); // RPD 3 validateRpd3s1(); validateRpd3s2(); validateRpd3s3(); validateRpd3s4(); validateRpd3s5(); validateRpd3s6(); validateRpd3s7(); validateRpd3s8(); validateRpd3s9(); validateRpd3s10(); validateRpd3s11(); validateRpd3s12(); validateRpd3s13(); validateRpd3s14(); validateRpd3s15(); // RPD 4 validateRpd4s1(); validateRpd4s2(); validateRpd4s3(); validateRpd4s4(); validateRpd4s5(); validateRpd4s6(); validateRpd4s7(); // RPD 5 validateRpd5s1(); // RPD 6 validateRpd6s1(); validateRpd6s2(); // RPD 7 validateRpd7s1(); validateRpd7s2(); validateRpd7s3(); validateRpd7s4(); validateRpd7s5(); validateRpd7s6(); validateRpd7s7(); // RPD 8 validateRpd8s1(); validateRpd8s2(); validateRpd8s3(); validateRpd8s4(); validateRpd8s5(); validateRpd8s6(); validateRpd8s7(); validateRpd8s8(); validateRpd8s9(); validateRpd8s10(); validateRpd8s11(); validateRpd8s12(); validateRpd8s13(); validateRpd8s14(); validateRpd8s15(); validateRpd8s16(); validateRpd8s17(); validateRpd8s18(); validateRpd8s19(); validateRpd8s20(); validateRpd8s21(); validateRpd8s22(); validateRpd8s23(); // RPD 9 validateRpd9s1(); validateRpd9s2(); // RPD 10 validateRpd10s1(); validateRpd10s2(); validateRpd10s3(); // RPD 11 validateRpd11s1(); validateRpd11s2(); validateRpd11s3(); validateRpd11s4(); validateRpd11s5(); validateRpd11s6(); validateRpd11s7(); validateRpd11s8(); validateRpd11s9(); validateRpd11s10(); // RPD 12 validateRpd12s1(); // RPD 13 validateRpd13s1(); validateRpd13s2(); validateRpd13s3(); validateRpd13s4(); validateRpd13s5(); validateRpd13s6(); validateRpd13s7(); validateRpd13s8(); validateRpd13s9(); validateRpd13s10(); validateRpd13s11(); validateRpd13s12(); validateRpd13s13(); validateRpd13s14(); validateRpd13s15(); validateRpd13s16(); validateRpd13s17(); validateRpd13s18(); // RPD 14 validateRpd14s1(); // RPD 15 validateRpd15s1(); validateRpd15s2(); validateRpd15s3(); validateRpd15s4(); validateRpd15s5(); validateRpd15s6(); validateRpd15s7(); // RPD 16 validateRpd16s1(); validateRpd16s2(); validateRpd16s3(); validateRpd16s4(); // RPD 18 validateRpd18s1(); validateRpd18s2(); // RPD 22 validateRpd22s1(); validateRpd22s2(); validateRpd22s3(); validateRpd22s4(); validateRpd22s5(); validateRpd22s6(); validateRpd22s7(); validateRpd22s8(); validateRpd22s9(); validateRpd22s10(); }
1463490_3
public void validateRpd1s3() { // Links validation. Elements linkElements = getElements("a"); // Links must not use javascript in href. for (String hrefValue : getAttributeValues(linkElements, "href")) { assertFalse(Type.ERROR, "rpd1s3.javascript", hrefValue.startsWith("javascript:")); } // Links must not use the attributes listed below. List<String> forbiddenAttributes = Arrays.asList(ATTR_BLUR, ATTR_CHANGE, ATTR_CLICK, ATTR_FOCUS, ATTR_LOAD, ATTR_MOUSEOVER, ATTR_SELECT, ATTR_SELECT, ATTR_UNLOAD); for (Element linkElement : linkElements) { if (!ListUtils.intersection(getAttributeNames(linkElement), forbiddenAttributes).isEmpty()) { assertFalse(Type.ERROR, "rpd1s3.inlineEventHandlers", getAttributeValue(linkElement, ATTR_HREF).equals( "") || getAttributeValue(linkElement, ATTR_HREF).equals("#")); } } validateRpd1s3AboutForms(); }
1463490_4
public void validateRpd1s3() { // Links validation. Elements linkElements = getElements("a"); // Links must not use javascript in href. for (String hrefValue : getAttributeValues(linkElements, "href")) { assertFalse(Type.ERROR, "rpd1s3.javascript", hrefValue.startsWith("javascript:")); } // Links must not use the attributes listed below. List<String> forbiddenAttributes = Arrays.asList(ATTR_BLUR, ATTR_CHANGE, ATTR_CLICK, ATTR_FOCUS, ATTR_LOAD, ATTR_MOUSEOVER, ATTR_SELECT, ATTR_SELECT, ATTR_UNLOAD); for (Element linkElement : linkElements) { if (!ListUtils.intersection(getAttributeNames(linkElement), forbiddenAttributes).isEmpty()) { assertFalse(Type.ERROR, "rpd1s3.inlineEventHandlers", getAttributeValue(linkElement, ATTR_HREF).equals( "") || getAttributeValue(linkElement, ATTR_HREF).equals("#")); } } validateRpd1s3AboutForms(); }
1463490_5
public void validateRpd1s3() { // Links validation. Elements linkElements = getElements("a"); // Links must not use javascript in href. for (String hrefValue : getAttributeValues(linkElements, "href")) { assertFalse(Type.ERROR, "rpd1s3.javascript", hrefValue.startsWith("javascript:")); } // Links must not use the attributes listed below. List<String> forbiddenAttributes = Arrays.asList(ATTR_BLUR, ATTR_CHANGE, ATTR_CLICK, ATTR_FOCUS, ATTR_LOAD, ATTR_MOUSEOVER, ATTR_SELECT, ATTR_SELECT, ATTR_UNLOAD); for (Element linkElement : linkElements) { if (!ListUtils.intersection(getAttributeNames(linkElement), forbiddenAttributes).isEmpty()) { assertFalse(Type.ERROR, "rpd1s3.inlineEventHandlers", getAttributeValue(linkElement, ATTR_HREF).equals( "") || getAttributeValue(linkElement, ATTR_HREF).equals("#")); } } validateRpd1s3AboutForms(); }
1463490_6
public void validateRpd1s3() { // Links validation. Elements linkElements = getElements("a"); // Links must not use javascript in href. for (String hrefValue : getAttributeValues(linkElements, "href")) { assertFalse(Type.ERROR, "rpd1s3.javascript", hrefValue.startsWith("javascript:")); } // Links must not use the attributes listed below. List<String> forbiddenAttributes = Arrays.asList(ATTR_BLUR, ATTR_CHANGE, ATTR_CLICK, ATTR_FOCUS, ATTR_LOAD, ATTR_MOUSEOVER, ATTR_SELECT, ATTR_SELECT, ATTR_UNLOAD); for (Element linkElement : linkElements) { if (!ListUtils.intersection(getAttributeNames(linkElement), forbiddenAttributes).isEmpty()) { assertFalse(Type.ERROR, "rpd1s3.inlineEventHandlers", getAttributeValue(linkElement, ATTR_HREF).equals( "") || getAttributeValue(linkElement, ATTR_HREF).equals("#")); } } validateRpd1s3AboutForms(); }
1463490_7
public void validateRpd1s3() { // Links validation. Elements linkElements = getElements("a"); // Links must not use javascript in href. for (String hrefValue : getAttributeValues(linkElements, "href")) { assertFalse(Type.ERROR, "rpd1s3.javascript", hrefValue.startsWith("javascript:")); } // Links must not use the attributes listed below. List<String> forbiddenAttributes = Arrays.asList(ATTR_BLUR, ATTR_CHANGE, ATTR_CLICK, ATTR_FOCUS, ATTR_LOAD, ATTR_MOUSEOVER, ATTR_SELECT, ATTR_SELECT, ATTR_UNLOAD); for (Element linkElement : linkElements) { if (!ListUtils.intersection(getAttributeNames(linkElement), forbiddenAttributes).isEmpty()) { assertFalse(Type.ERROR, "rpd1s3.inlineEventHandlers", getAttributeValue(linkElement, ATTR_HREF).equals( "") || getAttributeValue(linkElement, ATTR_HREF).equals("#")); } } validateRpd1s3AboutForms(); }
1463490_8
public void validateRpd1s3() { // Links validation. Elements linkElements = getElements("a"); // Links must not use javascript in href. for (String hrefValue : getAttributeValues(linkElements, "href")) { assertFalse(Type.ERROR, "rpd1s3.javascript", hrefValue.startsWith("javascript:")); } // Links must not use the attributes listed below. List<String> forbiddenAttributes = Arrays.asList(ATTR_BLUR, ATTR_CHANGE, ATTR_CLICK, ATTR_FOCUS, ATTR_LOAD, ATTR_MOUSEOVER, ATTR_SELECT, ATTR_SELECT, ATTR_UNLOAD); for (Element linkElement : linkElements) { if (!ListUtils.intersection(getAttributeNames(linkElement), forbiddenAttributes).isEmpty()) { assertFalse(Type.ERROR, "rpd1s3.inlineEventHandlers", getAttributeValue(linkElement, ATTR_HREF).equals( "") || getAttributeValue(linkElement, ATTR_HREF).equals("#")); } } validateRpd1s3AboutForms(); }
1463490_9
public void validateRpd1s3() { // Links validation. Elements linkElements = getElements("a"); // Links must not use javascript in href. for (String hrefValue : getAttributeValues(linkElements, "href")) { assertFalse(Type.ERROR, "rpd1s3.javascript", hrefValue.startsWith("javascript:")); } // Links must not use the attributes listed below. List<String> forbiddenAttributes = Arrays.asList(ATTR_BLUR, ATTR_CHANGE, ATTR_CLICK, ATTR_FOCUS, ATTR_LOAD, ATTR_MOUSEOVER, ATTR_SELECT, ATTR_SELECT, ATTR_UNLOAD); for (Element linkElement : linkElements) { if (!ListUtils.intersection(getAttributeNames(linkElement), forbiddenAttributes).isEmpty()) { assertFalse(Type.ERROR, "rpd1s3.inlineEventHandlers", getAttributeValue(linkElement, ATTR_HREF).equals( "") || getAttributeValue(linkElement, ATTR_HREF).equals("#")); } } validateRpd1s3AboutForms(); }
1469749_0
public boolean match(String ipIn) throws IPMatcherException { byte[] candidate; if (ipIn.indexOf(':') < 0) { candidate = new byte[4]; ipToBytes(ipIn, candidate, true); candidate = ip4ToIp6(candidate); } else try { candidate = Inet6Address.getByName(ipIn).getAddress(); } catch (UnknownHostException e) { throw new IPMatcherException("Malformed IPv6 address ",e); } for (int i = 0; i < netmask.length; i++) { if ((candidate[i] & netmask[i]) != (network[i] & netmask[i])) { return false; } } return true; }
1469749_1
public boolean match(String ipIn) throws IPMatcherException { byte[] candidate; if (ipIn.indexOf(':') < 0) { candidate = new byte[4]; ipToBytes(ipIn, candidate, true); candidate = ip4ToIp6(candidate); } else try { candidate = Inet6Address.getByName(ipIn).getAddress(); } catch (UnknownHostException e) { throw new IPMatcherException("Malformed IPv6 address ",e); } for (int i = 0; i < netmask.length; i++) { if ((candidate[i] & netmask[i]) != (network[i] & netmask[i])) { return false; } } return true; }
1469749_2
public boolean match(String ipIn) throws IPMatcherException { byte[] candidate; if (ipIn.indexOf(':') < 0) { candidate = new byte[4]; ipToBytes(ipIn, candidate, true); candidate = ip4ToIp6(candidate); } else try { candidate = Inet6Address.getByName(ipIn).getAddress(); } catch (UnknownHostException e) { throw new IPMatcherException("Malformed IPv6 address ",e); } for (int i = 0; i < netmask.length; i++) { if ((candidate[i] & netmask[i]) != (network[i] & netmask[i])) { return false; } } return true; }
1469749_3
public DSpaceCSV(boolean exportAll) { // Initialise the class init(); // Store the exportAll setting this.exportAll = exportAll; }
1469749_4
static Item create(Context context) throws SQLException, AuthorizeException { TableRow row = DatabaseManager.create(context, "item"); Item i = new Item(context, row); // Call update to give the item a last modified date. OK this isn't // amazingly efficient but creates don't happen that often. context.turnOffAuthorisationSystem(); i.update(); context.restoreAuthSystemState(); context.addEvent(new Event(Event.CREATE, Constants.ITEM, i.getID(), null)); log.info(LogManager.getHeader(context, "create_item", "item_id=" + row.getIntColumn("item_id"))); return i; }
1469749_5
public static ItemIterator findAll(Context context) throws SQLException { String myQuery = "SELECT * FROM item WHERE in_archive='1'"; TableRowIterator rows = DatabaseManager.queryTable(context, "item", myQuery); return new ItemIterator(context, rows); }
1469749_6
public static ItemIterator findBySubmitter(Context context, EPerson eperson) throws SQLException { String myQuery = "SELECT * FROM item WHERE in_archive='1' AND submitter_id=" + eperson.getID(); TableRowIterator rows = DatabaseManager.queryTable(context, "item", myQuery); return new ItemIterator(context, rows); }
1469749_7
public int getID() { return itemRow.getIntColumn("item_id"); }
1469749_8
public String getHandle() { if(handle == null) { try { handle = HandleManager.findHandle(this.ourContext, this); } catch (SQLException e) { // TODO Auto-generated catch block //e.printStackTrace(); } } return handle; }
1469749_9
public boolean isArchived() { return itemRow.getBooleanColumn("in_archive"); }
1475915_0
public String mapProxyToHidden(String proxyUrl) { String path = extractPath(proxyUrl, proxyDomain, proxyResource); return extractProtocol(proxyUrl) + SEP + hiddenDomain + path; }
1475915_1
public String mapHiddenToProxy(String hiddenUrl) { String path = extractPath(hiddenUrl, hiddenDomain, ""); return extractProtocol(hiddenUrl) + SEP + proxy + path; }
1475915_2
public Mapping findByProxyUrl(String proxyUrl) { String noProtocol= substringAfter(proxyUrl, SEP); for (Mapping mapping: this) { if (startsWithIgnoreCase(noProtocol, mapping.proxy)) return mapping; } return null; }
1475915_3
public Mapping findByHiddenUrl(String hiddenUrl) { String noProtocol= substringAfter(hiddenUrl, SEP); for (Mapping mapping: this) { if (startsWithIgnoreCase(noProtocol, mapping.hiddenDomain)) return mapping; } return null; }
1475915_4
public String translate(String text) { for (TagTranslator translator : tagTranslators) { text= translator.translate(text); } return text; }
1475915_5
public String mapContentUrl(String url) { if (isEmpty(url)) return EMPTY; if (startsWith(url, "/")) { url = currentMapping.proxyResource + url; } url= mapFullUrlIfCan(url); return url; }
1475915_6
@VisibleForTesting String translateTag(String tag) { Tuple3<Integer, Integer, String> value = attributeValue(tag); if (value.isNull()) return tag; String newUrl = urlMapper.mapContentUrl(value.e3); return left(tag, value.e1) + dquoteAround(newUrl) + substring(tag, value.e2); }
1475915_7
@VisibleForTesting Tuple3<Integer, Integer, String> attributeValue(String tag) { String normalized= TextTools.removeControlChars(tag); List<Tuple3<Integer, Integer, String>> matches = RegexTools.findAll(attributePattern, normalized, true); if (matches.isEmpty()) return Tuple3.nil(); Tuple3<Integer, Integer, String> match = matches.get(0); String value = match.e3; char quote= value.charAt(0); if (isQuote(quote)) { value= extractBetweenQuotes(value, quote); } return Tuple3.tuple3(match.e1, match.e2, value); }
1475915_8
@VisibleForTesting static Mappings readMappings(PropertiesFile propertiesFile) { Mappings mappings= new Mappings(); PropertiesFile subset = propertiesFile.subset("mapping."); for(String key: subset.keys()) { String value = subset.getString(key); mappings.add( new Mapping(value) ); } return mappings; }
1475915_9
public static String removeControlChars(String text) { StringBuilder sb= new StringBuilder(); for (int i=0, n=StringUtils.length(text) ; i<n; i++) { char ch= text.charAt(i); if (ch < ' ') ch= ' '; sb.append(ch); } return sb.toString(); }
1481910_0
public boolean validate(TypeElement element) { IsValid valid = new IsValid(); if (element.getKind() != ElementKind.CLASS) { valid.invalidate(); printBuildableError(element, "%s can only be used on class"); } if (element.getEnclosingElement().getKind() != ElementKind.PACKAGE) { valid.invalidate(); printBuildableError(element, "%s can only be used on a top-level class, no inner class please"); } if (element.getModifiers().contains(Modifier.ABSTRACT)) { valid.invalidate(); printBuildableError(element, "%s cannot be used on an abstract class"); } Buildable buildableAnnotation = element.getAnnotation(Buildable.class); String builderNameSuffix = buildableAnnotation.value(); if ("".equals(builderNameSuffix)) { valid.invalidate(); AnnotationMirror annotationMirror = findAnnotationMirror(element, Buildable.class); AnnotationValue annotationValue = annotationMirror.getElementValues().values().iterator().next(); processingEnv.getMessager().printMessage(Kind.ERROR, "The builder name suffix should not be an empty String", element, annotationMirror, annotationValue); } Set<ExecutableElement> constructors = elementHelper.findAccessibleConstructors(element); if (constructors.size() == 0) { valid.invalidate(); printBuildableError(element, "No accessible constructor found. Please provide at least one not private constructor."); } else { ExecutableElement builderConstructor = null; if (constructors.size() == 1) { builderConstructor = constructors.iterator().next(); } else { Set<ExecutableElement> builderConstructors = elementHelper.findBuilderConstructors(constructors); if (builderConstructors.size() == 0) { valid.invalidate(); String message = "Multiple constructor candidates found. Please use @" + Build.class.getSimpleName() + " annotation on the selected constructor."; printBuildableError(element, message); for (ExecutableElement constructor : constructors) { processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, message, constructor); } } else if (builderConstructors.size() > 1) { valid.invalidate(); for (ExecutableElement constructor : builderConstructors) { printBuildError(constructor, "%s should not be used more than once in a class."); } } else { builderConstructor = builderConstructors.iterator().next(); } } if (builderConstructor != null) { List<? extends TypeMirror> thrownTypes = builderConstructor.getThrownTypes(); if (thrownTypes.size() > 0) { Types typeUtils = processingEnv.getTypeUtils(); Elements elementUtils = processingEnv.getElementUtils(); TypeElement exceptionElement = elementUtils.getTypeElement(Exception.class.getName()); TypeMirror exceptionMirror = exceptionElement.asType(); for (TypeMirror thrownType : thrownTypes) { if (!typeUtils.isSubtype(thrownType, exceptionMirror)) { valid.invalidate(); processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "The constructor used by the builder can only throw subtypes of Exception", builderConstructor); } } } } } return valid.isValid(); }
1481910_1
public boolean validate(TypeElement element) { IsValid valid = new IsValid(); if (element.getKind() != ElementKind.CLASS) { valid.invalidate(); printBuildableError(element, "%s can only be used on class"); } if (element.getEnclosingElement().getKind() != ElementKind.PACKAGE) { valid.invalidate(); printBuildableError(element, "%s can only be used on a top-level class, no inner class please"); } if (element.getModifiers().contains(Modifier.ABSTRACT)) { valid.invalidate(); printBuildableError(element, "%s cannot be used on an abstract class"); } Buildable buildableAnnotation = element.getAnnotation(Buildable.class); String builderNameSuffix = buildableAnnotation.value(); if ("".equals(builderNameSuffix)) { valid.invalidate(); AnnotationMirror annotationMirror = findAnnotationMirror(element, Buildable.class); AnnotationValue annotationValue = annotationMirror.getElementValues().values().iterator().next(); processingEnv.getMessager().printMessage(Kind.ERROR, "The builder name suffix should not be an empty String", element, annotationMirror, annotationValue); } Set<ExecutableElement> constructors = elementHelper.findAccessibleConstructors(element); if (constructors.size() == 0) { valid.invalidate(); printBuildableError(element, "No accessible constructor found. Please provide at least one not private constructor."); } else { ExecutableElement builderConstructor = null; if (constructors.size() == 1) { builderConstructor = constructors.iterator().next(); } else { Set<ExecutableElement> builderConstructors = elementHelper.findBuilderConstructors(constructors); if (builderConstructors.size() == 0) { valid.invalidate(); String message = "Multiple constructor candidates found. Please use @" + Build.class.getSimpleName() + " annotation on the selected constructor."; printBuildableError(element, message); for (ExecutableElement constructor : constructors) { processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, message, constructor); } } else if (builderConstructors.size() > 1) { valid.invalidate(); for (ExecutableElement constructor : builderConstructors) { printBuildError(constructor, "%s should not be used more than once in a class."); } } else { builderConstructor = builderConstructors.iterator().next(); } } if (builderConstructor != null) { List<? extends TypeMirror> thrownTypes = builderConstructor.getThrownTypes(); if (thrownTypes.size() > 0) { Types typeUtils = processingEnv.getTypeUtils(); Elements elementUtils = processingEnv.getElementUtils(); TypeElement exceptionElement = elementUtils.getTypeElement(Exception.class.getName()); TypeMirror exceptionMirror = exceptionElement.asType(); for (TypeMirror thrownType : thrownTypes) { if (!typeUtils.isSubtype(thrownType, exceptionMirror)) { valid.invalidate(); processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "The constructor used by the builder can only throw subtypes of Exception", builderConstructor); } } } } } return valid.isValid(); }
1481910_2
public boolean isValid() { return valid; }
1481910_3
@Override public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { FileObject resource = filer.createResource(StandardLocation.SOURCE_OUTPUT, pkg.name(), fileName); return resource.openOutputStream(); }
1481910_4
@Override public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { FileObject resource = filer.createResource(StandardLocation.SOURCE_OUTPUT, pkg.name(), fileName); return resource.openOutputStream(); }
1481910_5
@Override public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { String qualifiedClassName = toQualifiedClassName(pkg, fileName); JavaFileObject sourceFile = filer.createSourceFile(qualifiedClassName); return sourceFile.openOutputStream(); }
1481910_6
@Override public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { String qualifiedClassName = toQualifiedClassName(pkg, fileName); JavaFileObject sourceFile = filer.createSourceFile(qualifiedClassName); return sourceFile.openOutputStream(); }
1481910_7
public String getStringField() { return stringField; }
1481910_8
public Integer getIntegerField() { return integerField; }
1484463_0
@VisibleForTesting void writeJsonForInMemoryChunks(final JsonGenerator generator, final ObjectWriter writer, final Map<Integer, Map<Integer, DecimatingSampleFilter>> filters, final List<Integer> hostIdsList, final List<Integer> sampleKindIdsList, @Nullable final DateTime startTime, @Nullable final DateTime endTime, final boolean decodeSamples) throws IOException, ExecutionException { for (final Integer hostId : hostIdsList) { final Collection<? extends TimelineChunk> inMemorySamples = processor.getInMemoryTimelineChunks(hostId, sampleKindIdsList, startTime, endTime); writeJsonForChunks(generator, writer, filters, inMemorySamples, decodeSamples); } }
1484463_1
public void getAndProcessTimelineAggregationCandidates() { if (!isAggregating.compareAndSet(false, true)) { log.info("Asked to aggregate, but we're already aggregating!"); return; } else { log.debug("Starting aggregating"); } aggregationRuns.incrementAndGet(); final String[] chunkCountsToAggregate = config.getChunksToAggregate().split(","); for (int aggregationLevel=0; aggregationLevel<config.getMaxAggregationLevel(); aggregationLevel++) { final long startingAggregatesCreated = aggregatesCreated.get(); final Map<String, Long> initialCounters = captureAggregatorCounters(); final int chunkCountIndex = aggregationLevel >= chunkCountsToAggregate.length ? chunkCountsToAggregate.length - 1 : aggregationLevel; final int chunksToAggregate = Integer.parseInt(chunkCountsToAggregate[chunkCountIndex]); streamingAggregateLevel(aggregationLevel, chunksToAggregate); final Map<String, Long> counterDeltas = subtractFromAggregatorCounters(initialCounters); final long netAggregatesCreated = aggregatesCreated.get() - startingAggregatesCreated; if (netAggregatesCreated == 0) { if (aggregationLevel == 0) { foundNothingRuns.incrementAndGet(); } log.debug("Created no new aggregates, so skipping higher-level aggregations"); break; } else { final StringBuilder builder = new StringBuilder(); builder .append("For aggregation level ") .append(aggregationLevel) .append(", runs ") .append(aggregationRuns.get()) .append(", foundNothingRuns ") .append(foundNothingRuns.get()); for (Map.Entry<String, Long> entry : counterDeltas.entrySet()) { builder.append(", ").append(entry.getKey()).append(": ").append(entry.getValue()); } log.info(builder.toString()); } } log.debug("Aggregation done"); isAggregating.set(false); }