summaryrefslogtreecommitdiff
path: root/javaSE
diff options
context:
space:
mode:
authorBilal Alsharifi <bilal.alsharifi@gmail.com>2020-09-17 16:31:17 -0400
committerBilal Alsharifi <bilal.alsharifi@gmail.com>2020-09-17 16:31:17 -0400
commite00f2c1f9310e7423be3a094aa77b1e84b1a0a80 (patch)
tree6baf06361ea4c09538a825e6ca6f57aa351ff85c /javaSE
parent33d48a40a5625db0967bed780654fce8b1abbd5c (diff)
downloadsdl_android-e00f2c1f9310e7423be3a094aa77b1e84b1a0a80.tar.gz
Run the Reformat Code tool on the project
Diffstat (limited to 'javaSE')
-rw-r--r--javaSE/javaSE/bintray.gradle4
-rw-r--r--javaSE/javaSE/build.gradle4
-rw-r--r--javaSE/javaSE/src/main/java/com/livio/BSON/BsonEncoder.java24
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/BuildConfig.java58
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java55
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java165
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlArtwork.java49
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java78
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/EncryptionLifecycleManager.java2
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java2
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManager.java2
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/managers/permission/PermissionManager.java12
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/ScreenManager.java14
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/SoftButtonManager.java4
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/SubscribeButtonManager.java3
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java33
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManager.java2
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/MenuManager.java14
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/VoiceCommandManager.java12
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/protocol/SdlPacket.java2
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java3
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/security/SdlSecurityBase.java4
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/session/SdlSession.java2
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/trace/SdlTrace.java12
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransport.java29
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransportConfig.java4
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportCallback.java5
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportInterface.java4
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportManager.java60
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServer.java40
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServerConfig.java8
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLConfig.java24
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLWebSocketFactoryGenerator.java69
-rw-r--r--javaSE/javaSE/src/main/java/org/json/JSON.java2
-rw-r--r--javaSE/javaSE/src/main/java/org/json/JSONArray.java57
-rw-r--r--javaSE/javaSE/src/main/java/org/json/JSONObject.java153
-rw-r--r--javaSE/javaSE/src/main/java/org/json/JSONStringer.java13
-rw-r--r--javaSE/javaSE/src/main/java/org/json/JSONTokener.java17
-rw-r--r--javaSE/javaSE/src/test/java/com/smartdevicelink/test/TestValues.java10
39 files changed, 575 insertions, 480 deletions
diff --git a/javaSE/javaSE/bintray.gradle b/javaSE/javaSE/bintray.gradle
index d40cb0e28..9b890b842 100644
--- a/javaSE/javaSE/bintray.gradle
+++ b/javaSE/javaSE/bintray.gradle
@@ -45,7 +45,7 @@ bintray {
version {
name = libVersion // Change to release version
desc = libDescription
- released = new Date() // Will be the current date & time
+ released = new Date() // Will be the current date & time
vcsTag = libVersion // Should match git tag
}
}
@@ -54,7 +54,7 @@ bintray {
def pomConfig = {
Properties props = new Properties()
props.load(new FileInputStream("$projectDir/bintray.properties"))
-
+
licenses {
license {
name 'BSD 3-Clause'
diff --git a/javaSE/javaSE/build.gradle b/javaSE/javaSE/build.gradle
index 1390cd913..09da6d5a6 100644
--- a/javaSE/javaSE/build.gradle
+++ b/javaSE/javaSE/build.gradle
@@ -65,11 +65,11 @@ task generateSources {
srcFile.append("\n")
}
srcFile.append("*/\n")
- }else{
+ } else {
srcFile.write("\n")
}
srcFile.append(
-"""package com.smartdevicelink;
+ """package com.smartdevicelink;
// THIS FILE IS AUTO GENERATED, DO NOT MODIFY!!
public final class BuildConfig {
diff --git a/javaSE/javaSE/src/main/java/com/livio/BSON/BsonEncoder.java b/javaSE/javaSE/src/main/java/com/livio/BSON/BsonEncoder.java
index 30037bad6..e00101ef2 100644
--- a/javaSE/javaSE/src/main/java/com/livio/BSON/BsonEncoder.java
+++ b/javaSE/javaSE/src/main/java/com/livio/BSON/BsonEncoder.java
@@ -47,7 +47,7 @@ public class BsonEncoder {
private static final String TAG = "BsonEncoder";
public static byte[] encodeToBytes(HashMap<String, Object> map) throws ClassCastException {
- if(map != null) {
+ if (map != null) {
BasicBSONObject bson = new BasicBSONObject();
bson.putAll(sanitizeMap(map));
BasicBSONEncoder encoder = new BasicBSONEncoder();
@@ -60,7 +60,7 @@ public class BsonEncoder {
}
public static HashMap<String, Object> decodeFromBytes(byte[] bytes) {
- if(bytes != null) {
+ if (bytes != null) {
BasicBSONDecoder decoder = new BasicBSONDecoder();
BSONObject object = decoder.readObject(bytes);
if (object != null) {
@@ -77,28 +77,29 @@ public class BsonEncoder {
/**
* Goes through the map and ensures that all the values included are supported by SDL. If they are not of a supported
* value it is removed from the map
+ *
* @param map the map to be sanitized
* @return a sanitized HashMap with non-supported object type removes
*/
- private static HashMap<String, Object> sanitizeMap(HashMap<String, Object> map){
+ private static HashMap<String, Object> sanitizeMap(HashMap<String, Object> map) {
Set<String> keys = map.keySet();
Object value;
- for(String key : keys){
+ for (String key : keys) {
value = map.get(key);
//First check to see if it value is a valid type used in SDL
- if(isSupportedType(value)){
+ if (isSupportedType(value)) {
continue;
- }else if(value instanceof List){ //Next, check to see if it is a list of values
- List list = (List)value;
+ } else if (value instanceof List) { //Next, check to see if it is a list of values
+ List list = (List) value;
//If the list is empty, there shouldn't be a problem leaving it in the map
- if(list.isEmpty()){
+ if (list.isEmpty()) {
continue;
}
//Since the list isn't empty, check the first item
- if(isSupportedType(list.get(0))){
+ if (isSupportedType(list.get(0))) {
continue;
}
}
@@ -111,10 +112,11 @@ public class BsonEncoder {
/**
* Checks the value to ensure it is of a supported type
- * @param value the generic object value
+ *
+ * @param value the generic object value
* @return if the object is an instanceOf one of the supported SDL BSON objects
*/
- private static boolean isSupportedType(Object value){
+ private static boolean isSupportedType(Object value) {
return value instanceof Integer
|| value instanceof Long
|| value instanceof Double
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/BuildConfig.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/BuildConfig.java
index ecd7b1f9b..926db35b3 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/BuildConfig.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/BuildConfig.java
@@ -1,33 +1,33 @@
/*
-* Copyright (c) 2017 - 2020, SmartDeviceLink Consortium, Inc.
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-*
-* * Redistributions of source code must retain the above copyright notice, this
-* list of conditions and the following disclaimer.
-*
-* * Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the documentation
-* and/or other materials provided with the distribution.
-*
-* * Neither the name of SmartDeviceLink Consortium, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * Copyright (c) 2017 - 2020, SmartDeviceLink Consortium, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of SmartDeviceLink Consortium, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
package com.smartdevicelink;
// THIS FILE IS AUTO GENERATED, DO NOT MODIFY!!
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java
index 43aad3161..cf3e7d04c 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java
@@ -36,34 +36,35 @@ import com.smartdevicelink.proxy.rpc.enums.Language;
public interface SdlManagerListener extends BaseSdlManagerListener {
- /**
- * Called when a manager is ready for use
- */
- void onStart(SdlManager manager);
+ /**
+ * Called when a manager is ready for use
+ */
+ void onStart(SdlManager manager);
- /**
- * Called when the manager is destroyed
- */
- void onDestroy(SdlManager manager);
+ /**
+ * Called when the manager is destroyed
+ */
+ void onDestroy(SdlManager manager);
- /**
- * Called when the manager encounters an error
- * @param info info regarding the error
- * @param e the exception
- */
- void onError(SdlManager manager, String info, Exception e);
+ /**
+ * Called when the manager encounters an error
+ *
+ * @param info info regarding the error
+ * @param e the exception
+ */
+ void onError(SdlManager manager, String info, Exception e);
- /**
- * Called when the SDL manager detected a language mismatch. In case of a language mismatch the
- * manager should change the apps registration by updating the lifecycle configuration to the
- * specified language. If the app can support the specified language it should return an Object
- * of LifecycleConfigurationUpdate, otherwise it should return null to indicate that the language
- * is not supported.
- *
- * @param language The VR+TTS language of the connected head unit the manager is trying to update the configuration.
- * @param hmiLanguage The HMI display language of the connected head unit the manager is trying to update the configuration.
- * @return An object of LifecycleConfigurationUpdate if the head unit language is supported,
- * otherwise null to indicate that the language is not supported.
- */
- LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language, Language hmiLanguage);
+ /**
+ * Called when the SDL manager detected a language mismatch. In case of a language mismatch the
+ * manager should change the apps registration by updating the lifecycle configuration to the
+ * specified language. If the app can support the specified language it should return an Object
+ * of LifecycleConfigurationUpdate, otherwise it should return null to indicate that the language
+ * is not supported.
+ *
+ * @param language The VR+TTS language of the connected head unit the manager is trying to update the configuration.
+ * @param hmiLanguage The HMI display language of the connected head unit the manager is trying to update the configuration.
+ * @return An object of LifecycleConfigurationUpdate if the head unit language is supported,
+ * otherwise null to indicate that the language is not supported.
+ */
+ LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language, Language hmiLanguage);
}
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java
index a84f0a7c7..a2a464c11 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java
@@ -35,8 +35,8 @@ package com.smartdevicelink.managers.file;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
-import com.smartdevicelink.managers.file.filetypes.SdlFile;
import com.smartdevicelink.managers.ISdl;
+import com.smartdevicelink.managers.file.filetypes.SdlFile;
import com.smartdevicelink.proxy.rpc.PutFile;
import com.smartdevicelink.util.DebugTool;
import com.smartdevicelink.util.FileUtls;
@@ -47,100 +47,103 @@ import java.net.URI;
/**
* <strong>FileManager</strong> <br>
- *
+ * <p>
* Note: This class must be accessed through the SdlManager. Do not instantiate it by itself. <br>
- *
+ * <p>
* The SDLFileManager uploads files and keeps track of all the uploaded files names during a session. <br>
- *
+ * <p>
* We need to add the following struct: SDLFile<br>
- *
+ * <p>
* It is broken down to these areas: <br>
- *
+ * <p>
* 1. Getters <br>
* 2. Deletion methods <br>
* 3. Uploading Files / Artwork
*/
public class FileManager extends BaseFileManager {
- /**
- * Constructor for FileManager
- * @param internalInterface an instance of the ISdl interface that can be used for common SDL operations (sendRpc, addRpcListener, etc)
- * @param fileManagerConfig an instance of the FileManagerConfig gives access to artworkRetryCount and fileRetryCount to let us if those file types can be re-upload if they fail
- */
- @RestrictTo(RestrictTo.Scope.LIBRARY)
- public FileManager(ISdl internalInterface, FileManagerConfig fileManagerConfig) {
- // setup
- super(internalInterface, fileManagerConfig);
- }
+ /**
+ * Constructor for FileManager
+ *
+ * @param internalInterface an instance of the ISdl interface that can be used for common SDL operations (sendRpc, addRpcListener, etc)
+ * @param fileManagerConfig an instance of the FileManagerConfig gives access to artworkRetryCount and fileRetryCount to let us if those file types can be re-upload if they fail
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ public FileManager(ISdl internalInterface, FileManagerConfig fileManagerConfig) {
+ // setup
+ super(internalInterface, fileManagerConfig);
+ }
- /**
- * Creates and returns a PutFile request that would upload a given SdlFile
- * @param file SdlFile with fileName and one of A) fileData, B) Uri, or C) resourceID set
- * @return a valid PutFile request if SdlFile contained a fileName and sufficient data
- */
- @Override
- PutFile createPutFile(@NonNull final SdlFile file){
- PutFile putFile = new PutFile();
- if(file.getName() == null){
- throw new IllegalArgumentException("You must specify an file name in the SdlFile");
- }else{
- putFile.setSdlFileName(file.getName());
- }
+ /**
+ * Creates and returns a PutFile request that would upload a given SdlFile
+ *
+ * @param file SdlFile with fileName and one of A) fileData, B) Uri, or C) resourceID set
+ * @return a valid PutFile request if SdlFile contained a fileName and sufficient data
+ */
+ @Override
+ PutFile createPutFile(@NonNull final SdlFile file) {
+ PutFile putFile = new PutFile();
+ if (file.getName() == null) {
+ throw new IllegalArgumentException("You must specify an file name in the SdlFile");
+ } else {
+ putFile.setSdlFileName(file.getName());
+ }
- if(file.getFilePath() != null){
- //Attempt to access the file via a path
- byte[] data = FileUtls.getFileData(file.getFilePath());
- if(data != null ){
- putFile.setFileData(data);
- }else{
- throw new IllegalArgumentException("File at path was empty");
- }
- }else if(file.getURI() != null){
- // Use URI to upload file
- byte[] data = contentsOfUri(file.getURI());
- if(data != null){
- putFile.setFileData(data);
- }else{
- throw new IllegalArgumentException("Uri was empty");
- }
- }else if(file.getFileData() != null){
- // Use file data (raw bytes) to upload file
- putFile.setFileData(file.getFileData());
- }else{
- throw new IllegalArgumentException("The SdlFile to upload does " +
- "not specify its resourceId, Uri, or file data");
- }
+ if (file.getFilePath() != null) {
+ //Attempt to access the file via a path
+ byte[] data = FileUtls.getFileData(file.getFilePath());
+ if (data != null) {
+ putFile.setFileData(data);
+ } else {
+ throw new IllegalArgumentException("File at path was empty");
+ }
+ } else if (file.getURI() != null) {
+ // Use URI to upload file
+ byte[] data = contentsOfUri(file.getURI());
+ if (data != null) {
+ putFile.setFileData(data);
+ } else {
+ throw new IllegalArgumentException("Uri was empty");
+ }
+ } else if (file.getFileData() != null) {
+ // Use file data (raw bytes) to upload file
+ putFile.setFileData(file.getFileData());
+ } else {
+ throw new IllegalArgumentException("The SdlFile to upload does " +
+ "not specify its resourceId, Uri, or file data");
+ }
- if(file.getType() != null){
- putFile.setFileType(file.getType());
- }
- putFile.setPersistentFile(file.isPersistent());
+ if (file.getType() != null) {
+ putFile.setFileType(file.getType());
+ }
+ putFile.setPersistentFile(file.isPersistent());
- return putFile;
- }
+ return putFile;
+ }
- /**
- * Helper method to take Uri and turn it into byte array
- * @param uri Uri for desired file
- * @return Resulting byte array
- */
- private byte[] contentsOfUri(URI uri){
- InputStream is = null;
- try{
- is = uri.toURL().openStream();
- return contentsOfInputStream(is);
- } catch (IOException e){
- DebugTool.logError(TAG, "Can't read from URI", e);
- return null;
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
+ /**
+ * Helper method to take Uri and turn it into byte array
+ *
+ * @param uri Uri for desired file
+ * @return Resulting byte array
+ */
+ private byte[] contentsOfUri(URI uri) {
+ InputStream is = null;
+ try {
+ is = uri.toURL().openStream();
+ return contentsOfInputStream(is);
+ } catch (IOException e) {
+ DebugTool.logError(TAG, "Can't read from URI", e);
+ return null;
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
}
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlArtwork.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlArtwork.java
index eee60bd69..affa4ec36 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlArtwork.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlArtwork.java
@@ -44,20 +44,22 @@ import java.net.URI;
/**
* A class that extends SdlFile, representing artwork (JPEG, PNG, or BMP) to be uploaded to core
*/
-public class SdlArtwork extends SdlFile implements Cloneable{
+public class SdlArtwork extends SdlFile implements Cloneable {
private boolean isTemplate;
private Image imageRPC;
/**
* Creates a new instance of SdlArtwork
*/
- public SdlArtwork(){}
+ public SdlArtwork() {
+ }
/**
* Creates a new instance of SdlArtwork
- * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name
- * @param fileType a FileType enum value representing the type of the file
- * @param filePath a String value representing the the location of the file
+ *
+ * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name
+ * @param fileType a FileType enum value representing the type of the file
+ * @param filePath a String value representing the the location of the file
* @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles
*/
public SdlArtwork(String fileName, @NonNull FileType fileType, String filePath, boolean persistentFile) {
@@ -66,9 +68,10 @@ public class SdlArtwork extends SdlFile implements Cloneable{
/**
* Creates a new instance of SdlArtwork
- * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name
- * @param fileType a FileType enum value representing the type of the file
- * @param uri a URI value representing a file's location. Currently, it only supports local files
+ *
+ * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name
+ * @param fileType a FileType enum value representing the type of the file
+ * @param uri a URI value representing a file's location. Currently, it only supports local files
* @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles
*/
public SdlArtwork(String fileName, @NonNull FileType fileType, URI uri, boolean persistentFile) {
@@ -77,9 +80,10 @@ public class SdlArtwork extends SdlFile implements Cloneable{
/**
* Creates a new instance of SdlArtwork
- * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name
- * @param fileType a FileType enum value representing the type of the file
- * @param data a byte array representing the data of the file
+ *
+ * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name
+ * @param fileType a FileType enum value representing the type of the file
+ * @param data a byte array representing the data of the file
* @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles
*/
public SdlArtwork(String fileName, @NonNull FileType fileType, byte[] data, boolean persistentFile) {
@@ -88,6 +92,7 @@ public class SdlArtwork extends SdlFile implements Cloneable{
/**
* Creates a new instance of SdlArtwork
+ *
* @param staticIconName a StaticIconName enum value representing the name of a static file that comes pre-shipped with the head unit
*/
public SdlArtwork(@NonNull StaticIconName staticIconName) {
@@ -96,33 +101,36 @@ public class SdlArtwork extends SdlFile implements Cloneable{
/**
* Sets whether this SdlArtwork is a template image whose coloring should be decided by the HMI
+ *
* @param isTemplate boolean that tells whether this SdlArtwork is a template image
*/
- public void setTemplateImage(boolean isTemplate){
+ public void setTemplateImage(boolean isTemplate) {
this.isTemplate = isTemplate;
}
/**
* Gets whether this SdlArtwork is a template image whose coloring should be decided by the HMI
+ *
* @return boolean that tells whether this SdlArtwork is a template image
*/
- public boolean isTemplateImage(){
+ public boolean isTemplateImage() {
return isTemplate;
}
@Override
public void setType(@NonNull FileType fileType) {
- if(fileType == null || fileType.equals(FileType.GRAPHIC_JPEG) || fileType.equals(FileType.GRAPHIC_PNG)
- || fileType.equals(FileType.GRAPHIC_BMP)){
+ if (fileType == null || fileType.equals(FileType.GRAPHIC_JPEG) || fileType.equals(FileType.GRAPHIC_PNG)
+ || fileType.equals(FileType.GRAPHIC_BMP)) {
super.setType(fileType);
- }else{
+ } else {
throw new IllegalArgumentException("Only JPEG, PNG, and BMP image types are supported.");
}
}
/**
* Gets the Image RPC representing this artwork. Generally for use internally, you should instead pass an artwork to a Screen Manager method
+ *
* @return The Image RPC representing this artwork.
*/
public Image getImageRPC() {
@@ -132,7 +140,7 @@ public class SdlArtwork extends SdlFile implements Cloneable{
return imageRPC;
}
- private Image createImageRPC(){
+ private Image createImageRPC() {
Image image;
if (isStaticIcon()) {
image = new Image(getName(), ImageType.STATIC);
@@ -146,18 +154,19 @@ public class SdlArtwork extends SdlFile implements Cloneable{
/**
* Creates a deep copy of the object
+ *
* @return deep copy of the object
*/
@Override
public SdlArtwork clone() {
- try{
+ try {
SdlArtwork artwork = (SdlArtwork) super.clone();
- if(artwork != null){
+ if (artwork != null) {
artwork.imageRPC = artwork.createImageRPC();
}
return artwork;
} catch (CloneNotSupportedException e) {
- if(DebugTool.isDebugEnabled()){
+ if (DebugTool.isDebugEnabled()) {
throw new RuntimeException("Clone not supported by super class");
}
}
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java
index 10e400f40..6fd91b8a0 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java
@@ -44,7 +44,7 @@ import java.util.Arrays;
/**
* A class representing data to be uploaded to core
*/
-public class SdlFile{
+public class SdlFile {
private String fileName;
private String filePath;
private URI uri;
@@ -59,16 +59,18 @@ public class SdlFile{
/**
* Creates a new instance of SdlFile
*/
- public SdlFile(){}
+ public SdlFile() {
+ }
/**
* Creates a new instance of SdlFile
- * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name
- * @param fileType a FileType enum value representing the type of the file
- * @param filePath a String value representing the the location of the file
+ *
+ * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name
+ * @param fileType a FileType enum value representing the type of the file
+ * @param filePath a String value representing the the location of the file
* @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles
*/
- public SdlFile(String fileName, @NonNull FileType fileType, String filePath, boolean persistentFile){
+ public SdlFile(String fileName, @NonNull FileType fileType, String filePath, boolean persistentFile) {
setName(fileName);
setType(fileType);
setFilePath(filePath);
@@ -77,12 +79,13 @@ public class SdlFile{
/**
* Creates a new instance of SdlFile
- * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name
- * @param fileType a FileType enum value representing the type of the file
- * @param uri a URI value representing a file's location. Currently, it only supports local files
+ *
+ * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name
+ * @param fileType a FileType enum value representing the type of the file
+ * @param uri a URI value representing a file's location. Currently, it only supports local files
* @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles
*/
- public SdlFile(String fileName, @NonNull FileType fileType, URI uri, boolean persistentFile){
+ public SdlFile(String fileName, @NonNull FileType fileType, URI uri, boolean persistentFile) {
setName(fileName);
setType(fileType);
setURI(uri);
@@ -91,12 +94,13 @@ public class SdlFile{
/**
* Creates a new instance of SdlFile
- * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name
- * @param fileType a FileType enum value representing the type of the file
- * @param data a byte array representing the data of the file
+ *
+ * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name
+ * @param fileType a FileType enum value representing the type of the file
+ * @param data a byte array representing the data of the file
* @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles
*/
- public SdlFile(String fileName, @NonNull FileType fileType, byte[] data, boolean persistentFile){
+ public SdlFile(String fileName, @NonNull FileType fileType, byte[] data, boolean persistentFile) {
setName(fileName);
setType(fileType);
setFileData(data);
@@ -105,9 +109,10 @@ public class SdlFile{
/**
* Creates a new instance of SdlFile
+ *
* @param staticIconName a StaticIconName enum value representing the name of a static file that comes pre-shipped with the head unit
*/
- public SdlFile(@NonNull StaticIconName staticIconName){
+ public SdlFile(@NonNull StaticIconName staticIconName) {
setName(staticIconName.toString());
setFileData(staticIconName.toString().getBytes());
setPersistent(false);
@@ -116,6 +121,7 @@ public class SdlFile{
/**
* Sets the name of the file
+ *
* @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name
*/
public void setName(String fileName) {
@@ -136,17 +142,19 @@ public class SdlFile{
/**
* Gets the name of the file
+ *
* @return a String value representing the name that will be used to store the file in the head unit
*/
- public String getName(){
+ public String getName() {
return fileName;
}
/**
* Sets the location of the file
+ *
* @param filePath a String value representing the the location of the file
*/
- public void setFilePath(String filePath){
+ public void setFilePath(String filePath) {
this.filePath = filePath;
if (shouldAutoGenerateName && filePath != null) {
this.fileName = generateFileNameFromFilePath(filePath);
@@ -155,17 +163,19 @@ public class SdlFile{
/**
* Gets the location of the file
+ *
* @return represents the path of the file
*/
- public String getFilePath(){
+ public String getFilePath() {
return this.filePath;
}
/**
* Sets the uri of the file
+ *
* @param uri a URI value representing a file's location. Currently, it only supports local files
*/
- public void setURI(URI uri){
+ public void setURI(URI uri) {
this.uri = uri;
if (shouldAutoGenerateName && uri != null) {
this.fileName = generateFileNameFromUri(uri);
@@ -174,17 +184,19 @@ public class SdlFile{
/**
* Gets the uri of the file
+ *
* @return a URI value representing a file's location. Currently, it only supports local files
*/
- public URI getURI(){
+ public URI getURI() {
return uri;
}
/**
* Sets the byte array that represents the content of the file
+ *
* @param data a byte array representing the data of the file
*/
- public void setFileData(byte[] data){
+ public void setFileData(byte[] data) {
this.fileData = data;
if (shouldAutoGenerateName && data != null) {
this.fileName = generateFileNameFromData(data);
@@ -193,46 +205,52 @@ public class SdlFile{
/**
* Gets the byte array that represents the content of the file
+ *
* @return a byte array representing the data of the file
*/
- public byte[] getFileData(){
+ public byte[] getFileData() {
return fileData;
}
/**
* Sets the type of the file
+ *
* @param fileType a FileType enum value representing the type of the file
*/
- public void setType(@NonNull FileType fileType){
+ public void setType(@NonNull FileType fileType) {
this.fileType = fileType;
}
/**
* Gets the type of the file
+ *
* @return a FileType enum value representing the type of the file
*/
- public FileType getType(){
+ public FileType getType() {
return fileType;
}
/**
* Sets whether the file should persist between sessions / ignition cycles
+ *
* @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles
*/
- public void setPersistent(boolean persistentFile){
+ public void setPersistent(boolean persistentFile) {
this.persistentFile = persistentFile;
}
/**
* Gets whether the file should persist between sessions / ignition cycles
+ *
* @return a boolean value that indicates if the file is meant to persist between sessions / ignition cycles
*/
- public boolean isPersistent(){
+ public boolean isPersistent() {
return this.persistentFile;
}
/**
* Sets the the name of the static file. Static files comes pre-shipped with the head unit
+ *
* @param staticIcon a StaticIconName enum value representing the name of a static file that comes pre-shipped with the head unit
*/
public void setStaticIcon(boolean staticIcon) {
@@ -241,6 +259,7 @@ public class SdlFile{
/**
* Gets the the name of the static file. Static files comes pre-shipped with the head unit
+ *
* @return a StaticIconName enum value representing the name of a static file that comes pre-shipped with the head unit
*/
public boolean isStaticIcon() {
@@ -249,6 +268,7 @@ public class SdlFile{
/**
* Gets the overwrite property for an SdlFile by default its set to true
+ *
* @return a boolean value that indicates if a file can be overwritten.
*/
public boolean getOverwrite() {
@@ -257,6 +277,7 @@ public class SdlFile{
/**
* Sets the overwrite property for an SdlFile by default its set to true
+ *
* @param overwrite a boolean value that indicates if a file can be overwritten
*/
public void setOverwrite(boolean overwrite) {
@@ -265,6 +286,7 @@ public class SdlFile{
/**
* Generates a file name from data by hashing the data and returning the last 16 chars
+ *
* @param data a byte array representing the data of the file
* @return a String value representing the name that will be used to store the file in the head unit
*/
@@ -292,6 +314,7 @@ public class SdlFile{
/**
* Generates a file name from filePath by hashing the filePath and returning the last 16 chars
+ *
* @param filePath a String value representing the the location of the file
* @return a String value representing the name that will be used to store the file in the head unit
*/
@@ -301,6 +324,7 @@ public class SdlFile{
/**
* Generates a file name from uri by hashing the uri string and returning the last 16 chars
+ *
* @param uri a URI value representing a file's location
* @return a String value representing the name that will be used to store the file in the head unit
*/
@@ -310,6 +334,7 @@ public class SdlFile{
/**
* Used to compile hashcode for SdlFile for use to compare in equals method
+ *
* @return Custom hashcode of SdlFile variables
*/
@Override
@@ -327,6 +352,7 @@ public class SdlFile{
/**
* Uses our custom hashCode for SdlFile objects
+ *
* @param o - The object to compare
* @return boolean of whether the objects are the same or not
*/
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/EncryptionLifecycleManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/EncryptionLifecycleManager.java
index d749811a1..a23a057c5 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/EncryptionLifecycleManager.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/EncryptionLifecycleManager.java
@@ -34,8 +34,8 @@ package com.smartdevicelink.managers.lifecycle;
import androidx.annotation.NonNull;
-import com.smartdevicelink.managers.ServiceEncryptionListener;
import com.smartdevicelink.managers.ISdl;
+import com.smartdevicelink.managers.ServiceEncryptionListener;
class EncryptionLifecycleManager extends BaseEncryptionLifecycleManager {
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java
index 89c9f3190..e29d34640 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java
@@ -34,9 +34,9 @@ package com.smartdevicelink.managers.lifecycle;
import androidx.annotation.RestrictTo;
-import com.smartdevicelink.session.SdlSession;
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason;
+import com.smartdevicelink.session.SdlSession;
import com.smartdevicelink.transport.BaseTransportConfig;
/**
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManager.java
index e10693770..4ca79c893 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManager.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManager.java
@@ -35,7 +35,7 @@ import com.smartdevicelink.managers.ISdl;
/**
* <strong>SystemCapabilityManager</strong> <br>
- *
+ * <p>
* Note: This class must be accessed through the SdlManager. Do not instantiate it by itself. <br>
*/
public class SystemCapabilityManager extends BaseSystemCapabilityManager {
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/permission/PermissionManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/permission/PermissionManager.java
index 141e16151..ffecb9fdd 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/permission/PermissionManager.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/permission/PermissionManager.java
@@ -37,13 +37,13 @@ import androidx.annotation.RestrictTo;
import com.smartdevicelink.managers.ISdl;
/**
- PermissionManager gives the developer information about what permissions are permitted in specific HMI level
- and helps developers setup listeners to be called when specific permissions become allowed.<br>
+ * PermissionManager gives the developer information about what permissions are permitted in specific HMI level
+ * and helps developers setup listeners to be called when specific permissions become allowed.<br>
+ * <p>
+ * This should be used through the {@link com.smartdevicelink.managers.SdlManager} and not be instantiated by itself
+ **/
- This should be used through the {@link com.smartdevicelink.managers.SdlManager} and not be instantiated by itself
-**/
-
- public class PermissionManager extends BasePermissionManager{
+public class PermissionManager extends BasePermissionManager {
/**
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/ScreenManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/ScreenManager.java
index d1f6811ac..2e0b0e244 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/ScreenManager.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/ScreenManager.java
@@ -34,18 +34,18 @@ package com.smartdevicelink.managers.screen;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
-import com.smartdevicelink.managers.file.FileManager;
import com.smartdevicelink.managers.ISdl;
+import com.smartdevicelink.managers.file.FileManager;
/**
* <strong>ScreenManager</strong> <br>
- *
+ * <p>
* Note: This class must be accessed through the SdlManager. Do not instantiate it by itself. <br>
-*/
+ */
public class ScreenManager extends BaseScreenManager {
- @RestrictTo(RestrictTo.Scope.LIBRARY)
- public ScreenManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager) {
- super(internalInterface, fileManager);
- }
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ public ScreenManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager) {
+ super(internalInterface, fileManager);
+ }
}
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/SoftButtonManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/SoftButtonManager.java
index 7f67faa47..e01ab736a 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/SoftButtonManager.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/SoftButtonManager.java
@@ -34,8 +34,8 @@ package com.smartdevicelink.managers.screen;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
-import com.smartdevicelink.managers.file.FileManager;
import com.smartdevicelink.managers.ISdl;
+import com.smartdevicelink.managers.file.FileManager;
/**
* <strong>SoftButtonManager</strong> <br>
@@ -49,7 +49,7 @@ class SoftButtonManager extends BaseSoftButtonManager {
* Creates a new instance of the SoftButtonManager
*
* @param internalInterface an instance of the ISdl interface that can be used for common SDL operations (sendRpc, addRpcListener, etc)
- * @param fileManager an instance of the FileManager so that button graphics can be sent
+ * @param fileManager an instance of the FileManager so that button graphics can be sent
*/
SoftButtonManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager) {
super(internalInterface, fileManager);
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/SubscribeButtonManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/SubscribeButtonManager.java
index b14ad987c..a77eb43cf 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/SubscribeButtonManager.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/SubscribeButtonManager.java
@@ -7,9 +7,8 @@ import com.smartdevicelink.managers.ISdl;
/**
* <strong>SubscribeButtonManager</strong> <br>
- *
+ * <p>
* Note: This class must be accessed through the SdlManager. Do not instantiate it by itself. <br>
- *
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public class SubscribeButtonManager extends BaseSubscribeButtonManager {
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java
index d5ff0f52f..b479e3ba5 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java
@@ -34,32 +34,31 @@ package com.smartdevicelink.managers.screen;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import com.smartdevicelink.managers.ISdl;
import com.smartdevicelink.managers.file.FileManager;
import com.smartdevicelink.managers.file.filetypes.SdlArtwork;
-import com.smartdevicelink.managers.ISdl;
import com.smartdevicelink.proxy.rpc.enums.FileType;
/**
* <strong>TextAndGraphicManager</strong> <br>
- *
+ * <p>
* Note: This class must be accessed through the SdlManager. Do not instantiate it by itself. <br>
- *
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
class TextAndGraphicManager extends BaseTextAndGraphicManager {
- TextAndGraphicManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager, @NonNull SoftButtonManager softButtonManager) {
- super(internalInterface, fileManager, softButtonManager);
- }
-
- @Override
- SdlArtwork getBlankArtwork(){
- if (blankArtwork == null){
- blankArtwork = new SdlArtwork();
- blankArtwork.setType(FileType.GRAPHIC_PNG);
- blankArtwork.setName("blankArtwork");
- blankArtwork.setFileData(new byte[50]);
- }
- return blankArtwork;
- }
+ TextAndGraphicManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager, @NonNull SoftButtonManager softButtonManager) {
+ super(internalInterface, fileManager, softButtonManager);
+ }
+
+ @Override
+ SdlArtwork getBlankArtwork() {
+ if (blankArtwork == null) {
+ blankArtwork = new SdlArtwork();
+ blankArtwork.setType(FileType.GRAPHIC_PNG);
+ blankArtwork.setName("blankArtwork");
+ blankArtwork.setFileData(new byte[50]);
+ }
+ return blankArtwork;
+ }
}
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManager.java
index ebcfa9c10..887d40e94 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManager.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManager.java
@@ -35,8 +35,8 @@ package com.smartdevicelink.managers.screen.choiceset;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
-import com.smartdevicelink.managers.file.FileManager;
import com.smartdevicelink.managers.ISdl;
+import com.smartdevicelink.managers.file.FileManager;
/**
* <strong>ChoiceSetManager</strong> <br>
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/MenuManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/MenuManager.java
index 6a51ddd65..ef4583968 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/MenuManager.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/MenuManager.java
@@ -34,22 +34,22 @@ package com.smartdevicelink.managers.screen.menu;
import androidx.annotation.RestrictTo;
-import com.smartdevicelink.managers.file.FileManager;
import com.smartdevicelink.managers.ISdl;
+import com.smartdevicelink.managers.file.FileManager;
/**
* <strong>MenuManager</strong> <br>
- *
+ * <p>
* Note: This class must be accessed through the ScreenManager via the SdlManager. Do not instantiate it by itself. <br>
- *
+ * <p>
* The MenuManager takes MenuCell objects and creates and sends all necessary RPCs to build out a menu
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public class MenuManager extends BaseMenuManager {
- public MenuManager(ISdl internalInterface, FileManager fileManager) {
- // setup
- super(internalInterface, fileManager);
- }
+ public MenuManager(ISdl internalInterface, FileManager fileManager) {
+ // setup
+ super(internalInterface, fileManager);
+ }
}
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/VoiceCommandManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/VoiceCommandManager.java
index 641ab189e..40e2d27d7 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/VoiceCommandManager.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/VoiceCommandManager.java
@@ -38,17 +38,17 @@ import com.smartdevicelink.managers.ISdl;
/**
* <strong>VoiceCommandManager</strong> <br>
- *
+ * <p>
* Note: This class must be accessed through the ScreenManager via the SdlManager. Do not instantiate it by itself. <br>
- *
+ * <p>
* The VoiceCommandManager takes a List of VoiceCommand objects and sets them on the Head unit for you.
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public class VoiceCommandManager extends BaseVoiceCommandManager {
- public VoiceCommandManager(ISdl internalInterface) {
- // setup
- super(internalInterface);
- }
+ public VoiceCommandManager(ISdl internalInterface) {
+ // setup
+ super(internalInterface);
+ }
}
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/protocol/SdlPacket.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/protocol/SdlPacket.java
index 0c9481c2d..df4144286 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/protocol/SdlPacket.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/protocol/SdlPacket.java
@@ -48,7 +48,7 @@ public class SdlPacket extends BaseSdlPacket {
super(version, encryption, frameType, serviceType, frameInfo, sessionId, dataSize, messageId, payload, offset, bytesToWrite);
}
- protected SdlPacket() {
+ protected SdlPacket() {
super();
}
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java
index 64cd728ca..a83cdf0e0 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java
@@ -43,11 +43,10 @@ import com.smartdevicelink.transport.TransportManager;
@RestrictTo(RestrictTo.Scope.LIBRARY)
public class SdlProtocol extends SdlProtocolBase {
- public SdlProtocol( ISdlProtocol iSdlProtocol, BaseTransportConfig config) {
+ public SdlProtocol(ISdlProtocol iSdlProtocol, BaseTransportConfig config) {
super(iSdlProtocol, config);
this.setTransportManager(new TransportManager(config, transportEventListener));
}
-
}
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/security/SdlSecurityBase.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/security/SdlSecurityBase.java
index e8ed85b70..0d1f2d72a 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/security/SdlSecurityBase.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/security/SdlSecurityBase.java
@@ -14,7 +14,7 @@
* distribution.
*
* Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
+ * contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
@@ -32,5 +32,5 @@
package com.smartdevicelink.security;
public abstract class SdlSecurityBase extends AbstractSdlSecurityBase {
-
+
}
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/session/SdlSession.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/session/SdlSession.java
index 4aaef8985..ba92df647 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/session/SdlSession.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/session/SdlSession.java
@@ -35,11 +35,11 @@ package com.smartdevicelink.session;
import androidx.annotation.RestrictTo;
+import com.smartdevicelink.protocol.ISdlServiceListener;
import com.smartdevicelink.protocol.SdlPacket;
import com.smartdevicelink.protocol.SdlProtocol;
import com.smartdevicelink.protocol.SdlProtocolBase;
import com.smartdevicelink.protocol.enums.SessionType;
-import com.smartdevicelink.protocol.ISdlServiceListener;
import com.smartdevicelink.transport.BaseTransportConfig;
import com.smartdevicelink.util.DebugTool;
import com.smartdevicelink.util.Version;
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/trace/SdlTrace.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/trace/SdlTrace.java
index 482b4a846..987dbc223 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/trace/SdlTrace.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/trace/SdlTrace.java
@@ -14,7 +14,7 @@
* distribution.
*
* Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
+ * contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
@@ -40,9 +40,9 @@ package com.smartdevicelink.trace;
It is manifested in the <SmartDeviceLink>...</SmartDeviceLink> tags
*/
-public class SdlTrace extends SdlTraceBase{
- private static String getPid(){
- //Default implementation is not able to get this information
- return "UNKNOWN";
- }
+public class SdlTrace extends SdlTraceBase {
+ private static String getPid() {
+ //Default implementation is not able to get this information
+ return "UNKNOWN";
+ }
} // end-class \ No newline at end of file
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransport.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransport.java
index ad02f96d2..5bb61e7d3 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransport.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransport.java
@@ -39,7 +39,7 @@ import com.smartdevicelink.util.DebugTool;
import java.nio.ByteBuffer;
-public abstract class CustomTransport implements TransportInterface{
+public abstract class CustomTransport implements TransportInterface {
private static final String TAG = "CustomTransport";
final TransportRecord transportRecord;
@@ -47,27 +47,27 @@ public abstract class CustomTransport implements TransportInterface{
TransportCallback transportCallback;
-
public CustomTransport(String address) {
//Creates a callback for when packets
psm = new SdlPsm();
- transportRecord = new TransportRecord(TransportType.CUSTOM,address);
+ transportRecord = new TransportRecord(TransportType.CUSTOM, address);
}
- public TransportRecord getTransportRecord(){
+ public TransportRecord getTransportRecord() {
return this.transportRecord;
}
/**
* Call this method when reading a byte array off the transport
+ *
* @param bytes the bytes read off the transport
*/
- public synchronized void onByteArrayReceived (byte[] bytes, int offset, int length) {
+ public synchronized void onByteArrayReceived(byte[] bytes, int offset, int length) {
- if(bytes != null && bytes.length > 0){
+ if (bytes != null && bytes.length > 0) {
boolean stateProgress;
- for(int i = 0; i < length; i++){
+ for (int i = 0; i < length; i++) {
stateProgress = psm.handleByte(bytes[i]);
if (!stateProgress) {//We are trying to weed through the bad packet info until we get something
//Log.w(TAG, "Packet State Machine did not move forward from state - "+ psm.getState()+". PSM being Reset.");
@@ -90,10 +90,11 @@ public abstract class CustomTransport implements TransportInterface{
/**
* Call this method when reading a ByteBuffer off the transport
+ *
* @param message the byte buffer that was read off the transport
*/
- public synchronized void onByteBufferReceived (ByteBuffer message) {
- if(message != null){
+ public synchronized void onByteBufferReceived(ByteBuffer message) {
+ if (message != null) {
boolean stateProgress;
while (message.hasRemaining()) {
stateProgress = psm.handleByte(message.get());
@@ -134,7 +135,7 @@ public abstract class CustomTransport implements TransportInterface{
@Override
public void write(SdlPacket packet) {
byte[] bytes = packet.constructPacket();
- if(bytes != null && bytes.length > 0) {
+ if (bytes != null && bytes.length > 0) {
try {
onWrite(bytes, 0, bytes.length);
} catch (Exception exc) {
@@ -148,7 +149,7 @@ public abstract class CustomTransport implements TransportInterface{
this.transportCallback = transportCallback;
}
- public void onError(){
+ public void onError() {
if (transportCallback != null) {
transportCallback.onError();
}
@@ -158,14 +159,12 @@ public abstract class CustomTransport implements TransportInterface{
/**
* Integrator should write out these bytes to whatever actual transport there is. This will be called from the
* internals of the library.
- * @param bytes a deconstructed packet into a byte array that needs to be written out
+ *
+ * @param bytes a deconstructed packet into a byte array that needs to be written out
* @param offset in bytes
* @param length in bytes
*/
public abstract void onWrite(byte[] bytes, int offset, int length);
-
-
-
}
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransportConfig.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransportConfig.java
index af0613aa1..ee82c68d7 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransportConfig.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransportConfig.java
@@ -38,7 +38,7 @@ public class CustomTransportConfig extends BaseTransportConfig {
final CustomTransport customTransport;
- public CustomTransportConfig(CustomTransport customTransport){
+ public CustomTransportConfig(CustomTransport customTransport) {
this.customTransport = customTransport;
}
@@ -47,7 +47,7 @@ public class CustomTransportConfig extends BaseTransportConfig {
return TransportType.CUSTOM;
}
- public TransportInterface getTransportInterface(){
+ public TransportInterface getTransportInterface() {
return this.customTransport;
}
}
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportCallback.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportCallback.java
index 551ed9d29..327b4dd5c 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportCallback.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportCallback.java
@@ -14,7 +14,7 @@
* distribution.
*
* Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
+ * contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
@@ -38,7 +38,10 @@ import com.smartdevicelink.protocol.SdlPacket;
*/
public interface TransportCallback {
void onConnectionEstablished();
+
void onError();
+
void onConnectionTerminated(String reason);
+
void onPacketReceived(SdlPacket packet);
} \ No newline at end of file
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportInterface.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportInterface.java
index 989b2df33..e9fdaf4c6 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportInterface.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportInterface.java
@@ -40,8 +40,12 @@ import com.smartdevicelink.transport.utl.TransportRecord;
*/
public interface TransportInterface {
void start();
+
void stop();
+
void write(SdlPacket packet);
+
void setCallback(TransportCallback callback);
+
TransportRecord getTransportRecord();
} \ No newline at end of file
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportManager.java
index ee08f19de..69a8de75a 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportManager.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportManager.java
@@ -41,7 +41,7 @@ import com.smartdevicelink.util.DebugTool;
import java.util.Collections;
import java.util.List;
-public class TransportManager extends TransportManagerBase{
+public class TransportManager extends TransportManagerBase {
private static final String TAG = "TransportManager";
TransportInterface transport;
@@ -52,13 +52,13 @@ public class TransportManager extends TransportManagerBase{
* If transport is not connected. Request Router service connect to it. Get connected message
*/
- public TransportManager(BaseTransportConfig config, TransportEventListener listener){
+ public TransportManager(BaseTransportConfig config, TransportEventListener listener) {
super(config, listener);
//Start the new transport
- switch (config.getTransportType()){
+ switch (config.getTransportType()) {
case WEB_SOCKET_SERVER:
- transport = new WebSocketServer((WebSocketServerConfig)config, new SingleTransportCallbackImpl(new TransportRecord(TransportType.WEB_SOCKET_SERVER,"127.0.0.1:"+((WebSocketServerConfig)config).port)));
+ transport = new WebSocketServer((WebSocketServerConfig) config, new SingleTransportCallbackImpl(new TransportRecord(TransportType.WEB_SOCKET_SERVER, "127.0.0.1:" + ((WebSocketServerConfig) config).port)));
break;
case CUSTOM:
transport = ((CustomTransportConfig) config).getTransportInterface();
@@ -69,32 +69,33 @@ public class TransportManager extends TransportManagerBase{
}
@Override
- public void start(){
- if(transport != null){
+ public void start() {
+ if (transport != null) {
transport.start();
- }else{
+ } else {
System.out.print("Unable to start transport.");
}
}
@Override
- public void close(long sessionId){
- if(transport != null) {
+ public void close(long sessionId) {
+ if (transport != null) {
transport.stop();
}
}
/**
* Check to see if a transport is connected.
+ *
* @param transportType the transport to have its connection status returned. If `null` is
* passed in, all transports will be checked and if any are connected a
* true value will be returned.
- * @param address the address associated with the transport type. If null, the first transport
- * of supplied type will be used to return if connected.
+ * @param address the address associated with the transport type. If null, the first transport
+ * of supplied type will be used to return if connected.
* @return if a transport is connected based on included variables
*/
@Override
- public boolean isConnected(TransportType transportType, String address){
+ public boolean isConnected(TransportType transportType, String address) {
synchronized (TRANSPORT_STATUS_LOCK) {
if (transportType == null) {
return !transportStatus.isEmpty();
@@ -114,15 +115,17 @@ public class TransportManager extends TransportManagerBase{
return false;
}
}
+
/**
* Retrieve a transport record with the supplied params
+ *
* @param transportType the transport to have its connection status returned.
- * @param address the address associated with the transport type. If null, the first transport
- * of supplied type will be returned.
+ * @param address the address associated with the transport type. If null, the first transport
+ * of supplied type will be returned.
* @return the transport record for the transport type and address if supplied
*/
@Override
- public TransportRecord getTransportRecord(TransportType transportType, String address){
+ public TransportRecord getTransportRecord(TransportType transportType, String address) {
synchronized (TRANSPORT_STATUS_LOCK) {
if (transportType == null) {
return null;
@@ -145,26 +148,27 @@ public class TransportManager extends TransportManagerBase{
@Override
- public void sendPacket(SdlPacket packet){
- if(transport !=null){
+ public void sendPacket(SdlPacket packet) {
+ if (transport != null) {
transport.write(packet);
- }else {
+ } else {
}
}
- class SingleTransportCallbackImpl implements TransportCallback {
+ class SingleTransportCallbackImpl implements TransportCallback {
final List<TransportRecord> finalList;
final TransportRecord record;
- protected SingleTransportCallbackImpl(TransportRecord transportRecord){
- record = transportRecord;
- finalList = Collections.singletonList(record);
+
+ protected SingleTransportCallbackImpl(TransportRecord transportRecord) {
+ record = transportRecord;
+ finalList = Collections.singletonList(record);
}
@Override
public void onConnectionEstablished() {
- synchronized (TRANSPORT_STATUS_LOCK){
+ synchronized (TRANSPORT_STATUS_LOCK) {
transportStatus.clear();
transportStatus.addAll(finalList);
}
@@ -174,21 +178,21 @@ public class TransportManager extends TransportManagerBase{
@Override
public void onError() {
DebugTool.logError(TAG, "Error in the transport manager from the web socket server");
- if(transportListener != null){
+ if (transportListener != null) {
transportListener.onError("");
}
}
@Override
public void onConnectionTerminated(String reason) {
- if(record != null){
+ if (record != null) {
DebugTool.logInfo(TAG, "Transport disconnected - " + record);
- }else{
+ } else {
DebugTool.logInfo(TAG, "Transport disconnected");
}
- synchronized (TRANSPORT_STATUS_LOCK){
+ synchronized (TRANSPORT_STATUS_LOCK) {
TransportManager.this.transportStatus.remove(record);
//Might check connectedTransports vs transportStatus to ensure they are equal
}
@@ -198,7 +202,7 @@ public class TransportManager extends TransportManagerBase{
@Override
public void onPacketReceived(SdlPacket packet) {
- if(packet!=null){
+ if (packet != null) {
transportListener.onPacketReceived(packet);
}
}
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServer.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServer.java
index 65037f6b8..d98acff2c 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServer.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServer.java
@@ -45,7 +45,7 @@ import org.java_websocket.handshake.ClientHandshake;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
-public class WebSocketServer extends org.java_websocket.server.WebSocketServer implements TransportInterface{
+public class WebSocketServer extends org.java_websocket.server.WebSocketServer implements TransportInterface {
private static final String TAG = "WebSocketServer";
final TransportCallback callback;
final WebSocketServerConfig config;
@@ -54,31 +54,31 @@ public class WebSocketServer extends org.java_websocket.server.WebSocketServer i
final TransportRecord transportRecord;
- public WebSocketServer(WebSocketServerConfig config, TransportCallback callback){
+ public WebSocketServer(WebSocketServerConfig config, TransportCallback callback) {
super((new InetSocketAddress(config.port)));
this.config = config;
this.callback = callback;
- transportRecord = new TransportRecord(TransportType.WEB_SOCKET_SERVER,"127.0.0.1:" + config.port); //If changed, change in transport manager as well
+ transportRecord = new TransportRecord(TransportType.WEB_SOCKET_SERVER, "127.0.0.1:" + config.port); //If changed, change in transport manager as well
//This will set the connection lost timeout to not occur. So we might ping, but not pong
this.setConnectionLostTimeout(config.connectionLostTimeout);
- if(config.getSslConfig() != null){
+ if (config.getSslConfig() != null) {
WebSocketServerFactory factory = SSLWebSocketFactoryGenerator.generateWebSocketServer(config.getSslConfig());
- if(factory!=null){
+ if (factory != null) {
this.setWebSocketFactory(factory);
- }else{
+ } else {
DebugTool.logError(TAG, "WebSocketServer: Unable to generate SSL Web Socket Server Factory");
}
}
}
- public TransportRecord getTransportRecord(){
+ public TransportRecord getTransportRecord() {
return this.transportRecord;
}
@Override
- public void stop(){
+ public void stop() {
try {
this.stop(500);
} catch (InterruptedException e) {
@@ -87,9 +87,9 @@ public class WebSocketServer extends org.java_websocket.server.WebSocketServer i
}
@Override
- public void write(SdlPacket packet){
+ public void write(SdlPacket packet) {
//DebugTool.logInfo(TAG, "Attempt to write packet " + packet);
- if(packet != null
+ if (packet != null
&& this.webSocket != null
&& this.webSocket.isOpen()) {
this.webSocket.send(packet.constructPacket());
@@ -107,7 +107,7 @@ public class WebSocketServer extends org.java_websocket.server.WebSocketServer i
DebugTool.logInfo(TAG, "onOpen");
this.webSocket = webSocket;
- if(callback!=null){
+ if (callback != null) {
callback.onConnectionEstablished();
}
}
@@ -115,15 +115,15 @@ public class WebSocketServer extends org.java_websocket.server.WebSocketServer i
@Override
public void onClose(WebSocket webSocket, int i, String s, boolean b) {
DebugTool.logInfo(TAG, "onClose");
- try{
+ try {
DebugTool.logInfo(TAG, "Closing id - " + i);
DebugTool.logInfo(TAG, "Closing string - " + s);
DebugTool.logInfo(TAG, "Closing from remote? " + b);
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
}
- if(callback!=null) {
+ if (callback != null) {
callback.onConnectionTerminated(s);
}
}
@@ -132,9 +132,10 @@ public class WebSocketServer extends org.java_websocket.server.WebSocketServer i
@Override
public void onWebsocketCloseInitiated(WebSocket conn, int code, String reason) {
super.onWebsocketCloseInitiated(conn, code, reason);
- try{
+ try {
DebugTool.logInfo(TAG, "Code - " + code + " Reason - " + reason);
- }catch (Exception e){}
+ } catch (Exception e) {
+ }
}
@Override
@@ -148,7 +149,7 @@ public class WebSocketServer extends org.java_websocket.server.WebSocketServer i
//DebugTool.logInfo(TAG, "on Message - ByteBuffer");
byte input;
- if(message != null){
+ if (message != null) {
synchronized (WebSocketServer.this) {
boolean stateProgress;
while (message.hasRemaining()) {
@@ -164,7 +165,7 @@ public class WebSocketServer extends org.java_websocket.server.WebSocketServer i
synchronized (WebSocketServer.this) {
SdlPacket packet = psm.getFormedPacket();
if (callback != null && packet != null) {
- /// DebugTool.logInfo(TAG, "Read a packet: " + packet);
+ /// DebugTool.logInfo(TAG, "Read a packet: " + packet);
packet.setTransportRecord(transportRecord);
callback.onPacketReceived(packet);
}
@@ -180,11 +181,10 @@ public class WebSocketServer extends org.java_websocket.server.WebSocketServer i
}
-
@Override
public void onError(WebSocket webSocket, Exception e) {
DebugTool.logError(TAG, "bad", e);
- if(callback!=null) {
+ if (callback != null) {
callback.onError();
}
}
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServerConfig.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServerConfig.java
index 316375bf3..9dc4dab9c 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServerConfig.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServerConfig.java
@@ -34,17 +34,19 @@ package com.smartdevicelink.transport;
import com.smartdevicelink.transport.enums.TransportType;
import com.smartdevicelink.transport.utl.SSLConfig;
-public class WebSocketServerConfig extends BaseTransportConfig{
+public class WebSocketServerConfig extends BaseTransportConfig {
final int port, connectionLostTimeout;
SSLConfig sslConfig;
+
/**
* Default constructor for WebSocketConfig
- * @param port the port this web socket should listen on
+ *
+ * @param port the port this web socket should listen on
* @param connectionLostTimeout the timeout for a connection lost, default would be 60 seconds. If a value less than
* 0 is used, then the web socket will wait indefinitely.
*/
- public WebSocketServerConfig(int port, int connectionLostTimeout){
+ public WebSocketServerConfig(int port, int connectionLostTimeout) {
this.port = port;
this.connectionLostTimeout = connectionLostTimeout;
}
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLConfig.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLConfig.java
index e2eb1c2b0..92e703996 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLConfig.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLConfig.java
@@ -42,12 +42,15 @@ public class SSLConfig {
@IntDef({JKS, PEM})
@Retention(RetentionPolicy.SOURCE)
- public @interface SSLCertificateType {}
+ public @interface SSLCertificateType {
+ }
+
public static final int JKS = 0;
public static final int PEM = 1;
- final @SSLCertificateType int sslCertificateType;
+ final @SSLCertificateType
+ int sslCertificateType;
String pemCertificate, privateKey, password;
String storePassword, keyPassword;
File jksFile;
@@ -55,11 +58,12 @@ public class SSLConfig {
/**
* This creates an SSLConfig using a PEM type certificate.
+ *
* @param pemCertificate string representation of a PEM file that should be used for the SSL session
- * @param privateKey the private key used with the PEM file
- * @param password the password used with the PEN file
+ * @param privateKey the private key used with the PEM file
+ * @param password the password used with the PEN file
*/
- public SSLConfig(@NonNull String pemCertificate, @NonNull String privateKey, @NonNull String password){
+ public SSLConfig(@NonNull String pemCertificate, @NonNull String privateKey, @NonNull String password) {
this.sslCertificateType = PEM;
this.pemCertificate = pemCertificate;
this.privateKey = privateKey;
@@ -69,18 +73,20 @@ public class SSLConfig {
/**
* This creates an SSLConfig using a JKS file.
- * @param jksFile File that contains the JKS that should be used for the SSL session
+ *
+ * @param jksFile File that contains the JKS that should be used for the SSL session
* @param storePassword the password associated with the JKS
- * @param keyPassword the key password used with the JKS
+ * @param keyPassword the key password used with the JKS
*/
- public SSLConfig(@NonNull File jksFile, @NonNull String storePassword, @NonNull String keyPassword){
+ public SSLConfig(@NonNull File jksFile, @NonNull String storePassword, @NonNull String keyPassword) {
this.sslCertificateType = JKS;
this.jksFile = jksFile;
this.storePassword = storePassword;
this.keyPassword = keyPassword;
}
- public @SSLCertificateType int getSslCertificateType() {
+ public @SSLCertificateType
+ int getSslCertificateType() {
return sslCertificateType;
}
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLWebSocketFactoryGenerator.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLWebSocketFactoryGenerator.java
index 4bcb9ca8d..7ba8957e0 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLWebSocketFactoryGenerator.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLWebSocketFactoryGenerator.java
@@ -62,9 +62,9 @@ public class SSLWebSocketFactoryGenerator {
private static final String TLS = "TLS";
private static final String SUNX509 = "SunX509";
- public static WebSocketServerFactory generateWebSocketServer(SSLConfig config){
+ public static WebSocketServerFactory generateWebSocketServer(SSLConfig config) {
SSLContext context;
- switch (config.getSslCertificateType()){
+ switch (config.getSslCertificateType()) {
case SSLConfig.JKS:
context = getSSLContextFromJKS(config);
break;
@@ -75,17 +75,17 @@ public class SSLWebSocketFactoryGenerator {
DebugTool.logError(TAG, "Unable to generateWebSocketServer. Unsupported cert type.");
return null;
}
- if(context != null) {
+ if (context != null) {
return new DefaultSSLWebSocketServerFactory(context);
- }else{
+ } else {
DebugTool.logError(TAG, "SSLWebSocketFactoryGenerator: Unable to create SSL Context");
return null;
}
}
-/* ******************************************* JKS ********************************************/
+ /* ******************************************* JKS ********************************************/
- private static SSLContext getSSLContextFromJKS(SSLConfig config){
+ private static SSLContext getSSLContextFromJKS(SSLConfig config) {
try {
KeyStore ks = KeyStore.getInstance(JAVA_KEY_STORE);
@@ -101,9 +101,8 @@ public class SSLWebSocketFactoryGenerator {
sslContext = SSLContext.getInstance(TLS);
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
return sslContext;
- }
- catch(Exception e){
- DebugTool.logError(TAG, "Issue creating SSLContext with JKS : " , e);
+ } catch (Exception e) {
+ DebugTool.logError(TAG, "Issue creating SSLContext with JKS : ", e);
}
return null;
}
@@ -114,51 +113,51 @@ public class SSLWebSocketFactoryGenerator {
SSLContext context;
try {
- context = SSLContext.getInstance( TLS );
+ context = SSLContext.getInstance(TLS);
- byte[] certBytes = parseDERFromPEM( config.getPemCertificate().getBytes(), "-----BEGIN CERTIFICATE-----", "-----END CERTIFICATE-----" );
- byte[] keyBytes = parseDERFromPEM( config.getPrivateKey().getBytes(), "-----BEGIN PRIVATE KEY-----", "-----END PRIVATE KEY-----" );
+ byte[] certBytes = parseDERFromPEM(config.getPemCertificate().getBytes(), "-----BEGIN CERTIFICATE-----", "-----END CERTIFICATE-----");
+ byte[] keyBytes = parseDERFromPEM(config.getPrivateKey().getBytes(), "-----BEGIN PRIVATE KEY-----", "-----END PRIVATE KEY-----");
- X509Certificate cert = generateCertificateFromDER( certBytes );
- RSAPrivateKey key = generatePrivateKeyFromDER( keyBytes );
+ X509Certificate cert = generateCertificateFromDER(certBytes);
+ RSAPrivateKey key = generatePrivateKeyFromDER(keyBytes);
- KeyStore keystore = KeyStore.getInstance( JAVA_KEY_STORE );
- keystore.load( null );
- keystore.setCertificateEntry( "cert-alias", cert );
- keystore.setKeyEntry( "key-alias", key, config.getPassword().toCharArray(), new Certificate[]{ cert } );
+ KeyStore keystore = KeyStore.getInstance(JAVA_KEY_STORE);
+ keystore.load(null);
+ keystore.setCertificateEntry("cert-alias", cert);
+ keystore.setKeyEntry("key-alias", key, config.getPassword().toCharArray(), new Certificate[]{cert});
- KeyManagerFactory kmf = KeyManagerFactory.getInstance( SUNX509 );
- kmf.init( keystore, config.getPassword().toCharArray() );
+ KeyManagerFactory kmf = KeyManagerFactory.getInstance(SUNX509);
+ kmf.init(keystore, config.getPassword().toCharArray());
KeyManager[] km = kmf.getKeyManagers();
- context.init( km, null, null );
- } catch ( Exception e ) {
+ context.init(km, null, null);
+ } catch (Exception e) {
context = null;
- DebugTool.logError(TAG, "Issue creating SSLContext with PEM Cert : " , e);
+ DebugTool.logError(TAG, "Issue creating SSLContext with PEM Cert : ", e);
}
return context;
}
- private static byte[] parseDERFromPEM( byte[] pem, String beginDelimiter, String endDelimiter ) {
- String data = new String( pem );
- String[] tokens = data.split( beginDelimiter );
- tokens = tokens[1].split( endDelimiter );
- return DatatypeConverter.parseBase64Binary( tokens[0] );
+ private static byte[] parseDERFromPEM(byte[] pem, String beginDelimiter, String endDelimiter) {
+ String data = new String(pem);
+ String[] tokens = data.split(beginDelimiter);
+ tokens = tokens[1].split(endDelimiter);
+ return DatatypeConverter.parseBase64Binary(tokens[0]);
}
- private static RSAPrivateKey generatePrivateKeyFromDER( byte[] keyBytes ) throws InvalidKeySpecException, NoSuchAlgorithmException {
- PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec( keyBytes );
+ private static RSAPrivateKey generatePrivateKeyFromDER(byte[] keyBytes) throws InvalidKeySpecException, NoSuchAlgorithmException {
+ PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes);
- KeyFactory factory = KeyFactory.getInstance( "RSA" );
+ KeyFactory factory = KeyFactory.getInstance("RSA");
- return ( RSAPrivateKey ) factory.generatePrivate( spec );
+ return (RSAPrivateKey) factory.generatePrivate(spec);
}
- private static X509Certificate generateCertificateFromDER( byte[] certBytes ) throws CertificateException {
- CertificateFactory factory = CertificateFactory.getInstance( "X.509" );
+ private static X509Certificate generateCertificateFromDER(byte[] certBytes) throws CertificateException {
+ CertificateFactory factory = CertificateFactory.getInstance("X.509");
- return ( X509Certificate ) factory.generateCertificate( new ByteArrayInputStream( certBytes ) );
+ return (X509Certificate) factory.generateCertificate(new ByteArrayInputStream(certBytes));
}
diff --git a/javaSE/javaSE/src/main/java/org/json/JSON.java b/javaSE/javaSE/src/main/java/org/json/JSON.java
index 1b32e698d..ac304a80e 100644
--- a/javaSE/javaSE/src/main/java/org/json/JSON.java
+++ b/javaSE/javaSE/src/main/java/org/json/JSON.java
@@ -93,7 +93,7 @@ class JSON {
}
public static JSONException typeMismatch(Object indexOrName, Object actual,
- String requiredType) throws JSONException {
+ String requiredType) throws JSONException {
if (actual == null) {
throw new JSONException("Value at " + indexOrName + " is null.");
} else {
diff --git a/javaSE/javaSE/src/main/java/org/json/JSONArray.java b/javaSE/javaSE/src/main/java/org/json/JSONArray.java
index 996f44909..30a5fb072 100644
--- a/javaSE/javaSE/src/main/java/org/json/JSONArray.java
+++ b/javaSE/javaSE/src/main/java/org/json/JSONArray.java
@@ -62,14 +62,14 @@ public class JSONArray {
* collection.
*
* @param copyFrom a collection whose values are of supported types.
- * Unsupported values are not permitted and will yield an array in an
- * inconsistent state.
+ * Unsupported values are not permitted and will yield an array in an
+ * inconsistent state.
*/
/* Accept a raw type for API compatibility */
public JSONArray(Collection copyFrom) {
this();
if (copyFrom != null) {
- for (Iterator it = copyFrom.iterator(); it.hasNext();) {
+ for (Iterator it = copyFrom.iterator(); it.hasNext(); ) {
put(JSONObject.wrap(it.next()));
}
}
@@ -80,9 +80,9 @@ public class JSONArray {
* tokener.
*
* @param readFrom a tokener whose nextValue() method will yield a
- * {@code JSONArray}.
+ * {@code JSONArray}.
* @throws JSONException if the parse fails or doesn't yield a
- * {@code JSONArray}.
+ * {@code JSONArray}.
*/
public JSONArray(JSONTokener readFrom) throws JSONException {
/*
@@ -102,7 +102,7 @@ public class JSONArray {
*
* @param json a JSON-encoded string containing an array.
* @throws JSONException if the parse fails or doesn't yield a {@code
- * JSONArray}.
+ * JSONArray}.
*/
public JSONArray(String json) throws JSONException {
this(new JSONTokener(json));
@@ -143,7 +143,7 @@ public class JSONArray {
* Appends {@code value} to the end of this array.
*
* @param value a finite value. May not be {@link Double#isNaN() NaNs} or
- * {@link Double#isInfinite() infinities}.
+ * {@link Double#isInfinite() infinities}.
* @return this array.
*/
public JSONArray put(double value) throws JSONException {
@@ -175,10 +175,10 @@ public class JSONArray {
* Appends {@code value} to the end of this array.
*
* @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean,
- * Integer, Long, Double, {@link JSONObject#NULL}, or {@code null}. May
- * not be {@link Double#isNaN() NaNs} or {@link Double#isInfinite()
- * infinities}. Unsupported values are not permitted and will cause the
- * array to be in an inconsistent state.
+ * Integer, Long, Double, {@link JSONObject#NULL}, or {@code null}. May
+ * not be {@link Double#isNaN() NaNs} or {@link Double#isInfinite()
+ * infinities}. Unsupported values are not permitted and will cause the
+ * array to be in an inconsistent state.
* @return this array.
*/
public JSONArray put(Object value) {
@@ -214,7 +214,7 @@ public class JSONArray {
* index}, it will be replaced.
*
* @param value a finite value. May not be {@link Double#isNaN() NaNs} or
- * {@link Double#isInfinite() infinities}.
+ * {@link Double#isInfinite() infinities}.
* @return this array.
*/
public JSONArray put(int index, double value) throws JSONException {
@@ -249,9 +249,9 @@ public class JSONArray {
* index}, it will be replaced.
*
* @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean,
- * Integer, Long, Double, {@link JSONObject#NULL}, or {@code null}. May
- * not be {@link Double#isNaN() NaNs} or {@link Double#isInfinite()
- * infinities}.
+ * Integer, Long, Double, {@link JSONObject#NULL}, or {@code null}. May
+ * not be {@link Double#isNaN() NaNs} or {@link Double#isInfinite()
+ * infinities}.
* @return this array.
*/
public JSONArray put(int index, Object value) throws JSONException {
@@ -279,8 +279,8 @@ public class JSONArray {
* Returns the value at {@code index}.
*
* @throws JSONException if this array has no value at {@code index}, or if
- * that value is the {@code null} reference. This method returns
- * normally if the value is {@code JSONObject#NULL}.
+ * that value is the {@code null} reference. This method returns
+ * normally if the value is {@code JSONObject#NULL}.
*/
public Object get(int index) throws JSONException {
try {
@@ -321,7 +321,7 @@ public class JSONArray {
* be coerced to a boolean.
*
* @throws JSONException if the value at {@code index} doesn't exist or
- * cannot be coerced to a boolean.
+ * cannot be coerced to a boolean.
*/
public boolean getBoolean(int index) throws JSONException {
Object object = get(index);
@@ -355,7 +355,7 @@ public class JSONArray {
* be coerced to a double.
*
* @throws JSONException if the value at {@code index} doesn't exist or
- * cannot be coerced to a double.
+ * cannot be coerced to a double.
*/
public double getDouble(int index) throws JSONException {
Object object = get(index);
@@ -389,7 +389,7 @@ public class JSONArray {
* can be coerced to an int.
*
* @throws JSONException if the value at {@code index} doesn't exist or
- * cannot be coerced to a int.
+ * cannot be coerced to a int.
*/
public int getInt(int index) throws JSONException {
Object object = get(index);
@@ -423,7 +423,7 @@ public class JSONArray {
* can be coerced to a long.
*
* @throws JSONException if the value at {@code index} doesn't exist or
- * cannot be coerced to a long.
+ * cannot be coerced to a long.
*/
public long getLong(int index) throws JSONException {
Object object = get(index);
@@ -490,7 +490,7 @@ public class JSONArray {
* JSONArray}.
*
* @throws JSONException if the value doesn't exist or is not a {@code
- * JSONArray}.
+ * JSONArray}.
*/
public JSONArray getJSONArray(int index) throws JSONException {
Object object = get(index);
@@ -515,7 +515,7 @@ public class JSONArray {
* JSONObject}.
*
* @throws JSONException if the value doesn't exist or is not a {@code
- * JSONObject}.
+ * JSONObject}.
*/
public JSONObject getJSONObject(int index) throws JSONException {
Object object = get(index);
@@ -579,7 +579,8 @@ public class JSONArray {
* Encodes this array as a compact JSON string, such as:
* <pre>[94043,90210]</pre>
*/
- @Override public String toString() {
+ @Override
+ public String toString() {
try {
JSONStringer stringer = new JSONStringer();
writeTo(stringer);
@@ -599,7 +600,7 @@ public class JSONArray {
* ]</pre>
*
* @param indentSpaces the number of spaces to indent for each level of
- * nesting.
+ * nesting.
*/
public String toString(int indentSpaces) throws JSONException {
JSONStringer stringer = new JSONStringer(indentSpaces);
@@ -615,11 +616,13 @@ public class JSONArray {
stringer.endArray();
}
- @Override public boolean equals(Object o) {
+ @Override
+ public boolean equals(Object o) {
return o instanceof JSONArray && ((JSONArray) o).values.equals(values);
}
- @Override public int hashCode() {
+ @Override
+ public int hashCode() {
// diverge from the original, which doesn't implement hashCode
return values.hashCode();
}
diff --git a/javaSE/javaSE/src/main/java/org/json/JSONObject.java b/javaSE/javaSE/src/main/java/org/json/JSONObject.java
index 74ea973c2..f7fbd12b5 100644
--- a/javaSE/javaSE/src/main/java/org/json/JSONObject.java
+++ b/javaSE/javaSE/src/main/java/org/json/JSONObject.java
@@ -101,12 +101,19 @@ public class JSONObject {
*/
@NonNull
public static final Object NULL = new Object() {
- @Override public boolean equals(Object o) {
+ @Override
+ public boolean equals(Object o) {
return o == this || o == null; // API specifies this broken equals implementation
}
+
// at least make the broken equals(null) consistent with Objects.hashCode(null).
- @Override public int hashCode() { return Objects.hashCode(null); }
- @Override public String toString() {
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(null);
+ }
+
+ @Override
+ public String toString() {
return "null";
}
};
@@ -126,7 +133,7 @@ public class JSONObject {
* the given map.
*
* @param copyFrom a map whose keys are of type {@link String} and whose
- * values are of supported types.
+ * values are of supported types.
* @throws NullPointerException if any of the map's keys are null.
*/
/* (accept a raw type for API compatibility) */
@@ -151,9 +158,9 @@ public class JSONObject {
* object in the tokener.
*
* @param readFrom a tokener whose nextValue() method will yield a
- * {@code JSONObject}.
+ * {@code JSONObject}.
* @throws JSONException if the parse fails or doesn't yield a
- * {@code JSONObject}.
+ * {@code JSONObject}.
*/
public JSONObject(@NonNull JSONTokener readFrom) throws JSONException {
/*
@@ -174,7 +181,7 @@ public class JSONObject {
*
* @param json a JSON-encoded string containing an object.
* @throws JSONException if the parse fails or doesn't yield a {@code
- * JSONObject}.
+ * JSONObject}.
*/
public JSONObject(@NonNull String json) throws JSONException {
this(new JSONTokener(json));
@@ -185,7 +192,7 @@ public class JSONObject {
* from the given object. Names that aren't present in {@code copyFrom} will
* be skipped.
*/
- public JSONObject(@NonNull JSONObject copyFrom, @NonNull String [] names) throws JSONException {
+ public JSONObject(@NonNull JSONObject copyFrom, @NonNull String[] names) throws JSONException {
this();
for (String name : names) {
Object value = copyFrom.opt(name);
@@ -208,7 +215,8 @@ public class JSONObject {
*
* @return this object.
*/
- @NonNull public JSONObject put(@NonNull String name, boolean value) throws JSONException {
+ @NonNull
+ public JSONObject put(@NonNull String name, boolean value) throws JSONException {
nameValuePairs.put(checkName(name), value);
return this;
}
@@ -218,10 +226,11 @@ public class JSONObject {
* mapping with the same name.
*
* @param value a finite value. May not be {@link Double#isNaN() NaNs} or
- * {@link Double#isInfinite() infinities}.
+ * {@link Double#isInfinite() infinities}.
* @return this object.
*/
- @NonNull public JSONObject put(@NonNull String name, double value) throws JSONException {
+ @NonNull
+ public JSONObject put(@NonNull String name, double value) throws JSONException {
nameValuePairs.put(checkName(name), JSON.checkDouble(value));
return this;
}
@@ -232,7 +241,8 @@ public class JSONObject {
*
* @return this object.
*/
- @NonNull public JSONObject put(@NonNull String name, int value) throws JSONException {
+ @NonNull
+ public JSONObject put(@NonNull String name, int value) throws JSONException {
nameValuePairs.put(checkName(name), value);
return this;
}
@@ -243,7 +253,8 @@ public class JSONObject {
*
* @return this object.
*/
- @NonNull public JSONObject put(@NonNull String name, long value) throws JSONException {
+ @NonNull
+ public JSONObject put(@NonNull String name, long value) throws JSONException {
nameValuePairs.put(checkName(name), value);
return this;
}
@@ -254,12 +265,13 @@ public class JSONObject {
* mapping for {@code name} is removed.
*
* @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean,
- * Integer, Long, Double, {@link #NULL}, or {@code null}. May not be
- * {@link Double#isNaN() NaNs} or {@link Double#isInfinite()
- * infinities}.
+ * Integer, Long, Double, {@link #NULL}, or {@code null}. May not be
+ * {@link Double#isNaN() NaNs} or {@link Double#isInfinite()
+ * infinities}.
* @return this object.
*/
- @NonNull public JSONObject put(@NonNull String name, @Nullable Object value) throws JSONException {
+ @NonNull
+ public JSONObject put(@NonNull String name, @Nullable Object value) throws JSONException {
if (value == null) {
nameValuePairs.remove(name);
return this;
@@ -276,7 +288,8 @@ public class JSONObject {
* Equivalent to {@code put(name, value)} when both parameters are non-null;
* does nothing otherwise.
*/
- @NonNull public JSONObject putOpt(@Nullable String name, @Nullable Object value) throws JSONException {
+ @NonNull
+ public JSONObject putOpt(@Nullable String name, @Nullable Object value) throws JSONException {
if (name == null || value == null) {
return this;
}
@@ -298,12 +311,13 @@ public class JSONObject {
* depending on the number of calls to it.
*
* @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean,
- * Integer, Long, Double, {@link #NULL} or null. May not be {@link
- * Double#isNaN() NaNs} or {@link Double#isInfinite() infinities}.
+ * Integer, Long, Double, {@link #NULL} or null. May not be {@link
+ * Double#isNaN() NaNs} or {@link Double#isInfinite() infinities}.
*/
// TODO: Change {@code append) to {@link #append} when append is
// unhidden.
- @NonNull public JSONObject accumulate(@NonNull String name, @Nullable Object value) throws JSONException {
+ @NonNull
+ public JSONObject accumulate(@NonNull String name, @Nullable Object value) throws JSONException {
Object current = nameValuePairs.get(checkName(name));
if (current == null) {
return put(name, value);
@@ -328,8 +342,7 @@ public class JSONObject {
* will be thrown.
*
* @throws JSONException if {@code name} is {@code null} or if the mapping for
- * {@code name} is non-null and is not a {@link JSONArray}.
- *
+ * {@code name} is non-null and is not a {@link JSONArray}.
*/
public JSONObject append(String name, Object value) throws JSONException {
Object current = nameValuePairs.get(checkName(name));
@@ -361,9 +374,10 @@ public class JSONObject {
* Removes the named mapping if it exists; does nothing otherwise.
*
* @return the value previously mapped by {@code name}, or null if there was
- * no such mapping.
+ * no such mapping.
*/
- @Nullable public Object remove(@Nullable String name) {
+ @Nullable
+ public Object remove(@Nullable String name) {
return nameValuePairs.remove(name);
}
@@ -389,7 +403,8 @@ public class JSONObject {
*
* @throws JSONException if no such mapping exists.
*/
- @NonNull public Object get(@NonNull String name) throws JSONException {
+ @NonNull
+ public Object get(@NonNull String name) throws JSONException {
Object result = nameValuePairs.get(name);
if (result == null) {
throw new JSONException("No value for " + name);
@@ -401,7 +416,8 @@ public class JSONObject {
* Returns the value mapped by {@code name}, or null if no such mapping
* exists.
*/
- @Nullable public Object opt(@Nullable String name) {
+ @Nullable
+ public Object opt(@Nullable String name) {
return nameValuePairs.get(name);
}
@@ -410,7 +426,7 @@ public class JSONObject {
* can be coerced to a boolean, or throws otherwise.
*
* @throws JSONException if the mapping doesn't exist or cannot be coerced
- * to a boolean.
+ * to a boolean.
*/
public boolean getBoolean(@NonNull String name) throws JSONException {
Object object = get(name);
@@ -444,7 +460,7 @@ public class JSONObject {
* can be coerced to a double, or throws otherwise.
*
* @throws JSONException if the mapping doesn't exist or cannot be coerced
- * to a double.
+ * to a double.
*/
public double getDouble(@NonNull String name) throws JSONException {
Object object = get(name);
@@ -478,7 +494,7 @@ public class JSONObject {
* can be coerced to an int, or throws otherwise.
*
* @throws JSONException if the mapping doesn't exist or cannot be coerced
- * to an int.
+ * to an int.
*/
public int getInt(@NonNull String name) throws JSONException {
Object object = get(name);
@@ -514,7 +530,7 @@ public class JSONObject {
* so this is <a href="#lossy">lossy</a>; use strings to transfer numbers via JSON.
*
* @throws JSONException if the mapping doesn't exist or cannot be coerced
- * to a long.
+ * to a long.
*/
public long getLong(@NonNull String name) throws JSONException {
Object object = get(name);
@@ -552,7 +568,8 @@ public class JSONObject {
*
* @throws JSONException if no such mapping exists.
*/
- @NonNull public String getString(@NonNull String name) throws JSONException {
+ @NonNull
+ public String getString(@NonNull String name) throws JSONException {
Object object = get(name);
String result = JSON.toString(object);
if (result == null) {
@@ -565,7 +582,8 @@ public class JSONObject {
* Returns the value mapped by {@code name} if it exists, coercing it if
* necessary, or the empty string if no such mapping exists.
*/
- @NonNull public String optString(@Nullable String name) {
+ @NonNull
+ public String optString(@Nullable String name) {
return optString(name, "");
}
@@ -573,7 +591,8 @@ public class JSONObject {
* Returns the value mapped by {@code name} if it exists, coercing it if
* necessary, or {@code fallback} if no such mapping exists.
*/
- @NonNull public String optString(@Nullable String name, @NonNull String fallback) {
+ @NonNull
+ public String optString(@Nullable String name, @NonNull String fallback) {
Object object = opt(name);
String result = JSON.toString(object);
return result != null ? result : fallback;
@@ -584,9 +603,10 @@ public class JSONObject {
* JSONArray}, or throws otherwise.
*
* @throws JSONException if the mapping doesn't exist or is not a {@code
- * JSONArray}.
+ * JSONArray}.
*/
- @NonNull public JSONArray getJSONArray(@NonNull String name) throws JSONException {
+ @NonNull
+ public JSONArray getJSONArray(@NonNull String name) throws JSONException {
Object object = get(name);
if (object instanceof JSONArray) {
return (JSONArray) object;
@@ -599,7 +619,8 @@ public class JSONObject {
* Returns the value mapped by {@code name} if it exists and is a {@code
* JSONArray}, or null otherwise.
*/
- @Nullable public JSONArray optJSONArray(@Nullable String name) {
+ @Nullable
+ public JSONArray optJSONArray(@Nullable String name) {
Object object = opt(name);
return object instanceof JSONArray ? (JSONArray) object : null;
}
@@ -609,9 +630,10 @@ public class JSONObject {
* JSONObject}, or throws otherwise.
*
* @throws JSONException if the mapping doesn't exist or is not a {@code
- * JSONObject}.
+ * JSONObject}.
*/
- @NonNull public JSONObject getJSONObject(@NonNull String name) throws JSONException {
+ @NonNull
+ public JSONObject getJSONObject(@NonNull String name) throws JSONException {
Object object = get(name);
if (object instanceof JSONObject) {
return (JSONObject) object;
@@ -624,7 +646,8 @@ public class JSONObject {
* Returns the value mapped by {@code name} if it exists and is a {@code
* JSONObject}, or null otherwise.
*/
- @Nullable public JSONObject optJSONObject(@Nullable String name) {
+ @Nullable
+ public JSONObject optJSONObject(@Nullable String name) {
Object object = opt(name);
return object instanceof JSONObject ? (JSONObject) object : null;
}
@@ -634,7 +657,8 @@ public class JSONObject {
* array contains null for names that aren't mapped. This method returns
* null if {@code names} is either null or empty.
*/
- @Nullable public JSONArray toJSONArray(@Nullable JSONArray names) throws JSONException {
+ @Nullable
+ public JSONArray toJSONArray(@Nullable JSONArray names) throws JSONException {
JSONArray result = new JSONArray();
if (names == null) {
return null;
@@ -657,7 +681,8 @@ public class JSONObject {
* modified after the iterator is returned, the iterator's behavior is
* undefined. The order of the keys is undefined.
*/
- @NonNull public Iterator<String> keys() {
+ @NonNull
+ public Iterator<String> keys() {
return nameValuePairs.keySet().iterator();
}
@@ -666,9 +691,8 @@ public class JSONObject {
* is a view of the keys in this object. {@link Set#remove(Object)} will remove
* the corresponding mapping from this object and set iterator behaviour
* is undefined if this object is modified after it is returned.
- *
+ * <p>
* See {@link #keys()}.
- *
*/
public Set<String> keySet() {
return nameValuePairs.keySet();
@@ -678,7 +702,8 @@ public class JSONObject {
* Returns an array containing the string names in this object. This method
* returns null if this object contains no mappings.
*/
- @Nullable public JSONArray names() {
+ @Nullable
+ public JSONArray names() {
return nameValuePairs.isEmpty()
? null
: new JSONArray(new ArrayList<String>(nameValuePairs.keySet()));
@@ -688,7 +713,9 @@ public class JSONObject {
* Encodes this object as a compact JSON string, such as:
* <pre>{"query":"Pizza","locations":[94043,90210]}</pre>
*/
- @Override @NonNull public String toString() {
+ @Override
+ @NonNull
+ public String toString() {
try {
JSONStringer stringer = new JSONStringer();
writeTo(stringer);
@@ -711,9 +738,10 @@ public class JSONObject {
* }</pre>
*
* @param indentSpaces the number of spaces to indent for each level of
- * nesting.
+ * nesting.
*/
- @NonNull public String toString(int indentSpaces) throws JSONException {
+ @NonNull
+ public String toString(int indentSpaces) throws JSONException {
JSONStringer stringer = new JSONStringer(indentSpaces);
writeTo(stringer);
return stringer.toString();
@@ -732,9 +760,10 @@ public class JSONObject {
* Encodes the number as a JSON string.
*
* @param number a finite value. May not be {@link Double#isNaN() NaNs} or
- * {@link Double#isInfinite() infinities}.
+ * {@link Double#isInfinite() infinities}.
*/
- @NonNull public static String numberToString(@NonNull Number number) throws JSONException {
+ @NonNull
+ public static String numberToString(@NonNull Number number) throws JSONException {
if (number == null) {
throw new JSONException("Number must be non-null");
}
@@ -760,9 +789,10 @@ public class JSONObject {
* necessary character escaping.
*
* @param data the string to encode. Null will be interpreted as an empty
- * string.
+ * string.
*/
- @NonNull public static String quote(@Nullable String data) {
+ @NonNull
+ public static String quote(@Nullable String data) {
if (data == null) {
return "\"\"";
}
@@ -789,7 +819,8 @@ public class JSONObject {
* Otherwise if the object is from a {@code java} package, returns the result of {@code toString}.
* If wrapping fails, returns null.
*/
- @Nullable public static Object wrap(@Nullable Object o) {
+ @Nullable
+ public static Object wrap(@Nullable Object o) {
if (o == null) {
return NULL;
}
@@ -809,14 +840,14 @@ public class JSONObject {
return new JSONObject((Map) o);
}
if (o instanceof Boolean ||
- o instanceof Byte ||
- o instanceof Character ||
- o instanceof Double ||
- o instanceof Float ||
- o instanceof Integer ||
- o instanceof Long ||
- o instanceof Short ||
- o instanceof String) {
+ o instanceof Byte ||
+ o instanceof Character ||
+ o instanceof Double ||
+ o instanceof Float ||
+ o instanceof Integer ||
+ o instanceof Long ||
+ o instanceof Short ||
+ o instanceof String) {
return o;
}
if (o.getClass().getPackage().getName().startsWith("java.")) {
diff --git a/javaSE/javaSE/src/main/java/org/json/JSONStringer.java b/javaSE/javaSE/src/main/java/org/json/JSONStringer.java
index dd3b2a7d8..302129c4f 100644
--- a/javaSE/javaSE/src/main/java/org/json/JSONStringer.java
+++ b/javaSE/javaSE/src/main/java/org/json/JSONStringer.java
@@ -60,7 +60,9 @@ import java.util.List;
*/
public class JSONStringer {
- /** The output data, containing at most one top-level array or object. */
+ /**
+ * The output data, containing at most one top-level array or object.
+ */
final StringBuilder out = new StringBuilder();
/**
@@ -220,8 +222,8 @@ public class JSONStringer {
* Encodes {@code value}.
*
* @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean,
- * Integer, Long, Double or null. May not be {@link Double#isNaN() NaNs}
- * or {@link Double#isInfinite() infinities}.
+ * Integer, Long, Double or null. May not be {@link Double#isNaN() NaNs}
+ * or {@link Double#isInfinite() infinities}.
* @return this stringer.
*/
public JSONStringer value(Object value) throws JSONException {
@@ -273,7 +275,7 @@ public class JSONStringer {
* Encodes {@code value} to this stringer.
*
* @param value a finite value. May not be {@link Double#isNaN() NaNs} or
- * {@link Double#isInfinite() infinities}.
+ * {@link Double#isInfinite() infinities}.
* @return this stringer.
*/
public JSONStringer value(double value) throws JSONException {
@@ -426,7 +428,8 @@ public class JSONStringer {
* of {@link Object#toString}, this method returns null if the stringer
* contains no data.
*/
- @Override public String toString() {
+ @Override
+ public String toString() {
return out.length() == 0 ? null : out.toString();
}
}
diff --git a/javaSE/javaSE/src/main/java/org/json/JSONTokener.java b/javaSE/javaSE/src/main/java/org/json/JSONTokener.java
index 4bdd9ad37..ce47196be 100644
--- a/javaSE/javaSE/src/main/java/org/json/JSONTokener.java
+++ b/javaSE/javaSE/src/main/java/org/json/JSONTokener.java
@@ -62,7 +62,9 @@ package org.json;
*/
public class JSONTokener {
- /** The input JSON. */
+ /**
+ * The input JSON.
+ */
private final String in;
/**
@@ -73,8 +75,8 @@ public class JSONTokener {
/**
* @param in JSON encoded string. Null is not permitted and will yield a
- * tokener that throws {@code NullPointerExceptions} when methods are
- * called.
+ * tokener that throws {@code NullPointerExceptions} when methods are
+ * called.
*/
public JSONTokener(String in) {
// consume an optional byte order mark (BOM) if it exists
@@ -88,7 +90,7 @@ public class JSONTokener {
* Returns the next value from the input.
*
* @return a {@link JSONObject}, {@link JSONArray}, String, Boolean,
- * Integer, Long, Double or {@link JSONObject#NULL}.
+ * Integer, Long, Double or {@link JSONObject#NULL}.
* @throws JSONException if the input is malformed.
*/
public Object nextValue() throws JSONException {
@@ -453,7 +455,8 @@ public class JSONTokener {
/**
* Returns the current position and the entire input string.
*/
- @Override public String toString() {
+ @Override
+ public String toString() {
// consistent with the original implementation
return " at character " + pos + " of " + in;
}
@@ -514,7 +517,7 @@ public class JSONTokener {
* to avoid memory leaks.
*
* @throws JSONException if the remaining input is not long enough to
- * satisfy this request.
+ * satisfy this request.
*/
public String next(int length) throws JSONException {
if (pos + length > in.length()) {
@@ -595,7 +598,7 @@ public class JSONTokener {
* for non-hex input.
*
* @param hex a character in the ranges [0-9], [A-F] or [a-f]. Any other
- * character will yield a -1 result.
+ * character will yield a -1 result.
*/
public static int dehexchar(char hex) {
if (hex >= '0' && hex <= '9') {
diff --git a/javaSE/javaSE/src/test/java/com/smartdevicelink/test/TestValues.java b/javaSE/javaSE/src/test/java/com/smartdevicelink/test/TestValues.java
index d3efa2326..6ff8f26bb 100644
--- a/javaSE/javaSE/src/test/java/com/smartdevicelink/test/TestValues.java
+++ b/javaSE/javaSE/src/test/java/com/smartdevicelink/test/TestValues.java
@@ -5,9 +5,9 @@ import com.smartdevicelink.proxy.rpc.enums.FileType;
import java.net.URI;
public class TestValues {
- public static final boolean GENERAL_BOOLEAN = true;
- public static final byte[] GENERAL_BYTE_ARRAY = new byte[0];
- public static final String GENERAL_STRING = "test";
- public static final FileType GENERAL_FILETYPE = FileType.BINARY;
- public static final URI GENERAL_URI = URI.create("http://www.google.com");
+ public static final boolean GENERAL_BOOLEAN = true;
+ public static final byte[] GENERAL_BYTE_ARRAY = new byte[0];
+ public static final String GENERAL_STRING = "test";
+ public static final FileType GENERAL_FILETYPE = FileType.BINARY;
+ public static final URI GENERAL_URI = URI.create("http://www.google.com");
}