Javadoc Multi-Line Declaration Syntax? - java

If I have the variable declaration:
/**
* The Resource folder for the program Information.
*/
public static final Path RESOURCE_FOLDER_PATH = Paths.get("", "Resources"),
/**
* The folder holding all faction information.
*/
FACTION_FOLDER_PATH = Paths.get(RESOURCE_FOLDER_PATH.toString(), "Faction Information");
The Javadoc will not document the latter Path variable. Does Javadoc support this type of documenting style or do I have to declare them separately?

No unfortunately you can't.
You need to do it in the following way which is clearer and neater:
/**
* Returns an Image object that can then be painted on the screen.
* The url argument must specify an absolute {#link URL}. The name
* argument is a specifier that is relative to the url argument.
* <p>
* This method always returns immediately, whether or not the
* image exists. When this applet attempts to draw the image on
* the screen, the data will be loaded. The graphics primitives
* that draw the image will incrementally paint on the screen.
*
* #param url an absolute URL giving the base location of the image
* #param name the location of the image, relative to the url argument
* #return the image at the specified URL
* #see Image
*/
public Image getImage(URL url, String name) {
try {
return getImage(new URL(url, name));
} catch (MalformedURLException e) {
return null;
}
}

Related

How can I find all resources "shared with me" and "owned by me" using Keycloak authzClient?

On Keycloak I have several resources and I need to fetch all resources owned by me and "shared with me" by other users.
For example, this resource is owned by "test" user and it is shared with "test2" user:
So the idea is test2 will fetch resources shared with him.
But the only option I see is to find by Owner/Name/Uri: Keycloak docs
/**
* Query the server for any resource with the matching arguments.
*
* #param id the resource id
* #param name the resource name
* #param uri the resource uri
* #param owner the resource owner
* #param type the resource type
* #param scope the resource scope
* #param matchingUri the resource uri. Use this parameter to lookup a resource that best match the given uri
* #param exactName if the the {#code name} provided should have a exact match
* #param deep if the result should be a list of resource representations with details about the resource. If false, only ids are returned
* #param firstResult the position of the first resource to retrieve
* #param maxResult the maximum number of resources to retrieve
* #return a list of resource representations or an array of strings representing resource ids, depending on the generic type
*/
public <R> R find(final String id, final String name, final String uri, final String owner, final String type, final String scope, final boolean matchingUri, final boolean exactName, final boolean deep, final Integer firstResult, final Integer maxResult)
By other side, the keycloak account UI application seems to call to an
endpoint to fetch the resources shared-with-me
If you send an empty authorization request to Keycloak then it returns all allowed permissions with the associated resources. This list includes owned by you or sharing with you.
fun AuthzClient.findAllGrantedPermissions(accessToken: String): TokenIntrospectionResponse {
val request = AuthorizationRequest()
val rpt = this.authorization(accessToken).authorize(request).token
return this.protection().introspectRequestingPartyToken(rpt)
}

Eclipse Object Info Box on Custom Objects

I couldn't find how to do this anywhere else online, though I'm sure it's really easy to do. I'm primarily self taught though, and I'd like to start learning to document my code properly. This "yellow box" that pops up in eclipse with information about the method - I want it to pop up on a custom object. For my example below I have a custom class called "System Properties" and a method called "getOs" but when I hover that option, no information comes up. How do I add information to my object?
This picture shows the yellow box
This picture shows the lack of a "yellow box" on my object
and then finally my custom objects code...
public class SystemProperties {
private String os;
public SystemProperties() {
this.os = setOs();
}
private String setOs() {
String osName = System.getProperty("os.name");
if(osName.toLowerCase().contains("window"))
return "Windows";
else if(osName.toLowerCase().contains("mac"))
return "Mac";
else
return "Linux";
}
/**
* Method to grab the OS the user is running from
* #return String - the os
*/
public String getOs() {
return this.os;
}
}
Thank you in advance for your time and knowledge. :)
EDIT:
When I import the project of the custom object, it works just fine. It only doesn't work when I export the project of the custom class to a jar file and then use that instead. Do I have to click an option on the export screen?
Eclipse take the info from the notes above the methods in the built in objects.
see this:
/**
* Returns <tt>true</tt> if this map contains a mapping for the specified
* key. More formally, returns <tt>true</tt> if and only if
* this map contains a mapping for a key <tt>k</tt> such that
* <tt>(key==null ? k==null : key.equals(k))</tt>. (There can be
* at most one such mapping.)
*
* #param key key whose presence in this map is to be tested
* #return <tt>true</tt> if this map contains a mapping for the specified
* key
* #throws ClassCastException if the key is of an inappropriate type for
* this map
* (optional)
* #throws NullPointerException if the specified key is null and this map
* does not permit null keys
* (optional)
*/
boolean containsKey(Object key);
You can do the same to the methods of your own objects.

Increase MMS picture's width and height

So I have an SMS app and I'm sending MMS pictures. Pictures are resized before sending. I want to change maxImageWidth and maxImageHeight so the sent pictures will be bigger.
I have a class BugleCarrierConfigValuesLoader and a method inside:
/**
* Loading carrier config values
*
* #param subId which SIM to load for
* #param values the result to add to
* #return the source of the config, could be "resources" or "resources+system"
*/
private String loadLocked(final int subId, final Bundle values) {
// Load from resources in earlier platform
loadFromResources(subId, values);
if (OsUtil.isAtLeastL()) {
// Load from system to override if system API exists
loadFromSystem(subId, values);
return "resources+system";
}
return "resources";
}
This method loads values like maxImageWidth=640 or maxImageHeight=480.
I would like to understand why is it done like that. Why can't I just make final static int with maxImageWidth value. Why do I need to load these values from resources or system.

how to copy javadoc from variables to constructor

I am having some problems with Javadoc. I have written documentation for variables of a class. And then I want to use that same javaDoc in the constructor. I didn't seem to be able to use #link or #see for this purpose (Well, Netbeans didn't show the result I liked).
It seems like a hassle to copy-paste everything, so is there a tag/parameter to copy javaDoc?
Here is the example:
/**
* The id for identifying this specific detectionloop. It is assumed the
* Detectionloops are numbered in order, so Detectionloop '2' is always next to
* Detectionloop '1'.
*/
private int id;
/**
* Constructor for a detectionloop. Detectionloops are real-world sensors
* that register and identify a kart when it passes by. Please note that
* this class is still under heavy development and the parameters of the
* constructor may change along the way!
*
* #param id The id for identifying this specific detectionloop. It is assumed
* the Detectionloops are numbered in order, so Detectionloop '2' is always
* next to Detectionloop '1'.
* #param nextID The id of the next detectionloop is sequense.
* #param distanceToNext The distance in meters to the next detectionloop.
*/
DetectionLoop(int id, int nextID, int distanceToNext) {
this.distanceToNext = distanceToNext;
this.id = id;
if (Detectionloops.containsKey(id)) {
throw new IllegalArgumentException("Detectionloop " + this.id
+ " already exist, please use a unused identification!");
} else {
Detectionloops.put(this.id, this);
}
}
This is unfortunately impossible using standard Javadoc. As a workaround, you could use the #link tag to reference the field, and then people could click the link to get at its documentation. This would require a click, but at least you don't have to maintain redundant documentation:
/**
* ...
* #param id the value for {#link #id}
The only other way of solving this that I know of is to write a custom doclet, which would allow you to define your own tag for your purpose.

USB Settings in android not getting stored

I am new to android framework. I am working with USB Settings. I want to know where are USB settings stored in android.
I am having following problem :
when i connect my phone to Computer and select one of the option from mass storage, MTP,PTP and now if I switch off and then switch on the device my selection get cleared. I want the previous selection to be retained.
What should I do..??
Thanks in advance...
Edit : I discovered today that usb_device_manager.xml file should be created in /data/system folder but in my case it is not getting generated.
I am unable to find what is the reason behind this.
The file that creates this file is located at frameworks/base/services/java/com/android/server/usb/
Waiting for positive reply...
According to http://developer.android.com/reference/android/hardware/usb/UsbManager.html
You cannot find an open API for getting this information.
However, from the source code we can see this two functions:
/**
* Name of the MTP USB function.
* Used in extras for the {#link #ACTION_USB_STATE} broadcast
*
* {#hide}
*/
public static final String USB_FUNCTION_MTP = "mtp";
/**
* Name of the PTP USB function.
* Used in extras for the {#link #ACTION_USB_STATE} broadcast
*
* {#hide}
*/
public static final String USB_FUNCTION_PTP = "ptp";
/**
* Returns the current default USB function.
*
* #return name of the default function.
*
* {#hide}
*/
public String getDefaultFunction() {
String functions = SystemProperties.get("persist.sys.usb.config", "");
int commaIndex = functions.indexOf(',');
if (commaIndex > 0) {
return functions.substring(0, commaIndex);
} else {
return functions;
}
}
/**
* Sets the current USB function.
* If function is null, then the current function is set to the default function.
*
* #param function name of the USB function, or null to restore the default function
* #param makeDefault true if the function should be set as the new default function
*
* {#hide}
*/
public void setCurrentFunction(String function, boolean makeDefault) {
try {
mService.setCurrentFunction(function, makeDefault);
} catch (RemoteException e) {
Log.e(TAG, "RemoteException in setCurrentFunction", e);
}
}
It is not recommended to use hidden APIs, but this might solve your problem.
If you wants to know how to use the hidden APIs, refer to this link:
http://devmaze.wordpress.com/2011/01/18/using-com-android-internal-part-1-introduction/

Categories