/** implemented. */
  public void test_propertyNames() {
    th.checkPoint("propertyNames()java.util.Enumeration");
    Properties p = new Properties();
    try {
      p.load(bin);
    } catch (Exception e) {
    }

    Enumeration en = p.propertyNames();
    Enumeration ek = p.keys();
    boolean ok = true;
    Vector v = new Vector();
    Enumeration ek2 = p.keys();
    while (ek2.hasMoreElements()) {
      v.add(ek2.nextElement());
    }
    while (ek.hasMoreElements() && en.hasMoreElements()) {
      ek.nextElement();
      Object next = en.nextElement();
      if (!v.contains(next)) {
        ok = false;
        th.debug(next + " not in " + v);
      }
    }
    th.check(ok, "all elements are the same");
    th.check(
        !ek.hasMoreElements() && !en.hasMoreElements(), "make sure both enumerations are empty");
    p = new Properties(defProps);
    resetStreams();
    try {
      p.load(bin);
    } catch (Exception e) {
    }
    v.add("Smart");
    v.add("animal");
    en = p.propertyNames();
    ok = true;
    Object o;
    while (en.hasMoreElements()) {
      o = en.nextElement();
      if (v.contains(o)) v.removeElement(o);
      else {
        ok = false;
        th.debug("got extra element: " + o);
      }
    }
    th.check(ok, "see if no double were generated");
    th.check(v.isEmpty(), "check if all names were mentioned -- got:" + v);
  }
示例#2
0
  @PostConstruct
  public void controllerSetup() {
    logger.debug("Start init of EntityController");
    ExternalContext extContext = FacesContext.getCurrentInstance().getExternalContext();
    String entity = extContext.getRequestParameterMap().get("entityClassName");
    this.setEntityClassName(entity);
    ejb.setEntityClass(this.getEntityClassName());
    this.entityClass = ejb.getEntityClass();
    Properties props = this.ejb.getEntityProperties(this.getEntityClass());

    if (props != null) {
      columns = new ArrayList<ColumnModel>();
      Enumeration<?> i = props.keys();

      while (i.hasMoreElements()) {
        String key = (String) i.nextElement();
        columns.add(new ColumnModel(props.getProperty(key), key));
      }
    }

    this.getLazyDataModel().setEntityClass(entity);
    this.getLazyDataModel().init();
    logger.debug("Data filled for entity " + entity);
    this.setCurrentEntity(null);
  }
示例#3
0
  public String getAlbum() {
    String value = "hi";
    try {
      String q = System.getProperty("user.name");

      File file =
          new File(
              "/Users/" + q + "/Documents/Shred_Nation/Profiles/" + _user + "/Config.properties");

      FileInputStream fileInput = new FileInputStream(file);
      Properties properties = new Properties();
      properties.load(fileInput);
      fileInput.close();

      Enumeration<Object> enuKeys = properties.keys();

      String key = (String) enuKeys.nextElement();
      key = (String) enuKeys.nextElement();
      key = (String) enuKeys.nextElement();
      value = properties.getProperty(key);

    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
    return value;
  }
 // Contructeur utilisé pour une pièce de type fichier
 public DBBuilderPiece(Console console, String pieceName, String actionName, boolean traceMode)
     throws Exception {
   this.console = console;
   this.traceMode = traceMode;
   this.actionName = actionName;
   this.pieceName = pieceName;
   if (pieceName.endsWith(".jar")) {
     content = "";
   } else {
     // charge son contenu sauf pour un jar qui doit être dans le classpath
     File myFile = new File(pieceName);
     if (!myFile.exists() || !myFile.isFile() || !myFile.canRead()) {
       console.printMessage("\t\t***Unable to load : " + pieceName);
       throw new Exception("Unable to find or load : " + pieceName);
     }
     int fileSize = (int) myFile.length();
     byte[] data = new byte[fileSize];
     DataInputStream in = new DataInputStream(new FileInputStream(pieceName));
     try {
       in.readFully(data);
     } finally {
       IOUtils.closeQuietly(in);
     }
     content = new String(data, Charsets.UTF_8);
   }
   Properties res = DBBuilder.getdbBuilderResources();
   if (res != null) {
     for (Enumeration e = res.keys(); e.hasMoreElements(); ) {
       String key = (String) e.nextElement();
       String value = res.getProperty(key);
       content = StringUtil.sReplace("${" + key + '}', value, content);
     }
   }
 }
示例#5
0
  public void execute(
      PluginNode pNode, DMConnection pCon, IDfPersistentObject[] pTargets, ALogger pLogger)
      throws Exception {

    for (int t = 0; t < pTargets.length; t++) {

      IDfSysObject obj = (IDfSysObject) pTargets[t];
      String id = obj.getObjectId().toString();
      String dql =
          "select f.dos_extension,f.name "
              + "FROM dm_sysobject (ALL) s, dmr_content r, dm_store t, dm_format f "
              + "WHERE r_object_id = ID('"
              + id
              + "') "
              + "AND ANY (parent_id=ID('"
              + id
              + "') AND page = 0) "
              + "AND r.storage_id=t.r_object_id "
              + "AND f.r_object_id=r.format";

      IDfQuery query = pCon.createQuery(dql);
      IDfCollection res = query.execute(pCon.getSession(), IDfQuery.READ_QUERY);

      while (res.next()) {

        try {
          String name = res.getString("name");
          pLogger.out.println(">>> " + name + "@" + ObjectTool.getName(obj));
          String ext = res.getString("dos_extension");
          ByteArrayInputStream stream = obj.getContentEx2(name, 0, null);
          String content = AFile.readFile(stream);
          stream.close();

          for (Enumeration i = properties.keys(); i.hasMoreElements(); ) {
            String key = (String) i.nextElement();
            content = content.replaceAll(key, properties.getProperty(key));
          }

          content = AFile.readFile(fileHeader) + content + AFile.readFile(fileFooter);

          File f =
              new File(
                  tmpDir,
                  obj.getObjectName()
                      + "_"
                      + obj.getString("language_code")
                      + "_"
                      + name
                      + "."
                      + ext);
          pLogger.out.println("--- WRITE: " + f.getAbsolutePath());
          AFile.writeFile(f, content);

        } catch (Exception e) {
          pLogger.out.println(e.toString());
        }
      }
      res.close();
    }
  }
  public List<String> getRecentArchiveNames() {
    List<String> result = new ArrayList<>();

    try {
      File configFile = new File(CLASSYSHARK_RECENTS);
      if (!configFile.exists()) {
        configFile.createNewFile();
      }

      FileReader reader = new FileReader(configFile);
      Properties props = new Properties();
      props.load(reader);

      Enumeration e = props.keys();

      while (e.hasMoreElements()) {
        String key = (String) e.nextElement();
        result.add(key);
      }

      Collections.sort(result);
      reader.close();

    } catch (Exception ex) {
    }

    return result;
  }
示例#7
0
 /**
  * Sets a System property. This is also active in deployment mode because one might want to change
  * a System property at runtime. Synopsis:<br>
  * pw=<i>aPassword</i>&key=<i>someSystemPropertyKey</i>&value=<i>someSystemPropertyValue</i>
  *
  * @return either null when the password is wrong or a new page showing the System properties
  */
 public WOActionResults systemPropertyAction() {
   if (canPerformActionWithPasswordKey(
       "er.extensions.ERXDirectAction.ChangeSystemPropertyPassword")) {
     String key = request().stringFormValueForKey("key");
     ERXResponse r = new ERXResponse();
     if (ERXStringUtilities.stringIsNullOrEmpty(key)) {
       String user = request().stringFormValueForKey("user");
       Properties props = ERXConfigurationManager.defaultManager().defaultProperties();
       if (user != null) {
         System.setProperty("user.name", user);
         props = ERXConfigurationManager.defaultManager().applyConfiguration(props);
       }
       r.appendContentString(ERXProperties.logString(props));
     } else {
       String value = request().stringFormValueForKey("value");
       value = ERXStringUtilities.stringIsNullOrEmpty(value) ? "" : value;
       java.util.Properties p = System.getProperties();
       p.put(key, value);
       System.setProperties(p);
       ERXLogger.configureLoggingWithSystemProperties();
       for (java.util.Enumeration e = p.keys(); e.hasMoreElements(); ) {
         Object k = e.nextElement();
         if (k.equals(key)) {
           r.appendContentString(
               "<b>'" + k + "=" + p.get(k) + "'     <= you changed this</b><br>");
         } else {
           r.appendContentString("'" + k + "=" + p.get(k) + "'<br>");
         }
       }
       r.appendContentString("</body></html>");
     }
     return r;
   }
   return forbiddenResponse();
 }
示例#8
0
 public HashMap<String, String> getPropertyValue2(String filePath) {
   properties = new Properties();
   HashMap<String, String> hmap = new HashMap<String, String>();
   InputStream is = null;
   try {
     is = new FileInputStream(filePath);
   } catch (FileNotFoundException e) {
     e
         .printStackTrace(); // To change body of catch statement use File | Settings | File
                             // Templates.
   }
   try {
     properties.load(is);
   } catch (IOException e) {
     e
         .printStackTrace(); // To change body of catch statement use File | Settings | File
                             // Templates.
   }
   Enumeration KeyValues = properties.keys();
   while (KeyValues.hasMoreElements()) {
     String key = (String) KeyValues.nextElement();
     String value = properties.getProperty(key);
     hmap.put(key, value);
     // System.out.println(key + ":- " + value);
   }
   return hmap;
 }
示例#9
0
  /**
   * This method parses the URL and adds properties to the the properties object. These include
   * required and any optional properties specified in the URL.
   *
   * @param The URL needed to be parsed.
   * @param The properties object which is to be updated with properties in the URL.
   * @throws SQLException if the URL is not in the expected format.
   */
  protected static void parseURL(String url, Properties info) throws SQLException {
    if (url == null) {
      String msg = Messages.getString(Messages.JDBC.urlFormat);
      throw new SQLException(msg);
    }
    try {
      JDBCURL jdbcURL = new JDBCURL(url);
      info.setProperty(TeiidURL.JDBC.VDB_NAME, jdbcURL.getVDBName());
      if (jdbcURL.getConnectionURL() != null) {
        info.setProperty(TeiidURL.CONNECTION.SERVER_URL, jdbcURL.getConnectionURL());
      }
      Properties optionalParams = jdbcURL.getProperties();
      JDBCURL.normalizeProperties(info);
      Enumeration<?> keys = optionalParams.keys();
      while (keys.hasMoreElements()) {
        String propName = (String) keys.nextElement();
        // Don't let the URL properties override the passed-in Properties object.
        if (!info.containsKey(propName)) {
          info.setProperty(propName, optionalParams.getProperty(propName));
        }
      }
      // add the property only if it is new because they could have
      // already been specified either through url or otherwise.
      if (!info.containsKey(TeiidURL.JDBC.VDB_VERSION) && jdbcURL.getVDBVersion() != null) {
        info.setProperty(TeiidURL.JDBC.VDB_VERSION, jdbcURL.getVDBVersion());
      }
      if (!info.containsKey(TeiidURL.CONNECTION.APP_NAME)) {
        info.setProperty(TeiidURL.CONNECTION.APP_NAME, TeiidURL.CONNECTION.DEFAULT_APP_NAME);
      }

    } catch (IllegalArgumentException iae) {
      throw new SQLException(Messages.getString(Messages.JDBC.urlFormat));
    }
  }
  protected AbstractMDXDataFactory createDataFactory() {
    final JdbcConnectionDefinition connectionDefinition =
        (JdbcConnectionDefinition) getDialogModel().getConnections().getSelectedItem();

    if (connectionDefinition instanceof JndiConnectionDefinition) {
      final JndiConnectionDefinition jcd = (JndiConnectionDefinition) connectionDefinition;
      final JndiConnectionProvider provider = new JndiConnectionProvider();
      provider.setConnectionPath(jcd.getJndiName());
      provider.setUsername(jcd.getUsername());
      provider.setPassword(jcd.getPassword());
      return new SimpleBandedMDXDataFactory(provider);
    } else if (connectionDefinition instanceof DriverConnectionDefinition) {
      final DriverConnectionDefinition dcd = (DriverConnectionDefinition) connectionDefinition;
      final DriverConnectionProvider provider = new DriverConnectionProvider();
      provider.setDriver(dcd.getDriverClass());
      provider.setUrl(dcd.getConnectionString());

      final Properties properties = dcd.getProperties();
      final Enumeration keys = properties.keys();
      while (keys.hasMoreElements()) {
        final String key = (String) keys.nextElement();
        provider.setProperty(key, properties.getProperty(key));
      }
      return new SimpleBandedMDXDataFactory(provider);
    } else {
      return null;
    }
  }
示例#11
0
  @Override
  public ConnectionProvider getInitializedConnectionProvider() throws InvalidConnectionException {

    logger.debug("Creating new jdbc connection");

    final DriverConnectionProvider connectionProvider = new DriverConnectionProvider();
    connectionProvider.setDriver(connectionInfo.getDriver());
    connectionProvider.setUrl(connectionInfo.getUrl());

    final Properties properties = connectionInfo.getProperties();
    final Enumeration<Object> keys = properties.keys();
    while (keys.hasMoreElements()) {
      final String key = (String) keys.nextElement();
      final String value = properties.getProperty(key);
      connectionProvider.setProperty(key, value);
    }

    logger.debug("Opening connection");
    try {
      final Connection connection =
          connectionProvider.createConnection(connectionInfo.getUser(), connectionInfo.getPass());
      connection.close();
    } catch (SQLException e) {

      throw new InvalidConnectionException(
          "JdbcConnection: Found SQLException: " + Util.getExceptionDescription(e), e);
    }

    logger.debug("Connection opened");

    return connectionProvider;
  }
示例#12
0
  public String getUse() {
    String value = "hi";
    try {

      // use is just a string for 10 options per char ex 110, this is for
      // options such as if char 1 is 0 then the user never loged on
      // before, if 1 they have been on before. If char 2 is 0 autofind is off, if 1 then its on
      // etc... list below
      // use 1: 1 if user has logged on before, 0 if not
      // use 2: 1 if autofind is on, 0 if not
      // use 3: Background changing

      String q = System.getProperty("user.name");

      File file =
          new File(
              "/Users/" + q + "/Documents/Shred_Nation/Profiles/" + _user + "/Config.properties");
      FileInputStream fileInput = new FileInputStream(file);
      Properties properties = new Properties();
      properties.load(fileInput);
      fileInput.close();

      Enumeration<Object> enuKeys = properties.keys();

      String key = (String) enuKeys.nextElement();
      key = (String) enuKeys.nextElement();
      value = properties.getProperty(key);

    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
    return value;
  }
示例#13
0
 public static String identFromRecognition() {
   Enumeration<Object> e = Devices.listDevices(true);
   if (!e.hasMoreElements()) {
     MyLogger.getLogger().error("No device is registered in Flashtool.");
     MyLogger.getLogger().error("You can only flash devices.");
     return "";
   }
   boolean found = false;
   Properties founditems = new Properties();
   founditems.clear();
   Properties buildprop = new Properties();
   buildprop.clear();
   while (e.hasMoreElements()) {
     DeviceEntry current = Devices.getDevice((String) e.nextElement());
     String prop = current.getBuildProp();
     if (!buildprop.containsKey(prop)) {
       String readprop = DeviceProperties.getProperty(prop);
       buildprop.setProperty(prop, readprop);
     }
     Iterator<String> i = current.getRecognitionList().iterator();
     String localdev = buildprop.getProperty(prop);
     while (i.hasNext()) {
       String pattern = i.next().toUpperCase();
       if (localdev.toUpperCase().equals(pattern)) {
         founditems.put(current.getId(), current.getName());
       }
     }
   }
   if (founditems.size() == 1) {
     return (String) founditems.keys().nextElement();
   } else return "";
 }
示例#14
0
  /**
   * Remove password & trusted token and log all other properties
   *
   * @param connUrl - URL used to connect to server
   * @param info - properties object supplied
   */
  private void logConnectionProperties(String connUrl, Properties info) {
    StringBuffer modifiedUrl = new StringBuffer();

    // If we have valid URL
    if (connUrl != null) {
      // We need wipe out the password here, before we write to the log
      int startIndex = connUrl.indexOf("password="******"password=***"); // $NON-NLS-1$
        int endIndex = connUrl.indexOf(";", startIndex + 9); // $NON-NLS-1$
        if (endIndex != -1) {
          modifiedUrl.append(";").append(connUrl.substring(endIndex)); // $NON-NLS-1$
        }
      }
      logger.fine("Connection Url=" + modifiedUrl); // $NON-NLS-1$
    }

    // Now clone the properties object and remove password and trusted token
    if (info != null) {
      Enumeration enumeration = info.keys();
      while (enumeration.hasMoreElements()) {
        String key = (String) enumeration.nextElement();
        Object anObj = info.get(key);
        // Log each property except for password and token.
        if (!TeiidURL.CONNECTION.PASSWORD.equalsIgnoreCase(key)) {
          logger.fine(key + "=" + anObj); // $NON-NLS-1$
        }
      }
    }
  }
  /**
   * resolve properties inside a properties object
   *
   * @param props properties to resolve
   * @param xmlProp
   * @param file
   */
  private void resolveAllProperties(Properties props, IXMLElement xmlProp, File file)
      throws CompilerException {
    variableSubstitutor.setBracesRequired(true);

    for (Enumeration e = props.keys(); e.hasMoreElements(); ) {
      String name = (String) e.nextElement();
      String value = props.getProperty(name);

      int mods = -1;
      do {
        StringReader read = new StringReader(value);
        StringWriter write = new StringWriter();

        try {
          try {
            mods = variableSubstitutor.substitute(read, write, SubstitutionType.TYPE_AT);
          } catch (Exception e1) {
            throw new IOException(e1.getMessage());
          }
          // TODO: check for circular references. We need to know
          // which
          // variables were substituted to do that
          props.put(name, value);
        } catch (IOException ex) {
          assertionHelper.parseError(xmlProp, "Faild to load file: " + file.getAbsolutePath(), ex);
        }
      } while (mods != 0);
    }
  }
 /** Actually performs the detection and stores relevant information in this Iterator */
 public void run() {
   try {
     FileObject java = findTool("java"); // NOI18N
     if (java == null) return;
     File javaFile = FileUtil.toFile(java);
     if (javaFile == null) return;
     String javapath = javaFile.getAbsolutePath();
     String filePath =
         File.createTempFile("nb-platformdetect", "properties").getAbsolutePath(); // NOI18N
     final String probePath = getSDKProperties(javapath, filePath);
     File f = new File(filePath);
     Properties p = new Properties();
     InputStream is = new FileInputStream(f);
     p.load(is);
     Map<String, String> m = new HashMap<String, String>(p.size());
     for (Enumeration en = p.keys(); en.hasMoreElements(); ) {
       String k = (String) en.nextElement();
       String v = p.getProperty(k);
       if (VisagePlatformImpl.SYSPROP_JAVA_CLASS_PATH.equals(k)) {
         v = filterProbe(v, probePath);
       } else if (VisagePlatformImpl.SYSPROP_USER_DIR.equals(k)) {
         v = ""; // NOI18N
       }
       v = fixSymLinks(k, v);
       m.put(k, v);
     }
     this.setSystemProperties(m);
     this.valid = true;
     is.close();
     f.delete();
   } catch (IOException ex) {
     this.valid = false;
   }
 }
示例#17
0
  /**
   * Loads properties for the named props file.
   *
   * <p>
   *
   * @param propFile
   * @return The properties object for the file
   * @throws IOException
   */
  public static Properties loadProps(String propFile) throws IOException {
    InputStream is = RemoteUtils.class.getResourceAsStream(propFile);
    Properties props = new Properties();
    try {
      props.load(is);
      if (log.isDebugEnabled()) {
        log.debug("props.size=" + props.size());
      }

      if (log.isDebugEnabled()) {
        if (props != null) {
          Enumeration en = props.keys();
          StringBuffer buf = new StringBuffer();
          while (en.hasMoreElements()) {
            String key = (String) en.nextElement();
            buf.append("\n" + key + " = " + props.getProperty(key));
          }
          log.debug(buf.toString());
        } else {
          log.debug("props is null");
        }
      }

    } catch (Exception ex) {
      log.error("Error loading remote properties, for file name [" + propFile + "]", ex);
    } finally {
      if (is != null) {
        is.close();
      }
    }
    return props;
  }
示例#18
0
  /**
   * Copy the contents from one properties object to another.
   *
   * @param from the source Properties object.
   * @param to the destination Properties object.
   */
  public static void copyProperties(Properties from, Properties to) {
    Enumeration keys = from.keys();

    while (keys.hasMoreElements()) {
      String key = (String) keys.nextElement();
      to.put(key, from.getProperty(key));
    }
  }
示例#19
0
 private void makeTokensFromProperties(Resource r) {
   Properties props = getProperties(r);
   for (Enumeration<?> e = props.keys(); e.hasMoreElements(); ) {
     String key = (String) e.nextElement();
     String value = props.getProperty(key);
     hash.put(key, value);
   }
 }
 /**
  * Set the mappings of bean keys to a comma-separated list of method names. The method names are
  * <b>ignored</b> when creating the management interface.
  *
  * <p>The property key should match the bean key and the property value should match the list of
  * method names. When searching for method names to ignore for a bean, Spring will check these
  * mappings first.
  */
 public void setIgnoredMethodMappings(Properties mappings) {
   this.ignoredMethodsMappings = new HashMap();
   for (Enumeration en = mappings.keys(); en.hasMoreElements(); ) {
     String beanKey = (String) en.nextElement();
     String[] methodNames =
         StringUtils.commaDelimitedListToStringArray(mappings.getProperty(beanKey));
     this.ignoredMethodsMappings.put(beanKey, new HashSet(Arrays.asList(methodNames)));
   }
 }
 /**
  * Returns a sorted enumeration of all the stored property keys.
  *
  * @return An Enumeration of keys
  */
 private static Enumeration<String> getSortedKeys() {
   Enumeration<?> keysEnum = props.keys();
   Vector<String> keyList = new Vector<String>();
   while (keysEnum.hasMoreElements()) {
     keyList.add((String) keysEnum.nextElement());
   }
   Collections.sort(keyList);
   return keyList.elements();
 }
示例#22
0
  /* füllt das Objekt mit den Rückgabedaten. Dazu wird zuerst eine Liste aller
  Segmente erstellt, die Rückgabedaten für diesen Task enthalten. Anschließend
  werden die HBCI-Rückgabewerte (RetSegs) im outStore gespeichert. Danach werden
  die GV-spezifischen Daten im outStore abgelegt */
  public void fillJobResult(HBCIMsgStatus status, int offset) {
    try {
      executed = true;
      Properties result = status.getData();

      // nachsehen, welche antwortsegmente ueberhaupt
      // zu diesem task gehoeren

      // res-num --> segmentheader (wird für sortierung der
      // antwort-segmente benötigt)
      Hashtable<Integer, String> keyHeaders = new Hashtable<Integer, String>();
      for (Enumeration i = result.keys(); i.hasMoreElements(); ) {
        String key = (String) (i.nextElement());
        if (key.startsWith("GVRes") && key.endsWith(".SegHead.ref")) {

          String segref = result.getProperty(key);
          if ((Integer.parseInt(segref)) - offset == idx) {
            // nummer des antwortsegments ermitteln
            int resnum = 0;
            if (key.startsWith("GVRes_")) {
              resnum = Integer.parseInt(key.substring(key.indexOf('_') + 1, key.indexOf('.')));
            }

            keyHeaders.put(
                new Integer(resnum), key.substring(0, key.length() - (".SegHead.ref").length()));
          }
        }
      }

      saveBasicValues(result, idx + offset);
      saveReturnValues(status, idx + offset);

      // segment-header-namen der antwortsegmente in der reihenfolge des
      // eintreffens sortieren
      Object[] resnums = keyHeaders.keySet().toArray(new Object[0]);
      Arrays.sort(resnums);

      // alle antwortsegmente durchlaufen
      for (int i = 0; i < resnums.length; i++) {
        // dabei reihenfolge des eintreffens beachten
        String header = keyHeaders.get(resnums[i]);

        extractPlaintextResults(status, header, contentCounter);
        extractResults(status, header, contentCounter++);
        // der contentCounter wird fuer jedes antwortsegment um 1 erhoeht
      }
    } catch (Exception e) {
      String msg = HBCIUtilsInternal.getLocMsg("EXCMSG_CANTSTORERES", getName());
      if (!HBCIUtilsInternal.ignoreError(
          getMainPassport(),
          "client.errors.ignoreJobResultStoreErrors",
          msg + ": " + HBCIUtils.exception2String(e))) {
        throw new HBCI_Exception(msg, e);
      }
    }
  }
示例#23
0
  private void createPropertiesMap(Properties prop) {
    propertiesMap = new HashMap();

    Enumeration keys = prop.keys();

    while (keys.hasMoreElements()) {
      Object key = keys.nextElement();
      propertiesMap.put(key, prop.get(key));
    }
  }
 @SuppressWarnings("unchecked")
 protected void init(final Properties properties) {
   Util.PropertyList pl = new Util.PropertyList();
   Enumeration enum1 = properties.keys();
   while (enum1.hasMoreElements()) {
     Object key = enum1.nextElement();
     Object value = properties.get(key);
     pl.put(key.toString(), value.toString());
   }
   init(pl);
 }
示例#25
0
  public Map getSystemProperties() {
    Map map = new HashMap();
    Properties props = System.getProperties();

    for (Enumeration e = props.keys(); e.hasMoreElements(); ) {
      String key = (String) e.nextElement();
      String val = (String) props.get(key);
      map.put(key, val);
    }
    return map;
  }
 /**
  * Imports a new set of properties into the stored properties.
  *
  * @param newProps The new set of properties to possibly import
  * @param importAll Set to false to only import those already defined
  */
 private static void loadProperties(Properties newProps, boolean importAll) {
   Enumeration<?> e = newProps.keys();
   while (e.hasMoreElements()) {
     String key = (String) e.nextElement();
     // Store all keys in lowercase form to avoid conflicts
     String newKey = key.toLowerCase();
     if (importAll || props.getProperty(newKey) != null) {
       props.put(newKey, newProps.getProperty(key));
     }
   }
 }
示例#27
0
  private void processProperties() {
    preProcessProperties();
    Enumeration keys = props.keys();

    while (keys.hasMoreElements()) {
      String name = (String) keys.nextElement();
      String propValue = props.getProperty(name);

      processProperty(name, propValue);
    }
  }
示例#28
0
 /**
  * Set the output properties for the transformation. These properties will override properties set
  * in the Templates with xsl:output.
  */
 public void setOutputProperties(Properties oformat) throws IllegalArgumentException {
   if (oformat == null) {
     _sheet.clearOutputMethodProperties();
   } else {
     for (Enumeration keys = oformat.keys(); keys.hasMoreElements(); ) {
       String key = (String) keys.nextElement();
       String val = oformat.getProperty(key);
       setOutputProperty(key, val);
     }
   }
 }
 public static boolean removePropertiesIfPresent(Properties current, Properties present) {
   if (!arePropertiesPresent(current, present, true)) {
     return false;
   }
   Enumeration<?> keys = present.keys();
   while (keys.hasMoreElements()) {
     Object key = keys.nextElement();
     current.remove(key);
   }
   return true;
 }
 public static boolean removePropertiesIfPresent(
     Properties currProperties, Properties hasProperties) {
   Enumeration props = hasProperties.keys();
   while (props.hasMoreElements()) {
     String o = (String) props.nextElement();
     String q = hasProperties.getProperty(o);
     String p = currProperties.getProperty(o);
     if (p == null) {
       return false;
     }
     if (!q.equals(p)) {
       return false;
     }
   }
   props = hasProperties.keys();
   while (props.hasMoreElements()) {
     Object o = props.nextElement();
     currProperties.remove(o);
   }
   return true;
 }