本文整理汇总了C++中String::EndWith方法的典型用法代码示例。如果您正苦于以下问题:C++ String::EndWith方法的具体用法?C++ String::EndWith怎么用?C++ String::EndWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::EndWith方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsSpecialDomain
Boolean NetscapeDomainHandler::IsSpecialDomain(
/* [in] */ const String& domain)
{
String ucDomain = domain.ToUpperCase(/*ILocale::ENGLISH*/);
return ucDomain.EndWith(".COM")
|| ucDomain.EndWith(".EDU")
|| ucDomain.EndWith(".NET")
|| ucDomain.EndWith(".GOV")
|| ucDomain.EndWith(".MIL")
|| ucDomain.EndWith(".ORG")
|| ucDomain.EndWith(".INT");
}
示例2: IsExcluded
ECode CProxyProperties::IsExcluded(
/* [in] */ const String& url,
/* [out] */ Boolean* result)
{
VALIDATE_NOT_NULL(result);
Int32 length;
length = mParsedExclusionList->GetLength();
AutoPtr<ICharSequence> chars;
CStringWrapper::New(url, (ICharSequence**)&chars);
if (TextUtils::IsEmpty((ICharSequence*)&chars) || mParsedExclusionList == NULL ||length == 0) {
*result = FALSE;
return NOERROR;
}
AutoPtr<IUri> u;
Uri::Parse(url, (IUri**)&u);
String urlDomain;
u->GetHost(&urlDomain);
if (urlDomain.IsNull()) {
*result = FALSE;
return NOERROR;
}
Int32 length2;
length2 = mParsedExclusionList->GetLength();
for (Int32 i = 0; i< length2; i+=2) {
if (urlDomain.Equals((*mParsedExclusionList)[i]) || urlDomain.EndWith((*mParsedExclusionList)[i+1])) {
*result = TRUE;
return NOERROR;
}
}
*result = FALSE;
return NOERROR;
}
示例3: GuessUrl
String URLUtil::GuessUrl(
/* [in] */ const String& _inUrl)
{
String inUrl = _inUrl;
AutoPtr<IWebAddress> webAddress;
// if (DebugFlags.URL_UTIL) Log.v(LOGTAG, "guessURL before queueRequest: " + inUrl);
if (inUrl.IsEmpty()) {
return inUrl;
}
if (inUrl.StartWith("about:")) {
return inUrl;
}
// Do not try to interpret data scheme URLs
if (inUrl.StartWith("data:")) {
return inUrl;
}
// Do not try to interpret file scheme URLs
if (inUrl.StartWith("file:")) {
return inUrl;
}
// Do not try to interpret javascript scheme URLs
if (inUrl.StartWith("javascript:")) {
return inUrl;
}
// bug 762454: strip period off end of url
if (inUrl.EndWith(".") == TRUE) {
inUrl = inUrl.Substring(0, inUrl.GetLength() - 1);
}
assert(0);
//try {
// webAddress = new WebAddress(inUrl);
//} catch (ParseException ex) {
// if (DebugFlags.URL_UTIL) {
// Log.v(LOGTAG, "smartUrlFilter: failed to parse url = " + inUrl);
// }
// return retVal;
//}
// Check host
// if (webAddress->GetHost().IndexOf('.') == -1) {
// StringBuilder sb;
// sb.Append("www.");
// sb.Append(webAddress->GetHost());
// sb.Append(".com");
// no dot: user probably entered a bare domain. try .com
// webAddress->SetHost(sb.ToString());
// }
// return webAddress->ToString();
return String(NULL);
}
示例4:
AutoPtr<IInetAddress> InetAddress::ParseNumericAddressNoThrow(
/* [in] */ const String& _address)
{
String address = _address;
if (address.StartWith("[") && address.EndWith("]") && address.IndexOf(':') != -1) {
address = address.Substring(1, address.GetLength() - 1);
}
AutoPtr<IStructAddrinfo> hints;
CStructAddrinfo::New((IStructAddrinfo**)&hints);
hints->SetFlags(AI_NUMERICHOST);
AutoPtr< ArrayOf<IInetAddress*> > info;
CLibcore::sOs->Elastos_getaddrinfo(address, hints, NETID_UNSET, (ArrayOf<IInetAddress*>**)&info);
if (info == NULL)
return NULL;
AutoPtr<IInetAddress> result = (*info)[0];
return result;
}
示例5: DataModelPackageMonitor
ActivityChooserModel::ActivityChooserModel(
/* [in] */ IContext* context,
/* [in] */ const String& historyFileName)
{
mPackageMonitor = new DataModelPackageMonitor(this);
mActivitySorter = new DefaultSorter(this);
mHistoryMaxSize = DEFAULT_HISTORY_MAX_LENGTH;
mCanReadHistoricalData = TRUE;
mReadShareHistoryCalled = FALSE;
mHistoricalRecordsChanged = TRUE;
mReloadActivities = FALSE;
context->GetApplicationContext((IContext**)&mContext);
if (!TextUtils::IsEmpty(historyFileName) && !historyFileName.EndWith(HISTORY_FILE_EXTENSION)) {
mHistoryFileName = historyFileName + HISTORY_FILE_EXTENSION;
} else {
mHistoryFileName = historyFileName;
}
mPackageMonitor->Register(mContext, NULL, TRUE);
}
示例6: Create
ECode IntentTile::Create(
/* [in] */ IQSTileHost* host,
/* [in] */ const String& spec,
/* [out] */ IQSTile** tile)
{
VALIDATE_NOT_NULL(tile);
if (spec == NULL || !spec.StartWith(PREFIX) || !spec.EndWith(")")) {
tile = NULL;
// throw new IllegalArgumentException("Bad intent tile spec: " + spec);
return E_ILLEGAL_ARGUMENT_EXCEPTION;
}
const String action = spec.Substring(PREFIX.GetLength(), spec.GetLength() - 1);
if (action.IsEmpty()) {
tile = NULL;
// throw new IllegalArgumentException("Empty intent tile spec action");
return E_ILLEGAL_ARGUMENT_EXCEPTION;
}
*tile = new IntentTile(host, action);
REFCOUNT_ADD(*tile);
return NOERROR;
}
示例7: SetGpsLocation
void SettingsHelper::SetGpsLocation(
/* [in] */ const String& value)
{
AutoPtr<IInterface> obj;
mContext->GetSystemService(IContext::USER_SERVICE, (IInterface**)&obj);
AutoPtr<IUserManager> um = IUserManager::Probe(obj);
Boolean res;
if (um->HasUserRestriction(IUserManager::DISALLOW_SHARE_LOCATION, &res), res) {
return;
}
String GPS = ILocationManager::GPS_PROVIDER;
Boolean enabled = GPS.Equals(value) ||
value.StartWith(GPS + String(",")) ||
value.EndWith(String(",") + GPS) ||
value.Contains(String(",") + GPS + String(","));
AutoPtr<ISettingsSecure> secure;
CSettingsSecure::AcquireSingleton((ISettingsSecure**)&secure);
AutoPtr<IContentResolver> resolver;
mContext->GetContentResolver((IContentResolver**)&resolver);
secure->SetLocationProviderEnabled(resolver, GPS, enabled);
}
示例8: LoadResourcesFromXmlParser
ECode IconPackHelper::LoadResourcesFromXmlParser(
/* [in] */ IXmlPullParser* parser,
/* [in] */ IMap* iconPackResources)
{
mIconBackCount = 0;
Int32 eventType;
parser->GetEventType(&eventType);
do {
if (eventType != IXmlPullParser::START_TAG) {
continue;
}
if (ParseComposedIconComponent(parser, iconPackResources)) {
continue;
}
Boolean result;
FAIL_RETURN(ColorFilterUtils::ParseIconFilter(parser, mFilterBuilder, &result));
if (result) {
continue;
}
String strName;
if (parser->GetName(&strName), strName.EqualsIgnoreCase(ICON_SCALE_TAG)) {
String factor;
parser->GetAttributeValue(String(NULL), String("factor"), &factor);
if (factor.IsNull()) {
Int32 count;
if (parser->GetAttributeCount(&count), count == 1) {
parser->GetAttributeValue(0, &factor);
}
}
iconPackResources->Put(ICON_SCALE_COMPONENT, CoreUtils::Convert(factor));
continue;
}
if (parser->GetName(&strName), !strName.EqualsIgnoreCase("item")) {
continue;
}
String component;
parser->GetAttributeValue(String(NULL), String("component"), &component);
String drawable;
parser->GetAttributeValue(String(NULL), String("drawable"), &drawable);
// Validate component/drawable exist
if (TextUtils::IsEmpty(component) || TextUtils::IsEmpty(drawable)) {
continue;
}
// Validate format/length of component
if (!component.StartWith("ComponentInfo{") || !component.EndWith("}")
|| component.GetLength() < 16 || drawable.GetLength() == 0) {
continue;
}
// Sanitize stored value
component = component.Substring(14, component.GetLength() - 1).ToLowerCase();
AutoPtr<IComponentName> name;
if (!component.Contains("/")) {
// Package icon reference
CComponentName::New(component.ToLowerCase(), String(""), (IComponentName**)&name);
}
else {
CComponentName::UnflattenFromString(component, (IComponentName**)&name);
}
if (name != NULL) {
iconPackResources->Put(name, CoreUtils::Convert(drawable));
}
} while (parser->Next(&eventType), eventType != IXmlPullParser::END_DOCUMENT);
return NOERROR;
}
示例9: GuessFileName
String URLUtil::GuessFileName(
/* [in] */ const String& url,
/* [in] */ const String& contentDisposition,
/* [in] */ const String& _mimeType)
{
String filename;
String extension;
String mimeType = _mimeType;
// If we couldn't do anything with the hint, move toward the content disposition
if (filename.IsNull() && !contentDisposition.IsNull()) {
filename = ParseContentDisposition(contentDisposition);
if (!filename.IsNull()) {
Int32 index = filename.LastIndexOf('/') + 1;
if (index > 0) {
filename = filename.Substring(index);
}
}
}
// If all the other http-related approaches failed, use the plain uri
if (filename.IsNull()) {
String decodedUrl;
Uri::Decode(url, &decodedUrl);
if (!decodedUrl.IsNull()) {
Int32 queryIndex = decodedUrl.IndexOf('?');
// If there is a query string strip it, same as desktop browsers
if (queryIndex > 0) {
decodedUrl = decodedUrl.Substring(0, queryIndex);
}
if (!decodedUrl.EndWith("/")) {
Int32 index = decodedUrl.LastIndexOf('/') + 1;
if (index > 0) {
filename = decodedUrl.Substring(index);
}
}
}
}
// Finally, if couldn't get filename from URI, get a generic filename
if (filename.IsNull()) {
filename = "downloadfile";
}
// Split filename between base and extension
// Add an extension if filename does not have one
Int32 dotIndex = filename.IndexOf('.');
if (dotIndex < 0) {
if (!mimeType.IsNull()) {
AutoPtr<MimeTypeMap> mimeTypeMap = MimeTypeMap::GetSingleton();
mimeTypeMap->GetExtensionFromMimeType(mimeType, &extension);
if (!extension.IsNull()) {
extension = String(".") + extension;
}
}
if (extension.IsNull()) {
if (!mimeType.IsNull() && mimeType.StartWithIgnoreCase("text/")) {
if (mimeType.EqualsIgnoreCase("text/html")) {
extension = ".html";
}
else {
extension = ".txt";
}
}
else {
extension = ".bin";
}
}
}
else {
if (!mimeType.IsNull()) {
// Compare the last segment of the extension against the mime type.
// If there's a mismatch, discard the entire extension.
Int32 lastDotIndex = filename.LastIndexOf('.');
AutoPtr<MimeTypeMap> mimeTypeMap = MimeTypeMap::GetSingleton();
String typeFromExt;
mimeTypeMap->GetMimeTypeFromExtension(
filename.Substring(lastDotIndex + 1), &typeFromExt);
if (!typeFromExt.IsNull() && !typeFromExt.EqualsIgnoreCase(mimeType)) {
mimeTypeMap->GetExtensionFromMimeType(mimeType, &extension);
if (!extension.IsNull()) {
extension = String(".") + extension;
}
}
}
if (extension.IsNull()) {
extension = filename.Substring(dotIndex);
}
filename = filename.Substring(0, dotIndex);
}
return filename + extension;
}
示例10: LoadColorStateList
ECode CResources::LoadColorStateList(
/* [in] */ ITypedValue* value,
/* [in] */ Int32 id,
/* [out] */ IColorStateList** csl)
{
// if (TRACE_FOR_PRELOAD) {
// // Log only framework resources
// if ((id >>> 24) == 0x1) {
// final String name = getResourceName(id);
// if (name != null) android.util.Log.d("PreloadColorStateList", name);
// }
// }
Int32 key = (((CTypedValue*)value)->mAssetCookie << 24) | ((CTypedValue*)value)->mData;
if (((CTypedValue*)value)->mType >= TypedValue_TYPE_FIRST_COLOR_INT &&
((CTypedValue*)value)->mType <= TypedValue_TYPE_LAST_COLOR_INT) {
HashMap<Int32, AutoPtr<IColorStateList> >::Iterator it =
mPreloadedColorStateLists->Find(key);
*csl = it != mPreloadedColorStateLists->End()? it->mSecond : NULL;
if (*csl != NULL) {
(*csl)->AddRef();
return NOERROR;
}
assert(SUCCEEDED(CColorStateList::ValueOf(((CTypedValue*)value)->mData, csl)));
if (mPreloading) {
(*mPreloadedColorStateLists)[key] = *csl;
}
return NOERROR;
}
GetCachedColorStateList(key, csl);
if (*csl != NULL) {
return NOERROR;
}
HashMap<Int32, AutoPtr<IColorStateList> >::Iterator it =
mPreloadedColorStateLists->Find(key);
*csl = it != mPreloadedColorStateLists->End()? it->mSecond : NULL;
if (*csl != NULL) {
(*csl)->AddRef();
return NOERROR;
}
if (((CTypedValue*)value)->mString == NULL) {
Logger::E(TAG, StringBuffer("Resource is not a ColorStateList (color or path): ") + (Int32)value);
*csl = NULL;
return E_NOT_FOUND_EXCEPTION;
}
String file;
((CTypedValue*)value)->mString->ToString(&file);
if (file.EndWith(".xml")) {
//try {
AutoPtr<IXmlResourceParser> rp;
LoadXmlResourceParser(
file, id, ((CTypedValue*)value)->mAssetCookie, "colorstatelist",
(IXmlResourceParser**)&rp);
CColorStateList::CreateFromXml(this, rp, csl);
rp->Close();
//} catch (Exception e) {
// NotFoundException rnf = new NotFoundException(
// "File " + file + " from color state list resource ID #0x"
// + Integer.toHexString(id));
// rnf.initCause(e);
// throw rnf;
//}
}
else {
//throw new NotFoundException(
// "File " + file + " from drawable resource ID #0x"
// + Integer.toHexString(id) + ": .xml extension required");
return E_NOT_FOUND_EXCEPTION;
}
if (*csl != NULL) {
if (mPreloading) {
(*mPreloadedColorStateLists)[key] = *csl;
} else {
Mutex::Autolock lock(mTmpValueLock);
//Log.i(TAG, "Saving cached color state list @ #" +
// Integer.toHexString(key.intValue())
// + " in " + this + ": " + csl);
mColorStateListCache[key] = *csl;
}
}
return NOERROR;
}
示例11: LoadDrawable
ECode CResources::LoadDrawable(
/* [in] */ ITypedValue* value,
/* [in] */ Int32 id,
/* [out] */ IDrawable** drawable)
{
if (TRACE_FOR_PRELOAD) {
// Log only framework resources
// if ((id >>> 24) == 0x1) {
// final String name = GetResourceName(id);
// if (name != null) android.util.Log.d("PreloadDrawable", name);
// }
}
Int64 key = (((Int64)((CTypedValue*)value)->mAssetCookie) << 32) | ((CTypedValue*)value)->mData;
GetCachedDrawable(key, drawable);
if (*drawable != NULL) {
return NOERROR;
}
HashMap<Int64, AutoPtr<IDrawableConstantState> >::Iterator it =
sPreloadedDrawables->Find(key);
AutoPtr<IDrawableConstantState> cs =
it != sPreloadedDrawables->End()? it->mSecond : NULL;
if (cs != NULL) {
cs->NewDrawableEx((IResources*)this, drawable);
}
else {
if (((CTypedValue*)value)->mType >= TypedValue_TYPE_FIRST_COLOR_INT &&
((CTypedValue*)value)->mType <= TypedValue_TYPE_LAST_COLOR_INT) {
CColorDrawable::New(((CTypedValue*)value)->mData, (IColorDrawable**)drawable);
}
if (*drawable == NULL) {
if (((CTypedValue*)value)->mString == NULL) {
Logger::E(TAG, StringBuffer("Resource is not a Drawable (color or path): ") + (Int32)value);
*drawable = NULL;
return E_NOT_FOUND_EXCEPTION;
}
String file;
((CTypedValue*)value)->mString->ToString(&file);
if (DEBUG_LOAD) {
Logger::V(TAG, StringBuffer("Loading drawable for cookie ")
+ ((CTypedValue*)value)->mAssetCookie + ": " + file);
}
if (file.EndWith(".xml")) {
// try {
AutoPtr<IXmlResourceParser> rp;
LoadXmlResourceParser(file, id, ((CTypedValue*)value)->mAssetCookie,
"drawable", (IXmlResourceParser**)&rp);
Drawable::CreateFromXml(this, rp, drawable);
rp->Close();
// } catch (Exception e) {
// NotFoundException rnf = new NotFoundException(
// "File " + file + " from drawable resource ID #0x"
// + Integer.toHexString(id));
// rnf.initCause(e);
// throw rnf;
// }
//
}
else {
// try {
AutoPtr<IInputStream> is;
ASSERT_SUCCEEDED(mAssets->OpenNonAssetEx3(
((CTypedValue*)value)->mAssetCookie, file,
AssetManager_ACCESS_STREAMING, (IInputStream**)&is));
// System.out.println("Opened file " + file + ": " + is);
Drawable::CreateFromResourceStream((IResources*)this, value, is,
file, NULL, drawable);
is->Close();
// System.out.println("Created stream: " + dr);
// } catch (Exception e) {
// NotFoundException rnf = new NotFoundException(
// "File " + file + " from drawable resource ID #0x"
// + Integer.toHexString(id));
// rnf.initCause(e);
// throw rnf;
// }
}
}
}
if (*drawable != NULL) {
AutoPtr<IDrawableConstantState> cs2;
(*drawable)->SetChangingConfigurations(((CTypedValue*)value)->mChangingConfigurations);
(*drawable)->GetConstantState((IDrawableConstantState**)&cs2);
if (cs2 != NULL) {
if (mPreloading) {
(*sPreloadedDrawables)[key] = cs2;
}
else {
Mutex::Autolock lock(mTmpValueLock);
//Log.i(TAG, "Saving cached drawable @ #" +
// Integer.toHexString(key.intValue())
// + " in " + this + ": " + cs2);
mDrawableCache[key] = cs2;
//.........这里部分代码省略.........