/** * Creates a new {@link PropertyList} object that is associated with the given name and has the given properties as * its initial list of child properties. All properties found in <code>startingList</code> will have their * {@link Property#setParentList(PropertyList) parent list} set to this newly constructed list. * * @param name the name of the list itself * @param startingList a list of properties to be immediately added to this list */ public PropertyList(@NotNull String name, @NotNull Property... startingList) { this(name); for (Property property : startingList) { add(property); } }
private static void add(Object parent, Property prop) { if (parent instanceof AbstractPropertyMap) { ((AbstractPropertyMap) parent).put(prop); } else if (parent instanceof PropertyList) { ((PropertyList) parent).add(prop); } }
Calendar calendar = new Calendar(); PropertyList calendarProperties = calendar.getProperties(); calendarProperties.add(Version.VERSION_2_0); calendarProperties.add(Method.REQUEST); // other properties ... VEvent vEvent = new VEvent(/*startDate, endDate*/); PropertyList vEventProperties = vEvent.getProperties(); vEventProperties.add(Priority.MEDIUM); vEventProperties.add(Clazz.PUBLIC); // other properties ... calendar.getComponents().add(vEvent); messageBodyPart.setDataHandler(new DataHandler(new ByteArrayDataSource(calendar.toString(), "text/calendar")));
public PropertyList deepCopy(boolean keepId) { PropertyList copy = new PropertyList(this, keepId); for (Property property : list) { copy.add(property.deepCopy(false)); } return copy; }
/** * Closes the definition of the current map and returns to the parent context. * @return the parent context */ public Parent closeMap() { parent.getList().add(getMap()); return parent; } }
/** * Closes the definition of the current list and returns to the parent context. * @return the parent context */ public Parent closeList() { parent.getList().add(getList()); return parent; } }
private static PropertyList getPropertyList(String listName, String propertyName, List<? extends Object> objects) { PropertyList propertyList = new PropertyList(listName); for(Object o : objects) { propertyList.add(new PropertySimple(propertyName, o)); } return propertyList; }
/** * Adds a simple property. The name of the property is the member name defined by this list. * @param value the value of the simple property * @return continue with the definition */ public This addSimple(Object value) { list.add(new PropertySimple(list.memberPropertyName, value)); return castThis(); }
/** * Adds a number of simple properties. The names of the properties are the member name defined by this list. * @param values the values of the simple properties * @return continue with the definition */ public This addSimples(Object... values) { for(Object v : values) { list.add(new PropertySimple(list.memberPropertyName, v)); } return castThis(); }
private PropertyList createPropertyListOfAddresses(String propertyName, List<StorageNode> nodes) { PropertyList list = new PropertyList(propertyName); for (StorageNode storageNode : nodes) { list.add(new PropertySimple("address", storageNode.getAddress())); } return list; }
private void initLogEventSourcesConfigProp(String fileName, Configuration pluginConfiguration) { PropertyList logEventSources = pluginConfiguration .getList(LogFileEventResourceComponentHelper.LOG_EVENT_SOURCES_CONFIG_PROP); if (logEventSources == null) return; File serverLogFile = new File(fileName); if (serverLogFile.exists() && !serverLogFile.isDirectory()) { PropertyMap serverLogEventSource = new PropertyMap("logEventSource"); serverLogEventSource.put(new PropertySimple( LogFileEventResourceComponentHelper.LogEventSourcePropertyNames.LOG_FILE_PATH, serverLogFile)); serverLogEventSource.put(new PropertySimple( LogFileEventResourceComponentHelper.LogEventSourcePropertyNames.ENABLED, Boolean.FALSE)); logEventSources.add(serverLogEventSource); } }
private void addBundleDestinationSpecification(BundleDestinationSpecification def) { if (this.bundleConfiguration == null) { throw new NullPointerException("bundleConfiguration == null"); } PropertyList propertyList = this.bundleConfiguration.getList(BUNDLE_DEST_LIST_NAME); if (propertyList == null) { propertyList = new PropertyList(BUNDLE_DEST_LIST_NAME); this.bundleConfiguration.put(propertyList); } PropertyMap map = new PropertyMap(BUNDLE_DEST_LIST_ITEM_NAME); def.fillPropertyMap(map); propertyList.add(map); }
public Property createPropertyList(PropertyDefinitionList propDefList, AugeasNode node) throws AugeasRhqException { PropertyList propList = new PropertyList(propDefList.getName()); List<AugeasNode> nodes = tree.matchRelative(node, propDefList.getName()); PropertyDefinition listMemberPropDef = propDefList.getMemberDefinition(); for (AugeasNode listMemberNode : nodes) { propList.add(loadProperty(listMemberPropDef, listMemberNode)); } return propList; } }
private int addNewMap(AbstractConfigurationComponent config) { String listName = config.getListName(); PropertyDefinitionMap mapDefinition = (PropertyDefinitionMap) config.getConfigurationDefinition() .getPropertyDefinitionList(listName).getMemberDefinition(); String mapName = mapDefinition.getName(); PropertyMap newMap = new PropertyMap(mapName); for (PropertyDefinition mapMemberDefinition : mapDefinition.getOrderedPropertyDefinitions()) { PropertyDefinitionSimple simpleDefinition = (PropertyDefinitionSimple) mapMemberDefinition; newMap.put(new PropertySimple(simpleDefinition.getName(), (simpleDefinition.isRequired()) ? "" : null)); } PropertyList list = config.getConfiguration().getList(listName); list.add(newMap); return list.getList().size() - 1; }
private void initExcludes(DriftDescriptor descriptor, DriftDefinitionTemplate template) { if (descriptor.getExcludes() != null && descriptor.getExcludes().getExclude().size() > 0) { Configuration config = template.getConfiguration(); PropertyList excludes = new PropertyList(DriftConfigurationDefinition.PROP_EXCLUDES); for (DriftFilterDescriptor exclude : descriptor.getExcludes().getExclude()) { PropertyMap excludeMap = new PropertyMap(DriftConfigurationDefinition.PROP_EXCLUDES_EXCLUDE); excludeMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_PATH, exclude.getPath())); excludeMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_PATTERN, exclude.getPattern())); excludes.add(excludeMap); } config.put(excludes); } }
protected void fillPropertyMap(PropertyMap map) { map.put(new PropertySimple(BUNDLE_DEST_NAME_NAME, getName())); if (getDescription() != null) { PropertySimple descriptionProp = new PropertySimple(BUNDLE_DEST_DESCRIPTION_NAME, getDescription()); map.put(descriptionProp); } PropertyList accepts = new PropertyList(BUNDLE_DEST_ACCEPTS_LIST_NAME); map.put(accepts); for (String acc : acceptedBundleTypes) { PropertySimple p = new PropertySimple(BUNDLE_DEST_ACCEPTS_LIST_MEMBER_NAME, acc); accepts.add(p); } }
private void initIncludes(DriftDescriptor descriptor, DriftDefinitionTemplate template) { if (descriptor.getIncludes() != null && descriptor.getIncludes().getInclude().size() > 0) { Configuration config = template.getConfiguration(); PropertyList includes = new PropertyList(DriftConfigurationDefinition.PROP_INCLUDES); for (DriftFilterDescriptor include : descriptor.getIncludes().getInclude()) { PropertyMap includeMap = new PropertyMap(DriftConfigurationDefinition.PROP_INCLUDES_INCLUDE); includeMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_PATH, include.getPath())); includeMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_PATTERN, include.getPattern())); includes.add(includeMap); } config.put(includes); } }
public void addInclude(Filter filter) { PropertyList filtersList = configuration.getList(DriftConfigurationDefinition.PROP_INCLUDES); if (filtersList == null) { // this is going to be our first include filter - make sure we create an initial list and put it in the config filtersList = new PropertyList(DriftConfigurationDefinition.PROP_INCLUDES); configuration.put(filtersList); } PropertyMap filterMap = new PropertyMap(DriftConfigurationDefinition.PROP_INCLUDES_INCLUDE); filterMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_PATH, StringUtils.useForwardSlash(filter .getPath()))); filterMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_PATTERN, filter.getPattern())); filtersList.add(filterMap); }
public void addExclude(Filter filter) { PropertyList filtersList = configuration.getList(DriftConfigurationDefinition.PROP_EXCLUDES); if (filtersList == null) { // this is going to be our first include filter - make sure we create an initial list and put it in the config filtersList = new PropertyList(DriftConfigurationDefinition.PROP_EXCLUDES); configuration.put(filtersList); } PropertyMap filterMap = new PropertyMap(DriftConfigurationDefinition.PROP_EXCLUDES_EXCLUDE); filterMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_PATH, StringUtils.useForwardSlash(filter .getPath()))); filterMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_PATTERN, filter.getPattern())); filtersList.add(filterMap); }
@Override protected void fillPropertyMap(PropertyMap map) { super.fillPropertyMap(map); map.put(new PropertySimple(BUNDLE_DEST_DEFINITION_CONNECTION_NAME, connectionString)); PropertyList list = new PropertyList(BUNDLE_DEST_DEFINITION_REF_LIST_NAME); map.put(list); for (ConfigRef ref : referencedConfiguration) { PropertyMap refMap = new PropertyMap(BUNDLE_DEST_DEFINITION_REF_LIST_MEMBER_NAME); refMap.put(new PropertySimple(BUNDLE_DEST_DEF_REF_TYPE_NAME, ref.getType().name())); refMap.put(new PropertySimple(BUNDLE_DEST_DEF_REF_CONTEXT_NAME, ref.getContext().name())); refMap.put(new PropertySimple(BUNDLE_DEST_DEF_REF_NAME_NAME, ref.getName())); refMap.put(new PropertySimple(BUNDLE_DEST_DEF_REF_TARGET_NAME_NAME, ref.getTargetName())); list.add(refMap); } }