Пример #1
0
  @EventHandler(priority = EventPriority.LOW)
  public void onBlockChange(BlockChangeEvent event) {
    Map map = event.getMap();
    if (!Rixor.getRotation().getSlot().getMatch().isCurrentlyRunning()) {
      event.setCancelled(true);
      return;
    }

    if (event.getClient() != null) {
      Client client = event.getClient();

      if (event.getNewState().getLocation().getBlockY() > map.getMaxbuildheight()) {
        event.setCancelled(true);
        client.getPlayer().sendMessage(ChatColor.RED + "You have reached the maximum build height");
        return;
      }
    }

    List<Filter> filters = map.getFilters(event.getOldState().getLocation());
    for (Filter filter : filters) {
      if (event.getClient() != null) {
        if (filter.getParents().contains(FilterType.DENY_PLAYERS))
          if (filter.getAllowTeams().size() > 0) {
            event.setCancelled(true);
            if (filter.hasMessage())
              event.getClient().getPlayer().sendMessage(ChatColor.RED + filter.getMessage());
          }
      }
    }
  }
Пример #2
0
 /**
  * parseLine calls the other parse methods to parse the given text.
  *
  * @param line
  */
 protected int parseLine(String line, TestElement el) {
   int count = 0;
   // we clean the line to get
   // rid of extra stuff
   String cleanedLine = this.cleanURL(line);
   log.debug("parsing line: " + line);
   // now we set request method
   el.setProperty(HTTPSamplerBase.METHOD, RMETHOD);
   if (FILTER != null) {
     log.debug("filter is not null");
     if (!FILTER.isFiltered(line, el)) {
       log.debug("line was not filtered");
       // increment the current count
       count++;
       // we filter the line first, before we try
       // to separate the URL into file and
       // parameters.
       line = FILTER.filter(cleanedLine);
       if (line != null) {
         createUrl(line, el);
       }
     } else {
       log.debug("Line was filtered");
     }
   } else {
     log.debug("filter was null");
     // increment the current count
     count++;
     // in the case when the filter is not set, we
     // parse all the lines
     createUrl(cleanedLine, el);
   }
   return count;
 }
  public Criteria execute(Criteria criteria) {
    for (Filter filter : filters) {
      buildCriteria(criteria, filter.getProperty(), filter.getValue());
    }

    return criteria;
  }
Пример #4
0
 public List<String> getFilters() {
   List<String> rtn = new ArrayList<String>(this.filters.size());
   for (Filter f : this.filters) {
     rtn.add(f.toString());
   }
   return Collections.unmodifiableList(rtn);
 }
Пример #5
0
  private void replay() {
    List<Tag> feTags = new ArrayList<Tag>(featureTags);
    feTags.addAll(featureElementTags);
    List<String> feNames = Arrays.asList(featureName, featureElementName);
    List<Range> feRanges = Arrays.asList(featureElementRange);
    boolean featureElementOk = filter.evaluate(feTags, feNames, feRanges);

    List<Tag> exTags = new ArrayList<Tag>(feTags);
    exTags.addAll(examplesTags);
    List<String> exNames = new ArrayList<String>(feNames);
    exNames.add(examplesName);
    List<Range> exRanges = new ArrayList<Range>(feRanges);
    exRanges.add(examplesRange);
    boolean examplesOk = filter.evaluate(exTags, exNames, exRanges);

    if (featureElementOk || examplesOk) {
      replayEvents(featureEvents);
      replayEvents(backgroundEvents);
      replayEvents(featureElementEvents);
      if (examplesOk) {
        replayEvents(examplesEvents);
      }
    }
    examplesEvents.clear();
    examplesTags.clear();
    examplesName = null;
    examplesRange = null;
  }
Пример #6
0
    @SuppressWarnings("rawtypes")
    public Object eval(JSONPath path, Object rootObject, Object currentObject) {
      if (currentObject == null) {
        return null;
      }

      List<Object> items = new ArrayList<Object>();

      if (currentObject instanceof Iterable) {
        Iterator it = ((Iterable) currentObject).iterator();
        while (it.hasNext()) {
          Object item = it.next();

          if (filter.apply(path, rootObject, currentObject, item)) {
            items.add(item);
          }
        }

        return items;
      }

      if (filter.apply(path, rootObject, currentObject, currentObject)) {
        return currentObject;
      }

      return null;
    }
Пример #7
0
  public void preFrame(float tpf) {
    if (filters.isEmpty() || lastFilterIndex == -1) {
      // If the camera is initialized and there are no filter to render, the camera viewport is
      // restored as it was
      if (cameraInit) {
        viewPort.getCamera().resize(originalWidth, originalHeight, true);
        viewPort.getCamera().setViewPort(left, right, bottom, top);
        viewPort.setOutputFrameBuffer(outputBuffer);
        cameraInit = false;
      }

    } else {
      if (renderFrameBufferMS != null) {
        viewPort.setOutputFrameBuffer(renderFrameBufferMS);
      } else {
        viewPort.setOutputFrameBuffer(renderFrameBuffer);
      }
      // init of the camera if it wasn't already
      if (!cameraInit) {
        viewPort.getCamera().resize(width, height, true);
        viewPort.getCamera().setViewPort(0, 1, 0, 1);
      }
    }

    for (Iterator<Filter> it = filters.iterator(); it.hasNext(); ) {
      Filter filter = it.next();
      if (filter.isEnabled()) {
        filter.preFrame(tpf);
      }
    }
  }
Пример #8
0
  @Override
  public void examples(Examples examples) {
    replay();
    examplesTags = examples.getTags();
    examplesName = examples.getName();

    Range tableBodyRange;
    switch (examples.getRows().size()) {
      case 0:
        tableBodyRange =
            new Range(examples.getLineRange().getLast(), examples.getLineRange().getLast());
        break;
      case 1:
        tableBodyRange =
            new Range(examples.getRows().get(0).getLine(), examples.getRows().get(0).getLine());
        break;
      default:
        tableBodyRange =
            new Range(
                examples.getRows().get(1).getLine(),
                examples.getRows().get(examples.getRows().size() - 1).getLine());
    }
    examplesRange = new Range(examples.getLineRange().getFirst(), tableBodyRange.getLast());
    if (filter.evaluate(
        Collections.<Tag>emptyList(),
        Collections.<String>emptyList(),
        Collections.singletonList(tableBodyRange))) {
      examples.setRows(filter.filterTableBodyRows(examples.getRows()));
    }
    examplesEvents = new ArrayList<BasicStatement>();
    examplesEvents.add(examples);
  }
 public String execute(String criteria) {
   String theCriteria = "";
   for (Filter filter : filters) {
     theCriteria += buildCriteria(criteria, filter.getProperty(), filter.getValue());
   }
   return theCriteria;
 }
Пример #10
0
 public String toString() {
   String str = "";
   for (Filter filter : filters) {
     str += filter.getClass().getCanonicalName() + ":";
   }
   return str;
 }
Пример #11
0
  public Filter unmarshall(StaxUnmarshallerContext context) throws Exception {
    Filter filter = new Filter();
    int originalDepth = context.getCurrentDepth();
    int targetDepth = originalDepth + 1;

    if (context.isStartOfDocument()) targetDepth += 1;

    while (true) {
      XMLEvent xmlEvent = context.nextEvent();
      if (xmlEvent.isEndDocument()) return filter;

      if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) {

        if (context.testExpression("Name", targetDepth)) {
          filter.setName(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

        if (context.testExpression("Values", targetDepth)) {
          filter.withValues(new ArrayList<String>());
          continue;
        }

        if (context.testExpression("Values/member", targetDepth)) {
          filter.withValues(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

      } else if (xmlEvent.isEndElement()) {
        if (context.getCurrentDepth() < originalDepth) {
          return filter;
        }
      }
    }
  }
Пример #12
0
 public boolean isFilter(String name) {
   for (Filter f : filters) {
     if (f.getLabel().equalsIgnoreCase(name)) return true;
     if (f.getLabel().equalsIgnoreCase("No " + name)) return true;
   }
   return false;
 }
Пример #13
0
  public boolean accept(String name) {
    for (Filter filter : filters) {
      if (filter.accept(name)) return true;
    }

    return false;
  }
Пример #14
0
  static void testServiceChannel(Service<Integer, String> aService) throws InterruptedException {
    Publisher<String> stringPublisher = aService.requestChannel(just(1));
    List<String> strings0 = toList(stringPublisher);
    assertTrue(strings0.equals(Arrays.asList("CHANNEL:1", "CHANNEL(+1):2")));

    Publisher<String> stringPublisher2 = aService.requestChannel(from(1, 2, 3, 4, 5));
    List<String> strings1 = toList(stringPublisher2);
    assertTrue(
        strings1.equals(
            Arrays.asList(
                "CHANNEL:1", "CHANNEL(+1):2",
                "CHANNEL:2", "CHANNEL(+1):3",
                "CHANNEL:3", "CHANNEL(+1):4",
                "CHANNEL:4", "CHANNEL(+1):5",
                "CHANNEL:5", "CHANNEL(+1):6")));

    Publisher<Double> doubles = from(1.0, 2.0, 3.0, 4.0, 5.0);
    Filter<Double, Integer, String, String> filter =
        Filters.fromFunction(x -> (int) (2 * x), str -> "'" + str + "'");
    Publisher<String> apply = filter.requestChannel(doubles, aService);
    List<String> strings2 = toList(apply);
    assertTrue(
        strings2.equals(
            Arrays.asList(
                "'CHANNEL:2'", "'CHANNEL(+1):3'",
                "'CHANNEL:4'", "'CHANNEL(+1):5'",
                "'CHANNEL:6'", "'CHANNEL(+1):7'",
                "'CHANNEL:8'", "'CHANNEL(+1):9'",
                "'CHANNEL:10'", "'CHANNEL(+1):11'")));
  }
 @Override
 /** Overridden to also include our profile. If our profile is included it will always be first. */
 protected List /*<Profile>*/ fetchProfiles(Filter f) {
   initializationGate();
   List result = null;
   {
     JmxManagerAdvisee advisee = (JmxManagerAdvisee) getAdvisee();
     Profile myp = advisee.getMyMostRecentProfile();
     if (f == null || f.include(myp)) {
       if (result == null) {
         result = new ArrayList();
       }
       result.add(myp);
     }
   }
   Profile[] locProfiles = this.profiles; // grab current profiles
   for (int i = 0; i < locProfiles.length; i++) {
     Profile profile = locProfiles[i];
     if (f == null || f.include(profile)) {
       if (result == null) {
         result = new ArrayList(locProfiles.length);
       }
       result.add(profile);
     }
   }
   if (result == null) {
     result = Collections.EMPTY_LIST;
   } else {
     result = Collections.unmodifiableList(result);
   }
   return result;
 }
Пример #16
0
  /**
   * Generate code corresponding to the given classes. The classes must have previously been
   * returned from {@link #enter}. If there are classes outstanding to be analyzed, that will be
   * done before any classes are generated. If null is specified, code will be generated for all
   * outstanding classes.
   *
   * @param classes a list of class elements
   */
  public Iterable<? extends JavaFileObject> generate(Iterable<? extends TypeElement> classes)
      throws IOException {
    final ListBuffer<JavaFileObject> results = new ListBuffer<JavaFileObject>();
    try {
      analyze(null); // ensure all classes have been parsed, entered, and analyzed

      if (classes == null) {
        compiler.generate(compiler.desugar(genList), results);
        genList.clear();
      } else {
        Filter f =
            new Filter() {
              public void process(Env<AttrContext> env) {
                compiler.generate(compiler.desugar(ListBuffer.of(env)), results);
              }
            };
        f.run(genList, classes);
      }
      if (genList.isEmpty()) {
        compiler.reportDeferredDiagnostics();
        cleanup();
      }
    } finally {
      if (compiler != null) compiler.log.flush();
    }
    return results;
  }
Пример #17
0
 public boolean isCellEditable(int row, int column) {
   // JW: this impl relies on the fact that there's always the
   // identity filter installed
   // should use adapter if assigned and no filter
   Filter last = last();
   return (last == null) ? false : last.isCellEditable(row, column);
 }
 public static void filtersToParameters(
     Collection<Filter> filters, List<String> parameters, Collection<VirtualFile> paths) {
   for (Filter filter : filters) {
     filter.getCommandParametersFilter().applyToCommandLine(parameters);
     filter.getCommandParametersFilter().applyToPaths(paths);
   }
 }
Пример #19
0
 /**
  * Returns the value of the cell at the specified coordinates.
  *
  * @param row in view coordinates
  * @param column in model coordinates
  * @return the value of the cell at the specified coordinates
  */
 public Object getValueAt(int row, int column) {
   // JW: this impl relies on the fact that there's always the
   // identity filter installed
   // should use adapter if assigned and no filter
   Filter last = last();
   return (last == null) ? null : last.getValueAt(row, column);
 }
  public static List<MemoryFilter> combineFilters(final Collection<Filter> filters) {
    final Merger[] mergers = {new UsersMerger()};
    if (filters.isEmpty()) return Collections.emptyList();

    final List<MemoryFilter> result = new ArrayList<MemoryFilter>();
    for (Filter filter : filters) {
      boolean taken = false;
      for (Merger combiner : mergers) {
        if (combiner.accept(filter.getMemoryFilter())) {
          taken = true;
          break;
        }
      }
      if (!taken) {
        result.add(filter.getMemoryFilter());
      }
    }
    for (Merger combiner : mergers) {
      final MemoryFilter combined = combiner.getResult();
      if (combined != null) {
        result.add(combined);
      }
    }
    return result;
  }
    @Override
    public synchronized boolean flush(ByteBuffer... buffers) throws IOException {
      if (DEBUG) LOG.debug("{} flush enter {}", FilterConnection.this, Arrays.toString(buffers));

      if (BufferUtil.hasContent(_outBuffer)) return false;

      if (_outBuffer == null) _outBuffer = _bufferPool.acquire(_outputBufferSize, true);

      // Take as much data as we can
      boolean all_taken = true;
      for (ByteBuffer buffer : buffers) {
        if (buffer == null) continue;
        BufferUtil.flipPutFlip(buffer, _outBuffer);

        if (BufferUtil.hasContent(buffer)) {
          all_taken = false;
          break;
        }
      }

      for (Filter filter : _filters) filter.outgoing(getEndPoint(), _outBuffer);

      boolean flushed = getEndPoint().flush(_outBuffer);
      if (BufferUtil.isEmpty(_outBuffer)) {
        _bufferPool.release(_outBuffer);
        _outBuffer = null;
      }

      if (DEBUG) LOG.debug("{} flush exit, consumed {}", FilterConnection.this, flushed);

      return all_taken && flushed;
    }
Пример #22
0
  private DirFilter getDirFilter() {
    DirFilter deepestDirFilter = new DirFilter(Operator.EQ, preferences.get(Keys.MEDIA_DIR));
    for (Filter<? super Tables.Tracks> filter : getFilters()) {
      final DirFilter finalDeepestDirFilter = deepestDirFilter;
      deepestDirFilter =
          filter.accept(
              new TurtleFilterVisitor<Tables.Tracks, DirFilter>() {
                public DirFilter visit(DirFilter dirFilter) {
                  return finalDeepestDirFilter
                          .getValue()
                          .contains(dirFilter.getValueWithoutWildcards())
                      ? finalDeepestDirFilter
                      : new DirFilter(Operator.EQ, dirFilter.getValueWithoutWildcards());
                }

                public DirFilter visit(NotFilter<? super Tables.Tracks> notFilter) {
                  return finalDeepestDirFilter;
                }

                public <T, Z> DirFilter visit(
                    FieldFilter<? super Tables.Tracks, Z, T> fieldFilter) {
                  return finalDeepestDirFilter;
                }

                public DirFilter visit(FilterSet<? super Tables.Tracks> filterSet) {
                  return finalDeepestDirFilter;
                }
              });
    }
    return deepestDirFilter;
  }
Пример #23
0
 public void forward(HttpContext context, HttpRequest request, HttpResponse response) {
   if (!filters.empty()) {
     Filter next = filters.pop();
     if (next != null) {
       next.process(this, context, request, response);
     }
   }
 }
 @VisibleForTesting
 void doClean(long projectId, List<Filter> filters, DbSession session) {
   List<PurgeableSnapshotDto> history = selectProjectSnapshots(projectId, session);
   for (Filter filter : filters) {
     filter.log();
     delete(filter.filter(history), session);
   }
 }
Пример #25
0
 private Filter toFilter(List<String> filterList) {
   Filter filter = new Filter();
   if (filterList == null) return filter;
   for (String pattern : filterList) {
     filter.add(new IgnoredFiles(pattern));
   }
   return filter;
 }
Пример #26
0
  public void testControlled() {

    Filter filter = new EqualWidthFilter();

    double[] orig = {0.1, 3.4, 3.5, 3.6, 7.0, 9.0, 6.0, 4.4, 2.5, 3.9, 4.5, 2.8};

    filter.filter(orig);
  }
Пример #27
0
 /**
  * Returns the number of records in the filtered view.
  *
  * @return the number of records in the filtered view
  */
 public int getOutputSize() {
   // JW: don't need to check - but that's heavily dependent on the
   // implementation detail that there's always the identityFilter
   // (which might change any time)
   if (!isAssigned()) return 0;
   Filter last = last();
   return (last == null) ? adapter.getRowCount() : last.getSize();
 }
Пример #28
0
 /**
  * @param filter
  * @return returns the unfiltered data adapter size or 0 if unassigned.
  */
 int getInputSize(Filter filter) {
   Filter previous = previous(filter);
   if (previous != null) {
     return previous.getSize();
   }
   // fixed issue #64-swingx - removed precondition... (was: isAssigned())
   return getInputSize();
 }
Пример #29
0
  /*
   * def test_first_last
   *   assert_equal 1, @filters.first([1,2,3])
   *   assert_equal 3, @filters.last([1,2,3])
   *   assert_equal nil, @filters.first([])
   *   assert_equal nil, @filters.last([])
   * end
   */
  @Test
  public void applyOriginalTest() {

    Filter filter = Filter.getFilter("last");

    assertThat(filter.apply(new Integer[] {1, 2, 3}), is((Object) "3"));
    assertThat(filter.apply(new Integer[] {}), is((Object) null));
  }
Пример #30
0
 public boolean isNoResultFilter(String name) {
   for (Filter f : noResultsFilters) {
     if (f.getLabel().equalsIgnoreCase(name)) {
       return true;
     }
   }
   return false;
 }