1 19 package org.netbeans.modules.registry.mergedctx; 20 21 import org.netbeans.api.registry.ContextException; 22 import org.netbeans.spi.registry.BasicContext; 23 24 final class MaskUtils { 25 private static final String MASK_EXTENSION = "_mergehidden"; 27 28 static boolean existMaskForCtx(final BasicContext activeCtx, final String subcontextName) { 29 if (activeCtx == null) return false; 31 return (activeCtx.getSubcontextNames().contains(subcontextName + MASK_EXTENSION)); 32 } 33 34 static boolean existMaskForBinding(final BasicContext activeCtx, final String bindingName) { 35 if (activeCtx == null) return false; 36 return (activeCtx.getBindingNames().contains((bindingName + MASK_EXTENSION))); } 38 39 static boolean existMaskForAttributes(final BasicContext activeCtx, final String bindingName, final String attributeName) { 40 if (activeCtx == null) return false; 41 return (activeCtx.getAttributeNames(bindingName).contains(attributeName + MASK_EXTENSION)); 42 } 43 44 static boolean isMaskForCtxName(final String contextName) { 45 return contextName.endsWith(MASK_EXTENSION); 46 } 47 48 static boolean isMaskForBindingName(final String bindingName) { 49 return bindingName.endsWith(MASK_EXTENSION); 50 } 51 52 static boolean isMaskForAttributeName(final String attributeName) { 53 return attributeName.endsWith(MASK_EXTENSION); 54 55 } 56 57 static void createMaskForCtx(final BasicContext activeCtx, final String subcontextName) throws ContextException { 58 if (!existMaskForCtx(activeCtx, subcontextName)) 59 activeCtx.createSubcontext(subcontextName + MASK_EXTENSION); 60 } 61 62 static void createMaskForBinding(final BasicContext activeCtx, final String bindingName) throws ContextException { 63 if (!existMaskForBinding(activeCtx, bindingName)) 64 activeCtx.bindObject(bindingName + MASK_EXTENSION, "mask"); } 66 67 static void createMaskForAttributes(final BasicContext activeCtx, final String bindingName, final String attributeName) throws ContextException { 68 if (!existMaskForAttributes(activeCtx, bindingName, attributeName)) 69 activeCtx.setAttribute(bindingName, attributeName + MASK_EXTENSION, "mask"); } 71 72 static void deleteMaskForCtx(final BasicContext activeCtx, final String subcontextName) throws ContextException { 73 if (activeCtx == null) return; 74 75 if (existMaskForCtx(activeCtx, subcontextName)) 76 activeCtx.destroySubcontext(subcontextName + MASK_EXTENSION); 77 } 78 79 static void deleteMaskForBinding(final BasicContext activeCtx, final String bindingName) throws ContextException { 80 if (activeCtx == null) return; 81 82 if (existMaskForBinding(activeCtx, bindingName)) 83 activeCtx.bindObject(bindingName + MASK_EXTENSION, null); 84 } 85 86 static void deleteMaskForAttributes(final BasicContext activeCtx, final String bindingName, final String attributeName) throws ContextException { 87 if (activeCtx == null) return; 88 89 if (existMaskForAttributes(activeCtx, bindingName, attributeName)) 90 activeCtx.setAttribute(bindingName, attributeName + MASK_EXTENSION, null); 91 } 92 93 } 94 | Popular Tags |