Changeset 1418 for trunk


Ignore:
Timestamp:
07/24/19 13:58:00 (5 years ago)
Author:
bln4
Message:

Created a unioned list for item properties in DefaultFrameWriter. Used it in Item.

Location:
trunk/src/org/expeditee
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/encryption/io/EncryptedExpWriter.java

    r1416 r1418  
    141141                }
    142142               
    143                 LinkedHashMap<Character,Method> itemTags = new LinkedHashMap<Character, Method>(getItemTags());
    144                 LinkedHashMap<String,Method> itemTagsExt = new LinkedHashMap<String, Method>(getItemTagsExt());
     143                LinkedHashMap<Character,Method> itemTags = new LinkedHashMap<Character, Method>(getItemCharTags());
     144                LinkedHashMap<String,Method> itemTagsExt = new LinkedHashMap<String, Method>(getItemStrTags());
    145145               
    146146                writeTag(toWrite, new Object[] {}, itemTags, 'S');
  • trunk/src/org/expeditee/io/DefaultFrameWriter.java

    r1415 r1418  
    3030import java.util.HashSet;
    3131import java.util.LinkedHashMap;
     32import java.util.Set;
    3233
    3334import org.expeditee.agents.WriteTree;
     
    167168
    168169        // keep track of methods that are put on the same line
    169         private static LinkedHashMap<Character, Method> _ItemTags = new LinkedHashMap<Character, Method>();
     170        private static LinkedHashMap<Character, Method> _ItemCharTags = new LinkedHashMap<Character, Method>();
    170171        // IMPORTANT: keys in _ItemTagsExt must start with underscore as their first character
    171         private static LinkedHashMap<String, Method> _ItemTagsExt = new LinkedHashMap<String, Method>();
     172        private static LinkedHashMap<String, Method> _ItemStrTags = new LinkedHashMap<String, Method>();
     173       
     174        private static LinkedHashMap<String, Method> _ItemTags = new LinkedHashMap<String, Method>();
    172175
    173176        protected static LinkedHashMap<Character, Method> _FrameTags = new LinkedHashMap<Character, Method>();
     
    190193                       
    191194                        // Note: As of 26/11/18 there are no unused letter item tags.  Use other characters.
    192                         _ItemTags.put(DefaultFrameWriter.TYPE_AND_ID, Item.class.getMethod("getTypeAndID"));
    193                         _ItemTags.put(DefaultFrameWriter.DATE_CREATED, Item.class.getMethod("getDateCreated"));
    194                         _ItemTags.put(DefaultFrameWriter.COLOR, Item.class.getMethod("getColor"));
    195                         _ItemTags.put(DefaultFrameWriter.BACKGROUND_COLOR, Item.class.getMethod("getBackgroundColor"));
    196                         _ItemTags.put(DefaultFrameWriter.BORDER_COLOR, Item.class.getMethod("getBorderColor"));
    197 
    198                         _ItemTags.put(DefaultFrameWriter.POSITION, Item.class.getMethod("getPosition"));
    199                         _ItemTags.put(DefaultFrameWriter.TEXT, Text.class.getMethod("getText"));
    200                         _ItemTags.put(DefaultFrameWriter.LINK, Item.class.getMethod("getLink"));
    201                         _ItemTags.put(DefaultFrameWriter.ACTION, Item.class.getMethod("getAction"));
    202                         _ItemTags.put(DefaultFrameWriter.ACTION_MARK, Item.class.getMethod("getActionMark"));
    203                         _ItemTags.put(DefaultFrameWriter.ACTION_CURSOR_ENTER, Item.class.getMethod("getActionCursorEnter"));
    204                         _ItemTags.put(DefaultFrameWriter.ACTION_CURSOR_LEAVE, Item.class.getMethod("getActionCursorLeave"));
    205                         _ItemTags.put(DefaultFrameWriter.ACTION_ENTER_FRAME, Item.class.getMethod("getActionEnterFrame"));
    206                         _ItemTags.put(DefaultFrameWriter.ACTION_LEAVE_FRAME, Item.class.getMethod("getActionLeaveFrame"));
    207                         _ItemTags.put(DefaultFrameWriter.DATA, Item.class.getMethod("getData"));
    208                         _ItemTags.put(DefaultFrameWriter.HIGHLIGHT, Item.class.getMethod("getHighlight"));
    209                         _ItemTags.put(DefaultFrameWriter.FILL_COLOR, Item.class.getMethod("getFillColor"));
    210                         _ItemTags.put(DefaultFrameWriter.GRADIENT_COLOR, Item.class.getMethod("getGradientColor"));
    211                         _ItemTags.put(DefaultFrameWriter.GRADIENT_ANGLE, Item.class.getMethod("getGradientAngle"));
    212                        
    213                         _ItemTags.put(DefaultFrameWriter.ANCHOR_LEFT, Item.class.getMethod("getAnchorLeft"));
    214                         _ItemTags.put(DefaultFrameWriter.ANCHOR_RIGHT, Item.class.getMethod("getAnchorRight"));
    215                         _ItemTags.put(DefaultFrameWriter.ANCHOR_TOP, Item.class.getMethod("getAnchorTop"));
    216                         _ItemTags.put(DefaultFrameWriter.ANCHOR_BOTTOM, Item.class.getMethod("getAnchorBottom"));
    217 
    218                         _ItemTags.put(DefaultFrameWriter.FILL_PATTERN, Item.class.getMethod("getFillPattern"));
    219                         _ItemTags.put(DefaultFrameWriter.OWNER, Item.class.getMethod("getOwner"));
    220                         _ItemTags.put(DefaultFrameWriter.LINK_MARK, Item.class.getMethod("getLinkMark"));
    221                         _ItemTags.put(DefaultFrameWriter.LINK_FRAMESET, Item.class.getMethod("getLinkFrameset"));
    222                         _ItemTags.put(DefaultFrameWriter.LINK_TEMPLATE, Item.class.getMethod("getLinkTemplate"));
    223                         _ItemTags.put(DefaultFrameWriter.LINE_PATTERN, Item.class.getMethod("getLinePattern"));
    224 
    225                         _ItemTags.put(DefaultFrameWriter.ARROW, Item.class.getMethod("getArrow"));
    226                        
    227                         _ItemTags.put(DefaultFrameWriter.DOT_TYPE, Item.class.getMethod("getDotType"));
    228                         _ItemTags.put(DefaultFrameWriter.FILLED, Item.class.getMethod("getFilled"));
    229 
    230                         _ItemTags.put(DefaultFrameWriter.FONT, Text.class.getMethod("getFont"));
    231                         _ItemTags.put(DefaultFrameWriter.SPACING, Text.class.getMethod("getSpacing"));
    232                        
    233                         _ItemTags.put(DefaultFrameWriter.MASK, Text.class.getMethod("getMask"));
     195                        _ItemCharTags.put(DefaultFrameWriter.TYPE_AND_ID, Item.class.getMethod("getTypeAndID"));
     196                        _ItemCharTags.put(DefaultFrameWriter.DATE_CREATED, Item.class.getMethod("getDateCreated"));
     197                        _ItemCharTags.put(DefaultFrameWriter.COLOR, Item.class.getMethod("getColor"));
     198                        _ItemCharTags.put(DefaultFrameWriter.BACKGROUND_COLOR, Item.class.getMethod("getBackgroundColor"));
     199                        _ItemCharTags.put(DefaultFrameWriter.BORDER_COLOR, Item.class.getMethod("getBorderColor"));
     200
     201                        _ItemCharTags.put(DefaultFrameWriter.POSITION, Item.class.getMethod("getPosition"));
     202                        _ItemCharTags.put(DefaultFrameWriter.TEXT, Text.class.getMethod("getText"));
     203                        _ItemCharTags.put(DefaultFrameWriter.LINK, Item.class.getMethod("getLink"));
     204                        _ItemCharTags.put(DefaultFrameWriter.ACTION, Item.class.getMethod("getAction"));
     205                        _ItemCharTags.put(DefaultFrameWriter.ACTION_MARK, Item.class.getMethod("getActionMark"));
     206                        _ItemCharTags.put(DefaultFrameWriter.ACTION_CURSOR_ENTER, Item.class.getMethod("getActionCursorEnter"));
     207                        _ItemCharTags.put(DefaultFrameWriter.ACTION_CURSOR_LEAVE, Item.class.getMethod("getActionCursorLeave"));
     208                        _ItemCharTags.put(DefaultFrameWriter.ACTION_ENTER_FRAME, Item.class.getMethod("getActionEnterFrame"));
     209                        _ItemCharTags.put(DefaultFrameWriter.ACTION_LEAVE_FRAME, Item.class.getMethod("getActionLeaveFrame"));
     210                        _ItemCharTags.put(DefaultFrameWriter.DATA, Item.class.getMethod("getData"));
     211                        _ItemCharTags.put(DefaultFrameWriter.HIGHLIGHT, Item.class.getMethod("getHighlight"));
     212                        _ItemCharTags.put(DefaultFrameWriter.FILL_COLOR, Item.class.getMethod("getFillColor"));
     213                        _ItemCharTags.put(DefaultFrameWriter.GRADIENT_COLOR, Item.class.getMethod("getGradientColor"));
     214                        _ItemCharTags.put(DefaultFrameWriter.GRADIENT_ANGLE, Item.class.getMethod("getGradientAngle"));
     215                       
     216                        _ItemCharTags.put(DefaultFrameWriter.ANCHOR_LEFT, Item.class.getMethod("getAnchorLeft"));
     217                        _ItemCharTags.put(DefaultFrameWriter.ANCHOR_RIGHT, Item.class.getMethod("getAnchorRight"));
     218                        _ItemCharTags.put(DefaultFrameWriter.ANCHOR_TOP, Item.class.getMethod("getAnchorTop"));
     219                        _ItemCharTags.put(DefaultFrameWriter.ANCHOR_BOTTOM, Item.class.getMethod("getAnchorBottom"));
     220
     221                        _ItemCharTags.put(DefaultFrameWriter.FILL_PATTERN, Item.class.getMethod("getFillPattern"));
     222                        _ItemCharTags.put(DefaultFrameWriter.OWNER, Item.class.getMethod("getOwner"));
     223                        _ItemCharTags.put(DefaultFrameWriter.LINK_MARK, Item.class.getMethod("getLinkMark"));
     224                        _ItemCharTags.put(DefaultFrameWriter.LINK_FRAMESET, Item.class.getMethod("getLinkFrameset"));
     225                        _ItemCharTags.put(DefaultFrameWriter.LINK_TEMPLATE, Item.class.getMethod("getLinkTemplate"));
     226                        _ItemCharTags.put(DefaultFrameWriter.LINE_PATTERN, Item.class.getMethod("getLinePattern"));
     227
     228                        _ItemCharTags.put(DefaultFrameWriter.ARROW, Item.class.getMethod("getArrow"));
     229                       
     230                        _ItemCharTags.put(DefaultFrameWriter.DOT_TYPE, Item.class.getMethod("getDotType"));
     231                        _ItemCharTags.put(DefaultFrameWriter.FILLED, Item.class.getMethod("getFilled"));
     232
     233                        _ItemCharTags.put(DefaultFrameWriter.FONT, Text.class.getMethod("getFont"));
     234                        _ItemCharTags.put(DefaultFrameWriter.SPACING, Text.class.getMethod("getSpacing"));
     235                       
     236                        _ItemCharTags.put(DefaultFrameWriter.MASK, Text.class.getMethod("getMask"));
    234237
    235238                        // TODO set a boolean flag to indicate that the text is a formula
    236239                        // Store the formula in the text property NOT the answer
    237                         _ItemTags.put(DefaultFrameWriter.FORMULA, Item.class.getMethod("getFormula"));
    238 
    239                         _ItemTags.put(DefaultFrameWriter.WORD_SPACING, Text.class.getMethod("getWordSpacing"));
    240                         _ItemTags.put(DefaultFrameWriter.LETTER_SPACING, Text.class.getMethod("getLetterSpacing"));
    241                         _ItemTags.put(DefaultFrameWriter.INITIAL_SPACING, Text.class.getMethod("getInitialSpacing"));
    242                         _ItemTags.put(DefaultFrameWriter.WIDTH_TO_SAVE, Text.class.getMethod("getWidthToSave"));
    243                         _ItemTags.put(DefaultFrameWriter.MIN_WIDTH_TO_SAVE, Text.class.getMethod("getMinWidthToSave"));
    244                         _ItemTags.put(DefaultFrameWriter.JUSTIFICATION, Text.class.getMethod("getJustification"));
    245                         _ItemTags.put(DefaultFrameWriter.AUTO_WRAP_TO_SAVE, Text.class.getMethod("getAutoWrapToSave"));
    246 
    247                         _ItemTags.put(DefaultFrameWriter.THICKNESS, Item.class.getMethod("getThickness"));
    248                         _ItemTags.put(DefaultFrameWriter.LINE_IDS, Item.class.getMethod("getLineIDs"));
    249                         _ItemTags.put(DefaultFrameWriter.CONSTRAINT_IDS, Item.class.getMethod("getConstraintIDs"));
    250                        
    251                         _ItemTags.put(DefaultFrameWriter.TOOLTIP, Item.class.getMethod("getTooltip"));
    252                         _ItemTags.put(DefaultFrameWriter.LINK_HISTORY, Item.class.getMethod("getLinkHistory"));
    253                        
    254                         _ItemTags.put(DefaultFrameWriter.PERMISSION, Item.class.getMethod("getPermission"));
    255 
    256                         _ItemTags.put(DefaultFrameWriter.MAGNETIZED_ITEM_LEFT, Item.class.getMethod("getMagnetizedItemLeft"));
    257                         _ItemTags.put(DefaultFrameWriter.MAGNETIZED_ITEM_RIGHT, Item.class.getMethod("getMagnetizedItemRight"));
    258                         _ItemTags.put(DefaultFrameWriter.MAGNETIZED_ITEM_TOP, Item.class.getMethod("getMagnetizedItemTop"));
    259                         _ItemTags.put(DefaultFrameWriter.MAGNETIZED_ITEM_BOTTOM, Item.class.getMethod("getMagnetizedItemBottom"));
    260                        
    261                         _ItemTagsExt.put(DefaultFrameWriter.ENCRYPTION_LABEL_STR, Item.class.getMethod("getEncryptionLabel"));
    262                        
    263                         _ItemTagsExt.put(DefaultFrameWriter.PLACEHOLDER_STR, Text.class.getMethod("getPlaceholder"));
    264                         _ItemTagsExt.put(DefaultFrameWriter.SINGLE_LINE_ONLY_STR, Text.class.getMethod("isSingleLineOnly"));
    265                         _ItemTagsExt.put(DefaultFrameWriter.TAB_INDEX_STR, Text.class.getMethod("getTabIndex"));
    266                         _ItemTagsExt.put(DefaultFrameWriter.ACCEPTS_ENTER, Item.class.getMethod("acceptsKeyboardEnter"));
     240                        _ItemCharTags.put(DefaultFrameWriter.FORMULA, Item.class.getMethod("getFormula"));
     241
     242                        _ItemCharTags.put(DefaultFrameWriter.WORD_SPACING, Text.class.getMethod("getWordSpacing"));
     243                        _ItemCharTags.put(DefaultFrameWriter.LETTER_SPACING, Text.class.getMethod("getLetterSpacing"));
     244                        _ItemCharTags.put(DefaultFrameWriter.INITIAL_SPACING, Text.class.getMethod("getInitialSpacing"));
     245                        _ItemCharTags.put(DefaultFrameWriter.WIDTH_TO_SAVE, Text.class.getMethod("getWidthToSave"));
     246                        _ItemCharTags.put(DefaultFrameWriter.MIN_WIDTH_TO_SAVE, Text.class.getMethod("getMinWidthToSave"));
     247                        _ItemCharTags.put(DefaultFrameWriter.JUSTIFICATION, Text.class.getMethod("getJustification"));
     248                        _ItemCharTags.put(DefaultFrameWriter.AUTO_WRAP_TO_SAVE, Text.class.getMethod("getAutoWrapToSave"));
     249
     250                        _ItemCharTags.put(DefaultFrameWriter.THICKNESS, Item.class.getMethod("getThickness"));
     251                        _ItemCharTags.put(DefaultFrameWriter.LINE_IDS, Item.class.getMethod("getLineIDs"));
     252                        _ItemCharTags.put(DefaultFrameWriter.CONSTRAINT_IDS, Item.class.getMethod("getConstraintIDs"));
     253                       
     254                        _ItemCharTags.put(DefaultFrameWriter.TOOLTIP, Item.class.getMethod("getTooltip"));
     255                        _ItemCharTags.put(DefaultFrameWriter.LINK_HISTORY, Item.class.getMethod("getLinkHistory"));
     256                       
     257                        _ItemCharTags.put(DefaultFrameWriter.PERMISSION, Item.class.getMethod("getPermission"));
     258
     259                        _ItemCharTags.put(DefaultFrameWriter.MAGNETIZED_ITEM_LEFT, Item.class.getMethod("getMagnetizedItemLeft"));
     260                        _ItemCharTags.put(DefaultFrameWriter.MAGNETIZED_ITEM_RIGHT, Item.class.getMethod("getMagnetizedItemRight"));
     261                        _ItemCharTags.put(DefaultFrameWriter.MAGNETIZED_ITEM_TOP, Item.class.getMethod("getMagnetizedItemTop"));
     262                        _ItemCharTags.put(DefaultFrameWriter.MAGNETIZED_ITEM_BOTTOM, Item.class.getMethod("getMagnetizedItemBottom"));
     263                       
     264                        _ItemStrTags.put(DefaultFrameWriter.ENCRYPTION_LABEL_STR, Item.class.getMethod("getEncryptionLabel"));
     265                       
     266                        _ItemStrTags.put(DefaultFrameWriter.PLACEHOLDER_STR, Text.class.getMethod("getPlaceholder"));
     267                        _ItemStrTags.put(DefaultFrameWriter.SINGLE_LINE_ONLY_STR, Text.class.getMethod("isSingleLineOnly"));
     268                        _ItemStrTags.put(DefaultFrameWriter.TAB_INDEX_STR, Text.class.getMethod("getTabIndex"));
     269                        _ItemStrTags.put(DefaultFrameWriter.ACCEPTS_ENTER, Item.class.getMethod("acceptsKeyboardEnter"));
    267270                } catch (Exception e) {
    268271                        e.printStackTrace();
    269272                }
     273               
     274                Set<Character> keySet = _ItemCharTags.keySet();
     275                for (Character key: keySet) {
     276                        _ItemTags.put(key + "", _ItemCharTags.get(key));
     277                }
     278                _ItemTags.putAll(_ItemStrTags);
    270279        }
    271280
     
    428437                return "Not Supported";
    429438        }
     439       
     440        public static LinkedHashMap<String, Method> getItemTags() {
     441                return _ItemTags;
     442        }
    430443
    431444        /**
    432445         * @return the _ItemTags
    433446         */
    434         public static LinkedHashMap<Character, Method> getItemTags() {
    435                 return _ItemTags;
     447        public static LinkedHashMap<Character, Method> getItemCharTags() {
     448                return _ItemCharTags;
    436449        }
    437450
     
    439452         * @return the _ItemTagsExt
    440453         */
    441         public static LinkedHashMap<String, Method> getItemTagsExt() {
    442                 return _ItemTagsExt;
     454        public static LinkedHashMap<String, Method> getItemStrTags() {
     455                return _ItemStrTags;
    443456        }
    444457
  • trunk/src/org/expeditee/io/ExpWriter.java

    r1408 r1418  
    8888                try {
    8989                        _FrameTags.remove('A');
    90                         getItemTags().put('S', Item.class.getMethod("getTypeAndID",
     90                        getItemCharTags().put('S', Item.class.getMethod("getTypeAndID",
    9191                                        new Class[] {}));
    9292                } catch (Exception e) {
     
    306306
    307307        protected void writeClass(Item toWrite) throws IOException {
    308                 writeTags(toWrite, new Object[] {}, getItemTags());
    309                 writeTags(toWrite, new Object[] {}, getItemTagsExt());
     308                writeTags(toWrite, new Object[] {}, getItemCharTags());
     309                writeTags(toWrite, new Object[] {}, getItemStrTags());
    310310        }
    311311
  • trunk/src/org/expeditee/io/KMSWriter.java

    r1408 r1418  
    8181                try {
    8282                        _FrameTags.put('A', Frame.class.getMethod("getName", new Class[] {}));
    83                         getItemTags().put('S', Item.class.getMethod("getID", new Class[] {}));
     83                        getItemCharTags().put('S', Item.class.getMethod("getID", new Class[] {}));
    8484                } catch (Exception e) {
    8585
     
    258258
    259259        private void writeClass(Object toWrite) throws IOException {
    260                 Iterator<Character> it = getItemTags().keySet().iterator();
     260                Iterator<Character> it = getItemCharTags().keySet().iterator();
    261261                Object[] param = {};
    262262
    263263                while (it.hasNext()) {
    264264                        Character tag = it.next();
    265                         Method toRun = getItemTags().get(tag);
     265                        Method toRun = getItemCharTags().get(tag);
    266266                        Class<?> declarer = toRun.getDeclaringClass();
    267267                        if (declarer.isAssignableFrom(toWrite.getClass())) {
  • trunk/src/org/expeditee/items/Item.java

    r1417 r1418  
    334334        {
    335335                EncryptionDetail unencryptedOnSave = new EncryptionDetail(EncryptionDetail.Type.UnencryptedOnSave);
    336                 for(Character tag: DefaultFrameWriter.getItemTags().keySet()) {
    337                         if (tag == 'T' || tag == 'S') {
    338                                 surrogatePropertyInheritanceDefault.put(tag + "", false);
     336                for (String tag: DefaultFrameWriter.getItemTags().keySet()) {
     337                        if (tag == "T" || tag == "S") {
     338                                surrogatePropertyInheritanceDefault.put(tag, false);
    339339                        } else {
    340                                 surrogatePropertyInheritanceDefault.put(tag + "", true);
    341                         }
    342                         primaryPropertyEncryptionDefault.put(tag + "", unencryptedOnSave);
    343                 }
    344                
    345                 for(String tag: DefaultFrameWriter.getItemTagsExt().keySet()) {
    346                         surrogatePropertyInheritanceDefault.put(tag, true);
     340                                surrogatePropertyInheritanceDefault.put(tag, true);
     341                        }
    347342                        primaryPropertyEncryptionDefault.put(tag, unencryptedOnSave);
    348343                }
     
    41294124                EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
    41304125               
    4131                 for (Character tag: DefaultFrameWriter.getItemTags().keySet()) {
     4126                for (Character tag: DefaultFrameWriter.getItemCharTags().keySet()) {
    41324127                        if (tag == 'T') {
    41334128                                primaryPropertyEncryption.put(tag + "", reencryptOnSave.clone());
     
    41434138                }
    41444139               
    4145                 for (String tag: DefaultFrameWriter.getItemTagsExt().keySet()) {
     4140                for (String tag: DefaultFrameWriter.getItemStrTags().keySet()) {
    41464141                        primaryPropertyEncryption.put(tag, inheritanceCheckOnSave.clone());
    41474142                        surrogate.surrogatePropertyInheritance.put(tag + "", true);
Note: See TracChangeset for help on using the changeset viewer.