Ejemplo n.º 1
0
 /**
  * This method will fire the spell check event and then handle the event action that has been
  * selected by the user.
  *
  * @param tokenizer Description of the Parameter
  * @param event The event to handle
  * @return Returns true if the event action is to cancel the current spell checking, false if the
  *     spell checking should continue
  */
 @SuppressWarnings("unchecked")
 protected boolean fireAndHandleEvent(WordTokenizer tokenizer, SpellCheckEvent event) {
   fireSpellCheckEvent(event);
   String word = event.getInvalidWord();
   // Work out what to do in response to the event.
   switch (event.getAction()) {
     case SpellCheckEvent.INITIAL:
       break;
     case SpellCheckEvent.IGNORE:
       break;
     case SpellCheckEvent.IGNOREALL:
       ignoreAll(word);
       break;
     case SpellCheckEvent.REPLACE:
       tokenizer.replaceWord(event.getReplaceWord());
       break;
     case SpellCheckEvent.REPLACEALL:
       String replaceAllWord = event.getReplaceWord();
       if (!autoReplaceWords.containsKey(word)) {
         autoReplaceWords.put(word, replaceAllWord);
       }
       tokenizer.replaceWord(replaceAllWord);
       break;
     case SpellCheckEvent.ADDTODICT:
       String addWord = event.getReplaceWord();
       if (!addWord.equals(word)) tokenizer.replaceWord(addWord);
       userdictionary.addWord(addWord);
       break;
     case SpellCheckEvent.CANCEL:
       return true;
     default:
       throw new IllegalArgumentException("Unhandled case.");
   }
   return false;
 }
  /**
   * Adds the given permission to this <tt>UserAdminPermissionCollection</tt>. The key for the hash
   * is the name.
   *
   * @param permission the <tt>Permission</tt> object to add.
   * @throws IllegalArgumentException If the given permission is not a <tt>UserAdminPermission</tt>
   * @throws SecurityException If this <tt>UserAdminPermissionCollection</tt> object has been marked
   *     readonly
   */
  public void add(Permission permission) {
    if (!(permission instanceof UserAdminPermission))
      throw new IllegalArgumentException("Invalid permission: " + permission);
    if (isReadOnly()) {
      throw new SecurityException(
          "Attempt to add a Permission to a " + "readonly PermissionCollection");
    }

    UserAdminPermission uap = (UserAdminPermission) permission;
    String name = uap.getName();

    UserAdminPermission existing = (UserAdminPermission) permissions.get(name);

    if (existing != null) {
      int oldMask = existing.getMask();
      int newMask = uap.getMask();
      if (oldMask != newMask) {
        permissions.put(name, new UserAdminPermission(name, oldMask | newMask));
      }
    } else {
      permissions.put(name, permission);
    }

    if (!all_allowed) {
      if (name.equals("*")) all_allowed = true;
    }
  }
Ejemplo n.º 3
0
  public synchronized Class loadClass(String className, boolean resolve)
      throws ClassNotFoundException {
    Class newClass;
    byte[] classData;
    newClass = (Class) loadedClasses.get(className);
    if (newClass != null) {
      if (resolve) resolveClass(newClass);
      return newClass;
    }
    try {
      newClass = findSystemClass(className);
      return newClass;
    } catch (ClassNotFoundException e) {
      System.out.println(className + " is not a system class!");
    }

    try {
      // 用自定义方法载入类数据,存放于字节数组classData中。
      classData = getClassData(className);
      // 由字节数组所包含的数据建立一个class类型的对象。
      // newClass = defineClass(classData, 0, classData.length);
      // newClass=defineClass()
      if (newClass == null) throw new ClassNotFoundException(className);
    } catch (Exception e) {
      throw new ClassNotFoundException(className);
    }
    loadedClasses.put(className, newClass);
    if (resolve) {
      resolveClass(newClass);
    }
    return newClass;
  }
Ejemplo n.º 4
0
  /**
   * Add an geoloc sharing session in the list
   *
   * @param session Geoloc sharing session
   */
  protected static void addGeolocSharingSession(GeolocSharingImpl session) {
    if (logger.isActivated()) {
      logger.debug("Add a geoloc sharing session in the list (size=" + gshSessions.size() + ")");
    }

    gshSessions.put(session.getSharingId(), session);
  }
Ejemplo n.º 5
0
  private Hashtable<String, Vector2> getSpecialNPCStartPositions() {
    Hashtable<String, Vector2> specialNPCStartPositions = new Hashtable<String, Vector2>();

    for (MapObject object : spawnsLayer.getObjects()) {
      String objectName = object.getName();

      if (objectName == null || objectName.isEmpty()) {
        continue;
      }

      // This is meant for all the special spawn locations, a catch all, so ignore known ones
      if (objectName.equalsIgnoreCase(NPC_START) || objectName.equalsIgnoreCase(PLAYER_START)) {
        continue;
      }

      // Get center of rectangle
      float x = ((RectangleMapObject) object).getRectangle().getX();
      float y = ((RectangleMapObject) object).getRectangle().getY();

      // scale by the unit to convert from map coordinates
      x *= UNIT_SCALE;
      y *= UNIT_SCALE;

      specialNPCStartPositions.put(objectName, new Vector2(x, y));
    }
    return specialNPCStartPositions;
  }
Ejemplo n.º 6
0
  public static Bitmap bitmap(@Nonnull final String content, final int size) {
    try {
      final Hashtable<EncodeHintType, Object> hints = new Hashtable<EncodeHintType, Object>();
      hints.put(EncodeHintType.MARGIN, 0);
      hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
      final BitMatrix result =
          QR_CODE_WRITER.encode(content, BarcodeFormat.QR_CODE, size, size, hints);

      final int width = result.getWidth();
      final int height = result.getHeight();
      final int[] pixels = new int[width * height];

      for (int y = 0; y < height; y++) {
        final int offset = y * width;
        for (int x = 0; x < width; x++) {
          pixels[offset + x] = result.get(x, y) ? Color.BLACK : Color.TRANSPARENT;
        }
      }

      final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
      bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
      return bitmap;
    } catch (final WriterException x) {
      log.info("problem creating qr code", x);
      return null;
    }
  }
Ejemplo n.º 7
0
  private Bitmap createBitmap(String content, final int size) {
    final Hashtable<EncodeHintType, Object> hints = new Hashtable<EncodeHintType, Object>();
    hints.put(EncodeHintType.MARGIN, 0);
    hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
    BitMatrix result;
    try {
      result = sQRCodeWriter.encode(content, BarcodeFormat.QR_CODE, size, size, hints);
    } catch (WriterException ex) {
      mLogger.warn("qr encoder failed: " + ex.toString());
      return null;
    }

    final int width = result.getWidth();
    final int height = result.getHeight();
    final int[] pixels = new int[width * height];

    for (int y = 0; y < height; y++) {
      final int offset = y * width;
      for (int x = 0; x < width; x++) {
        pixels[offset + x] = result.get(x, y) ? Color.BLACK : Color.TRANSPARENT;
      }
    }

    final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    bitmap.setPixels(pixels, 0, width, 0, 0, width, height);

    return bitmap;
  }
Ejemplo n.º 8
0
 public void banLogin(Player player) {
   if (loginBans.containsKey(player.getName())) {
     loginBans.get(player.getName()).increaseLevel();
   } else {
     loginBans.put(player.getName(), new loginBan());
   }
 }
Ejemplo n.º 9
0
  static {
    SerializerFactory factory;
    String list;
    StringTokenizer token;
    String className;

    // The default factories are always registered first,
    // any factory specified in the properties file and supporting
    // the same method will override the default factory.
    factory = new SerializerFactoryImpl(Method.XML);
    registerSerializerFactory(factory);
    factory = new SerializerFactoryImpl(Method.HTML);
    registerSerializerFactory(factory);
    factory = new SerializerFactoryImpl(Method.XHTML);
    registerSerializerFactory(factory);
    factory = new SerializerFactoryImpl(Method.TEXT);
    registerSerializerFactory(factory);

    list = System.getProperty(FactoriesProperty);
    if (list != null) {
      token = new StringTokenizer(list, " ;,:");
      while (token.hasMoreTokens()) {
        className = token.nextToken();
        try {
          factory =
              (SerializerFactory)
                  ObjectFactory.newInstance(
                      className, SerializerFactory.class.getClassLoader(), true);
          if (_factories.containsKey(factory.getSupportedMethod()))
            _factories.put(factory.getSupportedMethod(), factory);
        } catch (Exception except) {
        }
      }
    }
  }
Ejemplo n.º 10
0
  private void initQuery() throws IOException {
    Hashtable<String, String> map = new Hashtable<String, String>();
    map.put("uid", "TEMP_USER");
    map.put("pwd", "TEMP_PASSWORD");
    map.put(QUERY_PARAM, Base64.encodeToString(TEST_QUERY.getBytes(), 0));

    HttpParams params = new BasicHttpParams();

    HttpConnectionParams.setStaleCheckingEnabled(params, false);
    HttpConnectionParams.setConnectionTimeout(params, ConnectionManager.DEFAULT_TIMEOUT);
    HttpConnectionParams.setSoTimeout(params, ConnectionManager.DEFAULT_TIMEOUT);
    DefaultHttpClient httpClient = new DefaultHttpClient(params);

    // create post method
    HttpPost postMethod = new HttpPost(QUERY_URI);

    ByteArrayOutputStream byteArrayOS = new ByteArrayOutputStream();
    ObjectOutputStream objOS = new ObjectOutputStream(byteArrayOS);
    objOS.writeObject(map);
    ByteArrayEntity req_entity = new ByteArrayEntity(byteArrayOS.toByteArray());
    req_entity.setContentType(MIMETypeConstantsIF.BINARY_TYPE);

    // associating entity with method
    postMethod.setEntity(req_entity);

    // Executing post method
    executeHttpClient(httpClient, postMethod);
  }
Ejemplo n.º 11
0
 public ActionButton(String caption, Icon img) {
   properties = new Hashtable();
   properties.put(DEFAULT, caption);
   properties.put(NAME, caption);
   properties.put(SHORT_DESCRIPTION, caption);
   if (img != null) properties.put(SMALL_ICON, img);
 }
Ejemplo n.º 12
0
  synchronized Hashtable getProperties() {
    if ((props == null) && (text != null)) {
      Hashtable props = new Hashtable();
      int off = 0;
      while (off < text.length) {
        // length of the next key value pair
        int len = text[off++] & 0xFF;
        if ((len == 0) || (off + len > text.length)) {
          props.clear();
          break;
        }
        // look for the '='
        int i = 0;
        for (; (i < len) && (text[off + i] != '='); i++) {;
        }

        // get the property name
        String name = readUTF(text, off, i);
        if (name == null) {
          props.clear();
          break;
        }
        if (i == len) {
          props.put(name, NO_VALUE);
        } else {
          byte value[] = new byte[len - ++i];
          System.arraycopy(text, off + i, value, 0, len - i);
          props.put(name, value);
          off += len;
        }
      }
      this.props = props;
    }
    return props;
  }
Ejemplo n.º 13
0
 /**
  * Construct a service description for registrating with JmDNS. The properties hashtable must map
  * property names to either Strings or byte arrays describing the property values.
  *
  * @param type fully qualified service type name, such as <code>_http._tcp.local.</code>.
  * @param name unqualified service instance name, such as <code>foobar</code>
  * @param port the local port on which the service runs
  * @param weight weight of the service
  * @param priority priority of the service
  * @param props properties describing the service
  */
 public ServiceInfo(
     String type, String name, int port, int weight, int priority, Hashtable props) {
   this(type, name, port, weight, priority, new byte[0]);
   if (props != null) {
     try {
       ByteArrayOutputStream out = new ByteArrayOutputStream(256);
       for (Enumeration e = props.keys(); e.hasMoreElements(); ) {
         String key = (String) e.nextElement();
         Object val = props.get(key);
         ByteArrayOutputStream out2 = new ByteArrayOutputStream(100);
         writeUTF(out2, key);
         if (val instanceof String) {
           out2.write('=');
           writeUTF(out2, (String) val);
         } else {
           if (val instanceof byte[]) {
             out2.write('=');
             byte[] bval = (byte[]) val;
             out2.write(bval, 0, bval.length);
           } else {
             if (val != NO_VALUE) {
               throw new IllegalArgumentException("invalid property value: " + val);
             }
           }
         }
         byte data[] = out2.toByteArray();
         out.write(data.length);
         out.write(data, 0, data.length);
       }
       this.text = out.toByteArray();
     } catch (IOException e) {
       throw new RuntimeException("unexpected exception: " + e);
     }
   }
 }
Ejemplo n.º 14
0
  /**
   * This method initiates and populates the hashmap reqs, with all requirements in the graph. There
   * are two types of requirements: Ordinary and Variable. All of them are fetched by calling
   * getReqTagKey for all the edges and vertexes in the graph The Ordinary requirements are directly
   * put into the reqs hashmap. The Variable requirements are used as a lookup in the list of all
   * the variable values returned by getAllVariableValues and the value matching the the Variable
   * requirement are splitted with colon and put as keys into the reqs hashmap. The value for each
   * entity in the reqs hashmap will be set to null, since no requirement are tested yet. Its never
   * needed to call this method more than once.
   */
  public void populateReqHashMap() {
    reqs = new HashMap<String, Boolean>();
    Hashtable<String, String> reqsVariables = getAllVariableValues();

    for (Edge edge : model.getEdges()) {
      String reqTag = edge.getReqTagKey();
      if (reqTag.length() == 0) continue;
      String[] tmp = reqTag.split(",");
      for (int i = 0; i < tmp.length; i++) {
        if (tmp[i].matches("[$][{].*[}]")) {
          String[] reqNames =
              reqsVariables.get(tmp[i].substring(2, tmp[i].length() - 1)).split(":");
          for (String reqVar : reqNames) this.reqs.put(reqVar, null);
        } else this.reqs.put(tmp[i], null);
      }
    }
    for (Vertex vertex : model.getVertices()) {
      String reqTag = vertex.getReqTagKey();
      if (reqTag.length() == 0) continue;
      String[] tmp = reqTag.split(",");
      for (int i = 0; i < tmp.length; i++) {
        if (tmp[i].matches("[$][{].*[}]")) {
          String savedReq = reqsVariables.get(tmp[i].substring(2, tmp[i].length() - 1));
          if (savedReq == null) continue;
          String[] reqNames = savedReq.split(":");
          for (String reqVar : reqNames) this.reqs.put(reqVar, null);
        } else this.reqs.put(tmp[i], null);
      }
    }
  }
 static {
   _methods.put("getOperandoEsquerdo", new java.lang.Integer(0));
   _methods.put("getOperandoDireito", new java.lang.Integer(1));
   _methods.put("getTrechoCodigoFonteOperador", new java.lang.Integer(2));
   _methods.put("getTrechoCodigoFonte", new java.lang.Integer(3));
   _methods.put("aceitar", new java.lang.Integer(4));
 }
  static {
    operationPattern = Pattern.compile(OPERATION_PATTERN);
    subscribedPattern = Pattern.compile(CHANNEL_PATTERN);
    receivedPattern = Pattern.compile(RECEIVED_PATTERN);
    receivedPatternFiltered = Pattern.compile(RECEIVED_PATTERN_FILTERED);
    multipartMessagePattern = Pattern.compile(MULTI_PART_MESSAGE_PATTERN);
    unsubscribedPattern = Pattern.compile(CHANNEL_PATTERN);
    exceptionPattern = Pattern.compile(EXCEPTION_PATTERN);
    permissionsPattern = Pattern.compile(PERMISSIONS_PATTERN);

    operationIndex.put("ortc-validated", OrtcOperation.Validated);
    operationIndex.put("ortc-subscribed", OrtcOperation.Subscribed);
    operationIndex.put("ortc-unsubscribed", OrtcOperation.Unsubscribed);
    operationIndex.put("ortc-error", OrtcOperation.Error);

    errorOperationIndex.put("ex", OrtcServerErrorException.OrtcServerErrorOperation.Unexpected);
    errorOperationIndex.put("validate", OrtcServerErrorException.OrtcServerErrorOperation.Validate);
    errorOperationIndex.put(
        "subscribe", OrtcServerErrorException.OrtcServerErrorOperation.Subscribe);
    errorOperationIndex.put(
        "subscribe_maxsize", OrtcServerErrorException.OrtcServerErrorOperation.Subscribe_MaxSize);
    errorOperationIndex.put(
        "unsubscribe_maxsize",
        OrtcServerErrorException.OrtcServerErrorOperation.Unsubscribe_MaxSize);
    errorOperationIndex.put(
        "send_maxsize", OrtcServerErrorException.OrtcServerErrorOperation.Send_MaxSize);
  }
Ejemplo n.º 17
0
 @Override
 public Hashtable<TextAttribute, Object> getFontAttrs() {
   Hashtable<TextAttribute, Object> fontAttrs = new Hashtable<TextAttribute, Object>();
   fontAttrs.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_DOTTED);
   fontAttrs.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
   return fontAttrs;
 }
Ejemplo n.º 18
0
  public void putHsLayout(int id) {
    Hashtable hs = sshare.userInfo();
    if (hs == null) return;
    String key, name;
    JComponent obj;
    PushpinIF pobj;

    for (int i = 0; i < keys.size(); i++) {
      key = (String) keys.get(i);
      obj = (JComponent) panes.get(key);
      if (obj != null && (obj instanceof PushpinIF)) {
        pobj = (PushpinIF) obj;
        name = "tabTool." + id + "." + pobj.getName() + ".";
        hs.put(name + "refY", new Float(pobj.getRefY()));
        hs.put(name + "refX", new Float(pobj.getRefX()));
        hs.put(name + "refH", new Float(pobj.getRefH()));
        key = "open";
        if (pobj.isHide()) key = "hide";
        else if (pobj.isClose()) key = "close";
        hs.put(name + "status", key);
      }
    }
    /*
    name = "tabTool."+id+".TabPanel.";
    key = pinPanel.getLastName();
    if (key != null)
       hs.put(name+"lastName", key);
    key = "open";
    if (pinPanel.isHide())
       key = "hide";
    else if (pinPanel.isClose())
       key = "close";
    hs.put(name+"status", key);
     */
  }
Ejemplo n.º 19
0
  /**
   * Generates the localized key for the given password and engine id for the privacy protocol
   * specified by the supplied OID.
   *
   * @param privProtocolID an <code>OID</code> identifying the privacy protocol the key should be
   *     created for.
   * @param authProtocolID an <code>OID</code> identifying the authentication protocol to use.
   * @param passwordString the authentication pass phrase.
   * @param engineID the engine ID of the authoritative engine.
   * @return the localized privacy key.
   */
  public byte[] passwordToKey(
      OID privProtocolID, OID authProtocolID, OctetString passwordString, byte[] engineID) {

    AuthenticationProtocol authProtocol = authProtocols.get(authProtocolID);
    if (authProtocol == null) {
      return null;
    }
    PrivacyProtocol privProtocol = privProtocols.get(privProtocolID);
    if (privProtocol == null) {
      return null;
    }
    byte[] key = authProtocol.passwordToKey(passwordString, engineID);

    if (key == null) {
      return null;
    }
    if (key.length >= privProtocol.getMinKeyLength()) {
      if (key.length > privProtocol.getMaxKeyLength()) {
        // truncate key
        byte[] truncatedKey = new byte[privProtocol.getMaxKeyLength()];
        System.arraycopy(key, 0, truncatedKey, 0, privProtocol.getMaxKeyLength());
        return truncatedKey;
      }
      return key;
    }
    // extend key if necessary
    byte[] extKey = privProtocol.extendShortKey(key, passwordString, engineID, authProtocol);
    return extKey;
  }
Ejemplo n.º 20
0
 /**
  * 获取所有会话
  *
  * @return
  */
 private List<EMConversation> loadConversationsWithRecentChat() {
   // 获取所有会话,包括陌生人
   Hashtable<String, EMConversation> conversations =
       EMChatManager.getInstance().getAllConversations();
   // 过滤掉messages size为0的conversation
   /**
    * 如果在排序过程中有新消息收到,lastMsgTime会发生变化 影响排序过程,Collection.sort会产生异常 保证Conversation在Sort过程中最后一条消息的时间不变
    * 避免并发问题
    */
   List<Pair<Long, EMConversation>> sortList = new ArrayList<Pair<Long, EMConversation>>();
   synchronized (conversations) {
     for (EMConversation conversation : conversations.values()) {
       if (conversation.getAllMessages().size() != 0) {
         // if(conversation.getType() != EMConversationType.ChatRoom){
         sortList.add(
             new Pair<Long, EMConversation>(
                 conversation.getLastMessage().getMsgTime(), conversation));
         // }
       }
     }
   }
   try {
     sortConversationByLastChatTime(sortList);
   } catch (Exception e) {
     e.printStackTrace();
   }
   List<EMConversation> list = new ArrayList<EMConversation>();
   for (Pair<Long, EMConversation> sortItem : sortList) {
     list.add(sortItem.second);
   }
   return list;
 }
  /**
   * Takes a table of nodes and adds a weighted score to each node score in the table. A vector of
   * nodes that we want to be near is also taken as an argument. Here are the rules for scoring: If
   * a node is two away from a node in the desired set of nodes it gets 100. Otherwise it gets 0.
   *
   * @param board the game board
   * @param nodesIn the table of nodes to evaluate: Hashtable<Integer,Integer>
   * @param nodeSet the set of desired nodes
   * @param weight the score multiplier
   */
  protected void bestSpot2AwayFromANodeSet(
      SOCBoard board, Hashtable nodesIn, Vector nodeSet, int weight) {
    Enumeration nodesInEnum = nodesIn.keys(); // <Integer>

    while (nodesInEnum.hasMoreElements()) {
      Integer nodeCoord = (Integer) nodesInEnum.nextElement();
      int node = nodeCoord.intValue();
      int score = 0;
      final int oldScore = ((Integer) nodesIn.get(nodeCoord)).intValue();

      Enumeration nodeSetEnum = nodeSet.elements();

      while (nodeSetEnum.hasMoreElements()) {
        int target = ((Integer) nodeSetEnum.nextElement()).intValue();

        if (node == target) {
          break;
        } else if (board.isNode2AwayFromNode(node, target)) {
          score = 100;
        }
      }

      /** multiply by weight */
      score *= weight;

      nodesIn.put(nodeCoord, new Integer(oldScore + score));

      // log.debug("BS2AFANS -- put node "+Integer.toHexString(node)+" with old score "+oldScore+" +
      // new score "+score);
    }
  }
Ejemplo n.º 22
0
  public void heapArrange(int index) {
    int l, r;
    int largest;
    l = 2 * index + 1;
    r = 2 * index + 2;
    if (l <= lastindex && heap[l] > heap[index]) {
      largest = l;
    } else {
      largest = index;
    }
    if (r <= lastindex && heap[r] > heap[largest]) {
      largest = r;
    }
    if (largest != index) {
      int temp = heap[largest];
      hash.remove(heap[index]);
      hash.put(heap[index], largest);
      hash.remove(temp);
      hash.put(temp, index);
      heap[largest] = heap[index];
      heap[index] = temp;

      heapArrange(largest);
    }
  }
Ejemplo n.º 23
0
  public static void main(String[] args) throws Exception {

    Context jndiContext = null;
    try {
      Hashtable env = new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY, providerContextFactory);
      env.put(Context.PROVIDER_URL, "tibjmsnaming://localhost:7222");
      //			env.put(Context.SECURITY_PRINCIPAL, "admin");
      //			env.put(Context.SECURITY_CREDENTIALS, "");
      jndiContext = new InitialContext(env);
    } catch (Exception e) {
      System.out.println("Failed to create InitialContext");
      e.printStackTrace();
    }
    System.out.println("contex is " + jndiContext.getEnvironment().toString());
    //		ConnectionFactory factory = (javax.jms.ConnectionFactory)
    // jndiContext.lookup("ConnectionFactory");
    //		System.out.println(jndiContext.lookup("topic.sample"));
    //		jndiContext.bind("jbofy","Jbofy Yang");
    //		TopicConnectionFactory topicFactory = (javax.jms.TopicConnectionFactory) jndiContext
    //				.lookup("jms");
    //
    QueueConnectionFactory queueFactory =
        (javax.jms.QueueConnectionFactory) jndiContext.lookup("QueueConnectionFactory");
    System.out.println(queueFactory);

    Topic topic = (javax.jms.Topic) jndiContext.lookup("topic/subscribe");
    Queue queue = (javax.jms.Queue) jndiContext.lookup("queue/request");

    System.out.println(topic);
    System.out.println(queue);
  }
Ejemplo n.º 24
0
  public void insert(int element) {
    int parentindex, tempIndex;
    int temp;
    lastindex += 1;
    heap[lastindex] = element;

    hash.put(element, lastindex);

    tempIndex = lastindex;

    while (tempIndex != 0) {
      parentindex = (tempIndex - 1) / 2;
      if (heap[tempIndex] > heap[parentindex]) {
        temp = heap[parentindex];
        hash.remove(heap[tempIndex]);
        hash.put(heap[tempIndex], parentindex);
        hash.remove(temp);
        hash.put(temp, tempIndex);
        heap[parentindex] = heap[tempIndex];
        heap[tempIndex] = temp;
        tempIndex = parentindex;
      } else {
        tempIndex = 0;
      }
    }
  }
Ejemplo n.º 25
0
 private static Hashtable<String, Integer> GenerateNamesTable(int colNum, String[] colNames) {
   Hashtable<String, Integer> table = new Hashtable<String, Integer>();
   for (int i = 0; i < ColumnNumber; ++i) {
     table.put(ColumnNames[i], i);
   }
   return table;
 }
Ejemplo n.º 26
0
  public ItemMap(ItemMappedById pMi) {
    mi = pMi;
    baseMap = mi.getMap();

    additionalAttributes.put(ITEM_PROPERTY_NAME, mi.getItem());
    additionalAttributes.put(ITEM_PROPERTY_ID, mi.getItem().getId());
  }
  /**
   * Checks to see if this <tt>PermissionCollection</tt> implies the given permission.
   *
   * @param permission the <tt>Permission</tt> object to check against
   * @return true if the given permission is implied by this <tt>PermissionCollection</tt>, false
   *     otherwise.
   */
  public boolean implies(Permission permission) {
    if (!(permission instanceof UserAdminPermission)) {
      return (false);
    }

    UserAdminPermission uap = (UserAdminPermission) permission;
    UserAdminPermission x;

    int desired = uap.getMask();
    int effective = 0;

    // Short circuit if the "*" Permission was added.
    // desired can only be ACTION_NONE when name is "admin".
    if (all_allowed && desired != UserAdminPermission.ACTION_NONE) {
      x = (UserAdminPermission) permissions.get("*");
      if (x != null) {
        effective |= x.getMask();
        if ((effective & desired) == desired) {
          return (true);
        }
      }
    }

    // strategy:
    // Check for full match first. Then work our way up the
    // name looking for matches on a.b.*
    String name = uap.getName();

    x = (UserAdminPermission) permissions.get(name);

    if (x != null) {
      // we have a direct hit!
      effective |= x.getMask();
      if ((effective & desired) == desired) {
        return (true);
      }
    }

    // work our way up the tree...
    int last;

    int offset = name.length() - 1;

    while ((last = name.lastIndexOf(".", offset)) != -1) {
      name = name.substring(0, last + 1) + "*";
      x = (UserAdminPermission) permissions.get(name);

      if (x != null) {
        effective |= x.getMask();
        if ((effective & desired) == desired) {
          return (true);
        }
      }
      offset = last - 1;
    }

    // we don't have to check for "*" as it was already checked
    // at the top (all_allowed), so we just return false
    return (false);
  }
Ejemplo n.º 28
0
 protected Bitmap createQrCodeBitmap(String input, int size) {
   Log.d(Config.LOGTAG, "qr code requested size: " + size);
   try {
     final QRCodeWriter QR_CODE_WRITER = new QRCodeWriter();
     final Hashtable<EncodeHintType, Object> hints = new Hashtable<>();
     hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
     final BitMatrix result =
         QR_CODE_WRITER.encode(input, BarcodeFormat.QR_CODE, size, size, hints);
     final int width = result.getWidth();
     final int height = result.getHeight();
     final int[] pixels = new int[width * height];
     for (int y = 0; y < height; y++) {
       final int offset = y * width;
       for (int x = 0; x < width; x++) {
         pixels[offset + x] = result.get(x, y) ? Color.BLACK : Color.TRANSPARENT;
       }
     }
     final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
     Log.d(Config.LOGTAG, "output size: " + width + "x" + height);
     bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
     return bitmap;
   } catch (final WriterException e) {
     return null;
   }
 }
Ejemplo n.º 29
0
  public void initEJB() {
    try {
      InputStream inputStream =
          this.getClass()
              .getClassLoader()
              .getResourceAsStream("hu/neuron/java/sales/services/Settings.properties");

      Properties properties = new Properties();

      try {
        properties.load(inputStream);
      } catch (IOException e) {
        e.printStackTrace();
      }

      Hashtable<String, String> env = new Hashtable<String, String>();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
      env.put(Context.SECURITY_PRINCIPAL, properties.getProperty("SECURITY_PRINCIPAL"));
      env.put(Context.SECURITY_CREDENTIALS, properties.getProperty("SECURITY_CREDENTIALS"));
      env.put(Context.PROVIDER_URL, properties.getProperty("PROVIDER_URL"));
      Context ctx;

      ctx = new InitialContext(env);
      System.out.println("ctx  = " + ctx);
      offerService =
          (OfferServiceRemote)
              ctx.lookup("OfferService#hu.neuron.java.sales.service.OfferServiceRemote");
    } catch (NamingException e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 30
0
  protected void printIRHelper() {
    PrintWriter ps = openOutput(name + "IRHelper");
    if (ps == null) {
      return;
    }

    printPackage(ps);
    ps.println(Environment.NL + "/**");
    ps.println(" * This class contains generated Interface Repository information.");
    ps.println(" * @author JacORB IDL compiler.");
    ps.println(" */" + Environment.NL);

    ps.println("public class " + name + "IRHelper");
    ps.println("{");

    String HASHTABLE =
        System.getProperty("java.version").startsWith("1.1")
            ? "com.sun.java.util.collections.Hashtable"
            : "java.util.Hashtable";

    ps.println("\tpublic static " + HASHTABLE + " irInfo = new " + HASHTABLE + "();");
    ps.println("\tstatic");
    ps.println("\t{");
    body.getIRInfo(irInfoTable);

    for (Enumeration e = irInfoTable.keys(); e.hasMoreElements(); ) {
      String key = (String) e.nextElement();
      ps.println("\t\tirInfo.put(\"" + key + "\", \"" + (String) irInfoTable.get(key) + "\");");
    }

    ps.println("\t}");
    ps.println("}");
    ps.close();
  }