Beispiel #1
0
 public ObfuscateData getObfuscateData() {
   ObfuscateData data = new ObfuscateData();
   data.resName = getResKey();
   data.typeMaping = Collections.unmodifiableMap(mTypeMaping);
   data.keyMaping = Collections.unmodifiableMap(mKeyMaping);
   return data;
 }
  // Initialize highlight mapping table
  static {
    Map<TextAttribute, Object> styles[] = new Map[4];
    HashMap<TextAttribute, Object> map;

    // UNSELECTED_RAW_TEXT_HIGHLIGHT
    map = new HashMap(1);
    map.put(TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.UNDERLINE_LOW_DOTTED);
    styles[0] = Collections.unmodifiableMap(map);

    // SELECTED_RAW_TEXT_HIGHLIGHT
    map = new HashMap(1);
    map.put(TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.UNDERLINE_LOW_GRAY);
    styles[1] = Collections.unmodifiableMap(map);

    // UNSELECTED_CONVERTED_TEXT_HIGHLIGHT
    map = new HashMap(1);
    map.put(TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.UNDERLINE_LOW_DOTTED);
    styles[2] = Collections.unmodifiableMap(map);

    // SELECTED_CONVERTED_TEXT_HIGHLIGHT
    map = new HashMap(4);
    Color navyBlue = new Color(0, 0, 128);
    map.put(TextAttribute.FOREGROUND, navyBlue);
    map.put(TextAttribute.BACKGROUND, Color.white);
    map.put(TextAttribute.SWAP_COLORS, TextAttribute.SWAP_COLORS_ON);
    map.put(TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.UNDERLINE_LOW_ONE_PIXEL);
    styles[3] = Collections.unmodifiableMap(map);

    highlightStyles = styles;
  }
  static {
    Map<Class, CoreMapAttributeAggregator> defaultAggr =
        new ArrayMap<Class, CoreMapAttributeAggregator>();
    defaultAggr.put(CoreAnnotations.TextAnnotation.class, CoreMapAttributeAggregator.CONCAT);
    defaultAggr.put(
        CoreAnnotations.CharacterOffsetBeginAnnotation.class, CoreMapAttributeAggregator.FIRST);
    defaultAggr.put(
        CoreAnnotations.CharacterOffsetEndAnnotation.class, CoreMapAttributeAggregator.LAST);
    defaultAggr.put(CoreAnnotations.TokenBeginAnnotation.class, CoreMapAttributeAggregator.FIRST);
    defaultAggr.put(CoreAnnotations.TokenEndAnnotation.class, CoreMapAttributeAggregator.LAST);
    defaultAggr.put(
        CoreAnnotations.TokensAnnotation.class, CoreMapAttributeAggregator.CONCAT_TOKENS);
    DEFAULT_AGGREGATORS = Collections.unmodifiableMap(defaultAggr);

    Map<Class, CoreMapAttributeAggregator> defaultNumericAggr =
        new ArrayMap<Class, CoreMapAttributeAggregator>(DEFAULT_AGGREGATORS);
    defaultNumericAggr.put(
        CoreAnnotations.NumericCompositeTypeAnnotation.class,
        CoreMapAttributeAggregator.FIRST_NON_NIL);
    defaultNumericAggr.put(
        CoreAnnotations.NumericCompositeValueAnnotation.class,
        CoreMapAttributeAggregator.FIRST_NON_NIL);
    defaultNumericAggr.put(
        CoreAnnotations.NamedEntityTagAnnotation.class, CoreMapAttributeAggregator.FIRST_NON_NIL);
    defaultNumericAggr.put(
        CoreAnnotations.NormalizedNamedEntityTagAnnotation.class,
        CoreMapAttributeAggregator.FIRST_NON_NIL);
    DEFAULT_NUMERIC_AGGREGATORS = Collections.unmodifiableMap(defaultNumericAggr);

    Map<Class, CoreMapAttributeAggregator> defaultNumericTokensAggr =
        new ArrayMap<Class, CoreMapAttributeAggregator>(DEFAULT_NUMERIC_AGGREGATORS);
    defaultNumericTokensAggr.put(
        CoreAnnotations.NumerizedTokensAnnotation.class, CoreMapAttributeAggregator.CONCAT_COREMAP);
    DEFAULT_NUMERIC_TOKENS_AGGREGATORS = Collections.unmodifiableMap(defaultNumericTokensAggr);
  }
    public synchronized Map<String, Object[]> getParameterMap() {
      if (parameterMap == null) {
        // Two conditions: file upload ("multipart/form-data") or not
        if (getContentType() != null && getContentType().startsWith("multipart/form-data")) {
          // Special handling for multipart/form-data

          // Decode the multipart data
          parameterMap =
              Multipart.getParameterMapMultipart(
                  pipelineContext, request, ServletExternalContext.DEFAULT_FORM_CHARSET_DEFAULT);
        } else if (portletRequest instanceof ResourceRequest) {
          // We encoded query parameters directly into the resource id in this case
          final String queryString =
              NetUtils.getQueryString(((ResourceRequest) portletRequest).getResourceID());
          if (queryString != null)
            parameterMap =
                Collections.unmodifiableMap(
                    StringConversions.stringArrayMapToObjectArrayMap(
                        NetUtils.decodeQueryString(queryString, false)));
          else parameterMap = Collections.emptyMap();
        } else {
          // Not a resource request, so just use native request parameters
          parameterMap = new HashMap<String, Object[]>(portletRequest.getParameterMap());
          parameterMap.remove(WSRPURLRewriter.PathParameterName());
          parameterMap = Collections.unmodifiableMap(parameterMap);
        }
      }
      return parameterMap;
    }
Beispiel #5
0
  public HttpEventImpl(
      HttpServer source,
      RequestMode mode,
      URI requestURI,
      InetSocketAddress remoteAddress,
      String plainUri,
      HttpSession session,
      Map<String, String> cookies,
      Map<String, String> get,
      Map<String, String> post,
      String requestBody) {

    this.source = source;
    this.mode = mode;
    this.requestUri = requestURI;
    this.plainUri = plainUri;
    this.clientIp = remoteAddress;
    this.session = session;
    this.requestBody = requestBody;

    this.cookies = Collections.unmodifiableMap(cookies);
    this.get = Collections.unmodifiableMap(get);
    this.post = Collections.unmodifiableMap(post);
    this.closeListener = new ArrayList<>();

    this.creationTime = new Date();
  }
  static {
    String path =
        "/2013-04-01/hostedzone/{Id}/rrset?type={Type}&name={Name}&identifier={Identifier}&maxitems={MaxItems}";
    Map<String, String> staticMap = new HashMap<String, String>();
    Map<String, String> dynamicMap = new HashMap<String, String>();

    int index = path.indexOf("?");
    if (index != -1) {
      String queryString = path.substring(index + 1);
      path = path.substring(0, index);

      for (String s : queryString.split("[;&]")) {
        index = s.indexOf("=");
        if (index != -1) {
          String name = s.substring(0, index);
          String value = s.substring(index + 1);

          if (value.startsWith("{") && value.endsWith("}")) {
            dynamicMap.put(value.substring(1, value.length() - 1), name);
          } else {
            staticMap.put(name, value);
          }
        }
      }
    }

    RESOURCE_PATH_TEMPLATE = path;
    STATIC_QUERY_PARAMS = Collections.unmodifiableMap(staticMap);
    DYNAMIC_QUERY_PARAMS = Collections.unmodifiableMap(dynamicMap);
  }
  @Override
  public Map<String, List<String>> get(
      final URI uri, final Map<String, List<String>> requestHeaders) {
    // pre-condition check
    if (uri == null || requestHeaders == null) {
      throw new IllegalArgumentException("Argument is null");
    }

    final Map<String, List<String>> cookieMap = new java.util.HashMap<String, List<String>>();
    // if there's no default CookieStore, no way for us to get any cookie
    if (getCookieStore() == null) {
      return Collections.unmodifiableMap(cookieMap);
    }

    final List<HttpCookie> cookies = new java.util.ArrayList<HttpCookie>();
    final List<String> auth =
        requestHeaders.get(StandardAuthenticationProviderWithUserInHeaders.USER_FOR_COOKIE);
    for (final HttpCookie cookie : getCookieStore().get(uri)) {
      // apply path-matches rule (RFC 2965 sec. 3.3.4)
      if (pathMatches(uri.getPath(), cookie.getPath()) && isSameAuth(auth, cookie)) {
        cookies.add(cookie);
      }
    }
    lastAuth.set(auth);

    // apply sort rule (RFC 2965 sec. 3.3.4)
    final List<String> cookieHeader = sortByPath(cookies);

    cookieMap.put("Cookie", cookieHeader);
    return Collections.unmodifiableMap(cookieMap);
  }
  public Map<String, String[]> getParameterMap() {
    if (_portletRequestDispatcherRequest != null) {
      return Collections.unmodifiableMap(_portletRequestDispatcherRequest.getParameterMap());
    }

    return Collections.unmodifiableMap(_request.getParameterMap());
  }
  /**
   * Constructor takes a lane's collection of Tiles and calculates the median phasing/prephasing for
   * the first and second (if available) reads
   */
  public LanePhasingMetricsCollector(final Collection<Tile> laneTiles) {
    final Map<TileTemplateRead, Float> medianPhasingMapLocal =
        new TreeMap<TileTemplateRead, Float>();
    final Map<TileTemplateRead, Float> medianPrePhasingMapLocal =
        new TreeMap<TileTemplateRead, Float>();

    final CollectionUtil.MultiMap<TileTemplateRead, Float> phasingValues =
        new CollectionUtil.MultiMap<TileTemplateRead, Float>();
    final CollectionUtil.MultiMap<TileTemplateRead, Float> prePhasingValues =
        new CollectionUtil.MultiMap<TileTemplateRead, Float>();

    // Collect the phasing/prephasing values from all of the tiles, sorted by template read #
    for (final Tile tile : laneTiles) {
      for (final TileTemplateRead tileTemplateRead : tile.getPhasingMap().keySet()) {
        phasingValues.append(tileTemplateRead, tile.getPhasingMap().get(tileTemplateRead));
        prePhasingValues.append(tileTemplateRead, tile.getPrePhasingMap().get(tileTemplateRead));
      }
    }

    // Calculate the medians for the collected data
    for (final TileTemplateRead tileTemplateRead : phasingValues.keySet()) {
      medianPhasingMapLocal.put(
          tileTemplateRead, medianPercentage(phasingValues.get(tileTemplateRead)));
      medianPrePhasingMapLocal.put(
          tileTemplateRead, medianPercentage(prePhasingValues.get(tileTemplateRead)));
    }

    this.medianPhasingMap = Collections.unmodifiableMap(medianPhasingMapLocal);
    this.medianPrePhasingMap = Collections.unmodifiableMap(medianPrePhasingMapLocal);
  }
  static {
    Map<Integer, String> statesTmp = new HashMap<Integer, String>();
    statesTmp.put(LoadListenerClient.PAGE_STARTED, "page_started");
    statesTmp.put(LoadListenerClient.PAGE_FINISHED, "page_finished");
    statesTmp.put(LoadListenerClient.PAGE_REDIRECTED, "page_redirected");
    statesTmp.put(LoadListenerClient.LOAD_FAILED, "load_failed");
    statesTmp.put(LoadListenerClient.LOAD_STOPPED, "load_stopped");
    statesTmp.put(LoadListenerClient.CONTENT_RECEIVED, "content_received");
    statesTmp.put(LoadListenerClient.TITLE_RECEIVED, "title_received");
    statesTmp.put(LoadListenerClient.ICON_RECEIVED, "icon_received");
    statesTmp.put(LoadListenerClient.CONTENTTYPE_RECEIVED, "contenttype_received");
    statesTmp.put(LoadListenerClient.DOCUMENT_AVAILABLE, "document_available");
    statesTmp.put(LoadListenerClient.RESOURCE_STARTED, "resource_started");
    statesTmp.put(LoadListenerClient.RESOURCE_REDIRECTED, "resource_redirected");
    statesTmp.put(LoadListenerClient.RESOURCE_FINISHED, "resource_finished");
    statesTmp.put(LoadListenerClient.RESOURCE_FAILED, "resource_failed");
    statesTmp.put(LoadListenerClient.PROGRESS_CHANGED, "progress_changed");
    states = Collections.unmodifiableMap(statesTmp);

    Map<Integer, String> errorsTmp = new HashMap<Integer, String>();
    errorsTmp.put(0, "none");
    errorsTmp.put(LoadListenerClient.UNKNOWN_HOST, "unknown_host");
    errorsTmp.put(LoadListenerClient.MALFORMED_URL, "malformed_url");
    errorsTmp.put(LoadListenerClient.SSL_HANDSHAKE, "ssl_handshake");
    errorsTmp.put(LoadListenerClient.CONNECTION_REFUSED, "connection_refused");
    errorsTmp.put(LoadListenerClient.CONNECTION_RESET, "connection_reset");
    errorsTmp.put(LoadListenerClient.NO_ROUTE_TO_HOST, "no_route_to_host");
    errorsTmp.put(LoadListenerClient.CONNECTION_TIMED_OUT, "connection_timed_out");
    errorsTmp.put(LoadListenerClient.PERMISSION_DENIED, "permission_denied");
    errorsTmp.put(LoadListenerClient.INVALID_RESPONSE, "invalid_response");
    errorsTmp.put(LoadListenerClient.TOO_MANY_REDIRECTS, "too_many_redirects");
    errorsTmp.put(LoadListenerClient.FILE_NOT_FOUND, "file_not_found");
    errorsTmp.put(LoadListenerClient.UNKNOWN_ERROR, "unknown_error");
    errors = Collections.unmodifiableMap(errorsTmp);
  }
  static {
    // these values cannot change!
    byte val = 0;
    Map<Class<?>, Byte> bytes = new HashMap<Class<?>, Byte>();
    Map<Byte, Class<?>> bytesRev = new HashMap<Byte, Class<?>>();
    bytes.put(byte[].class, val++);
    bytes.put(BigInteger.class, val++);
    bytes.put(Boolean.class, val++);
    bytes.put(Byte.class, val++);
    bytes.put(ByteBuffer.class, val++);
    bytes.put(Character.class, val++);
    bytes.put(Date.class, val++);
    bytes.put(Double.class, val++);
    bytes.put(Float.class, val++);
    bytes.put(Integer.class, val++);
    bytes.put(Long.class, val++);
    bytes.put(Short.class, val++);
    bytes.put(String.class, val++);
    bytes.put(UUID.class, val++);
    bytes.put(Serializable.class, val++);

    for (Entry<Class<?>, Byte> e : bytes.entrySet()) bytesRev.put(e.getValue(), e.getKey());

    INDICATOR_BYTES = Collections.unmodifiableMap(bytes);
    INDICATOR_BYTES_REV = Collections.unmodifiableMap(bytesRev);
  }
Beispiel #12
0
  public TestProcessingMap(
      final ResolvedAssessmentTest resolvedAssessmentTest,
      final boolean isValid,
      final List<AbstractPart> abstractPartListBuilder,
      final Map<AbstractPart, EffectiveItemSessionControl> effectiveItemSessionControlMap,
      final Map<Identifier, OutcomeDeclaration> outcomeDeclarationMapBuilder,
      final ResponseDeclaration durationResponseDeclaration,
      final Map<URI, ItemProcessingMap> itemProcessingMapMapBuilder) {
    this.resolvedAssessmentTest = resolvedAssessmentTest;
    this.durationResponseDeclaration = durationResponseDeclaration;
    this.isValid = isValid;

    /* Record AbstractParts */
    this.abstractPartList = Collections.unmodifiableList(abstractPartListBuilder);
    this.abstractPartToGlobalIndexMap = new HashMap<AbstractPart, Integer>();
    for (int i = 0; i < abstractPartListBuilder.size(); i++) {
      abstractPartToGlobalIndexMap.put(abstractPartListBuilder.get(i), Integer.valueOf(i));
    }

    /* Record the EffectiveItemSessionControl for each Node */
    this.effectiveItemSessionControlMap =
        Collections.unmodifiableMap(effectiveItemSessionControlMap);

    /* Record (valid) outcome variables in test */
    this.validOutcomeDeclarationMap =
        Collections.unmodifiableMap(
            new LinkedHashMap<Identifier, OutcomeDeclaration>(outcomeDeclarationMapBuilder));

    /* Record maps for each referenced item */
    this.itemProcessingMapMap =
        Collections.unmodifiableMap(
            new LinkedHashMap<URI, ItemProcessingMap>(itemProcessingMapMapBuilder));
  }
 /**
  * Combine this supplemental material descriptions with those specified in the "core" parameter.
  * This method has no side effect.
  *
  * @param core the core material descriptions to be supplemented; assumed to be unmodifiable.
  * @return the merged material descriptions; never null. The returned map is always unmodifiable,
  *     assuming the passed in core material descriptions are unmodifiable.
  * @throws IllegalArgumentException if this supplemental material descriptions contains
  *     conflicting entries
  * @throws UnsupportedOperationException if the conflict resolution strategy is not supported
  */
 public Map<String, String> mergeInto(Map<String, String> core) {
   if (extra.size() == 0) return core; // no supplemental descriptions
   if (core == null || core.size() == 0) return extra; // only core descriptions
   switch (resolve) {
     case FAIL_FAST:
       {
         final int total = core.size() + extra.size();
         Map<String, String> merged = new HashMap<String, String>(core);
         merged.putAll(extra);
         if (total != merged.size()) {
           throw new IllegalArgumentException(
               "The supplemental material descriptions contains conflicting entries");
         }
         return Collections.unmodifiableMap(merged);
       }
     case OVERRIDDEN:
       {
         Map<String, String> merged = new HashMap<String, String>(extra);
         merged.putAll(core);
         return Collections.unmodifiableMap(merged);
       }
     case OVERRIDE:
       {
         Map<String, String> merged = new HashMap<String, String>(core);
         merged.putAll(extra);
         return Collections.unmodifiableMap(merged);
       }
     default:
       throw new UnsupportedOperationException();
   }
 }
  static {
    try {
      Map<String, Method> orderedMethods = new TreeMap<String, Method>();
      for (Method m : MBeanServerConnection.class.getDeclaredMethods()) {
        orderedMethods.put(m.toGenericString(), m);
      }
      Method[] methods = orderedMethods.values().toArray(new Method[orderedMethods.size()]);
      Map<String, Method> asynchMethods = new TreeMap<String, Method>();
      for (Method asynchMethod : AsynchJMXResponseListener.class.getDeclaredMethods()) {
        asynchMethods.put(asynchMethod.getName(), asynchMethod);
      }

      Map<Method, Byte> m2k = new HashMap<Method, Byte>(methods.length);
      Map<Byte, Method> k2m = new HashMap<Byte, Method>(methods.length);
      Map<Byte, Method> k2am = new HashMap<Byte, Method>(methods.length);
      for (int i = 0; i < methods.length; i++) {
        m2k.put(methods[i], (byte) i);
        k2m.put((byte) i, methods[i]);
        Method asynchMethod = asynchMethods.get(methods[i].getName() + "Response");
        if (asynchMethod == null)
          throw new RuntimeException(
              "Failed to find asynch handler for [" + methods[i].toGenericString() + "]",
              new Throwable());
        k2am.put((byte) i, asynchMethod);
      }
      methodToKey = Collections.unmodifiableMap(m2k);
      keyToMethod = Collections.unmodifiableMap(k2m);
      keyToAsynchMethod = Collections.unmodifiableMap(k2am);
    } catch (Exception ex) {
      throw new RuntimeException(ex);
    }
  }
Beispiel #15
0
 private Map<String, Template> initMacros(
     Engine engine,
     Filter filter,
     Formatter<?> formatter,
     Map<Class<?>, Object> functions,
     Map<String, Template> importMacros) {
   Map<String, Template> macros = new HashMap<String, Template>();
   Map<String, Class<?>> macroTypes = getMacroTypes();
   if (macroTypes == null || macroTypes.size() == 0) {
     return Collections.unmodifiableMap(macros);
   }
   for (Map.Entry<String, Class<?>> entry : macroTypes.entrySet()) {
     try {
       Template macro =
           (Template)
               entry
                   .getValue()
                   .getConstructor(
                       Engine.class, Filter.class, Formatter.class, Map.class, Map.class)
                   .newInstance(engine, filter, formatter, functions, importMacros);
       macros.put(entry.getKey(), macro);
     } catch (Exception e) {
       throw new IllegalStateException(e.getMessage(), e);
     }
   }
   return Collections.unmodifiableMap(macros);
 }
  static {
    String path = "/identitypools/{IdentityPoolId}/bulkpublish";
    Map<String, String> staticMap = new HashMap<String, String>();
    Map<String, String> dynamicMap = new HashMap<String, String>();

    int index = path.indexOf("?");
    if (index != -1) {
      String queryString = path.substring(index + 1);
      path = path.substring(0, index);

      for (String s : queryString.split("[;&]")) {
        index = s.indexOf("=");
        if (index != -1) {
          String name = s.substring(0, index);
          String value = s.substring(index + 1);

          if (value.startsWith("{") && value.endsWith("}")) {
            dynamicMap.put(value.substring(1, value.length() - 1), name);
          } else {
            staticMap.put(name, value);
          }
        }
      }
    }

    RESOURCE_PATH_TEMPLATE = path;
    STATIC_QUERY_PARAMS = Collections.unmodifiableMap(staticMap);
    DYNAMIC_QUERY_PARAMS = Collections.unmodifiableMap(dynamicMap);
  }
Beispiel #17
0
 /** The maps will be wrapped in Collections.unmodifiableMap. */
 public RouteResult(
     T target, Map<String, String> pathParams, Map<String, List<String>> queryParams) {
   this.target = ObjectUtil.checkNotNull(target, "target");
   this.pathParams =
       Collections.unmodifiableMap(ObjectUtil.checkNotNull(pathParams, "pathParams"));
   this.queryParams =
       Collections.unmodifiableMap(ObjectUtil.checkNotNull(queryParams, "queryParams"));
 }
 Map<String, Map<String, Object>> getDataSourcesProperties() {
   final Map<String, Map<String, Object>> result =
       new LinkedHashMap<String, Map<String, Object>>();
   for (final Map.Entry<String, Map<String, Object>> entry : properties.entrySet()) {
     result.put(entry.getKey(), Collections.unmodifiableMap(entry.getValue()));
   }
   return Collections.unmodifiableMap(result);
 }
 public AllPartitionsMultipleHostsResult(
     Map<Integer, List<T>> hostsInfo,
     int partitionCount,
     Map<Integer, Integer> partitionsWithoutEnoughHosts) {
   _partitionInfo = Collections.unmodifiableMap(hostsInfo);
   _partitionCount = partitionCount;
   _partitionsWithoutEnoughHosts = Collections.unmodifiableMap(partitionsWithoutEnoughHosts);
 }
 @Override
 public void sessionFactoryCreated(SessionFactoryImplementor sessionFactoryImplementor) {
   this.associationQueries =
       Collections.unmodifiableMap(initializeAssociationQueries(sessionFactoryImplementor));
   this.entityQueries =
       Collections.unmodifiableMap(
           initializeEntityQueries(sessionFactoryImplementor, associationQueries));
 }
  static {
    Map<String, String> schemaAdsKeys = Maps.newHashMap();
    schemaAdsKeys.put("type", "ads");
    Map<String, String> schemaSalesKeys = Maps.newHashMap();
    schemaSalesKeys.put("type", "sales");

    SCHEMA_ADS_KEYS = Collections.unmodifiableMap(schemaAdsKeys);
    SCHEMA_SALES_KEYS = Collections.unmodifiableMap(schemaSalesKeys);
  }
Beispiel #22
0
  protected final void collectModels(
      IFile dir,
      String package_,
      String relativePath,
      Map<String, String> options,
      Collection<SModel> models) {
    if (FileSystem.getInstance().isFileIgnored(dir.getName())) return;
    if (!dir.isDirectory()) return;

    List<IFile> files = dir.getChildren();
    options.put(ModelFactory.OPTION_PACKAGE, package_);
    for (IFile file : files) {
      String fileName = file.getName();
      String extension = FileUtil.getExtension(fileName);

      if (extension == null) continue;
      ModelFactory modelFactory = PersistenceFacade.getInstance().getModelFactory(extension);
      if (modelFactory == null || file.isDirectory()) continue;

      FileDataSource source = new FileDataSource(file, this);
      options.put(ModelFactory.OPTION_RELPATH, combinePath(relativePath, fileName));
      String fileNameWE = FileUtil.getNameWithoutExtension(fileName);
      options.put(
          ModelFactory.OPTION_MODELNAME,
          package_ != null
              ? (package_.isEmpty() ? fileNameWE : package_ + "." + fileNameWE)
              : null);
      try {
        SModel model = modelFactory.load(source, Collections.unmodifiableMap(options));
        ((SModelBase) model).setModelRoot(this);
        models.add(model);
      } catch (UnsupportedDataSourceException ex) {
        /* model factory registration problem: ignore */
      }
    }

    options.put(ModelFactory.OPTION_RELPATH, relativePath);
    for (FolderModelFactory factory : PersistenceRegistry.getInstance().getFolderModelFactories()) {
      for (DataSource dataSource : factory.createDataSources(this, dir)) {
        SModel model = factory.load(dataSource, Collections.unmodifiableMap(options));
        ((SModelBase) model).setModelRoot(this);
        models.add(model);
      }
    }

    for (IFile childDir : files) {
      if (childDir.isDirectory()) {
        String name = childDir.getName();
        String innerPackage =
            package_ != null && JavaNameUtil.isJavaIdentifier(name)
                ? (package_.isEmpty() ? name : package_ + "." + name)
                : null;
        String innerPath = combinePath(relativePath, name);
        collectModels(childDir, innerPackage, innerPath, options, models);
      }
    }
  }
Beispiel #23
0
 Index(
     Map<DotName, List<AnnotationInstance>> annotations,
     Map<DotName, List<ClassInfo>> subclasses,
     Map<DotName, List<ClassInfo>> implementors,
     Map<DotName, ClassInfo> classes) {
   this.annotations = Collections.unmodifiableMap(annotations);
   this.classes = Collections.unmodifiableMap(classes);
   this.subclasses = Collections.unmodifiableMap(subclasses);
   this.implementors = Collections.unmodifiableMap(implementors);
 }
 static {
   final HashMap<String, LogType> mappingPattern = new HashMap<String, LogType>();
   final HashMap<String, LogType> mappingType = new HashMap<String, LogType>();
   for (LogType lt : values()) {
     mappingPattern.put(lt.iconName, lt);
     mappingType.put(lt.type, lt);
   }
   FIND_BY_ICONNAME = Collections.unmodifiableMap(mappingPattern);
   FIND_BY_TYPE = Collections.unmodifiableMap(mappingType);
 }
Beispiel #25
0
  /**
   * Ensures that every field in the {@code Event} are immutable to avoid confusion later.
   *
   * @param event event to make immutable.
   */
  private static void makeImmutable(Event event) {
    // Make the tags unmodifiable
    event.setTags(Collections.unmodifiableMap(event.getTags()));

    // Make the extra properties unmodifiable (everything in it is still mutable though)
    event.setExtra(Collections.unmodifiableMap(event.getExtra()));

    // Make the SentryInterfaces unmodifiable
    event.setSentryInterfaces(Collections.unmodifiableMap(event.getSentryInterfaces()));
  }
Beispiel #26
0
 static {
   final HashMap<String, CacheType> mappingId = new HashMap<String, CacheType>();
   final HashMap<String, CacheType> mappingPattern = new HashMap<String, CacheType>();
   for (CacheType ct : values()) {
     mappingId.put(ct.id, ct);
     mappingPattern.put(ct.pattern.toLowerCase(Locale.US), ct);
   }
   FIND_BY_ID = Collections.unmodifiableMap(mappingId);
   FIND_BY_PATTERN = Collections.unmodifiableMap(mappingPattern);
 }
  /**
   * Register web-specific environment beans ("contextParameters", "contextAttributes") with the
   * given BeanFactory, as used by the Portlet ApplicationContext.
   *
   * @param bf the BeanFactory to configure
   * @param sc the ServletContext that we're running within
   * @param pc the PortletContext that we're running within
   * @param config the PortletConfig of the containing Portlet
   */
  static void registerEnvironmentBeans(
      ConfigurableListableBeanFactory bf,
      ServletContext sc,
      PortletContext pc,
      PortletConfig config) {

    if (sc != null && !bf.containsBean(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME)) {
      bf.registerSingleton(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME, sc);
    }

    if (pc != null
        && !bf.containsBean(ConfigurablePortletApplicationContext.PORTLET_CONTEXT_BEAN_NAME)) {
      bf.registerSingleton(ConfigurablePortletApplicationContext.PORTLET_CONTEXT_BEAN_NAME, pc);
    }

    if (config != null
        && !bf.containsBean(ConfigurablePortletApplicationContext.PORTLET_CONFIG_BEAN_NAME)) {
      bf.registerSingleton(ConfigurablePortletApplicationContext.PORTLET_CONFIG_BEAN_NAME, config);
    }

    if (!bf.containsBean(WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME)) {
      Map<String, String> parameterMap = new HashMap<String, String>();
      if (pc != null) {
        Enumeration paramNameEnum = pc.getInitParameterNames();
        while (paramNameEnum.hasMoreElements()) {
          String paramName = (String) paramNameEnum.nextElement();
          parameterMap.put(paramName, pc.getInitParameter(paramName));
        }
      }
      if (config != null) {
        Enumeration paramNameEnum = config.getInitParameterNames();
        while (paramNameEnum.hasMoreElements()) {
          String paramName = (String) paramNameEnum.nextElement();
          parameterMap.put(paramName, config.getInitParameter(paramName));
        }
      }
      bf.registerSingleton(
          WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME,
          Collections.unmodifiableMap(parameterMap));
    }

    if (!bf.containsBean(WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME)) {
      Map<String, Object> attributeMap = new HashMap<String, Object>();
      if (pc != null) {
        Enumeration attrNameEnum = pc.getAttributeNames();
        while (attrNameEnum.hasMoreElements()) {
          String attrName = (String) attrNameEnum.nextElement();
          attributeMap.put(attrName, pc.getAttribute(attrName));
        }
      }
      bf.registerSingleton(
          WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME,
          Collections.unmodifiableMap(attributeMap));
    }
  }
Beispiel #28
0
 static {
   MetricURIEvent[] values = MetricURIEvent.values();
   Map<String, MetricURIEvent> tmp = new HashMap<String, MetricURIEvent>(values.length);
   Map<Byte, MetricURIEvent> btmp = new HashMap<Byte, MetricURIEvent>(values.length);
   for (MetricURIEvent ev : values) {
     tmp.put(ev.eventName, ev);
     btmp.put(ev.byteOrd, ev);
   }
   NAME2ENUM = Collections.unmodifiableMap(tmp);
   ORD2ENUM = Collections.unmodifiableMap(btmp);
 }
 /**
  * Sets relationships.
  *
  * <p>Looks at merge actions and whether the relationship is empty when adding, so not all
  * relationships are added.
  *
  * @param relationships list of data object relationships or null
  */
 public void setRelationships(List<DataObjectRelationship> relationships) {
   if (relationships == null) {
     this.relationships = null;
     relationshipMap = null;
     lastAttributeToRelationshipMap = null;
     attributeToRelationshipMap = null;
     return;
   }
   this.relationships = Collections.unmodifiableList(relationships);
   relationshipMap = new HashMap<String, DataObjectRelationship>(relationships.size());
   attributeToRelationshipMap = new HashMap<String, List<DataObjectRelationship>>();
   lastAttributeToRelationshipMap =
       new HashMap<String, DataObjectRelationship>(relationships.size());
   removedRelationshipNames = new ArrayList<String>();
   // Builds maps to link attribute names to their relationships
   for (DataObjectRelationship rel : relationships) {
     // This is not quite correct - we really only want to not add the NO_OVERRIDE items if they
     // are
     // overriding something. However, at the point this is running, we don't know whether we will
     // be embedding
     // anything...
     if (rel.getMergeAction() != MetadataMergeAction.REMOVE
         && rel.getMergeAction() != MetadataMergeAction.NO_OVERRIDE) {
       // related object attribute name
       relationshipMap.put(rel.getName(), rel);
       // last attribute in list linking the objects
       if (!rel.getAttributeRelationships().isEmpty()) {
         DataObjectAttributeRelationship relAttr =
             rel.getAttributeRelationships().get(rel.getAttributeRelationships().size() - 1);
         lastAttributeToRelationshipMap.put(relAttr.getParentAttributeName(), rel);
       }
       // all relationships relating to an attribute
       for (DataObjectAttributeRelationship relAttr : rel.getAttributeRelationships()) {
         List<DataObjectRelationship> rels =
             attributeToRelationshipMap.get(relAttr.getParentAttributeName());
         if (rels == null) {
           rels = new ArrayList<DataObjectRelationship>();
           attributeToRelationshipMap.put(relAttr.getParentAttributeName(), rels);
         }
         rels.add(rel);
       }
     }
     // since the attribute will still exist in the embedded metadata, we need to put a block in on
     // the standard
     // cascade
     if (rel.getMergeAction() == MetadataMergeAction.REMOVE) {
       removedRelationshipNames.add(rel.getName());
     }
   }
   relationshipMap = Collections.unmodifiableMap(relationshipMap);
   lastAttributeToRelationshipMap = Collections.unmodifiableMap(lastAttributeToRelationshipMap);
   attributeToRelationshipMap = Collections.unmodifiableMap(attributeToRelationshipMap);
 }
Beispiel #30
0
  /**
   * Creates a new <tt>StructLayout</tt> instance.
   *
   * @param runtime The runtime for the <tt>StructLayout</tt>.
   * @param fields The fields map for this struct.
   * @param size the total size of the struct.
   * @param alignment The minimum alignment required when allocating memory.
   */
  private StructLayout(
      Ruby runtime, RubyClass klass, Collection<IRubyObject> fields, int size, int alignment) {
    super(runtime, klass, NativeType.STRUCT, size, alignment);

    int cfCount = 0, refCount = 0;
    List<Field> fieldList = new ArrayList<Field>(fields.size());
    List<IRubyObject> names = new ArrayList<IRubyObject>(fields.size());
    List<Member> memberList = new ArrayList<Member>(fields.size());
    Map<IRubyObject, Member> memberStringMap = new HashMap<IRubyObject, Member>(fields.size());
    Map<IRubyObject, Member> memberSymbolMap =
        new IdentityHashMap<IRubyObject, Member>(fields.size() * 2);

    int index = 0;
    for (IRubyObject obj : fields) {

      if (!(obj instanceof Field)) {
        throw runtime.newTypeError(
            obj, runtime.fastGetModule("FFI").fastGetClass("StructLayout").fastGetClass("Field"));
      }

      Field f = (Field) obj;
      if (!(f.name instanceof RubySymbol)) {
        throw runtime.newTypeError("fields list contains field with invalid name");
      }

      names.add(f.name);
      fieldList.add(f);

      Member m =
          new Member(
              f,
              index,
              f.isCacheable() ? cfCount++ : -1,
              f.isValueReferenceNeeded() ? refCount++ : -1);
      memberSymbolMap.put(f.name, m);

      // Allow fields to be accessed as ['name'] as well as [:name] for legacy code
      memberStringMap.put(f.name, m);
      memberStringMap.put(f.name.asString(), m);
      memberList.add(m);
    }

    this.cacheableFieldCount = cfCount;
    this.referenceFieldCount = refCount;

    // Create the ordered list of field names from the map
    this.fieldNames = Collections.unmodifiableList(new ArrayList<IRubyObject>(names));
    this.fields = Collections.unmodifiableList(fieldList);
    this.fieldStringMap = Collections.unmodifiableMap(memberStringMap);
    this.fieldSymbolMap = Collections.unmodifiableMap(memberSymbolMap);
    this.members = Collections.unmodifiableList(memberList);
  }