Coverage Report - org.apache.myfaces.view.facelets.component._CommonPropertyConstants
 
Classes in this File Line Coverage Branch Coverage Complexity
_CommonPropertyConstants
0%
0/55
0%
0/6
3
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *   http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 package org.apache.myfaces.view.facelets.component;
 20  
 
 21  
 import java.util.HashMap;
 22  
 import java.util.Map;
 23  
 
 24  
 import javax.faces.component.UIComponent;
 25  
 
 26  
 /**
 27  
  * This is a list of the most common properties used by a JSF html
 28  
  * component, organized by interfaces.
 29  
  * 
 30  
  * Note there is a copy of this class on 
 31  
  * org.apache.myfaces.shared.renderkit.html.CommonPropertyConstants.
 32  
  * Any changes here should be committed there too.
 33  
  * 
 34  
  * @author Leonardo Uribe
 35  
  *
 36  
  */
 37  0
 class _CommonPropertyConstants
 38  
 {
 39  
     public static final String COMMON_PROPERTIES_MARKED = "oam.COMMON_PROPERTIES_MARKED";
 40  
     
 41  
     //_StyleProperties
 42  
     public static final long STYLE_PROP       = 0x1L;
 43  
     public static final long STYLECLASS_PROP = 0x2L;
 44  
     
 45  
     //_UniversalProperties
 46  
     //_TitleProperty
 47  
     public static final long DIR_PROP         = 0x4L;
 48  
     public static final long LANG_PROP        = 0x8L;
 49  
     public static final long TITLE_PROP       = 0x10L;
 50  
     
 51  
     //_EscapeProperty
 52  
     public static final long ESCAPE_PROP      = 0x20L;
 53  
 
 54  
     //_DisabledClassEnabledClassProperties
 55  
     //_DisabledReadonlyProperties
 56  
     public static final long DISABLED_PROP    = 0x40L;
 57  
     public static final long ENABLED_PROP     = 0x80L;
 58  
     public static final long READONLY_PROP    = 0x100L;
 59  
 
 60  
     //_AccesskeyProperty
 61  
     public static final long ACCESSKEY_PROP  = 0x200L;
 62  
     
 63  
     //_AltProperty
 64  
     public static final long ALT_PROP         = 0x400L;
 65  
     
 66  
     //_ChangeSelectProperties
 67  
     public static final long ONCHANGE_PROP    = 0x800L;
 68  
     public static final long ONSELECT_PROP    = 0x1000L;
 69  
     
 70  
     //_EventProperties
 71  
     public static final long ONCLICK_PROP     = 0x2000L;
 72  
     public static final long ONDBLCLICK_PROP  = 0x4000L;
 73  
     public static final long ONMOUSEDOWN_PROP = 0x8000L;
 74  
     public static final long ONMOUSEUP_PROP   = 0x10000L;
 75  
     public static final long ONMOUSEOVER_PROP = 0x20000L;
 76  
     public static final long ONMOUSEMOVE_PROP = 0x40000L;
 77  
     public static final long ONMOUSEOUT_PROP  = 0x80000L;
 78  
     public static final long ONKEYPRESS_PROP  = 0x100000L;
 79  
     public static final long ONKEYDOWN_PROP   = 0x200000L;
 80  
     public static final long ONKEYUP_PROP     = 0x400000L;
 81  
     
 82  
     //_FocusBlurProperties
 83  
     public static final long ONFOCUS_PROP     = 0x800000L;
 84  
     public static final long ONBLUR_PROP      = 0x1000000L;
 85  
 
 86  
     //_LabelProperty
 87  
     public static final long LABEL_PROP       = 0x2000000L;
 88  
     
 89  
     //_LinkProperties
 90  
     public static final long CHARSET_PROP     = 0x4000000L;
 91  
     public static final long COORDS_PROP      = 0x8000000L;
 92  
     public static final long HREFLANG_PROP    = 0x10000000L;
 93  
     public static final long REL_PROP         = 0x20000000L;
 94  
     public static final long REV_PROP         = 0x40000000L;
 95  
     public static final long SHAPE_PROP       = 0x80000000L;
 96  
     public static final long TARGET_PROP      = 0x100000000L;
 97  
     public static final long TYPE_PROP        = 0x200000000L;
 98  
 
 99  
     //_TabindexProperty
 100  
     public static final long TABINDEX_PROP    = 0x400000000L;
 101  
     
 102  
     //Common to input fields
 103  
     public static final long ALIGN_PROP       = 0x800000000L;
 104  
     public static final long CHECKED_PROP     = 0x1000000000L;
 105  
     public static final long MAXLENGTH_PROP   = 0x2000000000L;
 106  
     public static final long SIZE_PROP        = 0x4000000000L;
 107  
     
 108  0
     public static final Map<String, Long> COMMON_PROPERTIES_KEY_BY_NAME = new HashMap<String, Long>(64,1);
 109  
     
 110  
     static
 111  
     {
 112  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("style",      STYLE_PROP);
 113  
         
 114  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("styleClass", STYLECLASS_PROP);
 115  
         
 116  
         //_UniversalProperties
 117  
         //_TitleProperty
 118  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("dir",        DIR_PROP);
 119  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("lang",       LANG_PROP);
 120  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("title",      TITLE_PROP);
 121  
         
 122  
         //_EscapeProperty
 123  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("escape",     ESCAPE_PROP);
 124  
 
 125  
         //_DisabledClassEnabledClassProperties
 126  
         //_DisabledReadonlyProperties
 127  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("disabled",   DISABLED_PROP);
 128  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("enabled",    ENABLED_PROP);
 129  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("readonly",   READONLY_PROP);
 130  
 
 131  
         //_AccesskeyProperty
 132  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("accesskey",  ACCESSKEY_PROP);
 133  
         
 134  
         //_AltProperty
 135  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("alt",        ALT_PROP);
 136  
         
 137  
         //_ChangeSelectProperties
 138  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("onchange",   ONCHANGE_PROP);
 139  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("onselect",   ONSELECT_PROP);
 140  
         
 141  
         //_EventProperties
 142  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("onclick",    ONCLICK_PROP);
 143  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("ondblclick", ONDBLCLICK_PROP);
 144  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("onmousedown",ONMOUSEDOWN_PROP);
 145  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("onmouseup",  ONMOUSEUP_PROP);
 146  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("onmouseover",ONMOUSEOVER_PROP);
 147  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("onmousemove",ONMOUSEMOVE_PROP);
 148  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("onmouseout", ONMOUSEOUT_PROP);
 149  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("onkeypress", ONKEYPRESS_PROP);
 150  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("onkeydown",  ONKEYDOWN_PROP);
 151  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("onkeyup",    ONKEYUP_PROP);
 152  
         
 153  
         //_FocusBlurProperties
 154  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("onfocus",    ONFOCUS_PROP);
 155  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("onblur",     ONBLUR_PROP);
 156  
 
 157  
         //_LabelProperty
 158  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("label",      LABEL_PROP);
 159  
         
 160  
         //_LinkProperties
 161  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("charset",    CHARSET_PROP);
 162  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("coords",     COORDS_PROP);
 163  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("hreflang",   HREFLANG_PROP);
 164  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("rel",        REL_PROP);
 165  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("rev",        REV_PROP);
 166  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("shape",      SHAPE_PROP);
 167  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("target",     TARGET_PROP);
 168  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("type",       TYPE_PROP);
 169  
 
 170  
         //_TabindexProperty
 171  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("tabindex",   TABINDEX_PROP);
 172  
 
 173  
         //Common to input fields
 174  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("align",      ALIGN_PROP);
 175  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("checked",    CHECKED_PROP);
 176  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("maxlength",  MAXLENGTH_PROP);
 177  0
         COMMON_PROPERTIES_KEY_BY_NAME.put("size",       SIZE_PROP);
 178  0
     }
 179  
     
 180  
     public static void markProperty(UIComponent component, String name)
 181  
     {
 182  0
         Long propertyConstant = COMMON_PROPERTIES_KEY_BY_NAME.get(name);
 183  0
         if (propertyConstant == null)
 184  
         {
 185  0
             return;
 186  
         }
 187  0
         Long commonPropertiesSet = (Long) component.getAttributes().get(COMMON_PROPERTIES_MARKED);
 188  0
         if (commonPropertiesSet == null)
 189  
         {
 190  0
             commonPropertiesSet = 0L;
 191  
         }
 192  0
         component.getAttributes().put(COMMON_PROPERTIES_MARKED, commonPropertiesSet | propertyConstant);
 193  0
     }
 194  
     
 195  
     public static void markProperty(UIComponent component, long propertyConstant)
 196  
     {
 197  0
         Long commonPropertiesSet = (Long) component.getAttributes().get(COMMON_PROPERTIES_MARKED);
 198  0
         if (commonPropertiesSet == null)
 199  
         {
 200  0
             commonPropertiesSet = 0L;
 201  
         }
 202  0
         component.getAttributes().put(COMMON_PROPERTIES_MARKED, commonPropertiesSet | propertyConstant);
 203  0
     }
 204  
 }