예제 #1
0
  @Deprecated
  public static void makeCode() {
    File infile = new File("/home/hoshun/dmoz/dmoz-indexed-url");
    File outfile = new File("/home/hoshun/dmoz/generateUrlToSpecifiedCategory");
    File outformatfile = new File("/home/hoshun/dmoz/dmoz-specified-url");

    CategorizedURLs urlToCategory = new CategorizedURLs(infile, true);
    SpecifiedTopics specifiedTopics = new SpecifiedTopics();
    try {
      PrintWriter out = new PrintWriter(outfile);
      PrintWriter out2 = new PrintWriter(outformatfile);

      Map<Integer, Category> idToCategory = urlToCategory.idToCategory;
      Map<Integer, String> idToUrl = urlToCategory.idToUrl;

      for (int id : idToCategory.keySet()) {
        Category cat = idToCategory.get(id);
        if (specifiedTopics.containsCategory(cat)) {
          String url = idToUrl.get(id);

          out.printf(
              "idToCategory.put(%s,new Category(\"%s\",\"%s\"));\n", id, cat.first, cat.second);
          out.printf("idToURL.put(%s,\"%s\");\n", id, url);

          out2.printf("%s\t%s\t%s\t%s\n", id, cat.first, cat.second, url);
        }
      }

      out.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
 private void initVars(Map vm) {
   variable_PAGE_NUMBER = (JRFillVariable) vm.get("PAGE_NUMBER");
   variable_COLUMN_NUMBER = (JRFillVariable) vm.get("COLUMN_NUMBER");
   variable_REPORT_COUNT = (JRFillVariable) vm.get("REPORT_COUNT");
   variable_PAGE_COUNT = (JRFillVariable) vm.get("PAGE_COUNT");
   variable_COLUMN_COUNT = (JRFillVariable) vm.get("COLUMN_COUNT");
 }
예제 #3
0
 private static String getPath(Map<String, Object> map, String part) {
   Object obj = "/".equals(part) ? null : map.get(part);
   if (obj == null) {
     obj = map.get("/");
     if (obj != null) {
       return (String) obj;
     }
     obj = map.get("*");
     String path = (String) obj;
     if (path != null && path.endsWith("*")) {
       return path.substring(0, path.length() - 1) + part;
     } else {
       return path;
     }
   }
   if (obj instanceof String) {
     return (String) obj;
   }
   map = (Map<String, Object>) obj;
   obj = map.get("/");
   if (obj != null) {
     return (String) obj;
   }
   obj = map.get("*");
   return (String) obj;
 }
예제 #4
0
  /**
   * Compares the specified Object with this Map for equality, as per the definition in the Map
   * interface.
   *
   * @param o object to be compared for equality with this hashtable
   * @return true if the specified Object is equal to this Map
   * @see Map#equals(Object)
   * @since 1.2
   */
  public synchronized boolean equals(Object o) {
    if (o == this) return true;

    if (!(o instanceof Map)) return false;
    Map<K, V> t = (Map<K, V>) o;
    if (t.size() != size()) return false;

    try {
      Iterator<Map.Entry<K, V>> i = entrySet().iterator();
      while (i.hasNext()) {
        Map.Entry<K, V> e = i.next();
        K key = e.getKey();
        V value = e.getValue();
        if (value == null) {
          if (!(t.get(key) == null && t.containsKey(key))) return false;
        } else {
          if (!value.equals(t.get(key))) return false;
        }
      }
    } catch (ClassCastException unused) {
      return false;
    } catch (NullPointerException unused) {
      return false;
    }

    return true;
  }
예제 #5
0
 public void setSdkInfo(Map<String, String> map) {
   if (map != null) {
     mMinSdkVersion = map.get("minSdkVersion");
     mTargetSdkVersion = map.get("targetSdkVersion");
     mMaxSdkVersion = map.get("maxSdkVersion");
   }
 }
예제 #6
0
 // Note: this comparator imposes orderings that are inconsistent with equals.
 public int compare(String a, String b) {
   if (base.get(a) >= base.get(b)) {
     return -1;
   } else {
     return 1;
   } // returning 0 would merge keys
 }
예제 #7
0
파일: Compiler.java 프로젝트: CM-9xx/cm9xx
  static private List getCommandCompilerCPP(String avrBasePath,
    List includePaths, String sourceName, String objectName,
    Map<String, String> boardPreferences) {
    
    List baseCommandCompilerCPP = new ArrayList(Arrays.asList(new String[] {
      avrBasePath + "avr-g++",
      "-c", // compile, don't link
      "-g", // include debugging info (so errors include line numbers)
      "-Os", // optimize for size
      Preferences.getBoolean("build.verbose") ? "-Wall" : "-w", // show warnings if verbose
      "-fno-exceptions",
      "-ffunction-sections", // place each function in its own section
      "-fdata-sections",
      "-mmcu=" + boardPreferences.get("build.mcu"),
      "-DF_CPU=" + boardPreferences.get("build.f_cpu"),
      "-MMD", // output dependancy info
      "-DUSB_VID=" + boardPreferences.get("build.vid"),
      "-DUSB_PID=" + boardPreferences.get("build.pid"),      
      "-DARDUINO=" + Base.REVISION,
    }));

    for (int i = 0; i < includePaths.size(); i++) {
      baseCommandCompilerCPP.add("-I" + (String) includePaths.get(i));
    }

    baseCommandCompilerCPP.add(sourceName);
    baseCommandCompilerCPP.add("-o");
    baseCommandCompilerCPP.add(objectName);

    return baseCommandCompilerCPP;
  }
  private Counter getCounterFromVerificationData(Map<String, String> verificationData) {

    String sizeAndSymbol = verificationData.get(Constants.COUNTER_SIZE_AND_SYMBOL);
    String[] parts = sizeAndSymbol.split(" ");
    if (parts.length < Constants.MIN_LENGTH) {
      throw new NoSuchElementException();
    }
    String standardSize = parts[0] + " " + parts[1];
    String symbol = parts[2];
    if (parts.length > Constants.MIN_LENGTH) {
      for (int i = Constants.MIN_LENGTH; i < parts.length; i++) {
        symbol += " " + parts[i];
      }
    }
    CounterType counterType =
        counterTypeService.findOneBySymbolAndStandardSize(symbol, standardSize);
    if (counterType == null) {
      throw new NoSuchElementException();
    }
    Counter counter =
        new Counter(
            verificationData.get(Constants.YEAR),
            verificationData.get(Constants.COUNTER_NUMBER),
            counterType,
            verificationData.get(Constants.STAMP));

    return counter;
  }
예제 #9
0
 /**
  * Logs the time and the number of needed queries for a specific QSS type
  *
  * @param queries
  * @param times
  * @param type
  * @param statisticName
  */
 private void logStatistics(
     Map<QSSType, List<Double>> queries,
     Map<QSSType, DurationStat> times,
     QSSType type,
     String statisticName) {
   List<Double> queriesOfType = queries.get(type);
   double res = 0;
   for (Double qs : queriesOfType) {
     res += qs;
   }
   logger.info(
       statisticName
           + " needed time "
           + type
           + ": "
           + getStringTime(times.get(type).getOverall())
           + ", max "
           + getStringTime(times.get(type).getMax())
           + ", min "
           + getStringTime(times.get(type).getMin())
           + ", avg2 "
           + getStringTime(times.get(type).getMean())
           + ", Queries max "
           + Collections.max(queries.get(type))
           + ", min "
           + Collections.min(queries.get(type))
           + ", avg2 "
           + res / queriesOfType.size());
 }
예제 #10
0
 /*
  * Verify that the provider JAR files are signed properly, which
  * means the signer's certificate can be traced back to a
  * JCE trusted CA.
  * Return null if ok, failure Exception if verification failed.
  */
 static synchronized Exception getVerificationResult(Provider p) {
   Object o = verificationResults.get(p);
   if (o == PROVIDER_VERIFIED) {
     return null;
   } else if (o != null) {
     return (Exception) o;
   }
   if (verifyingProviders.get(p) != null) {
     // this method is static synchronized, must be recursion
     // return failure now but do not save the result
     return new NoSuchProviderException("Recursion during verification");
   }
   try {
     verifyingProviders.put(p, Boolean.FALSE);
     URL providerURL = getCodeBase(p.getClass());
     verifyProviderJar(providerURL);
     // Verified ok, cache result
     verificationResults.put(p, PROVIDER_VERIFIED);
     return null;
   } catch (Exception e) {
     verificationResults.put(p, e);
     return e;
   } finally {
     verifyingProviders.remove(p);
   }
 }
	// post方式发送email
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		File file = doAttachment(request);
		EmailAttachment attachment = new EmailAttachment();
		attachment.setPath(file.getPath());
		attachment.setDisposition(EmailAttachment.ATTACHMENT);
		attachment.setName(file.getName());
		MultiPartEmail email = new MultiPartEmail();
		email.setCharset("UTF-8");
		email.setHostName("smtp.sina.com");
		email.setAuthentication("T-GWAP", "dangdang");
		try {
			email.addTo(parameters.get("to"));
			email.setFrom(parameters.get("from"));
			email.setSubject(parameters.get("subject"));
			email.setMsg(parameters.get("body"));
			email.attach(attachment);
			email.send();
			request.setAttribute("sendmail.message", "邮件发送成功!");
		} catch (EmailException e) {
			Logger logger = Logger.getLogger(SendAttachmentMailServlet.class);
			logger.error("邮件发送不成功", e);
			request.setAttribute("sendmail.message", "邮件发送不成功!");
		}
		request.getRequestDispatcher("/sendResult.jsp").forward(request,
				response);
	}
  public AnnotationMigration(File labelled, File unlabelled, File roles, File output, int start)
      throws IOException {
    pw =
        new PrintWriter(
            new BufferedWriter(new OutputStreamWriter(new FileOutputStream(output), "UTF-8")));
    tokenier = new HardTokenizer();
    Map<Integer, String> labelledMap = readTraining(labelled);
    Map<Integer, String> unlabelledMap = readTraining(unlabelled);
    roleMap = readRoles(roles);
    // logger.info(labelledMap);
    if (labelledMap.size() != unlabelledMap.size()) {
      logger.warn(labelledMap.size() + " != " + unlabelledMap.size());
    }

    for (int i = start; i < labelledMap.size(); i++) {
      logger.info(i);

      logger.info("\n" + labelledMap.get(i));
      logger.info("\n" + unlabelledMap.get(i));

      process(labelledMap.get(i), unlabelledMap.get(i));
      logger.info("***\n");
    }

    /*Iterator<Integer> it = unlabelledMap.keySet().iterator();
    while(it.hasNext()) {
    	int id = it.next();
    	if (labelledMap.get(id)==null){
    		logger.warn(id);
    		logger.warn(unlabelledMap.get(id));

    	}
    }*/
    pw.close();
  }
예제 #13
0
  public static void main(String[] args) throws IOException {
    if (args.length < 2) {
      System.out.println("Usage: WordSort inputfile outputfile");
      return;
    }
    String inputfile = args[0];
    String outputfile = args[1];

    /* Create the word map. Each key is a word and each value is an
     * Integer that represents the number of times the word occurs
     * in the input file.
     */

    Map<String, Integer> map = new TreeMap<String, Integer>();

    // read every line of the input file
    Scanner scanner = new Scanner(new File(inputfile));
    while (scanner.hasNext()) {
      String word = scanner.next();
      Integer count = map.get(word);
      count = (count == null ? 1 : count + 1);
      map.put(word, count);
    }
    scanner.close();

    // get the map's keys
    List<String> keys = new ArrayList<String>(map.keySet());

    // write the results to the output file
    PrintWriter out = new PrintWriter(new FileWriter(outputfile));
    for (String key : keys) {
      out.println(key + " : " + map.get(key));
    }
    out.close();
  }
예제 #14
0
  @Override
  public Response serve(IHTTPSession session) {
    Map<String, String> header = session.getHeaders();
    Map<String, String> parms = session.getParms();
    String uri = session.getUri();

    if (logRequests) {
      Log.i(TAG, session.getMethod() + " '" + uri + "' ");

      Iterator<String> e = header.keySet().iterator();
      while (e.hasNext()) {
        String value = e.next();
        Log.i(TAG, "  HDR: '" + value + "' = '" + header.get(value) + "'");
      }
      e = parms.keySet().iterator();
      while (e.hasNext()) {
        String value = e.next();
        Log.i(TAG, "  PRM: '" + value + "' = '" + parms.get(value) + "'");
      }
    }

    if (!webRoot.isDirectory()) {
      return createResponse(
          Response.Status.INTERNAL_ERROR,
          NanoHTTPD.MIME_PLAINTEXT,
          "INTERNAL ERRROR: given path is not a directory (" + webRoot + ").");
    }

    return respond(Collections.unmodifiableMap(header), uri);
  }
예제 #15
0
  /**
   * Select/Deselect pack(s) based on packsData mapping. This is related to the onSelect and
   * onDeselect attributes for packs. User is not allowed to has a required pack for onSelect and
   * onDeselect.
   *
   * @param packsData
   */
  private void selectionUpdate(Map<String, String> packsData) {
    RulesEngine rules = installData.getRules();
    for (Map.Entry<String, String> packData : packsData.entrySet()) {
      int value, packPos;
      String packName = packData.getKey();
      String condition = packData.getValue();

      if (condition != null && !rules.isConditionTrue(condition)) {
        return; // Do nothing if condition is false
      }

      Pack pack;

      if (packName.startsWith("!")) {
        packName = packName.substring(1);
        pack = nameToPack.get(packName);
        packPos = getPos(packName);
        value = DESELECTED;
      } else {
        pack = nameToPack.get(packName);
        packPos = getPos(packName);
        value = SELECTED;
      }
      if (!pack.isRequired() && dependenciesResolved(pack)) {
        checkValues[packPos] = value;
      }
    }
  }
예제 #16
0
파일: MemoryStudy.java 프로젝트: ePADD/muse
  private static void assignTypes(
      Collection<MemoryQuestion> questions, Map<String, NameInfo> nameMap) throws IOException {
    // assign categories. we have to assemble all the terms we want to look up together for
    // efficient lookup..
    // we'll put them in map
    Map<String, NameInfo> map = new LinkedHashMap<String, NameInfo>();
    for (MemoryQuestion mq : questions) {
      String name = mq.correctAnswer;
      String cname = name.toLowerCase().trim();
      map.put(cname, nameMap.get(cname));
    }

    // now we do a bulk type lookup...
    NameTypes.readTypes(map);

    // ... and copy the types back into the mq's
    for (MemoryQuestion mq : questions)
      try {
        if (mq != null && mq.correctAnswer != null) {
          NameInfo ni = nameMap.get(mq.correctAnswer.toLowerCase().trim().replaceAll(" ", "_"));
          if (ni != null) mq.clue.clueStats.answerCategory = ni.type;
        }
      } catch (Exception e) {
        Util.print_exception("Error reading types for question: " + mq, e, log);
      }
  }
예제 #17
0
  private int dfsVisit(Pack u, int[] status, boolean wipe, Map<String, PackColor> colours) {
    colours.put(u.getName(), PackColor.GREY);
    int check = checkValues[getPos(u.getName())];

    if (Math.abs(check) != 1) {
      wipe = true;
    }
    List<String> deps = u.getDependants();
    if (deps != null) {
      for (String name : deps) {
        Pack v = nameToPack.get(name);
        if (wipe) {
          status[getPos(v.getName())] = 1;
        }
        if (colours.get(v.getName()) == PackColor.WHITE) {
          final int result = dfsVisit(v, status, wipe, colours);
          if (result != 0) {
            return result;
          }
        }
      }
    }
    colours.put(u.getName(), PackColor.BLACK);
    return 0;
  }
 /**
  * Builds a new AgentMBeanServerConnectionFactory and returns the underlying
  * MBeanServerConnection
  *
  * @return a new MBeanServerConnection
  */
 public MBeanServerConnection build() {
   final String key = buildKey();
   MBeanServerConnection conn = INSTANCES.get(key);
   if (conn == null) {
     synchronized (INSTANCES) {
       conn = INSTANCES.get(key);
       if (conn == null) {
         conn =
             (MBeanServerConnection)
                 Proxy.newProxyInstance(
                     Thread.currentThread().getContextClassLoader(),
                     new Class[] {MBeanServerConnection.class},
                     new AgentMBeanServerConnectionFactory(this));
         INSTANCES.put(key, conn);
         channel
             .getCloseFuture()
             .addListener(
                 new ChannelFutureListener() {
                   @Override
                   public void operationComplete(ChannelFuture future) throws Exception {
                     INSTANCES.remove(key);
                   }
                 });
       }
     }
   }
   return conn;
 }
예제 #19
0
  public void processMethodMapping(
      String className,
      int firstLineNumber,
      int lastLineNumber,
      String methodReturnType,
      String methodName,
      String methodArguments,
      String newMethodName) {
    // Original class name -> obfuscated method names.
    Map methodMap = (Map) classMethodMap.get(className);
    if (methodMap == null) {
      methodMap = new HashMap();
      classMethodMap.put(className, methodMap);
    }

    // Obfuscated method name -> methods.
    Set methodSet = (Set) methodMap.get(newMethodName);
    if (methodSet == null) {
      methodSet = new LinkedHashSet();
      methodMap.put(newMethodName, methodSet);
    }

    // Add the method information.
    methodSet.add(
        new MethodInfo(
            firstLineNumber, lastLineNumber, methodReturnType, methodArguments, methodName));
  }
예제 #20
0
  private VirtualMachine connect(String bndlPrefix, AttachingConnector connector, Map args)
      throws DebuggerException {
    if (bndlPrefix != null) {
      if (connector.transport().name().equals("dt_shmem")) {
        Argument a = (Argument) args.get("name");
        if (a == null) println(bundle.getString(bndlPrefix + "_shmem_noargs"), ERR_OUT);
        else
          println(
              new MessageFormat(bundle.getString(bndlPrefix + "_shmem"))
                  .format(new Object[] {a.value()}),
              ERR_OUT);
      } else if (connector.transport().name().equals("dt_socket")) {
        Argument name = (Argument) args.get("hostname");
        Argument port = (Argument) args.get("port");
        if ((name == null) || (port == null))
          println(bundle.getString(bndlPrefix + "_socket_noargs"), ERR_OUT);
        else
          println(
              new MessageFormat(bundle.getString(bndlPrefix + "_socket"))
                  .format(new Object[] {name.value(), port.value()}),
              ERR_OUT);
      } else println(bundle.getString(bndlPrefix), ERR_OUT);
    }

    // launch VM
    try { // S ystem.out.println ("attach to:" + ac + " : " + password); // NOI18N
      return connector.attach(args);
    } catch (Exception e) {
      finishDebugger();
      throw new DebuggerException(
          new MessageFormat(bundle.getString("EXC_While_connecting_to_debuggee"))
              .format(new Object[] {e.toString()}),
          e);
    }
  }
예제 #21
0
    @Override
    public String process(File page, Map<String, String> query) {
      JSONObject jo = new JSONObject();
      jo.put("tip", "");

      if (graphs.containsKey(query.get("graphName")) && query.containsKey("sk")) {
        CortexGraph cg = graphs.get(query.get("graphName"));

        CortexKmer ck = new CortexKmer(query.get("sk"));

        CortexRecord cr = cg.findRecord(ck);
        if (cr != null) {
          String sampleName = cg.getColor(0).getSampleName();
          for (CortexLinksMap link : LINKS) {
            if (sampleName.equals(link.getCortexLinks().getColor(0).getSampleName())) {
              if (link.containsKey(ck)) {
                CortexLinksRecord clr = link.get(ck);

                clr = CortexUtils.orientLinksRecord(query.get("sk"), clr);

                jo.put("tip", clr.toString().replaceAll("\n", ", "));

                break;
              }
            }
          }
        }
      }

      return jo.toString();
    }
예제 #22
0
    /**
     * Parse the parameters of a connection into a CoreNLP properties file that can be passed into
     * {@link StanfordCoreNLP}, and used in the I/O stages.
     *
     * @param httpExchange The http exchange; effectively, the request information.
     * @return A {@link Properties} object corresponding to a combination of default and passed
     *     properties.
     * @throws UnsupportedEncodingException Thrown if we could not decode the key/value pairs with
     *     UTF-8.
     */
    private Properties getProperties(HttpExchange httpExchange)
        throws UnsupportedEncodingException {
      // Load the default properties
      Properties props = new Properties();
      defaultProps
          .entrySet()
          .stream()
          .forEach(
              entry -> props.setProperty(entry.getKey().toString(), entry.getValue().toString()));

      // Try to get more properties from query string.
      Map<String, String> urlParams = getURLParams(httpExchange.getRequestURI());
      if (urlParams.containsKey("properties")) {
        StringUtils.decodeMap(URLDecoder.decode(urlParams.get("properties"), "UTF-8"))
            .entrySet()
            .forEach(entry -> props.setProperty(entry.getKey(), entry.getValue()));
      } else if (urlParams.containsKey("props")) {
        StringUtils.decodeMap(URLDecoder.decode(urlParams.get("properties"), "UTF-8"))
            .entrySet()
            .forEach(entry -> props.setProperty(entry.getKey(), entry.getValue()));
      }

      // Make sure the properties compile
      props.setProperty(
          "annotators",
          StanfordCoreNLP.ensurePrerequisiteAnnotators(
              props.getProperty("annotators").split("[, \t]+")));

      return props;
    }
예제 #23
0
 private void writeEdges(Writer writer, List<Edge> edges, Map<Vertex, Integer> ids)
     throws IOException {
   for (Edge e : edges) {
     writeEdgeProperties(
         writer, e, ids.get(e.getVertex(Direction.OUT)), ids.get(e.getVertex(Direction.IN)));
   }
 }
 protected void createNodesTable() throws Exception {
   table().attr("cellpadding", "0", "cellspacing", "0", "border", "0", "class", "display");
   thead();
   tr();
   createThs(
       "Node", "Health", "Count", "Errors", "Time since last up", "Current Threads", "Action");
   end();
   end();
   tbody();
   for (Node n : router.getClusterManager().getAllNodesByCluster(params.get("cluster"))) {
     tr();
     td();
     createLink(
         "" + n.getHost() + ":" + n.getPort(),
         "node",
         "show",
         createQueryString(
             "cluster", params.get("cluster"), "host", n.getHost(), "port", "" + n.getPort()));
     end();
     createTds(
         n.isUp() ? "Up" : "Down",
         "" + n.getCounter(),
         String.format("%1$.2f%%", n.getErrors() * 100),
         formatDurationHMS(System.currentTimeMillis() - n.getLastUpTime()),
         "" + n.getThreads());
     td();
     createIcon("ui-icon-trash", "node", "delete", createQuery4Node(n));
     createIcon("ui-icon-circle-arrow-n", "node", "up", createQuery4Node(n));
     createIcon("ui-icon-circle-arrow-s", "node", "down", createQuery4Node(n));
     end();
     end();
   }
   end();
   end();
 }
  /**
   * Compares the specified Object with this Map for equality, as per the definition in the Map
   * interface.
   *
   * @param o object to be compared for equality with this hashtable
   * @return true if the specified Object is equal to this Map
   * @see Map#equals(Object)
   * @since 1.2
   */
  public synchronized boolean equals(Object o) {
    if (o == this) return true;

    if (!(o instanceof Map)) return false;
    Map<?, ?> t = (Map<?, ?>) o;
    if (t.size() != size()) return false;

    try {
      for (Map.Entry<K, V> e : entrySet()) {
        K key = e.getKey();
        V value = e.getValue();
        if (value == null) {
          if (!(t.get(key) == null && t.containsKey(key))) return false;
        } else {
          if (!value.equals(t.get(key))) return false;
        }
      }
    } catch (ClassCastException unused) {
      return false;
    } catch (NullPointerException unused) {
      return false;
    }

    return true;
  }
예제 #26
0
파일: Lexicon.java 프로젝트: ePADD/muse
  /** gets map for all languages */
  public Map<String, String> getCaptionToQueryMap(Collection<Document> docs) {
    // identify all the langs in the docs, and the corresponding lexicons
    Set<String> languages = IndexUtils.allLanguagesInDocs(docs);
    Set<Lexicon1Lang> lexicons = new LinkedHashSet<Lexicon1Lang>();
    for (String lang : languages) {
      Lexicon1Lang lex = languageToLexicon.get(lang);
      if (lex != null) lexicons.add(lex);
      // this lexicon doesn't know about this language
      else log.warn("Warning: no support for " + lang + " in lexicon " + name);
    }

    Map<String, String> result = new LinkedHashMap<String, String>();
    // aggregate results for each lang into result
    for (Lexicon1Lang lex : lexicons) {
      Map<String, String> resultsForThisLang = lex.captionToExpandedQuery;

      for (String caption : resultsForThisLang.keySet()) {
        String queryThisLang = resultsForThisLang.get(caption);
        String query = result.get(caption);
        // if caption doesn't exist already, create a new entry, or else add to the existing set of
        // docs that match this caption
        if (query == null) result.put(caption, queryThisLang);
        else result.put(caption, query + "|" + queryThisLang);
      }
    }
    return result;
  }
예제 #27
0
  // ---------------------------------------------------------------------------
  public Rule findTargetRule(String target) throws TablesawException {
    Rule rule = null;

    if (m_resolved) {
      ArrayList<String> posTargets;
      String posTarget = target;

      if (m_noRulesList.contains(target)) return (null);

      if ((rule = m_locatedRules.get(target)) != null) return (rule);

      // First look in name map
      rule = m_nameRuleMap.get(target);

      if (rule == null) { // Now look for targets
        rule = m_targetRuleMap.get(posTarget);
        if (rule == null) {
          posTargets = m_fileManager.getPossibleFiles(posTarget);
          for (String t : posTargets) {
            rule = m_targetRuleMap.get(t);
            if (rule != null) break;
          }
        }
      }

      Debug.print("Rule for " + target + " is " + rule);
      if (rule != null) {
        m_locatedRules.put(target, rule);
      } else m_noRulesList.add(target);
    }

    return (rule);
  }
예제 #28
0
  /**
   * Set the value of the parent pack of the given pack to SELECTED, PARTIAL_SELECT, or DESELECTED.
   * Value of the pack is dependent of its children values.
   *
   * @param childPack
   */
  private void updateParent(Pack childPack) {
    String parentName = childPack.getParent();
    Pack parentPack = nameToPack.get(parentName);
    int parentPosition = nameToRow.get(parentName);

    int childrenSelected = 0;
    for (String childName : parentPack.getChildren()) {
      int childPosition = nameToRow.get(childName);
      if (isChecked(childPosition)) {
        childrenSelected += 1;
      }
    }

    if (parentPack.getChildren().size() == childrenSelected) {
      if (checkValues[parentPosition] < 0) {
        checkValues[parentPosition] = REQUIRED_SELECTED;
      } else {
        checkValues[parentPosition] = SELECTED;
      }
    } else if (childrenSelected > 0) {

      if (checkValues[parentPosition] < 0) {
        checkValues[parentPosition] = REQUIRED_PARTIAL_SELECTED;
      } else {
        checkValues[parentPosition] = PARTIAL_SELECTED;
      }
    } else {
      if (checkValues[parentPosition] < 0) {
        checkValues[parentPosition] = REQUIRED_DESELECTED;
      } else {
        checkValues[parentPosition] = DESELECTED;
      }
    }
  }
예제 #29
0
 /**
  * 验证项目是否ok
  *
  * @param contextPath 项目路径
  */
 public static boolean isdomainok(String contextPath, String securityKey, String domiankey) {
   try {
     if (contextPath.indexOf("127.0.") > -1 || contextPath.indexOf("192.168.") > -1) {
       return true;
     }
     String dedomaininfo = PurseSecurityUtils.decryption(domiankey, securityKey);
     Gson gson = new Gson();
     JsonParser jsonParser = new JsonParser();
     JsonObject jsonObject = jsonParser.parse(dedomaininfo).getAsJsonObject();
     Map<String, String> map =
         gson.fromJson(jsonObject, new TypeToken<Map<String, String>>() {}.getType());
     String domain = map.get("domain");
     if (contextPath.indexOf(domain) < 0) {
       System.exit(2);
       return false;
     }
     String dt = map.get("dt");
     if (com.yizhilu.os.core.util.StringUtils.isNotEmpty(dt)) {
       Date t = DateUtils.toDate(dt, "yyyy-MM-dd");
       if (t.compareTo(new Date()) < 0) {
         System.exit(3);
         return false;
       }
     }
     return true;
   } catch (Exception e) {
     return false;
   }
 }
예제 #30
0
  public static boolean mapsAreIdentical(Map map1, Map map2) {
    if (map1 == null && map2 == null) {

      return (true);

    } else if (map1 == null || map2 == null) {

      return (false);
    }

    if (map1.size() != map2.size()) {

      return (false);
    }

    Iterator it = map1.keySet().iterator();

    while (it.hasNext()) {

      Object key = it.next();

      Object v1 = map1.get(key);
      Object v2 = map2.get(key);

      if (!objectsAreIdentical(v1, v2)) {

        return (false);
      }
    }

    return (true);
  }