下面列出了java.util.EnumSet#contains ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
void start() {
if (connected) {
try {
EnumSet<UsbSerialPort.ControlLine> controlLines = usbSerialPort.getSupportedControlLines();
if (!controlLines.contains(UsbSerialPort.ControlLine.RTS)) rtsBtn.setVisibility(View.INVISIBLE);
if (!controlLines.contains(UsbSerialPort.ControlLine.CTS)) ctsBtn.setVisibility(View.INVISIBLE);
if (!controlLines.contains(UsbSerialPort.ControlLine.DTR)) dtrBtn.setVisibility(View.INVISIBLE);
if (!controlLines.contains(UsbSerialPort.ControlLine.DSR)) dsrBtn.setVisibility(View.INVISIBLE);
if (!controlLines.contains(UsbSerialPort.ControlLine.CD)) cdBtn.setVisibility(View.INVISIBLE);
if (!controlLines.contains(UsbSerialPort.ControlLine.RI)) riBtn.setVisibility(View.INVISIBLE);
} catch (IOException e) {
Toast.makeText(getActivity(), "getSupportedControlLines() failed: " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
if (refresh())
mainLooper.postDelayed(runnable, refreshInterval);
}
}
private boolean isOfKindAndType(TypeMirror type, Element e, EnumSet<ElementKind> kinds, TypeMirror base, Scope scope, Trees trees, Types types) {
if (type.getKind() != TypeKind.ERROR && kinds.contains(e.getKind())) {
if (base == null)
return true;
if (types.isSubtype(type, base))
return true;
}
if ((e.getKind().isClass() || e.getKind().isInterface()) &&
(kinds.contains(ANNOTATION_TYPE) || kinds.contains(CLASS) || kinds.contains(ENUM) || kinds.contains(INTERFACE))) {
DeclaredType dt = (DeclaredType)e.asType();
for (Element ee : e.getEnclosedElements())
if (trees.isAccessible(scope, ee, dt) && isOfKindAndType(ee.asType(), ee, kinds, base, scope, trees, types))
return true;
}
return false;
}
/**
* Clear the tracked visited folders & the cached {@link LocalPkgInfo} for the
* given filter types.
*
* @param filters A set of PkgType constants or {@link PkgType#PKG_ALL} to clear everything.
*/
public void clearLocalPkg(@NonNull EnumSet<PkgType> filters) {
mLegacyBuildTools = null;
synchronized (mLocalPackages) {
for (PkgType filter : filters) {
mVisitedDirs.removeAll(filter);
mLocalPackages.removeAll(filter);
}
// Clear the targets if the platforms or addons are being cleared
if (filters.contains(PkgType.PKG_PLATFORM) || filters.contains(PkgType.PKG_ADDON)) {
mCachedMissingTargets = null;
mCachedTargets = null;
}
}
}
/**
* Set the available technologies for the given player.
* @param xplayer the player definition
* @param p the player object to load
* @param categoryFilter the set of main categories to pick up
*/
private void setTechAvailability(XElement xplayer, Player p, EnumSet<ResearchMainCategory> categoryFilter) {
XElement xavail0 = xplayer.childElement("available");
if (xavail0 != null) {
for (XElement xavail : xavail0.childrenWithName("type")) {
String id = xavail.get("id");
ResearchType rt = researches.get(id);
if (rt == null) {
System.out.println("WARN | Available technology not found: " + xavail);
} else
if (categoryFilter.contains(rt.category.main)) {
p.add(rt);
for (String liste : xavail.get("list", "").split("\\s*,\\s*")) {
if (liste.length() > 0) {
ResearchType rt0 = researches.get(liste);
if (rt0 == null) {
System.out.println("WARN | available technology not found: " + liste + " in " + xavail);
} else {
p.availableLevel(rt).add(rt0);
}
}
}
}
}
}
}
private List<ApplicationReport> getApplicationReports(
List<ApplicationReport> applicationReports,
Set<String> applicationTypes, EnumSet<YarnApplicationState> applicationStates) {
List<ApplicationReport> appReports = new ArrayList<ApplicationReport>();
for (ApplicationReport appReport : applicationReports) {
if (applicationTypes != null && !applicationTypes.isEmpty()) {
if (!applicationTypes.contains(appReport.getApplicationType())) {
continue;
}
}
if (applicationStates != null && !applicationStates.isEmpty()) {
if (!applicationStates.contains(appReport.getYarnApplicationState())) {
continue;
}
}
appReports.add(appReport);
}
return appReports;
}
private static void processDelinquent(final PowerTenant tenant, final Registry registry,
final Investment currentDelinquent) {
final long investmentId = currentDelinquent.getId();
final EnumSet<Category> knownCategories = registry.getCategories(currentDelinquent);
if (knownCategories.contains(Category.HOPELESS)) {
LOGGER.debug("Investment #{} may not be promoted anymore.", investmentId);
return;
}
final int daysPastDue = currentDelinquent.getLegalDpd()
.orElse(0);
final EnumSet<Category> unusedCategories = EnumSet.complementOf(knownCategories);
final Optional<Category> firstNextCategory = unusedCategories.stream()
.filter(c -> c.getThresholdInDays() >= 0) // ignore the DEFAULTED category, which gets special treatment
.filter(c -> c.getThresholdInDays() <= daysPastDue)
.max(Comparator.comparing(Category::getThresholdInDays));
if (firstNextCategory.isPresent()) {
final Category category = firstNextCategory.get();
LOGGER.debug("Investment #{} placed to category {}.", investmentId, category);
category.process(tenant, currentDelinquent);
registry.addCategory(currentDelinquent, category);
} else {
LOGGER.debug("Investment #{} can not yet be promoted to the next category.", investmentId);
}
}
public MessageSievingInputStreamTest(EnumSet<TransformerOptions> options) throws Exception {
this.options = options;
this.storeKeyFactory = new MockIdFactory();
this.randomKeyConverter = new RandomKeyConverter();
if (options.contains(TransformerOptions.Validate)) {
transformers.add(new ValidatingTransformer(storeKeyFactory, randomKeyConverter));
}
if (options.contains(TransformerOptions.KeyConvert)) {
transformers.add(new ValidatingKeyConvertingTransformer(storeKeyFactory, randomKeyConverter));
}
}
public int getWeakPower(BlockFace side) {
if (!this.canProvidePower) {
return 0;
} else {
int power = this.meta;
if (power == 0) {
return 0;
} else if (side == BlockFace.UP) {
return power;
} else {
EnumSet<BlockFace> enumset = EnumSet.noneOf(BlockFace.class);
for (BlockFace face : Plane.HORIZONTAL) {
if (this.isPowerSourceAt(face)) {
enumset.add(face);
}
}
if (side.getAxis().isHorizontal() && enumset.isEmpty()) {
return power;
} else if (enumset.contains(side) && !enumset.contains(side.rotateYCCW()) && !enumset.contains(side.rotateY())) {
return power;
} else {
return 0;
}
}
}
}
@Override
void parseRootLoggerElement(final XMLExtendedStreamReader reader, final PathAddress address, final List<ModelNode> operations) throws XMLStreamException {
// No attributes
if (reader.getAttributeCount() > 0) {
throw unexpectedAttribute(reader, 0);
}
final ModelNode operation = Util.createAddOperation(address.append(RootLoggerResourceDefinition.NAME, RESOURCE_NAME));
final EnumSet<Element> encountered = EnumSet.noneOf(Element.class);
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
if (encountered.contains(element)) {
throw duplicateNamedElement(reader, reader.getLocalName());
}
encountered.add(element);
switch (element) {
case FILTER_SPEC: {
LoggerAttributes.FILTER_SPEC.parseAndSetParameter(readValueAttribute(reader), operation, reader);
break;
}
case LEVEL: {
LEVEL.parseAndSetParameter(readNameAttribute(reader), operation, reader);
break;
}
case HANDLERS: {
parseHandlersElement(element.getDefinition(), operation, reader);
break;
}
default:
throw unexpectedElement(reader);
}
}
operations.add(operation);
}
private static Script script(ExecutionContext cx, ExecutionContext caller, String sourceCode, int flags) {
try {
Realm realm = cx.getRealm();
Source source = evalSource(caller);
EnumSet<Parser.Option> options = EvalFlags.toOptions(flags);
EnumSet<Parser.Option> contextOptions = realm.getRuntimeContext().getParserOptions();
if (contextOptions.contains(Parser.Option.NativeCall)) {
options.add(Parser.Option.NativeCall);
}
return realm.getScriptLoader().evalScript(source, sourceCode, options);
} catch (ParserException | CompilationException e) {
throw e.toScriptException(cx);
}
}
void parseRootLoggerElement(final XMLExtendedStreamReader reader, final PathAddress address, final List<ModelNode> operations) throws XMLStreamException {
// No attributes
if (reader.getAttributeCount() > 0) {
throw unexpectedAttribute(reader, 0);
}
final ModelNode operation = Util.createAddOperation(address.append(RootLoggerResourceDefinition.NAME, RESOURCE_NAME));
final EnumSet<Element> encountered = EnumSet.noneOf(Element.class);
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
if (encountered.contains(element)) {
throw duplicateNamedElement(reader, reader.getLocalName());
}
encountered.add(element);
switch (element) {
case FILTER: {
parseFilter(operation, LoggerAttributes.FILTER_SPEC, reader);
break;
}
case LEVEL: {
LEVEL.parseAndSetParameter(readNameAttribute(reader), operation, reader);
break;
}
case HANDLERS: {
parseHandlersElement(element.getDefinition(), operation, reader);
break;
}
default:
throw unexpectedElement(reader);
}
}
operations.add(operation);
}
private static TimelineEntity maskFields(
TimelineEntity entity, EnumSet<Field> fields) {
// Conceal the fields that are not going to be exposed
TimelineEntity entityToReturn = new TimelineEntity();
entityToReturn.setEntityId(entity.getEntityId());
entityToReturn.setEntityType(entity.getEntityType());
entityToReturn.setStartTime(entity.getStartTime());
entityToReturn.setDomainId(entity.getDomainId());
// Deep copy
if (fields.contains(Field.EVENTS)) {
entityToReturn.addEvents(entity.getEvents());
} else if (fields.contains(Field.LAST_EVENT_ONLY)) {
entityToReturn.addEvent(entity.getEvents().get(0));
} else {
entityToReturn.setEvents(null);
}
if (fields.contains(Field.RELATED_ENTITIES)) {
entityToReturn.addRelatedEntities(entity.getRelatedEntities());
} else {
entityToReturn.setRelatedEntities(null);
}
if (fields.contains(Field.PRIMARY_FILTERS)) {
entityToReturn.addPrimaryFilters(entity.getPrimaryFilters());
} else {
entityToReturn.setPrimaryFilters(null);
}
if (fields.contains(Field.OTHER_INFO)) {
entityToReturn.addOtherInfo(entity.getOtherInfo());
} else {
entityToReturn.setOtherInfo(null);
}
return entityToReturn;
}
/**
* Creates a JSON-like Watchman query to get a list of matching files.
*
* <p>The implementation should ideally match the one in glob_watchman.py.
*/
private ImmutableMap<String, ?> createWatchmanQuery(
Collection<String> include, Collection<String> exclude, EnumSet<Option> options) {
ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
builder.putAll(
ImmutableMap.of(
"relative_root",
basePath,
"expression",
toMatchExpressions(exclude, options),
"glob",
include,
"fields",
FIELDS_TO_INCLUDE));
if (options.contains(Option.FORCE_CASE_SENSITIVE)) {
builder.put("case_sensitive", true);
}
// Sync cookies cause a massive overhead when issuing thousands of
// glob queries. Only enable them (by not setting sync_timeout to 0)
// for the very first request issued by this process.
if (syncCookieState.shouldSyncCookies()) {
syncCookieState.disableSyncCookies();
} else {
builder.put("sync_timeout", 0);
}
return builder.build();
}
@Override
public FSDataOutputStream create(Path f, EnumSet<CreateFlag> createFlag,
CreateOpts... opts) throws AccessControlException,
FileAlreadyExistsException, FileNotFoundException,
ParentNotDirectoryException, UnsupportedFileSystemException, IOException {
// Need to translate the FileContext-style options into FileSystem-style
// Permissions with umask
CreateOpts.Perms permOpt = CreateOpts.getOpt(
CreateOpts.Perms.class, opts);
FsPermission umask = FsPermission.getUMask(fs.getConf());
FsPermission permission = (permOpt != null) ? permOpt.getValue()
: FsPermission.getFileDefault().applyUMask(umask);
permission = permission.applyUMask(umask);
// Overwrite
boolean overwrite = createFlag.contains(CreateFlag.OVERWRITE);
// bufferSize
int bufferSize = fs.getConf().getInt(
CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_KEY,
CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT);
CreateOpts.BufferSize bufOpt = CreateOpts.getOpt(
CreateOpts.BufferSize.class, opts);
bufferSize = (bufOpt != null) ? bufOpt.getValue() : bufferSize;
// replication
short replication = fs.getDefaultReplication(f);
CreateOpts.ReplicationFactor repOpt =
CreateOpts.getOpt(CreateOpts.ReplicationFactor.class, opts);
replication = (repOpt != null) ? repOpt.getValue() : replication;
// blockSize
long blockSize = fs.getDefaultBlockSize(f);
CreateOpts.BlockSize blockOpt = CreateOpts.getOpt(
CreateOpts.BlockSize.class, opts);
blockSize = (blockOpt != null) ? blockOpt.getValue() : blockSize;
// Progressable
Progressable progress = null;
CreateOpts.Progress progressOpt = CreateOpts.getOpt(
CreateOpts.Progress.class, opts);
progress = (progressOpt != null) ? progressOpt.getValue() : progress;
return fs.create(f, permission, overwrite, bufferSize, replication,
blockSize, progress);
}
ModelNode parsePolicyElement(XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list) throws XMLStreamException {
final ModelNode policy = new ModelNode();
policy.get(OP).set(ADD);
policy.get(OP_ADDR).set(address).add(SaslPolicyResource.SASL_POLICY_CONFIG_PATH.getKey(), SaslPolicyResource.SASL_POLICY_CONFIG_PATH.getValue());
list.add(policy);
if (reader.getAttributeCount() > 0) {
throw ParseUtils.unexpectedAttribute(reader, 0);
}
// Handle nested elements.
final EnumSet<Element> visited = EnumSet.noneOf(Element.class);
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
if (visited.contains(element)) {
throw ParseUtils.unexpectedElement(reader);
}
visited.add(element);
switch (element) {
case FORWARD_SECRECY: {
SaslPolicyResource.FORWARD_SECRECY.parseAndSetParameter(readStringAttributeElement(reader, "value"), policy, reader);
break;
}
case NO_ACTIVE: {
SaslPolicyResource.NO_ACTIVE.parseAndSetParameter(readStringAttributeElement(reader, "value"), policy, reader);
break;
}
case NO_ANONYMOUS: {
SaslPolicyResource.NO_ANONYMOUS.parseAndSetParameter(readStringAttributeElement(reader, "value"), policy, reader);
break;
}
case NO_DICTIONARY: {
SaslPolicyResource.NO_DICTIONARY.parseAndSetParameter(readStringAttributeElement(reader, "value"), policy, reader);
break;
}
case NO_PLAIN_TEXT: {
SaslPolicyResource.NO_PLAIN_TEXT.parseAndSetParameter(readStringAttributeElement(reader, "value"), policy, reader);
break;
}
case PASS_CREDENTIALS: {
SaslPolicyResource.PASS_CREDENTIALS.parseAndSetParameter(readStringAttributeElement(reader, "value"), policy, reader);
break;
}
default: {
throw unexpectedElement(reader);
}
}
}
return policy;
}
/**
* Creates a new, empty map with the specified initial
* capacity, reference types, load factor and concurrency level.
* <p/>
* Behavioral changing options such as {@link Option#IDENTITY_COMPARISONS}
* can also be specified.
*
* @param initialCapacity the initial capacity. The implementation
* performs internal sizing to accommodate this many elements.
* @param loadFactor the load factor threshold, used to control resizing.
* Resizing may be performed when the average number of elements per
* bin exceeds this threshold.
* @param concurrencyLevel the estimated number of concurrently
* updating threads. The implementation performs internal sizing
* to try to accommodate this many threads.
* @param keyType the reference type to use for keys
* @param valueType the reference type to use for values
* @param options the behavioral options
*
* @throws IllegalArgumentException if the initial capacity is
* negative or the load factor or concurrencyLevel are
* nonpositive.
*/
public ConcurrentReferenceHashMap(
int initialCapacity,
float loadFactor, int concurrencyLevel,
ReferenceType keyType, ReferenceType valueType,
EnumSet<Option> options) {
if ( !( loadFactor > 0 ) || initialCapacity < 0 || concurrencyLevel <= 0 ) {
throw new IllegalArgumentException();
}
if ( concurrencyLevel > MAX_SEGMENTS ) {
concurrencyLevel = MAX_SEGMENTS;
}
// Find power-of-two sizes best matching arguments
int sshift = 0;
int ssize = 1;
while ( ssize < concurrencyLevel ) {
++sshift;
ssize <<= 1;
}
segmentShift = 32 - sshift;
segmentMask = ssize - 1;
this.segments = Segment.newArray( ssize );
if ( initialCapacity > MAXIMUM_CAPACITY ) {
initialCapacity = MAXIMUM_CAPACITY;
}
int c = initialCapacity / ssize;
if ( c * ssize < initialCapacity ) {
++c;
}
int cap = 1;
while ( cap < c ) {
cap <<= 1;
}
identityComparisons = options != null && options.contains( Option.IDENTITY_COMPARISONS );
for ( int i = 0; i < this.segments.length; ++i ) {
this.segments[i] = new Segment<K, V>(
cap, loadFactor,
keyType, valueType, identityComparisons
);
}
}
@Override
public ApplicationId
submitApplication(ApplicationSubmissionContext appContext)
throws YarnException, IOException {
ApplicationId applicationId = appContext.getApplicationId();
if (applicationId == null) {
throw new ApplicationIdNotProvidedException(
"ApplicationId is not provided in ApplicationSubmissionContext");
}
SubmitApplicationRequest request =
Records.newRecord(SubmitApplicationRequest.class);
request.setApplicationSubmissionContext(appContext);
// Automatically add the timeline DT into the CLC
// Only when the security and the timeline service are both enabled
if (isSecurityEnabled() && timelineServiceEnabled) {
addTimelineDelegationToken(appContext.getAMContainerSpec());
}
//TODO: YARN-1763:Handle RM failovers during the submitApplication call.
rmClient.submitApplication(request);
int pollCount = 0;
long startTime = System.currentTimeMillis();
EnumSet<YarnApplicationState> waitingStates =
EnumSet.of(YarnApplicationState.NEW,
YarnApplicationState.NEW_SAVING,
YarnApplicationState.SUBMITTED);
EnumSet<YarnApplicationState> failToSubmitStates =
EnumSet.of(YarnApplicationState.FAILED,
YarnApplicationState.KILLED);
while (true) {
try {
ApplicationReport appReport = getApplicationReport(applicationId);
YarnApplicationState state = appReport.getYarnApplicationState();
if (!waitingStates.contains(state)) {
if(failToSubmitStates.contains(state)) {
throw new YarnException("Failed to submit " + applicationId +
" to YARN : " + appReport.getDiagnostics());
}
LOG.info("Submitted application " + applicationId);
break;
}
long elapsedMillis = System.currentTimeMillis() - startTime;
if (enforceAsyncAPITimeout() &&
elapsedMillis >= asyncApiPollTimeoutMillis) {
throw new YarnException("Timed out while waiting for application " +
applicationId + " to be submitted successfully");
}
// Notify the client through the log every 10 poll, in case the client
// is blocked here too long.
if (++pollCount % 10 == 0) {
LOG.info("Application submission is not finished, " +
"submitted application " + applicationId +
" is still in " + state);
}
try {
Thread.sleep(submitPollIntervalMillis);
} catch (InterruptedException ie) {
LOG.error("Interrupted while waiting for application "
+ applicationId
+ " to be successfully submitted.");
}
} catch (ApplicationNotFoundException ex) {
// FailOver or RM restart happens before RMStateStore saves
// ApplicationState
LOG.info("Re-submit application " + applicationId + "with the " +
"same ApplicationSubmissionContext");
rmClient.submitApplication(request);
}
}
return applicationId;
}
/**
* Function to draw the arrows on the attack/being attacked ring.
*
* @param g2d The graphic context
* @param x The x-center of the arrows
* @param y The y-center of the arrows
* @param width ring width
* @param height ring height
* @param directions The directions an arrow should be drawn
* @param lineColor The color of the outline of the arrow
*/
private void drawArrows(final Graphics2D g2d, final int x, final int y, final int width, final int height, final EnumSet<Direction> directions, final Color lineColor) {
int arrowHeight = 6 + 2 * (height / 23 - 1);
int arrowWidth = 3 + (width / 34 - 1);
if (directions.contains(Direction.LEFT)) {
g2d.setColor(Color.RED);
g2d.fillPolygon(
new int[] {x+1, x-arrowWidth, x+1},
new int[]{y+(height/2)-(arrowHeight/2), y+(height/2),y+(height/2)+(arrowHeight/2)},
3);
g2d.setColor(lineColor);
g2d.drawPolyline(
new int[]{x, x-arrowWidth, x},
new int[]{y+(height/2)-(arrowHeight/2), y+(height/2), y+(height/2)+(arrowHeight/2)},
3);
}
if (directions.contains(Direction.RIGHT)) {
g2d.setColor(Color.RED);
g2d.fillPolygon(
new int[]{x+width, x+width+arrowWidth, x+width},
new int[]{y+(height/2)-(arrowHeight/2), y+(height/2), y+(height/2)+(arrowHeight/2)},
3);
g2d.setColor(lineColor);
g2d.drawPolyline(
new int[]{x+width, x+width+arrowWidth, x+width},
new int[]{y+(height/2)-(arrowHeight/2), y+(height/2), y+(height/2)+(arrowHeight/2)},
3);
}
if (directions.contains(Direction.UP)) {
g2d.setColor(Color.RED);
g2d.fillPolygon(
new int[]{x+(width/2)-(arrowHeight/2), x+(width/2), x+(width/2)+(arrowHeight/2)},
new int[]{y+1, y-arrowWidth, y+1},
3);
g2d.setColor(lineColor);
g2d.drawPolyline(
new int[]{x+(width/2)-(arrowHeight/2), x+(width/2), x+(width/2)+(arrowHeight/2)},
new int[]{y, y-arrowWidth, y},
3);
}
if (directions.contains(Direction.DOWN)) {
g2d.setColor(Color.RED);
g2d.fillPolygon(
new int[]{x+(width/2)-(arrowHeight/2), x+(width/2), x+(width/2)+(arrowHeight/2)},
new int[]{y+height, y+height+arrowWidth, y+height},
3);
g2d.setColor(lineColor);
g2d.drawPolyline(
new int[]{x+(width/2)-(arrowHeight/2), x+(width/2), x+(width/2)+(arrowHeight/2)},
new int[]{y+height, y+height+arrowWidth, y+height},
3);
}
}
private void copy(RemoteFile srf, RemoteFile drf, EnumSet<Mode> mode, boolean jobSucceeded) throws Exception {
String srcScheme = defaultToLocal(srf.getProtocol());
String dstScheme = defaultToLocal(drf.getProtocol());
Service ss = new ServiceImpl(srcScheme, getServiceContact(srf), null);
Service ds = new ServiceImpl(dstScheme, getServiceContact(drf), null);
FileResource sres = FileResourceCache.getDefault().getResource(ss);
FileResource dres = FileResourceCache.getDefault().getResource(ds);
String srcPath = getPath(srf);
boolean delete = false;
if (mode.contains(Mode.IF_PRESENT) && !sres.exists(srcPath)) {
delete = true;
}
if (mode.contains(Mode.ON_SUCCESS) && !jobSucceeded) {
delete = true;
}
if (mode.contains(Mode.ON_ERROR) && jobSucceeded) {
delete = true;
}
String dstPath = getPath(drf);
if (delete) {
if (dres.exists(dstPath)) {
dres.deleteFile(dstPath);
}
return;
}
InputStream is = sres.openInputStream(srcPath);
OutputStream os = dres.openOutputStream(dstPath);
byte[] buffer = new byte[BUFFER_SIZE];
int len = is.read(buffer);
while (len != -1) {
os.write(buffer, 0, len);
len = is.read(buffer);
}
os.close();
is.close();
FileResourceCache.getDefault().releaseResource(sres);
FileResourceCache.getDefault().releaseResource(dres);
}
/**
* Returns true if a given feature is supported in the given layout version
* @param f Feature
* @param lv LayoutVersion
* @return true if {@code f} is supported in layout version {@code lv}
*/
public static boolean supports(final Feature f, final int lv) {
final EnumSet<Feature> set = map.get(lv);
return set != null && set.contains(f);
}