com.day.util.NameValuePair Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aem-sdk-api Show documentation
Show all versions of aem-sdk-api Show documentation
The Adobe Experience Manager SDK
/*************************************************************************
* ADOBE CONFIDENTIAL
* __________________
*
* Copyright 2020 Adobe
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe and its suppliers, if any. The intellectual
* and technical concepts contained herein are proprietary to Adobe
* and its suppliers and are protected by all applicable intellectual
* property laws, including trade secret and copyright laws.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe.
**************************************************************************/
package com.day.util;
/**
* The NameValuePair class implements a structure of a name and an optional
* value.
*
* @version $Revision: 1.4 $, $Date: 2004-08-22 06:56:09 +0200 (Sun, 22 Aug 2004) $
* @author tripod
* @since coati
* Audience wad
*/
public class NameValuePair {
/** the name */
private final String name;
/** the value */
private final String value;
/**
* Creates a new name value pair
* @param name the name
* @param value the value
*/
public NameValuePair(String name, String value) {
this.name = name;
this.value = value;
}
/**
* Gets the name
* @return the name
*/
public String getName() {
return name;
}
/**
* Gets the value
* @return the value
*/
public String getValue() {
return value;
}
/**
* Parses a line of the form:
* {ws} name {ws} ["=" {ws} value {ws}];
*
* @param str the string to parse
* @return the parsed nv pair
*/
public static NameValuePair parse(String str) {
return parse(str, '=');
}
/**
* Parses a line of the form:
* {ws} name {ws} ["<equal>
" {ws} value {ws}];
*
* @param str the string to parse
* @param equal the delimiter for the equal sign
* @return the parsed nv pair
*/
public static NameValuePair parse(String str, char equal) {
int state=0;
int lastState=0;
int nameStart=0;
int nameEnd=0;
StringBuffer value = new StringBuffer();
for (int i=0; i