예제 #1
0
        /*
         * Constructs a {@code LogRecord} object using the supplied the logging
         * level and message. The millis property is set to the current time. The
         * sequence property is set to a new unique value, allocated in increasing
         * order within the virtual machine. The thread ID is set to a unique value
         * for the current thread. All other properties are set to {@code null}.
         *
         * @param level
         *            the logging level, may not be {@code null}.
         * @param msg
         *            the raw message.
         * @throws NullPointerException
         *             if {@code level} is {@code null}.
         */
        public LogRecord(Level level, String msg)
        {
            if (null == level)
            {
                // logging.4=The 'level' parameter is null.
                throw new java.lang.NullPointerException("The 'level' parameter is null."); //$NON-NLS-1$
            }
            this.level   = level;
            this.message = msg;
            this.millis  = java.lang.SystemJ.currentTimeMillis();

            lock (typeof(LogRecord).getClass()) {
                this.sequenceNumber = currentSequenceNumber++;
                java.lang.Integer id = currentThreadId.get();
                if (null == id)
                {
                    this.threadID = initThreadId;
                    currentThreadId.set(java.lang.Integer.valueOf(initThreadId++));
                }
                else
                {
                    this.threadID = id.intValue();
                }
            }

            this.sourceClassName    = null;
            this.sourceMethodName   = null;
            this.loggerName         = null;
            this.parameters         = null;
            this.resourceBundle     = null;
            this.resourceBundleName = null;
            this.thrown             = null;
        }
예제 #2
0
 // init properties
 private void init(String p, java.lang.Boolean a, java.lang.Integer l, java.lang.Integer c)
 {    //throws IOException {
     // check access
     manager = LogManager.getLogManager();
     manager.checkAccess();
     initProperties(p, a, l, c);
     initOutputFiles();
 }
        /**
         * Returns the number of occurrence of the given element in this bag
         * by looking up its count in the underlying map.
         *
         * @param object  the object to search for
         * @return the number of occurrences of the object, zero if not found
         */
        public virtual int getCount(Object obj)
        {
            int result = 0;

            java.lang.Integer count = MapUtils.getInteger(_map, obj);
            if (count != null)
            {
                result = count.intValue();
            }
            return(result);
        }
        /**
         * Adds a new item, which compares as equal to the given existing item.
         *
         * @param existingObj  an item already in the Comparator's set of
         *  known objects
         * @param newObj  an item to be added to the Comparator's set of
         *  known objects
         * @return true if newObj has been added for the first time, false if
         *  it was already known to the Comparator.
         * @throws IllegalArgumentException if existingObject is not in the
         *  Comparator's set of known objects.
         * @throws UnsupportedOperationException if a comparison has already been made
         */
        public bool addAsEqual(Object existingObj, Object newObj)
        {
            checkLocked();
            java.lang.Integer position = (java.lang.Integer)map.get(existingObj);
            if (position == null)
            {
                throw new java.lang.IllegalArgumentException(existingObj + " not known to " + this);
            }
            Object result = map.put(newObj, position);

            return(result == null);
        }
예제 #5
0
 /**
  * Increment the active count for the given key. Also
  * increments the total active count.
  *
  * @param key pool key
  */
 private void incrementActiveCount(K key)
 {
     _totActive++;
     java.lang.Integer old = _activeCount.get(key);
     if (null == old)
     {
         _activeCount.put(key, new java.lang.Integer(1));
     }
     else
     {
         _activeCount.put(key, new java.lang.Integer(old.intValue() + 1));
     }
 }
예제 #6
0
 /**
  * Decrements the active count for the given key.
  * Also decrements the total active count.
  *
  * @param key pool key
  */
 private void decrementActiveCount(K key)
 {
     _totActive--;
     java.lang.Integer active = _activeCount.get(key);
     if (null == active)
     {
         // do nothing, either null or zero is OK
     }
     else if (active.intValue() <= 1)
     {
         _activeCount.remove(key);
     }
     else
     {
         _activeCount.put(key, new java.lang.Integer(active.intValue() - 1));
     }
 }
        // Comparator methods
        //-----------------------------------------------------------------------

        /**
         * Compares two objects according to the order of this Comparator.
         * <p>
         * It is important to note that this class will throw an IllegalArgumentException
         * in the case of an unrecognised object. This is not specified in the
         * Comparator interface, but is the most appropriate exception.
         *
         * @param obj1  the first object to compare
         * @param obj2  the second object to compare
         * @return negative if obj1 is less, positive if greater, zero if equal
         * @throws IllegalArgumentException if obj1 or obj2 are not known
         *  to this Comparator and an alternative behavior has not been set
         *  via {@link #setUnknownObjectBehavior(int)}.
         */
        public int compare(Object obj1, Object obj2)
        {
            isLockedJ = true;
            java.lang.Integer position1 = (java.lang.Integer)map.get(obj1);
            java.lang.Integer position2 = (java.lang.Integer)map.get(obj2);
            if (position1 == null || position2 == null)
            {
                switch (unknownObjectBehavior)
                {
                case UNKNOWN_BEFORE:
                    if (position1 == null)
                    {
                        return((position2 == null) ? 0 : -1);
                    }
                    else
                    {
                        return(1);
                    }

                case UNKNOWN_AFTER:
                    if (position1 == null)
                    {
                        return((position2 == null) ? 0 : 1);
                    }
                    else
                    {
                        return(-1);
                    }

                case UNKNOWN_THROW_EXCEPTION:
                    Object unknownObj = (position1 == null) ? obj1 : obj2;
                    throw new java.lang.IllegalArgumentException("Attempting to compare unknown object " + unknownObj);

                default:
                    throw new java.lang.UnsupportedOperationException("Unknown unknownObjectBehavior: " + unknownObjectBehavior);
                }
            }
            else
            {
                return(position1.compareTo(position2));
            }
        }
예제 #8
0
        private void initProperties(String p, java.lang.Boolean a, java.lang.Integer l, java.lang.Integer c)
        {
            base.initProperties("ALL", null, "java.util.logging.XMLFormatter",
                                null);
            String className = this.getClass().getName();

            pattern = (null == p) ? getStringProperty(className + ".pattern",
                                                      DEFAULT_PATTERN) : p;
            if (null == pattern || "".equals(pattern))
            {
                // logging.19=Pattern cannot be empty
                throw new java.lang.NullPointerException("Pattern cannot be empty");
            }
            append = (null == a) ? getBooleanProperty(className + ".append",
                                                      DEFAULT_APPEND) : a.booleanValue();
            count = (null == c) ? getIntProperty(className + ".count",
                                                 DEFAULT_COUNT) : c.intValue();
            limit = (null == l) ? getIntProperty(className + ".limit",
                                                 DEFAULT_LIMIT) : l.intValue();
            count = count < 1 ? DEFAULT_COUNT : count;
            limit = limit < 0 ? DEFAULT_LIMIT : limit;
            files = new java.io.File[count];
        }