本文整理汇总了Java中org.opennms.core.utils.Argument.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java Argument.getValue方法的具体用法?Java Argument.getValue怎么用?Java Argument.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opennms.core.utils.Argument
的用法示例。
在下文中一共展示了Argument.getValue方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildMessageBody
import org.opennms.core.utils.Argument; //导入方法依赖的package包/类
/**
* <p>buildMessageBody</p>
*
* @param arguments a {@link java.util.List} object.
* @return a {@link java.lang.String} object.
*/
protected String buildMessageBody(List<Argument> arguments) {
String messageBody = null;
// Support PARAM_TEXT_MSG and PARAM_NUM_MSG but prefer PARAM_TEXT_MSG
for (Argument arg : arguments) {
if (NotificationManager.PARAM_TEXT_MSG.equals(arg.getSwitch())) {
messageBody = arg.getValue();
} else if (NotificationManager.PARAM_NUM_MSG.equals(arg.getSwitch())) {
if (messageBody == null) messageBody = arg.getValue();
}
}
if (messageBody == null) {
// FIXME We should have a better Exception to use here for configuration problems
throw new IllegalArgumentException("No message specified, but is required");
}
// Collapse whitespace in final message
messageBody = messageBody.replaceAll("\\s+", " ");
if (log().isDebugEnabled()) {
log().debug("Final message body after collapsing whitespace is: '" + messageBody + "'");
}
return messageBody;
}
示例2: buildMessage
import org.opennms.core.utils.Argument; //导入方法依赖的package包/类
private String buildMessage(List<Argument> arguments) {
String recipient = null;
String message = null;
for (Argument arg : arguments) {
if (NotificationManager.PARAM_EMAIL.equals(arg.getSwitch())) {
recipient = arg.getValue();
} else if (NotificationManager.PARAM_TEXT_MSG.equals(arg.getSwitch())) {
message = arg.getValue();
} else if (NotificationManager.PARAM_NUM_MSG.equals(arg.getSwitch())) {
message = arg.getValue();
} else {
throw new IllegalArgumentException("Unsupported notification argument switch '" + arg.getSwitch() + "'");
}
}
if (recipient == null) {
// FIXME We should have a better Exception to use here for configuration problems
throw new IllegalArgumentException("no recipient specified, but is required");
}
if (message == null) {
// FIXME We should have a better Exception to use here for configuration problems
throw new IllegalArgumentException("no message specified, but is required");
}
return recipient + " " + message;
}
示例3: getSwitchValue
import org.opennms.core.utils.Argument; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private String getSwitchValue(String argSwitch) {
String value = null;
for (Argument arg : m_arguments) {
if (arg.getSwitch().equals(argSwitch)) {
value = arg.getValue();
}
}
if (value != null && value.equals("")) value = null;
return value;
}
示例4: findDestName
import org.opennms.core.utils.Argument; //导入方法依赖的package包/类
/**
* <p>findDestName</p>
*
* @param arguments a {@link java.util.List} object.
* @return a {@link java.lang.String} object.
*/
protected String findDestName(List<Argument> arguments) {
for (Argument arg : arguments) {
if (NotificationManager.PARAM_MICROBLOG_USERNAME.equals(arg.getSwitch())) {
log().debug("Found destination microblog name: " + arg.getSwitch());
return arg.getValue();
}
}
log().debug("No destination microblog name found");
return null;
}
示例5: parseArguments
import org.opennms.core.utils.Argument; //导入方法依赖的package包/类
/**
* This method extracts the xmpp address and message text from the
* parameters passed in the notification.
*
* @param arguments
* @return String[]
* @throws Exception
*/
private String[] parseArguments(List<Argument> arguments) throws Exception {
String[] parsedArgs = new String[XMPP_MAX];
for (int i = 0; i < arguments.size(); i++) {
Argument arg = arguments.get(i);
if (NotificationManager.PARAM_XMPP_ADDRESS.equals(arg.getSwitch())) {
parsedArgs[XMPP_TO] = arg.getValue();
} else if (NotificationManager.PARAM_TEXT_MSG.equals(arg
.getSwitch())) {
parsedArgs[XMPP_MESSAGE] = arg.getValue();
}
}
for (int i = 0; i < XMPP_MAX; ++i) {
if (parsedArgs[i] == null) {
throw (new Exception(
"Incomplete argument set, missing argument: "
+ INDEX_TO_NAME[i]));
}
}
return parsedArgs;
}
示例6: parseArguments
import org.opennms.core.utils.Argument; //导入方法依赖的package包/类
/**
* This method extracts the xmpp address and message text from the
* parameters passed in the notification.
*
* @param arguments
* @return String[]
* @throws Exception
*/
private String[] parseArguments(List<Argument> arguments) throws Exception {
String[] parsedArgs = new String[XMPP_MAX];
for (int i = 0; i < arguments.size(); i++) {
Argument arg = arguments.get(i);
if (NotificationManager.PARAM_XMPP_ADDRESS.equals(arg.getSwitch())) {
parsedArgs[XMPP_TO] = arg.getValue();
} else if (NotificationManager.PARAM_TEXT_MSG.equals(arg.getSwitch())) {
parsedArgs[XMPP_MESSAGE] = arg.getValue();
} else if (NotificationManager.PARAM_NUM_MSG.equals(arg.getSwitch())) {
parsedArgs[XMPP_MESSAGE] = arg.getValue();
}
}
for (int i = 0; i < XMPP_MAX; ++i) {
if (parsedArgs[i] == null) {
throw (new Exception("Incomplete argument set, missing argument: " + INDEX_TO_NAME[i]));
}
}
return parsedArgs;
}
示例7: getPostArguments
import org.opennms.core.utils.Argument; //导入方法依赖的package包/类
private List<NameValuePair> getPostArguments() {
List<Argument> args = getArgsByPrefix("post-");
List<NameValuePair> retval = new ArrayList<NameValuePair>();
for (Argument arg : args) {
String argSwitch = arg.getSwitch().substring("post-".length());
if (arg.getValue() == null) {
arg.setValue("");
}
retval.add(new BasicNameValuePair(argSwitch, getValue(arg.getValue())));
}
return retval;
}
示例8: getNotificationValue
import org.opennms.core.utils.Argument; //导入方法依赖的package包/类
private String getNotificationValue(final String notificationManagerParamString) {
String message = "no notification text message defined for the \""+notificationManagerParamString+"\" switch.";
for (Iterator<Argument> it = m_arguments.iterator(); it.hasNext();) {
Argument arg = it.next();
if (arg.getSwitch().equals(notificationManagerParamString))
message = arg.getValue();
}
log().debug("getNotificationValue: "+message);
return message;
}
示例9: getUrlAsPrefix
import org.opennms.core.utils.Argument; //导入方法依赖的package包/类
private String getUrlAsPrefix() {
String url = null;
for (Argument arg: getArgsByPrefix("url")) {
log().debug("Found url switch: " + arg.getSwitch() + " with value: " + arg.getValue());
url = arg.getValue();
}
return url;
}
示例10: getSwitchValue
import org.opennms.core.utils.Argument; //导入方法依赖的package包/类
/**
* Helper method to look into the Argument list and return the associated value.
* If the value is an empty String, this method returns null.
* @param argSwitch
* @return
*/
private String getSwitchValue(String argSwitch) {
String value = null;
for (Iterator<Argument> it = m_arguments.iterator(); it.hasNext();) {
Argument arg = it.next();
if (arg.getSwitch().equals(argSwitch)) {
value = arg.getValue();
}
}
if (value != null && value.equals(""))
value = null;
return value;
}
示例11: getSwitchValue
import org.opennms.core.utils.Argument; //导入方法依赖的package包/类
/**
* Helper method to look into the Argument list and return the associaated value.
* If the value is an empty String, this method returns null.
* @param argSwitch
* @return
*/
private String getSwitchValue(String argSwitch) {
String value = null;
for (Iterator<Argument> it = m_arguments.iterator(); it.hasNext();) {
Argument arg = it.next();
if (arg.getSwitch().equals(argSwitch)) {
value = arg.getValue();
}
}
if (value != null && value.equals(""))
value = null;
return value;
}
示例12: getPostArguments
import org.opennms.core.utils.Argument; //导入方法依赖的package包/类
private List<NameValuePair> getPostArguments() {
List<Argument> args = getArgsByPrefix("post-");
List<NameValuePair> retval = new ArrayList<NameValuePair>();
for (Argument arg : args) {
String argSwitch = arg.getSwitch().substring("post-".length());
if (arg.getValue() == null) {
arg.setValue("");
}
retval.add(new BasicNameValuePair(argSwitch, arg.getValue().equals("-tm") ? getMessage() : arg.getValue()));
}
return retval;
}
示例13: getMessage
import org.opennms.core.utils.Argument; //导入方法依赖的package包/类
private String getMessage() {
String message = "no notification text message defined for the \"-tm\" switch.";
for (Iterator<Argument> it = m_arguments.iterator(); it.hasNext();) {
Argument arg = it.next();
if (arg.getSwitch().equals("-tm"))
message = arg.getValue();
}
log().debug("getMessage: "+message);
return message;
}
示例14: send
import org.opennms.core.utils.Argument; //导入方法依赖的package包/类
/** {@inheritDoc} */
public int send(List<Argument> arguments) {
String eventID = null;
String eventUEI = null;
String noticeID = null;
m_arguments = arguments;
// Pull the arguments we're interested in from the list.
for (Argument arg : m_arguments) {
log().debug("arguments: "+arg.getSwitch() +" = "+arg.getValue());
if ("eventID".equalsIgnoreCase(arg.getSwitch())) {
eventID = arg.getValue();
} else if ("eventUEI".equalsIgnoreCase(arg.getSwitch())) {
eventUEI = arg.getValue();
} else if ("noticeid".equalsIgnoreCase(arg.getSwitch())) {
noticeID = arg.getValue();
}
}
// Make sure we have the arguments we need.
if( StringUtils.isBlank(eventID) ) {
log().error("There is no event-id associated with the notice-id='" + noticeID + "'. Cannot create ticket.");
return 1;
} else if( StringUtils.isBlank(eventUEI) ) {
log().error("There is no event-uei associated with the notice-id='" + noticeID + "'. Cannot create ticket.");
return 1;
}
// Determine the type of alarm based on the UEI.
AlarmType alarmType = getAlarmTypeFromUEI(eventUEI);
if( alarmType == AlarmType.NOT_AN_ALARM ) {
log().warn("The event type associated with the notice-id='" + noticeID + "' is not an alarm. Will not create ticket.");
return 0;
}
// We know the event is an alarm, pull the alarm and current ticket details from the database
AlarmState alarmState = getAlarmStateFromEvent(Integer.parseInt(eventID));
if( alarmState.getAlarmID() == 0 ) {
log().error("There is no alarm-id associated with the event-id='" + eventID + "'. Will not create ticket.");
return 1;
}
/* Log everything we know so far.
* The tticketid and tticketstate are only informational.
*/
log().info("Got event-uei='"+ eventUEI +"' with event-id='" + eventID +
"', notice-id='" + noticeID + "', alarm-type='" + alarmType +
"', alarm-id='" + alarmState.getAlarmID() + "', tticket-id='" + alarmState.getTticketID() +
"'and tticket-state='" + alarmState.getTticketState() + "'");
sendCreateTicketEvent(alarmState.getAlarmID(), eventUEI);
return 0;
}