@Override
 public synchronized void open(EnumSet<Mode> mode, Path path, File file) throws IOException {
   if (isOpen) {
     return;
   }
   this.mode = mode;
   this.file = file;
   this.path = path;
   if (mode.contains(Mode.READ)) {
     this.in = createArchiveInputStream();
     this.isOpen = this.in != null;
     if (!isOpen) {
       throw new FileNotFoundException(
           "can't open for input, check existence or access rights: " + file.getAbsolutePath());
     }
   } else if (mode.contains(Mode.WRITE)) {
     this.out = createArchiveOutputStream(false);
     this.isOpen = this.out != null;
     if (!isOpen) {
       throw new FileNotFoundException(
           "can't open for output, check existence or access rights: " + file.getAbsolutePath());
     }
   } else if (mode.contains(Mode.OVERWRITE)) {
     this.out = createArchiveOutputStream(true);
     this.isOpen = this.out != null;
     if (!isOpen) {
       throw new FileNotFoundException(
           "can't open for output, check existence or access rights: " + file.getAbsolutePath());
     }
   }
 }
  private static List<RequirementBasedColumnKey> getRequirements(
      ViewDefinition viewDefinition, EnumSet<ComputationTargetType> targetTypes) {
    List<RequirementBasedColumnKey> result = new ArrayList<RequirementBasedColumnKey>();
    for (ViewCalculationConfiguration calcConfig :
        viewDefinition.getAllCalculationConfigurations()) {
      String calcConfigName = calcConfig.getName();
      if (targetTypes.contains(ComputationTargetType.POSITION)
          || targetTypes.contains(ComputationTargetType.PORTFOLIO_NODE)) {
        for (Pair<String, ValueProperties> portfolioOutput :
            calcConfig.getAllPortfolioRequirements()) {
          String valueName = portfolioOutput.getFirst();
          ValueProperties constraints = portfolioOutput.getSecond();
          RequirementBasedColumnKey columnKey =
              new RequirementBasedColumnKey(calcConfigName, valueName, constraints);
          result.add(columnKey);
        }
      }

      for (ValueRequirement specificRequirement : calcConfig.getSpecificRequirements()) {
        if (!targetTypes.contains(specificRequirement.getTargetSpecification().getType())) {
          continue;
        }
        String valueName = specificRequirement.getValueName();
        ValueProperties constraints = specificRequirement.getConstraints();
        RequirementBasedColumnKey columnKey =
            new RequirementBasedColumnKey(calcConfigName, valueName, constraints);
        result.add(columnKey);
      }
    }
    return result;
  }
  void updateFromTab(Tab tab, EnumSet<UpdateFlags> flags) {
    // Several parts of ToolbarDisplayLayout's state depends
    // on the views being attached to the view tree.
    if (!mIsAttached) {
      return;
    }

    if (flags.contains(UpdateFlags.TITLE)) {
      updateTitle(tab);
    }

    if (flags.contains(UpdateFlags.FAVICON)) {
      updateFavicon(tab);
    }

    if (flags.contains(UpdateFlags.SITE_IDENTITY)) {
      updateSiteIdentity(tab, flags);
    }

    if (flags.contains(UpdateFlags.PROGRESS)) {
      updateProgress(tab, flags);
    }

    if (flags.contains(UpdateFlags.PRIVATE_MODE)) {
      mTitle.setPrivateMode(tab != null && tab.isPrivate());
    }
  }
Exemple #4
0
  private static void finalize(
      Configuration conf, JobConf jobconf, final Path destPath, String presevedAttributes)
      throws IOException {
    if (presevedAttributes == null) {
      return;
    }
    EnumSet<FileAttribute> preseved = FileAttribute.parse(presevedAttributes);
    if (!preseved.contains(FileAttribute.USER)
        && !preseved.contains(FileAttribute.GROUP)
        && !preseved.contains(FileAttribute.PERMISSION)) {
      return;
    }

    FileSystem dstfs = destPath.getFileSystem(conf);
    Path dstdirlist = new Path(jobconf.get(DST_DIR_LIST_LABEL));
    SequenceFile.Reader in = null;
    try {
      in = new SequenceFile.Reader(dstdirlist.getFileSystem(jobconf), dstdirlist, jobconf);
      Text dsttext = new Text();
      FilePair pair = new FilePair();
      for (; in.next(dsttext, pair); ) {
        Path absdst = new Path(destPath, pair.output);
        updatePermissions(pair.input, dstfs.getFileStatus(absdst), preseved, dstfs);
      }
    } finally {
      checkAndClose(in);
    }
  }
 private boolean processOutputForSetResetGate(EntityRef blockEntity) {
   SignalConsumerAdvancedStatusComponent consumerAdvancedStatusComponent =
       blockEntity.getComponent(SignalConsumerAdvancedStatusComponent.class);
   EnumSet<Side> signals = SideBitFlag.getSides(consumerAdvancedStatusComponent.sidesWithSignals);
   SignalProducerComponent producerComponent =
       blockEntity.getComponent(SignalProducerComponent.class);
   int resultSignal = producerComponent.signalStrength;
   if (signals.contains(Side.TOP) || signals.contains(Side.BOTTOM)) {
     resultSignal = 0;
   } else if (signals.size() > 0) {
     resultSignal = -1;
   }
   if (producerComponent.signalStrength != resultSignal) {
     producerComponent.signalStrength = resultSignal;
     blockEntity.saveComponent(producerComponent);
     if (resultSignal != 0) {
       if (!blockEntity.hasComponent(SignalProducerModifiedComponent.class)) {
         blockEntity.addComponent(new SignalProducerModifiedComponent());
       }
     } else if (blockEntity.hasComponent(SignalProducerModifiedComponent.class)) {
       blockEntity.removeComponent(SignalProducerModifiedComponent.class);
     }
     return true;
   }
   return false;
 }
 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());
   // 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;
 }
  private EnumSet<ExecutableType> commonExecutableTypeChecks(
      ValidateOnExecution validateOnExecutionAnnotation) {
    if (validateOnExecutionAnnotation == null) {
      return EnumSet.noneOf(ExecutableType.class);
    }

    EnumSet<ExecutableType> executableTypes = EnumSet.noneOf(ExecutableType.class);
    if (validateOnExecutionAnnotation.type().length == 0) { // HV-757
      executableTypes.add(ExecutableType.NONE);
    } else {
      Collections.addAll(executableTypes, validateOnExecutionAnnotation.type());
    }

    // IMPLICIT cannot be mixed 10.1.2 of spec - Mixing IMPLICIT and other executable types is
    // illegal
    if (executableTypes.contains(ExecutableType.IMPLICIT) && executableTypes.size() > 1) {
      throw log.getMixingImplicitWithOtherExecutableTypesException();
    }

    // NONE can be removed 10.1.2 of spec - A list containing NONE and other types of executables is
    // equivalent to a
    // list containing the types of executables without NONE.
    if (executableTypes.contains(ExecutableType.NONE) && executableTypes.size() > 1) {
      executableTypes.remove(ExecutableType.NONE);
    }

    // 10.1.2 of spec - A list containing ALL and other types of executables is equivalent to a list
    // containing only ALL
    if (executableTypes.contains(ExecutableType.ALL)) {
      executableTypes = ALL_EXECUTABLE_TYPES;
    }

    return executableTypes;
  }
 /** {@inheritDoc} */
 @Override
 public boolean traverse(final EnumSet<TraversalOption> options) {
   final Tile next = getNext();
   if (next == null) {
     return false;
   }
   if (next.equals(getEnd())) {
     if (Calculations.distanceTo(next) <= 1
         || end && (!Players.getLocal().isMoving() || Calculations.distanceTo(next) < 3)) {
       return false;
     }
     end = true;
   } else {
     end = false;
   }
   if (options != null
       && options.contains(TraversalOption.HANDLE_RUN)
       && !Walking.isRunEnabled()
       && Walking.getEnergy() > 50) {
     Walking.setRun(true);
     Task.sleep(300);
   }
   if (options != null && options.contains(TraversalOption.SPACE_ACTIONS)) {
     final Tile dest = Walking.getDestination();
     if (dest != null
         && Players.getLocal().isMoving()
         && Calculations.distanceTo(dest) > 5
         && Calculations.distanceBetween(next, dest) < 7) {
       return true;
     }
   }
   return Walking.walkTileMM(next, 0, 0);
 }
Exemple #9
0
 private boolean isSkipLoader(EnumSet<Flag> flags) {
   boolean hasCacheLoaderConfig =
       config.getCacheLoaderManagerConfig().getFirstCacheLoaderConfig() != null;
   return !hasCacheLoaderConfig
       || (hasCacheLoaderConfig
           && flags != null
           && (flags.contains(Flag.SKIP_CACHE_LOAD) || flags.contains(Flag.SKIP_CACHE_STORE)));
 }
 private void setFlag(Flag flag, boolean set) {
   if (set && !flagsEnum.contains(flag)) {
     flagsEnum.add(flag);
   } else if (!set) {
     flagsEnum.remove(flag);
     assert (!flagsEnum.contains(flag));
   }
 }
 public GroupInfo format(GroupDescription.Basic group) throws OrmException {
   GroupInfo info = init(group);
   if (options.contains(MEMBERS) || options.contains(INCLUDES)) {
     GroupResource rsrc = new GroupResource(groupControlFactory.controlFor(group));
     initMembersAndIncludes(rsrc, info);
   }
   return info;
 }
  /**
   * DO NOT USE DIRECTLY. public by accident. Calculate scale/offset/missing value info. This may
   * change the DataType.
   */
  public void enhance(Set<NetcdfDataset.Enhance> mode) {
    this.enhanceMode = EnumSet.copyOf(mode);
    boolean alreadyScaleOffsetMissing = false;
    boolean alreadyEnumConversion = false;

    // see if underlying variable has enhancements already applied
    if (orgVar != null && orgVar instanceof VariableDS) {
      VariableDS orgVarDS = (VariableDS) orgVar;
      EnumSet<NetcdfDataset.Enhance> orgEnhanceMode = orgVarDS.getEnhanceMode();
      if (orgEnhanceMode != null) {
        if (orgEnhanceMode.contains(NetcdfDataset.Enhance.ScaleMissing)) {
          alreadyScaleOffsetMissing = true;
          this.enhanceMode.add(
              NetcdfDataset.Enhance
                  .ScaleMissing); // Note: promote the enhancement to the wrapped variable
        }
        if (orgEnhanceMode.contains(NetcdfDataset.Enhance.ConvertEnums)) {
          alreadyEnumConversion = true;
          this.enhanceMode.add(
              NetcdfDataset.Enhance
                  .ConvertEnums); // Note: promote the enhancement to the wrapped variable
        }
      }
    }

    // do we need to calculate the ScaleMissing ?
    if (!alreadyScaleOffsetMissing
            && (dataType.isNumeric() || dataType == DataType.CHAR)
            && mode.contains(NetcdfDataset.Enhance.ScaleMissing)
        || mode.contains(NetcdfDataset.Enhance.ScaleMissingDefer)) {

      this.scaleMissingProxy = new EnhanceScaleMissingImpl(this);

      // promote the data type if ScaleMissing is set
      if (mode.contains(NetcdfDataset.Enhance.ScaleMissing)
          && scaleMissingProxy.hasScaleOffset()
          && (scaleMissingProxy.getConvertedDataType() != getDataType())) {
        setDataType(scaleMissingProxy.getConvertedDataType());
        removeAttributeIgnoreCase("_Unsigned");
      }

      // do we need to actually convert data ?
      needScaleOffsetMissing =
          mode.contains(NetcdfDataset.Enhance.ScaleMissing)
              && (scaleMissingProxy.hasScaleOffset() || scaleMissingProxy.getUseNaNs());
    }

    // do we need to do enum conversion ?
    if (!alreadyEnumConversion
        && mode.contains(NetcdfDataset.Enhance.ConvertEnums)
        && dataType.isEnum()) {
      this.needEnumConversion = true;

      // LOOK promote data type to STRING ????
      setDataType(DataType.STRING);
      removeAttributeIgnoreCase("_Unsigned");
    }
  }
 /** get ancestor with give blockType, starting from itself */
 public CourseComponent getAncestor(EnumSet<BlockType> types) {
   if (types.contains(type)) return this;
   IBlock ancestor = parent;
   if (ancestor == null) return null;
   do {
     if (types.contains(ancestor.getType())) return (CourseComponent) ancestor;
   } while ((ancestor = ancestor.getParent()) != null);
   return null;
 }
  public Map<EdgeLabel, Map<EdgeIndex, Edge>> getOutEdges(
      long receiverId,
      long senderId,
      NidVer oid,
      EnumSet<EdgeType> types,
      boolean queryableOnly,
      Optional<EdgeLabel> labelFilter,
      boolean checkExistenceOfPrivateLabelFilter)
      throws NodeNotFoundException {
    /* Check modifier */
    if (labelFilter.isPresent()) {
      if (labelFilter.get().isPublic() && (!types.contains(EdgeType.publicMod))) {
        throw new IllegalArgumentException(
            "Public label is given and EdgeType.publicMod " + "is missing");
      }
      if ((!labelFilter.get().isPublic()) && (!types.contains(EdgeType.privateMod))) {
        throw new IllegalArgumentException(
            "Private label is given and EdgeType.privateMod" + "is missing");
      }
    }

    /* Check label filter */
    if (checkExistenceOfPrivateLabelFilter
        && (labelFilter.isPresent())
        && (!labelFilter.get().isPublic())) {
      final NodeImpl node = getNodeFromCurrentOrHistorized(receiverId, oid);
      if (node == null) {
        throw new NodeNotFoundException("Node not found");
      }
      final long nodeClassId = node.getNodeSerie().getClassId();
      final NodeClass nodeClass = this.ncApi.getClassById(nodeClassId);
      if (!nodeClass.getEdgeClasses().containsKey(labelFilter.get().getPrivateEdgeIndex()))
        throw new IllegalArgumentException(
            "Given (private) label filter is not declared " + "in class.");
    }

    Map<EdgeLabel, Map<EdgeIndex, EdgeImpl>> outEdgesImpl =
        getOutEdgesImpl(receiverId, senderId, oid, types, queryableOnly);
    Map<EdgeLabel, Map<EdgeIndex, Edge>> outEdges = new HashMap<>();

    for (final Map.Entry<EdgeLabel, Map<EdgeIndex, EdgeImpl>> outEdgesImplEntry :
        outEdgesImpl.entrySet()) {
      final Map<EdgeIndex, Edge> singleEntry = new HashMap<>();
      final EdgeLabel edgeLabel = outEdgesImplEntry.getKey();
      if (labelFilter.isPresent() && (!labelFilter.get().equals(edgeLabel))) {
        /* Wrong label */
        continue;
      }
      outEdges.put(outEdgesImplEntry.getKey(), singleEntry);
      for (final Map.Entry<EdgeIndex, EdgeImpl> entry : outEdgesImplEntry.getValue().entrySet()) {
        final Edge edge = this.edgeUtil.toEdge(entry.getValue());
        singleEntry.put(entry.getKey(), edge);
      }
    }

    return outEdges;
  }
 protected final void clearBrowsingData(EnumSet<DialogOption> selectedOptions) {
   PrefServiceBridge.getInstance()
       .clearBrowsingData(
           this,
           selectedOptions.contains(DialogOption.CLEAR_HISTORY),
           selectedOptions.contains(DialogOption.CLEAR_CACHE),
           selectedOptions.contains(DialogOption.CLEAR_COOKIES_AND_SITE_DATA),
           selectedOptions.contains(DialogOption.CLEAR_PASSWORDS),
           selectedOptions.contains(DialogOption.CLEAR_FORM_DATA));
 }
Exemple #16
0
 public DDLStringVisitor(EnumSet<SchemaObjectType> types, String regexPattern) {
   if (types != null) {
     this.includeTables = types.contains(SchemaObjectType.TABLES);
     this.includeProcedures = types.contains(SchemaObjectType.PROCEDURES);
     this.includeFunctions = types.contains(SchemaObjectType.FUNCTIONS);
   }
   if (regexPattern != null) {
     this.filter = Pattern.compile(regexPattern);
   }
 }
 /**
  * Provisions a new EC2 slave or starts a previously stopped on-demand instance.
  *
  * @return always non-null. This needs to be then added to {@link Hudson#addNode(Node)}.
  */
 public EC2AbstractSlave provision(
     TaskListener listener, Label requiredLabel, EnumSet<ProvisionOptions> provisionOptions)
     throws AmazonClientException, IOException {
   if (this.spotConfig != null) {
     if (provisionOptions.contains(ProvisionOptions.ALLOW_CREATE)
         || provisionOptions.contains(ProvisionOptions.FORCE_CREATE))
       return provisionSpot(listener);
     return null;
   }
   return provisionOndemand(listener, requiredLabel, provisionOptions);
 }
Exemple #18
0
  public void registerListeners() {

    // Register Chat Handler (Always enabled)
    new PwnFilterPlayerListener(this);
    new PwnFilterEntityListener(this);

    // Register Configured Handlers
    if (enabledEvents.contains(EventType.COMMAND)) new PwnFilterCommandListener(this);
    if (enabledEvents.contains(EventType.SIGN)) new PwnFilterSignListener(this);
    if (enabledEvents.contains(EventType.ITEM)) new PwnFilterInvListener(this);
  }
Exemple #19
0
 /**
  * This is called whenever one of active layer/edit layer or both may have been changed,
  *
  * @param oldActive The old active layer
  * @param oldEdit The old edit layer.
  * @param listenersToFire A mask of listeners to fire using {@link LayerListenerType}s
  */
 private void onActiveEditLayerChanged(
     final Layer oldActive,
     final OsmDataLayer oldEdit,
     EnumSet<LayerListenerType> listenersToFire) {
   if (listenersToFire.contains(LayerListenerType.EDIT_LAYER_CHANGE)) {
     onEditLayerChanged(oldEdit);
   }
   if (listenersToFire.contains(LayerListenerType.ACTIVE_LAYER_CHANGE)) {
     onActiveLayerChanged(oldActive);
   }
 }
Exemple #20
0
 public static String getModeString() {
   if (modes.contains(Mode.Producer) && modes.contains(Mode.Consumer)) {
     return "Producer,Consumer";
   } else if (modes.contains(Mode.Producer)) {
     return "Producer";
   } else if (modes.contains(Mode.Consumer)) {
     return "Consumer";
   } else {
     return "";
   }
 }
Exemple #21
0
 public boolean isActive(CardEnum e) {
   if (e instanceof ColorFlag) {
     return colors.contains(e);
   } else if (e instanceof Attribute) {
     return attributes.contains(e);
   } else if (e instanceof CardType) {
     return cardTypes.contains(e);
   } else {
     throw new RuntimeException("Unknown enum type");
   }
 }
Exemple #22
0
 protected int compareByConformanceHint(
     EnumSet<ConformanceHint> leftConformance,
     EnumSet<ConformanceHint> rightConformance,
     ConformanceHint unexpectedHint) {
   boolean leftContains = leftConformance.contains(unexpectedHint);
   boolean rightContains = rightConformance.contains(unexpectedHint);
   if (leftContains != rightContains) {
     if (leftContains) return 1;
     return -1;
   }
   return 0;
 }
Exemple #23
0
  @Test
  public void testKeysPressed2() throws Exception {
    ks1 = new KeyboardState(EnumSet.noneOf(Key.class), KeyEvent.NOTHING);
    ks2 = new KeyboardState(EnumSet.of(Key.A, Key.C, Key.D), KeyEvent.NOTHING);

    final EnumSet<Key> pressed = ks2.getKeysPressedSince(ks1);

    assertEquals("2 key", 3, pressed.size());
    assertTrue("a pressed", pressed.contains(Key.A));
    assertTrue("c pressed", pressed.contains(Key.C));
    assertTrue("d pressed", pressed.contains(Key.D));
  }
 private void checkisBoolean(ValueList leftValueList, ValueList rightValueList) {
   EnumSet booleanTypes = EnumSet.of(PrimitiveType.Boolean);
   if (!booleanTypes.contains(leftValueList.getType())) {
     throw new RuntimeException(
         "not a boolean with boolean operator: " + leftValueList.getType()); // TODO: proper errors
   }
   if (!booleanTypes.contains(rightValueList.getType())) {
     throw new RuntimeException(
         "not a boolean with boolean operator: "
             + rightValueList.getType()); // TODO: proper errors
   }
 }
Exemple #25
0
    static String toString(EnumSet<Preserve> preserve) {
      if (CollectionUtils.isEmpty(preserve)) {
        return "";
      }

      return toString(
          preserve.contains(REPLICATION),
          preserve.contains(BLOCKSIZE),
          preserve.contains(USER),
          preserve.contains(GROUP),
          preserve.contains(PERMISSION));
    }
    public static int toByte(EnumSet<CodePageUseFlag> flags) {
      int result = 0;

      if (flags.contains(SortOrder)) {
        result += 0x80;
      }
      if (flags.contains(VariableSpaceEnable)) {
        result += 0x08;
      }

      return result;
    }
 @Override
 public void execute(DialogState state) {
   if (set.contains(ObjectClass.ATTACK)) {
     state.setSelectedAttack(null);
   }
   if (set.contains(ObjectClass.ITEM)) {
     state.setSelectedItem(null);
   }
   if (set.contains(ObjectClass.MONSTER)) {
     state.setSelectedMonster(null);
   }
 }
 private void checkIsNumber(ValueList leftValueList, ValueList rightValueList) {
   EnumSet numberTypes = EnumSet.of(PrimitiveType.Integer, PrimitiveType.Real);
   if (!numberTypes.contains(leftValueList.getType())) {
     throw new RuntimeException(
         "Type supplied to operator should be a number, but it is not: "
             + leftValueList.getType()); // TODO: proper errors
   }
   if (!numberTypes.contains(rightValueList.getType())) {
     throw new RuntimeException(
         "Type supplied to operator should be a number, but it is not: "
             + rightValueList.getType()); // TODO: proper errors
   }
 }
 @Override
 public TypeConformanceResult isConformant(
     JvmTypeReference left, JvmTypeReference right, TypeConformanceComputationArgument flags) {
   TypeConformanceResult result = super.isConformant(left, right, flags);
   if (result.isConformant()) {
     EnumSet<TypeConformanceResult.Kind> kinds = result.getKinds();
     if (kinds.contains(TypeConformanceResult.Kind.DEMAND_CONVERSION)
         || kinds.contains(TypeConformanceResult.Kind.SYNONYM)) {
       return TypeConformanceResult.FAILED;
     }
   }
   return result;
 }
  private void storeDiffs(
      EnumSet<QueryOption> prev, EnumSet<QueryOption> val, List<ModificationItem> mods) {
    if (prev != null ? prev.equals(val) : val == null) return;

    storeDiff(
        mods,
        "dcmRelationalQueries",
        prev != null && prev.contains(QueryOption.RELATIONAL),
        val != null && val.contains(QueryOption.RELATIONAL),
        false);
    storeDiff(
        mods,
        "dcmCombinedDateTimeMatching",
        prev != null && prev.contains(QueryOption.DATETIME),
        val != null && val.contains(QueryOption.DATETIME),
        false);
    storeDiff(
        mods,
        "dcmFuzzySemanticMatching",
        prev != null && prev.contains(QueryOption.FUZZY),
        val != null && val.contains(QueryOption.FUZZY),
        false);
    storeDiff(
        mods,
        "dcmTimezoneQueryAdjustment",
        prev != null && prev.contains(QueryOption.TIMEZONE),
        val != null && val.contains(QueryOption.TIMEZONE),
        false);
  }