Search in sources :

Example 11 with NameValue

use of gov.nist.core.NameValue in project XobotOS by xamarin.

the class PChargingFunctionAddresses method delete.

/**
     * <p>Remove parameter </p>
     *
     * @param value - of the parameter
     * @param name - of the parameter
     * @return true if parameter was removed, and false if not
     */
public boolean delete(String value, String name) {
    Iterator li = this.parameters.iterator();
    NameValue nv;
    boolean removed = false;
    while (li.hasNext()) {
        nv = (NameValue) li.next();
        if (((String) nv.getValueAsObject()).equalsIgnoreCase(value) && nv.getName().equalsIgnoreCase(name)) {
            li.remove();
            removed = true;
        }
    }
    return removed;
}
Also used : NameValue(gov.nist.core.NameValue) Iterator(java.util.Iterator) ListIterator(java.util.ListIterator)

Example 12 with NameValue

use of gov.nist.core.NameValue in project XobotOS by xamarin.

the class PChargingFunctionAddresses method getChargingCollectionFunctionAddresses.

/**
     * <p>Get all the Charging Collection Function (CCF) Addresses set in this header</p>
     *
     * @return ListIterator that constains all CCF addresses of this header
     */
public ListIterator getChargingCollectionFunctionAddresses() {
    Iterator li = this.parameters.iterator();
    LinkedList ccfLIST = new LinkedList();
    NameValue nv;
    while (li.hasNext()) {
        nv = (NameValue) li.next();
        if (nv.getName().equalsIgnoreCase(ParameterNamesIms.CCF)) {
            NameValue ccfNV = new NameValue();
            ccfNV.setName(nv.getName());
            ccfNV.setValueAsObject(nv.getValueAsObject());
            ccfLIST.add(ccfNV);
        }
    }
    return ccfLIST.listIterator();
}
Also used : NameValue(gov.nist.core.NameValue) Iterator(java.util.Iterator) ListIterator(java.util.ListIterator) LinkedList(java.util.LinkedList)

Example 13 with NameValue

use of gov.nist.core.NameValue in project XobotOS by xamarin.

the class SecurityAgree method setParameter.

public void setParameter(String name, String value) throws ParseException {
    if (value == null)
        throw new NullPointerException("null value");
    NameValue nv = super.parameters.getNameValue(name.toLowerCase());
    if (nv == null) {
        nv = new NameValue(name, value);
        // quoted values
        if (name.equalsIgnoreCase(ParameterNamesIms.D_VER)) {
            nv.setQuotedValue();
            if (value.startsWith(Separators.DOUBLE_QUOTE))
                throw new ParseException(value + " : Unexpected DOUBLE_QUOTE", 0);
        }
        super.setParameter(nv);
    } else {
        nv.setValueAsObject(value);
    }
}
Also used : NameValue(gov.nist.core.NameValue) ParseException(java.text.ParseException)

Example 14 with NameValue

use of gov.nist.core.NameValue in project XobotOS by xamarin.

the class URLParser method tel_parameters.

private NameValueList tel_parameters() throws ParseException {
    NameValueList nvList = new NameValueList();
    // JvB: Need to handle 'phone-context' specially
    // 'isub' (or 'ext') MUST appear first, but we accept any order here
    NameValue nv;
    while (true) {
        String pname = paramNameOrValue();
        // Handle 'phone-context' specially, it may start with '+'
        if (pname.equalsIgnoreCase("phone-context")) {
            nv = phone_context();
        } else {
            if (lexer.lookAhead(0) == '=') {
                lexer.consume(1);
                String value = paramNameOrValue();
                nv = new NameValue(pname, value, false);
            } else {
                // flag param
                nv = new NameValue(pname, "", true);
            }
        }
        nvList.set(nv);
        if (lexer.lookAhead(0) == ';') {
            lexer.consume(1);
        } else {
            return nvList;
        }
    }
}
Also used : NameValue(gov.nist.core.NameValue) NameValueList(gov.nist.core.NameValueList)

Example 15 with NameValue

use of gov.nist.core.NameValue in project XobotOS by xamarin.

the class URLParser method sipURL.

/**
     * Parse and return a structure for a SIP URL.
     * @return a URL structure for a SIP url.
     * @throws ParseException if there was a problem parsing.
     */
public SipUri sipURL(boolean inBrackets) throws ParseException {
    if (debug)
        dbg_enter("sipURL");
    SipUri retval = new SipUri();
    // pmusgrave - handle sips case
    Token nextToken = lexer.peekNextToken();
    int sipOrSips = TokenTypes.SIP;
    String scheme = TokenNames.SIP;
    if (nextToken.getTokenType() == TokenTypes.SIPS) {
        sipOrSips = TokenTypes.SIPS;
        scheme = TokenNames.SIPS;
    }
    try {
        lexer.match(sipOrSips);
        lexer.match(':');
        retval.setScheme(scheme);
        int startOfUser = lexer.markInputPosition();
        // Note: user may contain ';', host may not...
        String userOrHost = user();
        String passOrPort = null;
        // name:password or host:port
        if (lexer.lookAhead() == ':') {
            lexer.consume(1);
            passOrPort = password();
        }
        // name@hostPort
        if (lexer.lookAhead() == '@') {
            lexer.consume(1);
            retval.setUser(userOrHost);
            if (passOrPort != null)
                retval.setUserPassword(passOrPort);
        } else {
            // then userOrHost was a host, backtrack just in case a ';' was eaten...
            lexer.rewindInputPosition(startOfUser);
        }
        HostNameParser hnp = new HostNameParser(this.getLexer());
        HostPort hp = hnp.hostPort(false);
        retval.setHostPort(hp);
        lexer.selectLexer("charLexer");
        while (lexer.hasMoreChars()) {
            // If the URI is not enclosed in brackets, parameters belong to header
            if (lexer.lookAhead(0) != ';' || !inBrackets)
                break;
            lexer.consume(1);
            NameValue parms = uriParam();
            if (parms != null)
                retval.setUriParameter(parms);
        }
        if (lexer.hasMoreChars() && lexer.lookAhead(0) == '?') {
            lexer.consume(1);
            while (lexer.hasMoreChars()) {
                NameValue parms = qheader();
                retval.setQHeader(parms);
                if (lexer.hasMoreChars() && lexer.lookAhead(0) != '&')
                    break;
                else
                    lexer.consume(1);
            }
        }
        return retval;
    } finally {
        if (debug)
            dbg_leave("sipURL");
    }
}
Also used : HostNameParser(gov.nist.core.HostNameParser) NameValue(gov.nist.core.NameValue) HostPort(gov.nist.core.HostPort) Token(gov.nist.core.Token) SipUri(gov.nist.javax.sip.address.SipUri)

Aggregations

NameValue (gov.nist.core.NameValue)18 Token (gov.nist.core.Token)3 Iterator (java.util.Iterator)3 ListIterator (java.util.ListIterator)3 ParseException (java.text.ParseException)2 LinkedList (java.util.LinkedList)2 Host (gov.nist.core.Host)1 HostNameParser (gov.nist.core.HostNameParser)1 HostPort (gov.nist.core.HostPort)1 NameValueList (gov.nist.core.NameValueList)1 SipUri (gov.nist.javax.sip.address.SipUri)1 PAccessNetworkInfo (gov.nist.javax.sip.header.ims.PAccessNetworkInfo)1