Example #1
1
 static {
   Set<String> set = new HashSet<String>();
   set.add("add");
   set.add("sub");
   set.add("and");
   set.add("or");
   twoArgArithmeticCommandSet = Collections.unmodifiableSet(set);
   set = new HashSet<String>();
   set.add("neg");
   set.add("not");
   singleArgArithmeticCommandSet = Collections.unmodifiableSet(set);
   set = new HashSet<String>();
   set.add("gt");
   set.add("lt");
   set.add("eq");
   twoArgArithmeticComparisonCommandSet = Collections.unmodifiableSet(set);
   Map<String, String> map = new HashMap<String, String>();
   map.put("add", "+");
   map.put("sub", "-");
   map.put("and", "&");
   map.put("or", "|");
   map.put("neg", "-");
   map.put("not", "!");
   map.put("gt", "JGT");
   map.put("lt", "JLT");
   map.put("eq", "JEQ");
   arithmeticOperatorMap = Collections.unmodifiableMap(map);
 }
Example #2
1
  public SelectMany05Bean() {

    HobbitBean[] hobbits = {
      new HobbitBean("Bilbo", "Ring Finder"),
      new HobbitBean("Frodo", "Ring Bearer"),
      new HobbitBean("Merry", "Trouble Maker"),
      new HobbitBean("Pippin", "Trouble Maker")
    };

    Set<SelectItem> items = new LinkedHashSet<SelectItem>();
    for (HobbitBean hobbit : hobbits) {
      items.add(new SelectItem(hobbit.getName()));
    }
    hobbitCollection = new TreeSet<HobbitBean>();
    hobbitCollection.addAll(Arrays.asList(hobbits));
    possibleValues = Collections.unmodifiableSet(items);
    initialSortedSetValues = new TreeSet<String>(Collections.reverseOrder());
    initialSortedSetValues.add("Pippin");
    initialSortedSetValues.add("Frodo");
    initialCollectionValues = new LinkedHashSet<String>(2);
    initialCollectionValues.add("Bilbo");
    initialCollectionValues.add("Merry");
    initialSetValues = new CopyOnWriteArraySet<String>(); // not Cloneable
    initialSetValues.add("Frodo");
    initialListValues = new Vector<String>();
    initialListValues.add("Bilbo");
    initialListValues.add("Pippin");
    initialListValues.add("Merry");
    hobbitDataModel =
        new ListDataModel<HobbitBean>(new ArrayList<HobbitBean>(Arrays.asList(hobbits)));
  }
Example #3
0
  protected AbstractTypedFilter(
      final Collection<RelationshipType> types,
      final Collection<RelationshipType> descendantTypes,
      final boolean includeManagedInfo,
      final boolean includeConcreteInfo) {
    if (types == null || types.isEmpty()) {
      this.types =
          Collections.unmodifiableSet(
              new HashSet<RelationshipType>(Arrays.asList(RelationshipType.values())));
    } else {
      this.types = Collections.unmodifiableSet(new HashSet<RelationshipType>(types));
    }

    if (descendantTypes == null || descendantTypes.isEmpty()) {
      this.descendantTypes =
          Collections.unmodifiableSet(
              new HashSet<RelationshipType>(Arrays.asList(RelationshipType.values())));
    } else {
      this.descendantTypes =
          Collections.unmodifiableSet(new HashSet<RelationshipType>(descendantTypes));
    }

    this.includeManagedInfo = includeManagedInfo;
    this.includeConcreteInfo = includeConcreteInfo;
  }
Example #4
0
  private Manufacturer(
      String displayName, String simpleName, Motor.Type motorType, String... alternateNames) {
    this.displayName = displayName;
    this.simpleName = simpleName;
    this.motorType = motorType;
    if (motorType == null) {
      throw new IllegalArgumentException("motorType cannot be null");
    }

    Set<String> all = new HashSet<String>();
    Set<String> search = new HashSet<String>();

    all.add(displayName);
    all.add(simpleName);
    search.add(generateSearchString(displayName));
    search.add(generateSearchString(simpleName));

    for (String name : alternateNames) {
      all.add(name);
      search.add(generateSearchString(name));
    }

    this.allNames = Collections.unmodifiableSet(all);
    this.searchNames = Collections.unmodifiableSet(search);
  }
  static {
    Set<Class<?>> customAnnotations = new HashSet<Class<?>>();
    customAnnotations.add(SetterCustomStringValue1.class);
    customAnnotations.add(SetterCustomStringValue2.class);
    customAnnotations.add(SetterCustomStringValue3.class);
    customAnnotations.add(SetterCustomStringValue4.class);
    customAnnotations.add(SetterCustomStringValue5.class);
    customAnnotations.add(SetterCustomNumberValue1.class);
    customAnnotations.add(SetterCustomNumberValue2.class);
    customAnnotations.add(SetterCustomNumberValue3.class);
    customAnnotations.add(SetterCustomNumberValue4.class);
    customAnnotations.add(SetterCustomNumberValue5.class);
    customAnnotations.add(SetterCustomDateValue1.class);
    customAnnotations.add(SetterCustomDateValue2.class);
    customAnnotations.add(SetterCustomDateValue3.class);
    CUSTOM_ANNOTATIONS = Collections.unmodifiableSet(customAnnotations);

    Set<Class<?>> mappingAnnotations = new HashSet<Class<?>>();
    mappingAnnotations.add(SetterPublisher.class);
    mappingAnnotations.add(SetterIncomingTime.class);
    mappingAnnotations.add(SetterOutcomingTime.class);
    mappingAnnotations.add(SetterInputName.class);
    mappingAnnotations.add(SetterUrl.class);
    mappingAnnotations.add(SetterRequest.class);
    mappingAnnotations.add(SetterResponse.class);
    mappingAnnotations.add(SetterServiceName.class);
    mappingAnnotations.add(UseLoggingInfoConvertor.class);

    MAPPING_ANNOTATIONS = Collections.unmodifiableSet(mappingAnnotations);
  }
  public TestListResolver(Collection<String> tests) {
    final IncludedExcludedPatterns patterns = new IncludedExcludedPatterns();
    final Set<ResolvedTest> includedFilters = new LinkedHashSet<ResolvedTest>(0);
    final Set<ResolvedTest> excludedFilters = new LinkedHashSet<ResolvedTest>(0);
    final Set<String> specificClasses = new LinkedHashSet<String>(0);

    for (final String csvTests : tests) {
      if (StringUtils.isNotBlank(csvTests)) {
        for (String request : StringUtils.split(csvTests, ",")) {
          request = request.trim();
          if (request.length() != 0 && !request.equals("!")) {
            resolveTestRequest(request, patterns, includedFilters, excludedFilters);
          }
        }
      }
    }

    for (ResolvedTest test : includedFilters) {
      populateSpecificClasses(specificClasses, test);
    }

    for (ResolvedTest test : excludedFilters) {
      populateSpecificClasses(specificClasses, test);
    }

    this.specificClasses = Collections.unmodifiableSet(specificClasses);
    this.includedPatterns = Collections.unmodifiableSet(includedFilters);
    this.excludedPatterns = Collections.unmodifiableSet(excludedFilters);
    this.hasIncludedMethodPatterns = patterns.hasIncludedMethodPatterns;
    this.hasExcludedMethodPatterns = patterns.hasExcludedMethodPatterns;
  }
Example #7
0
 protected Selection() {
   listeners = new ArrayList<>();
   selected = new HashSet<>();
   suppressed = new HashMap<>();
   selectedView = Collections.unmodifiableSet(selected);
   suppressedView = Collections.unmodifiableSet(suppressed.keySet());
 }
Example #8
0
  static {
    ResourceBundle rb =
        ResourceBundle.getBundle(
            "calendar/" + ISO_CALENDAR_TYPE,
            Locale.ROOT,
            getDefaultLoader(),
            UTF8ResourceControl.SINGLETON);

    String[] languages = rb.getString("languages").split(" ");
    Set<String> tmp = new HashSet<>();
    Collections.addAll(tmp, languages);
    LANGUAGES = Collections.unmodifiableSet(tmp);

    Set<Locale> locs = new HashSet<>();

    for (String lang : LANGUAGES) {
      locs.add(new Locale(lang));
    }

    // defensive strategy in case JDK should change its behaviour
    for (LanguageMatch lm : LanguageMatch.values()) {
      locs.add(new Locale(lm.name())); // in Java 8 or earlier no effect
    }

    LOCALES = Collections.unmodifiableSet(locs);
  }
 @SuppressWarnings({"rawtypes", "unchecked"})
 @Override
 public Iterable<Edge> getEdges(final Direction direction, final String... labels) {
   if (direction == Direction.IN) {
     if (labels == null || labels.length == 0) {
       return Collections.unmodifiableSet(getInEdgeObjects());
     } else {
       return getInEdgeObjects(labels);
     }
   } else if (direction == Direction.OUT) {
     if (labels == null || labels.length == 0) {
       return Collections.unmodifiableSet(getOutEdgeObjects());
     } else {
       return getOutEdgeObjects(labels);
     }
   } else {
     LinkedHashSet result = new LinkedHashSet<Edge>();
     if (labels == null || labels.length == 0) {
       result.addAll(getInEdgeObjects());
       result.addAll(getOutEdgeObjects());
     } else {
       result.addAll(getInEdgeObjects(labels));
       result.addAll(getOutEdgeObjects(labels));
     }
     return Collections.unmodifiableSet(result);
   }
 }
Example #10
0
  private void populateMedia() {
    initPrefinedMediaMaps();

    if (paperSet != null) {
      return; // already inited
    }
    Media[] media = (Media[]) service.getSupportedAttributeValues(Media.class, null, null);
    Set<Paper> pSet = new TreeSet<Paper>(PaperComparator.theComparator);
    Set<PaperSource> tSet = new TreeSet<PaperSource>(PaperSourceComparator.theComparator);
    /* We will get back a list of Media and want to look for
     * MediaSizeName and MediaTray instances and map to FX classes.
     * We will hard code here recognising the set we've chosen to
     * expose in FX API.
     * For the rest we'll need to create custom instances.
     */

    if (media != null) {
      for (int i = 0; i < media.length; i++) {
        Media m = media[i];
        if (m instanceof MediaSizeName) {
          pSet.add(addPaper(((MediaSizeName) m)));
        } else if (m instanceof MediaTray) {
          tSet.add(addPaperSource((MediaTray) m));
        }
      }
    }
    paperSet = Collections.unmodifiableSet(pSet);
    paperSourceSet = Collections.unmodifiableSet(tSet);
  }
Example #11
0
 void freeze() {
   if (freezed) return;
   synchronized (this) {
     if (freezed) return;
     matches = Collections.unmodifiableSet(matches);
     unmatches = Collections.unmodifiableSet(unmatches);
   }
 }
 @Deprecated
 public Set<Annotation> getQualifiers() {
   if (getMetaAnnotations(Qualifier.class).size() > 0) {
     return Collections.unmodifiableSet(getMetaAnnotations(Qualifier.class));
   } else {
     return Collections.unmodifiableSet(DEFAULT_QUALIFIERS);
   }
 }
  protected Set<Edge> getOutEdgeObjects(final String... labels) {
    Map<String, Set<Edge>> outCache = getOutEdgeCache();
    Set<Edge> result = null;

    if (labels == null || labels.length == 0) {
      result = new LinkedHashSet<Edge>();
      Set<String> labelSet = this.getOutEdgeLabels();
      //			System.out.println("INFO: Getting all OUT edges for a vertex across " + labelSet.size() +
      // " labels.");
      for (String label : labelSet) {
        Set<Edge> curEdges = getOutEdgeObjects(label);
        //				System.out.println("INFO: Found " + curEdges.size() + " OUT edges for label " +
        // label);
        result.addAll(curEdges);
      }
      //			System.out.println("INFO: Found " + result.size() + " OUT edges.");
    } else if (labels.length == 1) {
      String label = labels[0];
      if (label == null) {
        return Collections.unmodifiableSet(getOutEdgeObjects());
      }
      synchronized (outCache) {
        result = outCache.get(label);
      }
      if (result == null) {
        Set<String> edgeIds = getOutEdgesSet(label);
        Set<Edge> edges = getParent().getEdgesFromIds(edgeIds);
        if (edges != null) {
          result = Collections.synchronizedSet((LinkedHashSet) edges);
        }

        // result = Collections.synchronizedSet(new LinkedHashSet<Edge>());
        // Set<Edge> allEdges = Collections.unmodifiableSet(getOutEdgeObjects());
        // if (!allEdges.isEmpty()) {
        // for (Edge edge : allEdges) {
        // if (edge == null) {
        //
        // } else {
        // String curLabel = edge.getLabel();
        // if (label.equals(curLabel)) {
        // result.add(edge);
        // }
        // }
        // }
        // }

        synchronized (outCache) {
          outCache.put(label, result);
        }
      }
    } else {
      result = Collections.synchronizedSet(new LinkedHashSet<Edge>());
      for (String label : labels) {
        result.addAll(getOutEdgeObjects(label));
      }
    }
    return Collections.unmodifiableSet(result);
  }
 @Override
 public Set<String> getNewKillingJobInstanceIds(String ip, Watcher watcher) {
   try {
     return Collections.unmodifiableSet(
         new HashSet<String>(getChildrenNodeName(watcher, BASE, SCHEDULE, ip, DELETE)));
   } catch (Exception e) {
     return Collections.unmodifiableSet(new HashSet<String>(0));
   }
 }
Example #15
0
 public static void main(String[] args) {
   String string = "Find minimum size substring that contains given set of characters.";
   Set<Character> chars = new HashSet<Character>();
   chars.add('a');
   chars.add('c');
   chars.add('i');
   System.out.println(exhaustiveSearch(string, Collections.unmodifiableSet(chars)));
   System.out.println(indexedSearch(string, Collections.unmodifiableSet(chars)));
 }
Example #16
0
 /**
  * Constructs a <code>ThrowableSet</code> which contains the exception types represented in <code>
  * include</code>, except for those which are also in <code>exclude</code>. The constructor is
  * private to ensure that the only way to get a new <code>ThrowableSet</code> is by adding
  * elements to or removing them from an existing set.
  *
  * @param include The set of {@link RefType} and {@link AnySubType} objects representing the types
  *     to be included in the set.
  * @param exclude The set of {@link AnySubType} objects representing the types to be excluded from
  *     the set.
  */
 private ThrowableSet(Set include, Set exclude) {
   exceptionsIncluded = Collections.unmodifiableSet(include);
   exceptionsExcluded = Collections.unmodifiableSet(exclude);
   // We don't need to clone include and exclude to guarantee
   // immutability since ThrowableSet(Set,Set) is private to this
   // class, where it is only called (via
   // Manager.v().registerSetIfNew()) with arguments which the
   // callers do not subsequently modify.
 }
Example #17
0
  static void init() {
    TargetType.account.setInheritedByTargetTypes(new TargetType[] {TargetType.account});
    TargetType.calresource.setInheritedByTargetTypes(
        new TargetType[] {TargetType.account, TargetType.calresource});
    TargetType.dl.setInheritedByTargetTypes(
        new TargetType[] {TargetType.account, TargetType.calresource, TargetType.dl});
    TargetType.domain.setInheritedByTargetTypes(
        new TargetType[] {
          TargetType.account, TargetType.calresource, TargetType.dl, TargetType.domain
        });
    TargetType.cos.setInheritedByTargetTypes(new TargetType[] {TargetType.cos});
    TargetType.server.setInheritedByTargetTypes(new TargetType[] {TargetType.server});
    TargetType.xmppcomponent.setInheritedByTargetTypes(new TargetType[] {TargetType.xmppcomponent});
    TargetType.zimlet.setInheritedByTargetTypes(new TargetType[] {TargetType.zimlet});
    TargetType.config.setInheritedByTargetTypes(new TargetType[] {TargetType.config});
    TargetType.global.setInheritedByTargetTypes(
        new TargetType[] {
          TargetType.account,
          TargetType.calresource,
          TargetType.cos,
          TargetType.dl,
          domain,
          server,
          xmppcomponent,
          zimlet,
          config,
          global
        }); // inherited by all

    // compute mInheritFromTargetTypes and  mInheritedByOtherTargetTypes
    // from mInheritedByTargetTypes
    for (TargetType inheritFrom : TargetType.values()) {
      inheritFrom.mInheritFromTargetTypes = new HashSet<TargetType>();
      inheritFrom.mSubTargetTypes = new HashSet<TargetType>();

      for (TargetType inheritedBy : TargetType.values()) {
        if (inheritedBy.mInheritedByTargetTypes.contains(inheritFrom))
          inheritFrom.mInheritFromTargetTypes.add(inheritedBy);
      }

      for (TargetType tt : inheritFrom.mInheritedByTargetTypes) {
        // add this ugly check, see comments for mSubTargetTypes above
        if (inheritFrom == TargetType.calresource) {
          if (inheritFrom != tt && tt != TargetType.account) inheritFrom.mSubTargetTypes.add(tt);
        } else {
          if (inheritFrom != tt) inheritFrom.mSubTargetTypes.add(tt);
        }
      }
    }

    for (TargetType tt : TargetType.values()) {
      tt.mInheritedByTargetTypes = Collections.unmodifiableSet(tt.mInheritedByTargetTypes);
      tt.mInheritFromTargetTypes = Collections.unmodifiableSet(tt.mInheritFromTargetTypes);
      tt.mSubTargetTypes = Collections.unmodifiableSet(tt.mSubTargetTypes);
    }
  }
/**
 * ResourcesYamlFormatParser is ...
 *
 * @author Greg Schueler <a href="mailto:greg@dtosolutions.com">greg@dtosolutions.com</a>
 */
@Plugin(name = "resourceyaml", service = "ResourceFormatParser")
public class ResourceYamlFormatParser implements ResourceFormatParser, Describable {
  public static final String SERVICE_PROVIDER_TYPE = "resourceyaml";

  public static final Set<String> EXTENSIONS =
      Collections.unmodifiableSet(new HashSet<String>(Arrays.asList("yaml", "yml")));
  public static final Set<String> MIME_TYPES =
      Collections.unmodifiableSet(new HashSet<String>(Arrays.asList("*/yaml", "*/x-yaml")));

  public Set<String> getFileExtensions() {
    return EXTENSIONS;
  }

  public Set<String> getMIMETypes() {
    return MIME_TYPES;
  }

  public INodeSet parseDocument(final File file) throws ResourceFormatParserException {
    final NodeSetImpl nodes = new NodeSetImpl();
    try {
      new NodesYamlParser(file, nodes).parse();
    } catch (NodeFileParserException e) {
      throw new ResourceFormatParserException(e);
    }
    return nodes;
  }

  public INodeSet parseDocument(final InputStream input) throws ResourceFormatParserException {
    final NodeSetImpl nodes = new NodeSetImpl();
    try {
      new NodesYamlParser(input, nodes).parse();
    } catch (NodeFileParserException e) {
      throw new ResourceFormatParserException(e);
    }
    return nodes;
  }

  private static final Description DESCRIPTION =
      new AbstractBaseDescription() {
        public String getName() {
          return SERVICE_PROVIDER_TYPE;
        }

        public String getTitle() {
          return "Resource YAML";
        }

        public String getDescription() {
          return "The RunDeck Resource YAML format 1.3";
        }
      };

  public Description getDescription() {
    return DESCRIPTION;
  }
}
Example #19
0
 protected AbstractTypedFilter(
     final RelationshipType type,
     final RelationshipType descendantType,
     final boolean includeManagedInfo,
     final boolean includeConcreteInfo) {
   this.types = Collections.unmodifiableSet(Collections.singleton(type));
   this.descendantTypes = Collections.unmodifiableSet(Collections.singleton(descendantType));
   this.includeManagedInfo = includeManagedInfo;
   this.includeConcreteInfo = includeConcreteInfo;
 }
Example #20
0
 /** Constructor */
 public SimplePackageModel(
     PackageResource packageResource,
     DocModel packageInfo,
     Collection<String> exportedClasses,
     Collection<String> privateClasses) {
   _packageResource = packageResource;
   _packageInfo = packageInfo;
   _exportedClasses = Collections.unmodifiableSet(new HashSet<String>(exportedClasses));
   _privateClasses = Collections.unmodifiableSet(new HashSet<String>(privateClasses));
 }
  /**
   * Creates a new {@link BeanMetaDataImpl}
   *
   * @param beanClass The Java type represented by this meta data object.
   * @param defaultGroupSequence The default group sequence.
   * @param defaultGroupSequenceProvider The default group sequence provider if set.
   * @param constraintMetaDataSet All constraint meta data relating to the represented type.
   */
  public BeanMetaDataImpl(
      Class<T> beanClass,
      List<Class<?>> defaultGroupSequence,
      DefaultGroupSequenceProvider<? super T> defaultGroupSequenceProvider,
      Set<ConstraintMetaData> constraintMetaDataSet) {

    this.beanClass = beanClass;
    this.propertyMetaDataMap = newHashMap();

    Set<PropertyMetaData> propertyMetaDataSet = newHashSet();
    Set<ExecutableMetaData> executableMetaDataSet = newHashSet();

    for (ConstraintMetaData constraintMetaData : constraintMetaDataSet) {
      if (constraintMetaData.getKind() == ElementKind.PROPERTY) {
        propertyMetaDataSet.add((PropertyMetaData) constraintMetaData);
      } else {
        executableMetaDataSet.add((ExecutableMetaData) constraintMetaData);
      }
    }

    Set<Cascadable> cascadedProperties = newHashSet();
    Set<MetaConstraint<?>> allMetaConstraints = newHashSet();

    for (PropertyMetaData propertyMetaData : propertyMetaDataSet) {
      propertyMetaDataMap.put(propertyMetaData.getName(), propertyMetaData);

      if (propertyMetaData.isCascading()) {
        cascadedProperties.add(propertyMetaData);
      }

      allMetaConstraints.addAll(propertyMetaData.getConstraints());
    }

    this.cascadedProperties = Collections.unmodifiableSet(cascadedProperties);
    this.allMetaConstraints = Collections.unmodifiableSet(allMetaConstraints);

    this.classHierarchyWithoutInterfaces =
        ClassHierarchyHelper.getHierarchy(beanClass, Filters.excludeInterfaces());

    setDefaultGroupSequenceOrProvider(defaultGroupSequence, defaultGroupSequenceProvider);

    this.directMetaConstraints = getDirectConstraints();

    this.executableMetaDataMap = Collections.unmodifiableMap(byIdentifier(executableMetaDataSet));

    this.beanDescriptor =
        new BeanDescriptorImpl(
            beanClass,
            getClassLevelConstraintsAsDescriptors(),
            getConstrainedPropertiesAsDescriptors(),
            getConstrainedMethodsAsDescriptors(),
            getConstrainedConstructorsAsDescriptors(),
            defaultGroupSequenceIsRedefined(),
            getDefaultGroupSequence(null));
  }
 public Iterator iterator() {
   // If nodefilters are set, must execute them first to create node-set
   if (xi.getNodeFilters() != null && !xi.getNodeFilters().isEmpty()) {
     return Collections.unmodifiableSet(getNodeSet(xi.getNodeFilters())).iterator();
   }
   try {
     return Collections.unmodifiableSet(xi.getNodeSet()).iterator();
   } catch (Exception e) {
     // should not occur
     throw new RuntimeException("unrecoverable error retrieving nodeset", e);
   }
 }
Example #23
0
 public as(C0324a c0324a, SearchAdRequest searchAdRequest) {
   this.f52d = c0324a.f50d;
   this.lY = c0324a.lY;
   this.lZ = c0324a.lZ;
   this.f53f = Collections.unmodifiableSet(c0324a.mh);
   this.f54h = c0324a.f51h;
   this.ma = c0324a.ma;
   this.mb = Collections.unmodifiableMap(c0324a.mi);
   this.mc = Collections.unmodifiableMap(c0324a.mj);
   this.md = c0324a.md;
   this.me = searchAdRequest;
   this.mf = c0324a.mf;
   this.mg = Collections.unmodifiableSet(c0324a.mk);
 }
Example #24
0
 public au(a a1, SearchAdRequest searchadrequest) {
   d = a.a(a1);
   mi = a.b(a1);
   mj = a.c(a1);
   f = Collections.unmodifiableSet(a.d(a1));
   h = a.e(a1);
   mk = a.f(a1);
   ml = a.g(a1);
   mm = Collections.unmodifiableMap(a.h(a1));
   mn = a.i(a1);
   mo = searchadrequest;
   mp = a.j(a1);
   mq = Collections.unmodifiableSet(a.k(a1));
 }
  static {
    sensitiveKeys = new HashSet<String>(2);
    sensitiveKeys.add(LTI_KEY);
    sensitiveKeys.add(LTI_SECRET);
    sensitiveKeys = Collections.unmodifiableSet(sensitiveKeys);

    unsupportedKeys = new HashSet<String>(5);
    unsupportedKeys.add("jcr:primaryType");
    unsupportedKeys.add("jcr:created");
    unsupportedKeys.add("jcr:createdBy");
    unsupportedKeys.add(":operation");
    unsupportedKeys.add("_MODIFIERS"); // TrimPath stuff
    unsupportedKeys = Collections.unmodifiableSet(unsupportedKeys);
  }
Example #26
0
  /**
   * Statically analyze a query for various properties.
   *
   * @param query the query to analyze
   * @param params parameters for the query; if necessary parameters are left out they will be
   *     listed as required variables in the analysis
   * @return a query analysis facet
   */
  public QueryAnalysis analyze(String query, Object... params) {
    if (presub) query = presub(query, params);

    long t1 = System.currentTimeMillis(), t2 = 0, t3 = 0;
    DBBroker broker = null;
    try {
      broker = db.acquireBroker();
      prepareContext(broker);
      final org.exist.source.Source source = buildQuerySource(query, params, "analyze");
      final XQuery xquery = broker.getXQueryService();
      final XQueryPool pool = xquery.getXQueryPool();
      CompiledXQuery compiledQuery = pool.borrowCompiledXQuery(broker, source);
      try {
        AnalysisXQueryContext context;
        if (compiledQuery == null) {
          context = new AnalysisXQueryContext(broker, AccessContext.INTERNAL_PREFIX_LOOKUP);
          buildXQueryStaticContext(context, false);
          buildXQueryDynamicContext(context, params, null, false);
          t2 = System.currentTimeMillis();
          compiledQuery = xquery.compile(context, source);
          t3 = System.currentTimeMillis();
        } else {
          context = (AnalysisXQueryContext) compiledQuery.getContext();
          t2 = System.currentTimeMillis();
        }
        return new QueryAnalysis(
            compiledQuery,
            Collections.unmodifiableSet(context.requiredVariables),
            Collections.unmodifiableSet(context.requiredFunctions));
      } finally {
        if (compiledQuery != null) pool.returnCompiledXQuery(source, compiledQuery);
      }
    } catch (XPathException e) {
      LOG.warn(
          "query compilation failed --  "
              + query
              + "  -- "
              + (params == null ? "" : " with params " + Arrays.asList(params))
              + (bindings.isEmpty() ? "" : " and bindings " + bindings));
      throw new DatabaseException("failed to compile query", e);
    } catch (IOException e) {
      throw new DatabaseException("unexpected exception", e);
    } catch (PermissionDeniedException e) {
      throw new DatabaseException("permission denied", e);
    } finally {
      db.releaseBroker(broker);
      STATS.update(query, t1, t2, t3, 0, System.currentTimeMillis());
    }
  }
Example #27
0
  public X509IssuerInfo(
      final List<String> caIssuerURLs,
      final List<String> ocspURLs,
      final List<String> crlURLs,
      final List<String> deltaCrlURLs,
      final byte[] certBytes)
      throws CertificateException {
    ParamChecker.assertNotNull("certBytes", certBytes);

    if (CollectionUtil.isEmpty(caIssuerURLs)) {
      this.caIssuerURLs = null;
    } else {
      Set<String> set = new HashSet<>();
      set.addAll(caIssuerURLs);
      this.caIssuerURLs = Collections.unmodifiableSet(set);
    }

    if (CollectionUtil.isEmpty(ocspURLs)) {
      this.ocspURLs = null;
    } else {
      Set<String> set = new HashSet<>();
      set.addAll(ocspURLs);
      this.ocspURLs = Collections.unmodifiableSet(set);
    }

    if (CollectionUtil.isEmpty(crlURLs)) {
      this.crlURLs = null;
    } else {
      Set<String> set = new HashSet<>();
      set.addAll(crlURLs);
      this.crlURLs = Collections.unmodifiableSet(set);
    }

    if (CollectionUtil.isEmpty(deltaCrlURLs)) {
      this.deltaCrlURLs = null;
    } else {
      Set<String> set = new HashSet<>();
      set.addAll(deltaCrlURLs);
      this.deltaCrlURLs = Collections.unmodifiableSet(set);
    }

    try {
      this.cert = X509Util.parseCert(certBytes);
    } catch (IOException e) {
      throw new CertificateException(e.getMessage(), e);
    }
    this.bcCert = Certificate.getInstance(certBytes);
    this.ski = X509Util.extractSKI(cert);
  }
 static {
   HashSet hashset = new HashSet(8);
   hashset.add("system_app_crash");
   hashset.add("data_app_crash");
   hashset.add("system_app_wtf");
   hashset.add("system_server_crash");
   hashset.add("system_server_watchdog");
   JAVA_CRASH_ARTIFACT_TAGS = Collections.unmodifiableSet(hashset);
   hashset = new HashSet(4);
   hashset.add("system_app_crash");
   hashset.add("data_app_crash");
   hashset.add("system_server_crash");
   hashset.add("system_app_wtf");
   JAVA_STACK_TRACE_TAGS = Collections.unmodifiableSet(hashset);
 }
  public static Languages getInstance(String languagesResourceName) {
    // read languages list
    Set<String> ls = new HashSet<String>();
    InputStream langIS =
        Languages.class.getClassLoader().getResourceAsStream(languagesResourceName);

    if (langIS == null) {
      throw new IllegalArgumentException(
          "Unable to resolve required resource: " + languagesResourceName);
    }

    Scanner lsScanner = new Scanner(langIS, ResourceConstants.ENCODING);
    boolean inExtendedComment = false;
    while (lsScanner.hasNextLine()) {
      String line = lsScanner.nextLine().trim();
      if (inExtendedComment) {
        if (line.endsWith(ResourceConstants.EXT_CMT_END)) {
          inExtendedComment = false;
        } else {
          // skip
        }
      } else {
        if (line.startsWith(ResourceConstants.EXT_CMT_START)) {
          inExtendedComment = true;
        } else if (line.length() > 0) {
          ls.add(line);
        } else {
          // skip blank lines
        }
      }
    }

    return new Languages(Collections.unmodifiableSet(ls));
  }
Example #30
0
 static {
   JAVA_IMMUTABLE =
       Collections.unmodifiableSet(
           new HashSet<>(
               Arrays.asList(
                   Boolean.class,
                   Byte.class,
                   Character.class,
                   Double.class,
                   Float.class,
                   Short.class,
                   Integer.class,
                   Long.class,
                   BigInteger.class,
                   BigDecimal.class,
                   String.class,
                   Class.class,
                   UUID.class,
                   URL.class,
                   URI.class,
                   Pattern.class,
                   Inet4Address.class,
                   Inet6Address.class,
                   InetSocketAddress.class,
                   LocalDate.class,
                   LocalTime.class,
                   LocalDateTime.class,
                   Instant.class,
                   Duration.class)));
   Map<Class<?>, Function<Object, Object>> strategies = new HashMap<>();
   strategies.put(Calendar.class, o -> ((Calendar) o).clone());
   strategies.put(Date.class, o -> ((Date) o).clone());
   JAVA_DEEP_COPY = Collections.unmodifiableMap(strategies);
 }