예제 #1
0
        /**
         * Read a tag with a given tag id. The tag will be read out of the class
         * defined in getTagEnum().
         *
         * @param tagid
         *            A RPM tag id
         * @return The name of the RPM tag
         * @throws IllegalArgumentException
         *             if the tag id was not found
         */
        public String getTagNameForId(long tagid)
        {
            EnumIf e = RPMHeaderTag.getEnumById(tagid);

            if (e == null)
            {
                throw new java.lang.IllegalArgumentException("unknown tag with id <" + tagid
                                                             + ">");
            }
            return(e.getName());
        }
예제 #2
0
        /**
         * Read a tag with a given tag name. The tag will be read out of the class
         * defined in getTagEnum().
         *
         * @param tagname
         *            A RPM tag name
         * @return The id of the RPM tag
         * @throws IllegalArgumentException
         *             if the tag name was not found
         */
        public long getTagIdForName(String tagname)
        {
            EnumIf e = RPMHeaderTag.getEnumByName(tagname);

            if (e == null)
            {
                throw new java.lang.IllegalArgumentException("unknown tag with name <"
                                                             + tagname + ">");
            }

            return(e.getId());
        }
예제 #3
0
        /**
         * Get a enum by name
         *
         * @param refClass referencing class
         * @param name The name of the enum
         * @return The enum object
         */
        public static EnumIf getEnumByName(Type refClass, String name)
        {
            EnumIf   ret      = null;
            MapEntry mapEntry = null;

            mapEntry = (MapEntry)map.get(refClass);

            if (mapEntry != null)
            {
                ret = (EnumIf)mapEntry.nameMap.get(name.toLowerCase());

                if (ret == null)
                {
                    ret = (EnumIf)mapEntry.idMap.get(new java.lang.Long(EnumIfConstants._UNKNOWN));
                }
            }

            return(ret);
        }
예제 #4
0
        /**
         * Get a enum by id
         *
         * @param refClass referencing class
         * @param id The id of the enum
         * @return The enum object
         */
        public static EnumIf getEnumById(Type refClass, long id)
        {
            EnumIf   ret      = null;
            MapEntry mapEntry = null;

            mapEntry = (MapEntry)map.get(refClass);

            if (mapEntry != null)
            {
                ret = (EnumIf)mapEntry.idMap.get(new java.lang.Long(id));

                if (ret == null)
                {
                    // warn
                    ret = (EnumIf)mapEntry.idMap.get(new java.lang.Long(EnumIfConstants._UNKNOWN));
                }
            }

            return(ret);
        }
예제 #5
0
        /**
         * Creates a new EnumDelegate object.
         *
         * @param refClass Referencing class for this enum (the class that : the enum)
         * @param id A id for this enum
         * @param name A name for this enum
         * @param realEnum The actual reference of the enum object (the real enum object that : EnumIf)
         */
        public EnumDelegate(Type refClass, long id, String name, EnumIf realEnum)
        {
            this.id   = id;
            this.name = name;

            MapEntry mapEntry;

            if (map.containsKey(refClass))
            {
                mapEntry = (MapEntry)map.get(refClass);
            }
            else
            {
                mapEntry = new MapEntry();
                map.put(refClass, mapEntry);
            }

            mapEntry.idMap.put(new java.lang.Long(id), realEnum);
            mapEntry.nameMap.put(name.toLowerCase(), realEnum);
        }
예제 #6
0
        /**
         * Get a enum by id
         *
         * @param id The id of the enum
         * @return The enum object
         */
        public static EnumIf getEnumById(long id)
        {
            EnumIf result = EnumDelegate.getEnumById(typeof(LeadType), id);

            if (null == result)
            {
                switch (id)
                {
                case _BINARY:
                    result = LeadType.BINARY;
                    break;

                case _SOURCE:
                    result = LeadType.SOURCE;
                    break;

                default:
                    result = LeadType.UNKNOWN;
                    break;
                }
            }
            return(result);
        }
예제 #7
0
 public ArgTuple(KaitaiStream p__io, EnumIf.Operation p__parent = null, EnumIf p__root = null) : base(p__io)
 {
     m_parent = p__parent;
     m_root   = p__root;
     _read();
 }
예제 #8
0
 public EnumIf(KaitaiStream p__io, KaitaiStruct p__parent = null, EnumIf p__root = null) : base(p__io)
 {
     m_parent = p__parent;
     m_root   = p__root ?? this;
     _read();
 }
예제 #9
0
파일: LeadOS.cs 프로젝트: bastie/NetVampire
 private LeadOS(int os, String name)
 {
     delegateJ = new EnumDelegate(typeof(LeadOS), os, name, this);
 }
예제 #10
0
 private LeadSignature(int signature, String name)
 {
     delegateJ = new EnumDelegate(typeof(LeadSignature), signature, name, this);
 }
예제 #11
0
        /**
         * Get a enum by name
         *
         * @param name
         *                The name of the enum
         * @return The enum object
         */
        public static EnumIf getEnumByName(String name)
        {
            EnumIf result = EnumDelegate.getEnumByName(typeof(RPMHeaderTag), name);

            return(result);
        }
예제 #12
0
 private RPMHeaderTag(int tag, String name)
 {
     delegateJ = new EnumDelegate(typeof(RPMHeaderTag), tag, name, this);
 }
예제 #13
0
 private LeadType(int type, String name)
 {
     delegateJ = new EnumDelegate(typeof(LeadType), type, name, this);
 }
예제 #14
0
 private RPMIndexType(int type, String name, int size)
 {
     delegateJ = new EnumDelegate(typeof(RPMIndexType), type, name, this);
     this.size = size;
 }
예제 #15
0
 private LeadArchitecture(int architecture, String name)
 {
     delegateJ = new EnumDelegate(typeof(LeadArchitecture), architecture, name, this);
 }