com.axway.ats.uiengine.elements.UiElementProperties Maven / Gradle / Ivy
/*
* Copyright 2017 Axway Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.axway.ats.uiengine.elements;
import java.util.ArrayList;
import java.util.Properties;
import java.util.Set;
import com.axway.ats.common.PublicAtsApi;
import com.axway.ats.uiengine.exceptions.BadUiElementPropertyException;
import com.axway.ats.uiengine.exceptions.ErrorMatchingElementRules;
@PublicAtsApi
public class UiElementProperties {
private Properties properties = new Properties();
private Properties internalProperties = new Properties();
public static final String MAP_ID_INTERNAL_PARAM = "mapID";
@PublicAtsApi
public UiElementProperties() {
}
public void addInternalProperty(
String name,
String value ) {
internalProperties.put( name, value );
}
public String getInternalProperty(
String name ) {
String internalPropertyValue = internalProperties.getProperty( name );
if( internalPropertyValue == null ) {
throw new BadUiElementPropertyException( "The needed internal property '" + name
+ "' is not found for element with user properties: "
+ toString() );
}
return internalPropertyValue;
}
public boolean containsInternalProperty(
String name ) {
return internalProperties.containsKey( name );
}
@PublicAtsApi
public UiElementProperties addProperty(
String name,
String value ) {
if( name == null || name.trim().length() == 0 ) {
throw new BadUiElementPropertyException( "Bad property name '" + name + "'" );
}
if( value == null || value.trim().length() == 0 ) {
throw new BadUiElementPropertyException( "Bad value for property " + name + ": '" + value + "'" );
}
properties.put( name, value );
return this;
}
@PublicAtsApi
public String getProperty(
String name ) {
return properties.getProperty( name );
}
/**
* Number of element's non-internal properties
* @return the number of element's properties
*/
public int getPropertiesSize() {
return properties.size();
}
/**
* For internal use
* @return get all property keys
*/
public Set
© 2015 - 2024 Weber Informatics LLC | Privacy Policy