version 1.4, 2003/08/26 20:17:08
|
version 1.13, 2005/05/30 13:25:00
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%2005//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// The Open Group, Tivoli Systems |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
|
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation, The Open Group. |
|
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
// | // |
// Author: Humberto Rivero (hurivero@us.ibm.com) | // Author: Humberto Rivero (hurivero@us.ibm.com) |
// | // |
// Modified By: |
// Modified By: Aruran, IBM (ashanmug@in.ibm.com) for Bug# 3697, 3698 |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
| |
const LanguageParser LanguageParser::EMPTY = LanguageParser(); | const LanguageParser LanguageParser::EMPTY = LanguageParser(); |
| |
void LanguageParser::parseHdr(Array<String> &values, String & hdr){ |
void LanguageParser::parseHdr(Array<String> &values, String hdr){ |
// look for ',' which designates distict (Accept/Content)-Language fields | // look for ',' which designates distict (Accept/Content)-Language fields |
// the form: [languagetag, languagetag, languagetag] so whitespace removal | // the form: [languagetag, languagetag, languagetag] so whitespace removal |
// may be necessary. | // may be necessary. |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
| |
Real32 LanguageParser::parseAcceptLanguageValue(String &language_tag, String & hdr){ |
Real32 LanguageParser::parseAcceptLanguageValue(String &language_tag, String hdr){ |
// look for ';' in hdr, that means we have a quality value to capture | // look for ';' in hdr, that means we have a quality value to capture |
// if not, we only have a language | // if not, we only have a language |
| |
|
|
if(i != PEG_NOT_FOUND){ // extract and store language and quality | if(i != PEG_NOT_FOUND){ // extract and store language and quality |
if(isValid(hdr.subString(0,i), validate_length)){ | if(isValid(hdr.subString(0,i), validate_length)){ |
language_tag = hdr.subString(0,i); | language_tag = hdr.subString(0,i); |
|
if(hdr.size() > i + 3) |
hdr.remove(0,i+3); // remove everything but the quality value | hdr.remove(0,i+3); // remove everything but the quality value |
|
else{ |
|
MessageLoaderParms parms("Common.LanguageParser.INVALID_QUALITY_VALUE", |
|
"AcceptLanguage contains an invalid quality value"); |
|
throw InvalidAcceptLanguageHeader(MessageLoader::getMessage(parms)); |
|
} |
} | } |
else{ | else{ |
//l10n | //l10n |