下面列出了怎么用java.lang.String的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Replace page name in PageName2Node HasMap. This is general used in a
* page rename. In general this removes the old Page and add the new one with
* the given name.
* @param page Page that should be added into the map. If null, NPE thrown
* and nothing removed from the map.
* @param String newName String that you want to assign to the page.
* @param String oldName String that was assigned to the page.
* @return true if page was found to replace, false is page was not found.
**/
public boolean replacePageName2Page(Page page, String newName, String oldName) {
LOGGER.finest("PageName2Page: replace " + oldName + " to " + newName);
//assert (newName.length() > 0);
//assert (oldName.length() > 0);
if (page == null) {
throw new NullPointerException("Page can not be null.");
}
checkAWTThread();
synchronized (pageName2Page) {
WeakReference<Page> page2Ref = pageName2Page.remove(oldName);
if (page2Ref != null) {
Page pageFound = page2Ref.get();
if (pageFound != null) {
LOGGER.finest("Trying to replace page in map, but page not found:" + page);
}
pageName2Page.put(newName, new WeakReference<Page>(page));
return true;
}
return false;
}
}
/**
* Formats time in milliseconds to hh:mm:ss string format.
*/
public static String formatMillis(int millis) {
String result = "";
int hr = millis / 3600000;
millis %= 3600000;
int min = millis / 60000;
millis %= 60000;
int sec = millis / 1000;
if (hr > 0) {
result += hr + ":";
}
if (min >= 0) {
if (min > 9) {
result += min + ":";
} else {
result += "0" + min + ":";
}
}
if (sec > 9) {
result += sec;
} else {
result += "0" + sec;
}
return result;
}
public void addConfiguredDocumentType(DocumentType documentType) throws BuildException {
String name = documentType.getName();
String role = documentType.getRole();
List osTypes = documentType.getOSTypes();
List extensions = documentType.getExtensions();
List mimeTypes = documentType.getMimeTypes();
if ((name == null) || (role == null))
throw new BuildException(
"'<documenttype>' must have both a 'name' and a 'role' attibute");
if ((osTypes.isEmpty()) && (extensions.isEmpty()) && (mimeTypes.isEmpty()))
throw new BuildException(
"'<documenttype>' of \""
+ name
+ "\" must have 'osTypes' or 'extensions' or 'mimeTypes'");
bundleProperties.addDocumentType(documentType);
}
@Override
public TestManyTypesViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
assignedAttributes_epoxyGeneratedModel.clear();
this.stringValue_String = null;
this.nullableStringValue_String = (String) null;
this.intValue_Int = 0;
this.intValueWithAnnotation_Int = 0;
this.intValueWithRangeAnnotation_Int = 0;
this.intValueWithDimenTypeAnnotation_Int = 0;
this.intWithMultipleAnnotations_Int = 0;
this.integerValue_Integer = null;
this.boolValue_Boolean = false;
this.booleanValue_Boolean = null;
this.arrayValue_StringArray = null;
this.listValue_List = null;
this.clickListener_OnClickListener = null;
this.title_StringAttributeData = new StringAttributeData((CharSequence) null);
super.reset();
return this;
}
@Override
public String toString() {
return "LocalPositionNedCov{timeUsec=" + timeUsec
+ ", estimatorType=" + estimatorType
+ ", x=" + x
+ ", y=" + y
+ ", z=" + z
+ ", vx=" + vx
+ ", vy=" + vy
+ ", vz=" + vz
+ ", ax=" + ax
+ ", ay=" + ay
+ ", az=" + az
+ ", covariance=" + covariance + "}";
}
@Override
public final NullPointerException headerNameWasNull() {
final NullPointerException result = new NullPointerException(String.format(getLoggingLocale(), headerNameWasNull$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
public static void LoadApplication (Context context, String runtimeDataDir, String[] apks)
{
synchronized (lock) {
if (!initialized) {
System.loadLibrary("monodroid");
Locale locale = Locale.getDefault ();
String language = locale.getLanguage () + "-" + locale.getCountry ();
String filesDir = context.getFilesDir ().getAbsolutePath ();
String cacheDir = context.getCacheDir ().getAbsolutePath ();
String dataDir = context.getApplicationInfo ().dataDir + "/lib";
ClassLoader loader = context.getClassLoader ();
Runtime.init (
language,
apks,
runtimeDataDir,
new String[]{
filesDir,
cacheDir,
dataDir,
},
loader,
new java.io.File (
android.os.Environment.getExternalStorageDirectory (),
"Android/data/" + context.getPackageName () + "/files/.__override__").getAbsolutePath (),
MonoPackageManager_Resources.Assemblies,
context.getPackageName ());
initialized = true;
}
}
}
public static boolean imwrite(String filename, Mat img, MatOfInt params)
{
Mat params_mat = params;
boolean retVal = imwrite_0(filename, img.nativeObj, params_mat.nativeObj);
return retVal;
}
@Override
public String toString() {
if ($toString == null) {
$toString = "Data{"
+ "createReview=" + createReview
+ "}";
}
return $toString;
}
/**
* Givena pageName, look through the list of predefined webFiles and return the matching fileObject
* @return FileObject for which the match was found or null of none was found.
**/
private FileObject getFileObject(String pageName) {
for (FileObject webFile : webFiles) {
//DISPLAYNAME:
String webFileName = Page.getFolderDisplayName(getWebFolder(), webFile);
// String webFileName = webFile.getNameExt();
if (webFileName.equals(pageName)) {
return webFile;
}
}
return null;
}
/**
* Invokes the <code>getDialogTitle</code> method on each UI handled by this object.
*
* @return the value obtained from the first UI, which is
* the UI obtained from the default <code>LookAndFeel</code>
*/
public String getDialogTitle(JFileChooser a) {
String returnValue =
((FileChooserUI) (uis.elementAt(0))).getDialogTitle(a);
for (int i = 1; i < uis.size(); i++) {
((FileChooserUI) (uis.elementAt(i))).getDialogTitle(a);
}
return returnValue;
}
public AsDroid(@NotNull String __typename, @NotNull String name,
@Nullable String primaryFunction, @Nullable List<Friend1> friends) {
this.__typename = Utils.checkNotNull(__typename, "__typename == null");
this.name = Utils.checkNotNull(name, "name == null");
this.primaryFunction = Optional.fromNullable(primaryFunction);
this.friends = Optional.fromNullable(friends);
}
@Override
public String getVersionString() {
if (myVersionString == null && !myVersionDefined) {
String homePath = getHomePath();
if (homePath != null && !homePath.isEmpty()) {
setVersionString(getSdkType().getVersionString(this));
}
}
return myVersionString;
}
/**
* get the message for this exception
*/
public String getMessage() {
StringBuffer sb = new StringBuffer( HttpUnitUtils.DEFAULT_TEXT_BUFFER_SIZE );
sb.append( "Attempted to upload " ).append( _numSupplied ).append( " files using parameter '" ).append( _parameterName );
if (_numExpected == 0) {
sb.append( "' which is not a file parameter." );
} else {
sb.append( "' which only has room for " ).append( _numExpected ).append( '.' );
}
return sb.toString();
}
@Override
public String toString() {
return "HighLatency2{timestamp=" + timestamp
+ ", type=" + type
+ ", autopilot=" + autopilot
+ ", customMode=" + customMode
+ ", latitude=" + latitude
+ ", longitude=" + longitude
+ ", altitude=" + altitude
+ ", targetAltitude=" + targetAltitude
+ ", heading=" + heading
+ ", targetHeading=" + targetHeading
+ ", targetDistance=" + targetDistance
+ ", throttle=" + throttle
+ ", airspeed=" + airspeed
+ ", airspeedSp=" + airspeedSp
+ ", groundspeed=" + groundspeed
+ ", windspeed=" + windspeed
+ ", windHeading=" + windHeading
+ ", eph=" + eph
+ ", epv=" + epv
+ ", temperatureAir=" + temperatureAir
+ ", climbRate=" + climbRate
+ ", battery=" + battery
+ ", wpNum=" + wpNum
+ ", failureFlags=" + failureFlags
+ ", custom0=" + custom0
+ ", custom1=" + custom1
+ ", custom2=" + custom2 + "}";
}
/**
* <p>Writes a match object to a file storage.</p>
*
* @param fileName a fileName
*
* @see <a href="http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_generic_descriptor_matchers.html#genericdescriptormatcher-write">org.opencv.features2d.GenericDescriptorMatcher.write</a>
*/
public void write(String fileName)
{
write_0(nativeObj, fileName);
return;
}
public void forward(List<Mat> outputBlobs, String outputName)
{
Mat outputBlobs_mat = new Mat();
forward_2(nativeObj, outputBlobs_mat.nativeObj, outputName);
Converters.Mat_to_vector_Mat(outputBlobs_mat, outputBlobs);
outputBlobs_mat.release();
return;
}
/**
* Provides list of options for this category
* @return list of keywords for each optioncategory sub-panel
*/
public Set<String> getKeywordsByCategory() {
if (keywords != null) {
return Collections.singleton(keywords);
} else {
return Collections.emptySet();
}
}
public void forward(List<Mat> outputBlobs, List<String> outBlobNames)
{
Mat outputBlobs_mat = new Mat();
forward_4(nativeObj, outputBlobs_mat.nativeObj, outBlobNames);
Converters.Mat_to_vector_Mat(outputBlobs_mat, outputBlobs);
outputBlobs_mat.release();
return;
}
public Hero(@NotNull String __typename, @NotNull String name,
@NotNull @Deprecated String deprecated, @Deprecated boolean deprecatedBool) {
this.__typename = Utils.checkNotNull(__typename, "__typename == null");
this.name = Utils.checkNotNull(name, "name == null");
this.deprecated = Utils.checkNotNull(deprecated, "deprecated == null");
this.deprecatedBool = deprecatedBool;
}
/** Dispatch a message.
@threadsafe
@remarks: The function may not be running from the UI thread. It is listener's duty to handle multiple threading issue.
*/
public static void dispatch(String type,Map message) {
try {
Payload payload;
mutex.acquire();
if (dispatching) {
payload = new Payload();
payload.type = type;
payload.message = message;
queue.add(payload);
mutex.release();
return;
}
dispatching = true;
mutex.release();
emit(type,message); // Emit
mutex.acquire(); // Process queued message
while (queue.size() > 0 ) {
payload = queue.poll();
mutex.release();
emit(payload.type,payload.message);
mutex.acquire();
}
dispatching = false;
mutex.release();
} catch (Exception e) {
Log.e(TAG,"exception",e);
}
}
/**
* Generates a string map from a list of strings.
*/
private static HashMap<String, String> makeMap(String... strings) {
HashMap<String, String> result = new HashMap<>();
for(int i = 0; i < strings.length; i += 2) {
result.put(strings[i], strings[i + 1]);
}
return result;
}
@Override
public String operationId() {
return OPERATION_ID;
}
public FriendsConnection1(@NotNull String __typename, @Nullable Integer totalCount,
@Nullable List<Edge1> edges) {
this.__typename = Utils.checkNotNull(__typename, "__typename == null");
this.totalCount = Optional.fromNullable(totalCount);
this.edges = Optional.fromNullable(edges);
}
private void reportUOM(String s, Double number) {
String metricName = null;
StringBuilder results = new StringBuilder();
Boolean published = false;
if (whiteList.contains(s)) {
if (!metricMap.isEmpty() && metricMap.containsKey(s)) {
metricName = metricMap.get(s);
}
/* Send the unmapped uom as the same name storm calls it */
else {
metricName = s;
}
/* Make sure we don't send metric names that may be null or empty */
if (metricName != null && !metricName.isEmpty()) {
published = true;
}
}
/*
* To enable debug message, you also need to add an entry like this:
*
* <logger name="monasca.thresh" additivity="false">
* <level value="INFO" />
* <appender-ref ref="A1" />
* </logger>
*
* Storm/Thresh logger config file:
* /opt/storm/apache-storm-0.9.5/logback/cluster.xml
*
*/
if (debugMetrics) {
String mappedName = new String();
if (!metricMap.isEmpty() && metricMap.containsKey(s)) {
mappedName = metricMap.get(s);
}
else {
mappedName = s;
}
logger.info(", RawMetricName, {}, MappedMetricName, {}, "
+ "val, {}, {}", new Object[]
{ s, mappedName, number,
published == true ? "PUBLISHED" : "UNPUBLISHED"});
}
if (published) {
results = results.append(metricName).append(":")
.append(String.valueOf(number)).append("|c")
.append(statsdDimensions);
report(results.toString());
}
}
private static String jsonObjectString() throws Exception {
JSONObject json = new JSONObject().put(TEXT_NAME, TEXT_VALUE).put(COPY_NAME, COPY_VALUE);
return json.toString();
}
@Override
public Node map(ResponseReader reader) {
final String __typename = reader.readString($responseFields[0]);
final String name = reader.readString($responseFields[1]);
return new Node(__typename, name);
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("TypeParamValue{children=").append(this.children);
return builder.append('}').toString();
}
public @NotNull String __typename() {
return this.__typename;
}
@Override
public AsCharacter map(ResponseReader reader) {
final String __typename = reader.readString($responseFields[0]);
final String name = reader.readString($responseFields[1]);
return new AsCharacter(__typename, name);
}