コード例 #1
0
 public boolean isToolEnabled(HighlightDisplayKey key, PsiElement element) {
   if (key == null) {
     return false;
   }
   final Tools toolState = getTools(key.toString());
   return toolState != null && toolState.isEnabled(element);
 }
コード例 #2
0
ファイル: IconHelper.java プロジェクト: sreereddymenon/Hangar
  protected Bitmap cachedIconHelper(ComponentName componentTask) {
    Drawable iconPackIcon = null;
    String cachedIconString = IconCacheHelper.getPreloadedComponentUri(mContext, componentTask);
    ResolveInfo rInfo =
        new Tools().cachedImageResolveInfo(mContext, componentTask.getPackageName());
    if (rInfo == null) return null;

    mCount++;

    if (cachedIconString == null) {
      if (ich == null) {
        ich = new IconCacheHelper(mContext);
        Tools.HangarLog("Loading new IconCacheHelper instance");
      }
      iconPackIcon = ich.getFullResIcon(rInfo);
      IconCacheHelper.preloadComponent(
          mContext,
          componentTask,
          Tools.drawableToBitmap(iconPackIcon),
          Tools.dpToPx(mContext, Settings.CACHED_ICON_SIZE));
    }
    if (iconPackIcon == null) {
      return IconCacheHelper.getPreloadedComponent(mContext, componentTask);
    } else {
      return Tools.drawableToBitmap(iconPackIcon);
    }
  }
コード例 #3
0
ファイル: FileShared.java プロジェクト: Leph/Fileshare
  /** Initialise le header du fichier temporaire */
  private void initHeaderTmpFile() {
    try {
      FileOutputStream writer_tmp = new FileOutputStream(this);
      FileChannel writer = writer_tmp.getChannel();

      int offset = 0;

      // Taille de la clef
      Tools.write(writer, offset, _key.length());
      offset += 4;
      // Clef
      Tools.write(writer, offset, _key);
      offset += _key.length();
      // Size
      Tools.write(writer, offset, _size);
      offset += 4;
      // piecesize
      Tools.write(writer, offset, _piecesize);
      offset += 4;
      // Buffermap
      int i;
      for (i = 0; i < this.nbPieces(); i++) {
        Tools.write(writer, offset, -1);
        offset += 4;
      }

      writer.force(true);
      writer_tmp.close();
    } catch (Exception e) {
      System.out.println("Unable to create a new tmp file");
      e.printStackTrace();
    }
  }
  protected HighlightSeverity getSeverity(@NotNull RefElement element) {
    final PsiElement psiElement = element.getPointer().getContainingFile();
    if (psiElement != null) {
      final GlobalInspectionContextImpl context = getContext();
      final String shortName = getSeverityDelegateName();
      final Tools tools = context.getTools().get(shortName);
      if (tools != null) {
        for (ScopeToolState state : tools.getTools()) {
          InspectionToolWrapper toolWrapper = state.getTool();
          if (toolWrapper == getToolWrapper()) {
            return context
                .getCurrentProfile()
                .getErrorLevel(HighlightDisplayKey.find(shortName), psiElement)
                .getSeverity();
          }
        }
      }

      final InspectionProfile profile =
          InspectionProjectProfileManager.getInstance(context.getProject()).getInspectionProfile();
      final HighlightDisplayLevel level =
          profile.getErrorLevel(HighlightDisplayKey.find(shortName), psiElement);
      return level.getSeverity();
    }
    return null;
  }
コード例 #5
0
ファイル: FileShared.java プロジェクト: Leph/Fileshare
  /**
   * Lis et retourne une piece depuis le fichier temporaire sur le disque (la piece doit exister)
   *
   * @param num : numéros de la piece
   */
  private synchronized byte[] readPieceTmpFile(int num) {
    if (num < 0 || num >= this.nbPieces()) {
      throw new IllegalArgumentException();
    }

    try {
      FileInputStream reader_tmp = new FileInputStream(this);
      FileChannel reader = reader_tmp.getChannel();

      int index_piece = Tools.readInt(reader, 4 + _key.length() + 4 + 4 + 4 * num);
      if (index_piece < 0) {
        throw new IllegalArgumentException();
      }

      int size = _piecesize;
      if (num == this.nbPieces() - 1) {
        size = _size - _piecesize * (this.nbPieces() - 1);
      }

      byte[] piece = Tools.readBytes(reader, this.headerSize() + _piecesize * index_piece, size);
      reader_tmp.close();

      return piece;
    } catch (Exception e) {
      System.out.println("Unable to read tmp file piece");
      e.printStackTrace();
    }
    return new byte[0];
  }
コード例 #6
0
ファイル: FileShared.java プロジェクト: Leph/Fileshare
  /**
   * Ecrit la piece donnée dans le fichier temporaire sur le disque
   *
   * @param piece : pièce à écrire
   * @param num : numéros de la pièce
   */
  private synchronized void writePieceTmpFile(byte[] piece, int num) {
    if (num < 0 || num >= this.nbPieces()) {
      throw new IllegalArgumentException();
    }
    if (piece.length > _piecesize) {
      throw new IllegalArgumentException();
    }

    try {
      RandomAccessFile writer_tmp = new RandomAccessFile(this, "rw");
      FileChannel writer = writer_tmp.getChannel();

      int index_piece = ((int) this.length() - this.headerSize()) / _piecesize;

      if (piece.length < _piecesize) {
        piece = Arrays.copyOf(piece, _piecesize);
      }
      Tools.write(writer, 4 + _key.length() + 4 + 4 + 4 * num, index_piece);
      Tools.write(writer, this.headerSize() + _piecesize * index_piece, piece);

      writer.force(true);
      writer_tmp.close();
    } catch (Exception e) {
      System.out.println("Unable to write tmp file piece");
      e.printStackTrace();
    }
  }
コード例 #7
0
ファイル: Event.java プロジェクト: kvpbase/kvpbase-sdk-java
 public static void logException(String file, Exception e) {
   logWarning(Tools.line(79, "*"));
   logWarning("An exception was encountered in file " + file);
   logWarning("  Message: " + e.getMessage());
   logWarning("  Cause: " + e.getCause());
   logWarning(Tools.line(79, "*"));
 }
コード例 #8
0
  /**
   * A wrapper for sampling one tree during the Gibbs sampler
   *
   * @param sample_num The current sample number of the Gibbs sampler
   * @param t The current tree to be sampled
   * @param trees The trees in this Gibbs sampler
   * @param tree_array_illustration The tree array (for debugging purposes only)
   * @return The responses minus the sum of the trees' contribution up to this point
   */
  protected double[] SampleTree(
      int sample_num,
      int t,
      CGMBARTTreeNode[] trees,
      TreeArrayIllustration tree_array_illustration) {
    // first copy the tree from the previous gibbs position
    final CGMBARTTreeNode copy_of_old_jth_tree =
        gibbs_samples_of_cgm_trees[sample_num - 1][t].clone();

    // okay so first we need to get "y" that this tree sees. This is defined as R_j in formula 12 on
    // p274
    // just go to sum_residual_vec and subtract it from y_trans
    double[] R_j =
        Tools.add_arrays(
            Tools.subtract_arrays(y_trans, sum_resids_vec), copy_of_old_jth_tree.yhats);

    // now, (important!) set the R_j's as this tree's data.
    copy_of_old_jth_tree.updateWithNewResponsesRecursively(R_j);

    // sample from T_j | R_j, \sigma
    // now we will run one M-H step on this tree with the y as the R_j
    CGMBARTTreeNode new_jth_tree =
        metroHastingsPosteriorTreeSpaceIteration(
            copy_of_old_jth_tree, t, accept_reject_mh, accept_reject_mh_steps);

    // add it to the vector of current sample's trees
    trees[t] = new_jth_tree;

    // now set the new trees in the gibbs sample pantheon
    gibbs_samples_of_cgm_trees[sample_num] = trees;
    tree_array_illustration.AddTree(new_jth_tree);
    // return the updated residuals
    return R_j;
  }
コード例 #9
0
ファイル: IconHelper.java プロジェクト: sreereddymenon/Hangar
  protected boolean cachedIconHelper(ImageView taskIcon, ComponentName componentTask) {
    Drawable iconPackIcon;
    String cachedIconString = IconCacheHelper.getPreloadedComponentUri(mContext, componentTask);
    ResolveInfo rInfo =
        new Tools().cachedImageResolveInfo(mContext, componentTask.getPackageName());
    if (rInfo == null) return false;

    mCount++;

    if (cachedIconString == null) {
      if (ich == null) {
        ich = new IconCacheHelper(mContext);
        Tools.HangarLog("Loading new IconCacheHelper instance");
      }
      iconPackIcon = ich.getFullResIcon(rInfo);
      cachedIconString =
          IconCacheHelper.preloadComponent(
              mContext,
              componentTask,
              Tools.drawableToBitmap(iconPackIcon),
              Tools.dpToPx(mContext, Settings.CACHED_ICON_SIZE));
    }
    taskIcon.setImageURI(Uri.parse(cachedIconString));
    return true;
  }
コード例 #10
0
 public void testSimple() {
   String[] a = {"a", "b"};
   assertEquals(Collections.<String>emptyList(), Tools.list(new IterableArray<String>(a, 0, 0)));
   assertEquals(Arrays.asList("a"), Tools.list(new IterableArray<String>(a, 0, 1)));
   assertEquals(Arrays.asList("a", "b"), Tools.list(new IterableArray<String>(a, 0, 2)));
   assertEquals(Arrays.asList("b"), Tools.list(new IterableArray<String>(a, 1, 2)));
 }
コード例 #11
0
ファイル: CEListener.java プロジェクト: paul-palmer/ce
 @EventHandler(priority = EventPriority.HIGHEST)
 public void SignChangeEvent(SignChangeEvent e) {
   if (e.getLine(0).equals("[CustomEnchant]"))
     if (!e.getPlayer().isOp()) e.setCancelled(true);
     else {
       String ench = e.getLine(1);
       CEnchantment ce = Tools.getEnchantmentByDisplayname(ench);
       if (ce == null) ce = Tools.getEnchantmentByOriginalname(ench);
       if (ce == null)
         for (CEnchantment ceT : Main.enchantments)
           if (Tools.checkForEnchantment(ench, ceT)) ce = ceT;
       if (ce == null) {
         e.getPlayer()
             .sendMessage(ChatColor.RED + "[CE] Could not find Custom Enchantment " + ench + ".");
         e.setCancelled(true);
         return;
       }
       try {
         Integer.parseInt(e.getLine(3).replaceAll("\\D+", ""));
       } catch (NumberFormatException ex) {
         e.getPlayer().sendMessage(ChatColor.RED + "[CE] The cost you entered is invalid.");
         e.setCancelled(true);
         return;
       }
       e.getPlayer()
           .sendMessage(
               ChatColor.GREEN
                   + "[CE] Successfully created a sign shop for the enchantment "
                   + ench
                   + ".");
     }
 }
コード例 #12
0
ファイル: SOCK5.java プロジェクト: VinhTang/Proxy
  public void Calculate_AddressSOCK(byte AType) {

    switch (AType) {
        // Version IP 4
      case 0x01:
        RemoteHost = Tools.calcInetAddress(DST_Addr);
        RemotePort = Tools.calcPort(DST_Port);
        break;
        // Version IP DOMAIN NAME
      case 0x03:
        if (DST_Addr[0] <= 0) {
          Logs.Println(
              Logger.ERROR,
              "SOCKS 5 - calcInetAddress() : BAD IP in command - size : " + DST_Addr[0],
              true);
          return;
        }
        String sIA = "";

        for (int i = 1; i <= DST_Addr[0]; i++) {
          sIA += (char) DST_Addr[i];
        }

        RemoteHost = sIA;
        RemotePort = Tools.calcPort(DST_Port);
        break;
    }
  }
コード例 #13
0
  /** objectid will be one of following table: ad_listuiconf, ad_listdataconf, ad_objuiconf */
  public ValueHolder execute(DefaultWebEvent event) throws RemoteException, NDSException {
    User usr = helper.getOperator(event);
    TableManager manager = TableManager.getInstance();
    int columnId = Tools.getInt(event.getParameterValue("columnid", true), -1);
    Table table = manager.getColumn(columnId).getTable();
    int tableId = table.getId();
    int objectId = Tools.getInt(event.getParameterValue("objectid", true), -1);
    int type;
    if (tableId == manager.getTable("ad_listdataconf").getId()) {
      type = PortletConfig.TYPE_LIST_DATA;
    } else if (tableId == manager.getTable("ad_listuiconf").getId()) {
      type = PortletConfig.TYPE_LIST_UI;
    } else if (tableId == manager.getTable("ad_objuiconf").getId()) {
      type = PortletConfig.TYPE_OBJECT_UI;
    } else {
      throw new NDSException("Internal Error: table is not supported for PortletConfig:" + table);
    }
    PortletConfigManager pcManager =
        (PortletConfigManager)
            WebUtils.getServletContextManager().getActor(nds.util.WebKeys.PORTLETCONFIG_MANAGER);
    pcManager.removePortletConfig(objectId, type);
    // also try to clear config of specified name
    String name =
        (String)
            nds.query.QueryEngine.getInstance()
                .doQueryOne("select name from " + table.getName() + " where id=" + objectId);
    logger.debug("name=" + name);
    pcManager.removePortletConfig(name, type);

    ValueHolder holder = new ValueHolder();
    holder.put("message", "@complete@(cache size:" + pcManager.getCacheSize() + ")");
    holder.put("code", "0");
    return holder;
  }
コード例 #14
0
ファイル: SOCK5.java プロジェクト: VinhTang/Proxy
  // --------------------
  private void GetUserInfo() {
    byte b;
    int version = GetByte();

    // USername
    int Userlen = Tools.byte2int(GetByte());

    byte[] User = null;
    for (int i = 0; i < Userlen; i++) {
      Username += (char) GetByte();
    }
    //       User = Username.getBytes();
    //        Username = Tools.byte2str(User);

    // Password
    int Passlen = Tools.byte2int(GetByte());

    byte[] Pass = null;
    for (int i = 0; i < Passlen; i++) {
      Password += (char) GetByte();
    }
    //       Pass = Password.getBytes();
    //        Password = Tools.byte2str(User);

  }
コード例 #15
0
ファイル: Home.java プロジェクト: davidromeroxaandia/Revalida
  public static LayoutContent displayHome(spark.Request request, Configuration cfg) {
    String html = "";
    Map<String, String> root = Tools.listLayoutMap();
    root.replace("msg", DBH.getMsg(request.session().id()));
    Template temp;
    try {
      temp = cfg.getTemplate("user-home.htm");
      Writer out = new StringWriter();
      temp.process(root, out);
      html = out.toString();
    } catch (IOException | TemplateException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      html = e.getMessage();
    }
    HashMap<String, String> options = new HashMap<String, String>();
    options.put("addBtn", Tools.getAddBtn("/tramites/agregar", "Iniciar Trámite"));
    options.put(
        "toolBar",
        Tools.getToolbarItem("/tramites/agregar", "Iniciar Trámite", "", "btn red darken-3")
            + Tools.getToolbarItem("/tramites", "Trámites", "", "btn green darken-3"));

    LayoutContent lc = new LayoutContent(html, options);
    return lc;
  }
コード例 #16
0
ファイル: TincActivity.java プロジェクト: hwhw/tinc_gui
 private boolean checkRoot() {
   if (_service != null && _service._useSU) {
     // Ensure su is working correctly, as some implementations do simply nothing, without error...
     String aOut = Tools.ToString(Tools.Run("su", "id"));
     return (aOut.length() >= 5 && aOut.substring(0, 5).equals("uid=0"));
   }
   return true;
 }
コード例 #17
0
ファイル: Tools.java プロジェクト: Relicum/SuperSkyBros
 /**
  * Search the enum to see if a given item is on the list
  *
  * <p>Return true if it is false if it's not
  *
  * @param item the item {@link org.bukkit.Material} in it's String format
  * @return the boolean
  */
 public static boolean find(String item) {
   for (Tools v : values()) {
     if (v.name().equalsIgnoreCase(item)) {
       return true;
     }
   }
   return false;
 }
コード例 #18
0
ファイル: ToolsTest.java プロジェクト: CingHu/test-onos
 @Test
 public void toHex() throws Exception {
   assertEquals("0f", Tools.toHex(15, 2));
   assertEquals("ffff", Tools.toHex(65535, 4));
   assertEquals("1000", Tools.toHex(4096, 4));
   assertEquals("000000000000000f", Tools.toHex(15));
   assertEquals("ffffffffffffffff", Tools.toHex(0xffffffffffffffffL));
 }
コード例 #19
0
  private static void getRapidMinerParameters(StringBuffer string) {
    string.append("RapidMiner Parameters:" + Tools.getLineSeparator());

    for (String key : ParameterService.getParameterKeys()) {
      string.append(
          "  " + key + "\t= " + ParameterService.getParameterValue(key) + Tools.getLineSeparator());
    }
  }
コード例 #20
0
 public List<ScopeToolState> getDefaultStates() {
   initInspectionTools();
   final List<ScopeToolState> result = new ArrayList<ScopeToolState>();
   for (Tools tools : myTools.values()) {
     result.add(tools.getDefaultState());
   }
   return result;
 }
コード例 #21
0
ファイル: ToolsTest.java プロジェクト: CingHu/test-onos
 @Test
 public void fromHex() throws Exception {
   assertEquals(15, Tools.fromHex("0f"));
   assertEquals(16, Tools.fromHex("10"));
   assertEquals(65535, Tools.fromHex("ffff"));
   assertEquals(4096, Tools.fromHex("1000"));
   assertEquals(0xffffffffffffffffL, Tools.fromHex("ffffffffffffffff"));
 }
コード例 #22
0
 private static String getProperties() {
   StringBuffer string = new StringBuffer();
   string.append("System properties:" + Tools.getLineSeparator());
   string.append("------------" + Tools.getLineSeparator() + Tools.getLineSeparator());
   getSystemProperties("os", string);
   getSystemProperties("java", string);
   getRapidMinerParameters(string);
   return string.toString();
 }
コード例 #23
0
 @NotNull
 public InspectionProfileEntry[] getInspectionTools(PsiElement element) {
   initInspectionTools();
   List<InspectionTool> result = new ArrayList<InspectionTool>();
   for (Tools toolList : myTools.values()) {
     result.add((InspectionTool) toolList.getInspectionTool(element));
   }
   return result.toArray(new InspectionTool[result.size()]);
 }
コード例 #24
0
  public static void addToSRCSpring(
      BaseTable tmp, String daopath, String servicepath, String actionpath) {
    SAXReader reader = new SAXReader();
    String name = tmp.getClass().getSimpleName();
    Document document;
    try {
      document = reader.read(new File(SRC_SPRING_CONFIG));
      Element beans = document.getRootElement();
      beans.addComment(
          "===================以下是" + name + tmp.getComment() + "相关的beans====================");
      // DAO-------------------------------------------------------------
      if (!daopath.equals("")) {
        Element dao = beans.addElement("bean");
        dao.addAttribute("id", Tools.firstLowcase(name + "DAO"));
        dao.addAttribute("class", daopath);
        dao.addAttribute("parent", "DAO");
      }
      // Server----------------------------------------------------------
      if (!servicepath.equals("")) {
        Element service = beans.addElement("bean");
        service.addAttribute("id", Tools.firstLowcase(name + "Service"));
        service.addAttribute("class", servicepath);
        service.addAttribute("parent", "BaseService");
        Element serProperty = service.addElement("property");
        serProperty.addAttribute("name", "dao");
        serProperty.addAttribute("ref", Tools.firstLowcase(name + "DAO"));
      }
      // action----------------------------------------------------------
      if (!actionpath.equals("")) {
        Element action = beans.addElement("bean");
        action.addAttribute("name", name);
        action.addAttribute("class", actionpath);
        Element actionProperty = action.addElement("property");
        actionProperty.addAttribute("name", name.toLowerCase() + "Service");
        actionProperty.addAttribute("ref", name + "Server");
      }
      // action----------------------------------------------------------
      //			Element action = beans.addElement("bean");
      //			action.addAttribute("name", name);
      //			action.addAttribute("class", "com.zb.template." + name + "Action");
      //			Element actionProperty = action.addElement("property");
      //			actionProperty.addAttribute("name", name.toLowerCase() + "Service");
      //			actionProperty.addAttribute("ref", name + "Server");

      // 更新保存----------------------------------------------------
      XMLWriter writer = new XMLWriter(new FileWriter(SRC_SPRING_CONFIG));
      writer.write(document);
      writer.close();

    } catch (DocumentException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
コード例 #25
0
 public void lockProfile(boolean isLocked) {
   for (Tools toolList : myTools.values()) {
     final String key = toolList.getShortName();
     if (isLocked) {
       myDisplayLevelMap.put(key, Boolean.FALSE);
     }
   }
   myLockedProfile = isLocked;
 }
コード例 #26
0
 /**
  * Calculate angle of tangent line at a particular point
  *
  * @param t : parameter
  * @return angle
  */
 public double calcDirectionAt(double t) {
   final boolean db = false;
   calcTangentAt(t, workPt);
   double a = Math.atan2(workPt.y, workPt.x);
   if (db) {
     System.out.println("calcDirectionAt " + Tools.f(t) + " a=" + Tools.fa(a));
   }
   return a;
 }
コード例 #27
0
 public BondLocation(List<Location> subLocations) {
   super();
   Location min = Tools.getMin(subLocations);
   Location max = Tools.getMax(subLocations);
   setStart(min.getStart());
   setEnd(max.getEnd());
   setStrand(Strand.UNDEFINED);
   setSubLocations(subLocations);
   assertLocation();
 }
コード例 #28
0
 public static final Page sitePage(DocumentModel doc, CoreSession session) throws ClientException {
   Page page = null;
   if (LabsSiteConstants.Docs.SITE.type().equals(doc.getType())) {
     DocumentModel homePage = Tools.getAdapter(LabsSite.class, doc, session).getIndexDocument();
     page = Tools.getAdapter(Page.class, homePage, session);
   } else {
     page = Tools.getAdapter(Page.class, doc, session);
   }
   return page;
 }
コード例 #29
0
 public int getSliceNumber(String label) {
   int slice = 0;
   if (label.length() >= 14 && label.charAt(4) == '-' && label.charAt(9) == '-')
     slice = (int) Tools.parseDouble(label.substring(0, 4), -1);
   else if (label.length() >= 17 && label.charAt(5) == '-' && label.charAt(11) == '-')
     slice = (int) Tools.parseDouble(label.substring(0, 5), -1);
   else if (label.length() >= 20 && label.charAt(6) == '-' && label.charAt(13) == '-')
     slice = (int) Tools.parseDouble(label.substring(0, 6), -1);
   return slice;
 }
コード例 #30
0
 public int update_all(Map<String, Object> data) {
   ContentValues cv = new ContentValues();
   for (Entry<String, Object> e : data.entrySet()) {
     if (e.getValue() == null) continue;
     Tools.putObjectToContentValues(cv, e.getKey(), e.getValue());
   }
   int count = _db.update(_tableName, cv, Tools.join(_whereList, " AND "), null);
   this.release();
   return count;
 }