1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-12-15 09:31:08 +01:00

Enfore spaces for indentation

Although I'm in the tabs camp, Smack uses mostly spaces. Therefore it
is the logical choice for the indentation style.
This commit is contained in:
Florian Schmaus 2017-02-07 22:02:40 +01:00
parent ffe9397e66
commit ef0af66b21
125 changed files with 5336 additions and 5344 deletions

View file

@ -95,7 +95,7 @@ public final class PrivacyListManager extends Manager {
*
* @param connection the XMPP connection.
*/
private PrivacyListManager(XMPPConnection connection) {
private PrivacyListManager(XMPPConnection connection) {
super(connection);
connection.registerIQRequestHandler(new AbstractIqRequestHandler(Privacy.ELEMENT, Privacy.NAMESPACE,
@ -215,24 +215,24 @@ public final class PrivacyListManager extends Manager {
return plm;
}
/**
* Send the {@link Privacy} stanza(/packet) to the server in order to know some privacy content and then
* waits for the answer.
*
* @param requestPrivacy is the {@link Privacy} stanza(/packet) configured properly whose XML
/**
* Send the {@link Privacy} stanza(/packet) to the server in order to know some privacy content and then
* waits for the answer.
*
* @param requestPrivacy is the {@link Privacy} stanza(/packet) configured properly whose XML
* will be sent to the server.
* @return a new {@link Privacy} with the data received from the server.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
private Privacy getRequest(Privacy requestPrivacy) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// The request is a get iq type
requestPrivacy.setType(Privacy.Type.get);
* @return a new {@link Privacy} with the data received from the server.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
private Privacy getRequest(Privacy requestPrivacy) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// The request is a get iq type
requestPrivacy.setType(Privacy.Type.get);
return connection().createStanzaCollectorAndSend(requestPrivacy).nextResultOrThrow();
}
}
/**
* Send the {@link Privacy} stanza(/packet) to the server in order to modify the server privacy and waits
@ -253,22 +253,22 @@ public final class PrivacyListManager extends Manager {
return connection().createStanzaCollectorAndSend(requestPrivacy).nextResultOrThrow();
}
/**
* Answer a privacy containing the list structure without {@link PrivacyItem}.
*
* @return a Privacy with the list names.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
private Privacy getPrivacyWithListNames() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// The request of the list is an empty privacy message
Privacy request = new Privacy();
/**
* Answer a privacy containing the list structure without {@link PrivacyItem}.
*
* @return a Privacy with the list names.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
private Privacy getPrivacyWithListNames() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// The request of the list is an empty privacy message
Privacy request = new Privacy();
// Send the package to the server and get the answer
return getRequest(request);
}
// Send the package to the server and get the answer
return getRequest(request);
}
/**
* Answer the active privacy list. Returns <code>null</code> if there is no active list.
@ -386,20 +386,20 @@ public final class PrivacyListManager extends Manager {
return privacyAnswer.getPrivacyList(listName);
}
/**
* Answer the privacy list items under listName with the allowed and blocked permissions.
*
* @param listName the name of the list to get the allowed and blocked permissions.
* @return a privacy list under the list listName.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
public PrivacyList getPrivacyList(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
/**
* Answer the privacy list items under listName with the allowed and blocked permissions.
*
* @param listName the name of the list to get the allowed and blocked permissions.
* @return a privacy list under the list listName.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
public PrivacyList getPrivacyList(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
listName = StringUtils.requireNotNullOrEmpty(listName, "List name must not be null");
return new PrivacyList(false, false, listName, getPrivacyListItems(listName));
}
}
/**
* Answer every privacy list with the allowed and blocked permissions.
@ -423,87 +423,87 @@ public final class PrivacyListManager extends Manager {
return lists;
}
/**
* Set or change the active list to listName.
*
* @param listName the list name to set as the active one.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
public void setActiveListName(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setActiveName(listName);
/**
* Set or change the active list to listName.
*
* @param listName the list name to set as the active one.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
public void setActiveListName(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setActiveName(listName);
// Send the package to the server
setRequest(request);
}
// Send the package to the server
setRequest(request);
}
/**
* Client declines the use of active lists.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
public void declineActiveList() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setDeclineActiveList(true);
/**
* Client declines the use of active lists.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
public void declineActiveList() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setDeclineActiveList(true);
// Send the package to the server
setRequest(request);
}
// Send the package to the server
setRequest(request);
}
/**
* Set or change the default list to listName.
*
* @param listName the list name to set as the default one.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
public void setDefaultListName(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setDefaultName(listName);
/**
* Set or change the default list to listName.
*
* @param listName the list name to set as the default one.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
public void setDefaultListName(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setDefaultName(listName);
// Send the package to the server
setRequest(request);
}
// Send the package to the server
setRequest(request);
}
/**
* Client declines the use of default lists.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
public void declineDefaultList() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setDeclineDefaultList(true);
/**
* Client declines the use of default lists.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
public void declineDefaultList() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setDeclineDefaultList(true);
// Send the package to the server
setRequest(request);
}
// Send the package to the server
setRequest(request);
}
/**
* The client has created a new list. It send the new one to the server.
*
/**
* The client has created a new list. It send the new one to the server.
*
* @param listName the list that has changed its content.
* @param privacyItems a List with every privacy item in the list.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
public void createPrivacyList(String listName, List<PrivacyItem> privacyItems) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
updatePrivacyList(listName, privacyItems);
}
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
public void createPrivacyList(String listName, List<PrivacyItem> privacyItems) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
updatePrivacyList(listName, privacyItems);
}
/**
* The client has edited an existing list. It updates the server content with the resulting
@ -526,23 +526,23 @@ public final class PrivacyListManager extends Manager {
setRequest(request);
}
/**
* Remove a privacy list.
*
/**
* Remove a privacy list.
*
* @param listName the list that has changed its content.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
public void deletePrivacyList(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setPrivacyList(listName, new ArrayList<PrivacyItem>());
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
public void deletePrivacyList(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setPrivacyList(listName, new ArrayList<PrivacyItem>());
// Send the package to the server
setRequest(request);
}
// Send the package to the server
setRequest(request);
}
/**
* Adds a privacy list listener that will be notified of any new update in the user

View file

@ -45,17 +45,17 @@ public class Privacy extends IQ {
public static final String ELEMENT = QUERY_ELEMENT;
public static final String NAMESPACE = "jabber:iq:privacy";
/** declineActiveList is true when the user declines the use of the active list **/
private boolean declineActiveList=false;
/** activeName is the name associated with the active list set for the session **/
private String activeName;
/** declineDefaultList is true when the user declines the use of the default list **/
private boolean declineDefaultList=false;
/** defaultName is the name of the default list that applies to the user as a whole **/
private String defaultName;
/** itemLists holds the set of privacy items classified in lists. It is a map where the
* key is the name of the list and the value a collection with privacy items. **/
private Map<String, List<PrivacyItem>> itemLists = new HashMap<String, List<PrivacyItem>>();
/** declineActiveList is true when the user declines the use of the active list **/
private boolean declineActiveList=false;
/** activeName is the name associated with the active list set for the session **/
private String activeName;
/** declineDefaultList is true when the user declines the use of the default list **/
private boolean declineDefaultList=false;
/** defaultName is the name of the default list that applies to the user as a whole **/
private String defaultName;
/** itemLists holds the set of privacy items classified in lists. It is a map where the
* key is the name of the list and the value a collection with privacy items. **/
private Map<String, List<PrivacyItem>> itemLists = new HashMap<String, List<PrivacyItem>>();
public Privacy() {
super(ELEMENT, NAMESPACE);
@ -94,13 +94,13 @@ public class Privacy extends IQ {
public void deletePrivacyList(String listName) {
// Remove the list from the cache
// CHECKSTYLE:OFF
this.getItemLists().remove(listName);
this.getItemLists().remove(listName);
// CHECKSTYLE:ON
// Check if deleted list was the default list
if (this.getDefaultName() != null && listName.equals(this.getDefaultName())) {
// CHECKSTYLE:OFF
this.setDefaultName(null);
this.setDefaultName(null);
// CHECKSTYLE:ON
}
}
@ -114,9 +114,9 @@ public class Privacy extends IQ {
// Check if we have the default list
// CHECKSTYLE:OFF
if (this.getActiveName() == null) {
return null;
return null;
} else {
return this.getItemLists().get(this.getActiveName());
return this.getItemLists().get(this.getActiveName());
}
// CHECKSTYLE:ON
}
@ -130,9 +130,9 @@ public class Privacy extends IQ {
// Check if we have the default list
// CHECKSTYLE:OFF
if (this.getDefaultName() == null) {
return null;
return null;
} else {
return this.getItemLists().get(this.getDefaultName());
return this.getItemLists().get(this.getDefaultName());
}
// CHECKSTYLE:ON
}
@ -156,15 +156,15 @@ public class Privacy extends IQ {
*/
public PrivacyItem getItem(String listName, int order) {
// CHECKSTYLE:OFF
Iterator<PrivacyItem> values = getPrivacyList(listName).iterator();
PrivacyItem itemFound = null;
while (itemFound == null && values.hasNext()) {
PrivacyItem element = values.next();
if (element.getOrder() == order) {
itemFound = element;
}
}
return itemFound;
Iterator<PrivacyItem> values = getPrivacyList(listName).iterator();
PrivacyItem itemFound = null;
while (itemFound == null && values.hasNext()) {
PrivacyItem element = values.next();
if (element.getOrder() == order) {
itemFound = element;
}
}
return itemFound;
// CHECKSTYLE:ON
}
@ -180,7 +180,7 @@ public class Privacy extends IQ {
return true;
} else {
// CHECKSTYLE:OFF
return false;
return false;
// CHECKSTYLE:ON
}
}
@ -192,7 +192,7 @@ public class Privacy extends IQ {
*/
public void deleteList(String listName) {
// CHECKSTYLE:OFF
this.getItemLists().remove(listName);
this.getItemLists().remove(listName);
// CHECKSTYLE:ON
}
@ -203,9 +203,9 @@ public class Privacy extends IQ {
* @return the name of the active list.
*/
// CHECKSTYLE:OFF
public String getActiveName() {
return activeName;
}
public String getActiveName() {
return activeName;
}
// CHECKSTYLE:ON
/**
@ -215,9 +215,9 @@ public class Privacy extends IQ {
* @param activeName is the name of the active list.
*/
// CHECKSTYLE:OFF
public void setActiveName(String activeName) {
this.activeName = activeName;
}
public void setActiveName(String activeName) {
this.activeName = activeName;
}
// CHECKSTYLE:ON
/**
@ -228,9 +228,9 @@ public class Privacy extends IQ {
* @return the name of the default list.
*/
// CHECKSTYLE:OFF
public String getDefaultName() {
return defaultName;
}
public String getDefaultName() {
return defaultName;
}
// CHECKSTYLE:ON
/**
@ -243,9 +243,9 @@ public class Privacy extends IQ {
* @param defaultName is the name of the default list.
*/
// CHECKSTYLE:OFF
public void setDefaultName(String defaultName) {
this.defaultName = defaultName;
}
public void setDefaultName(String defaultName) {
this.defaultName = defaultName;
}
// CHECKSTYLE:ON
/**
@ -257,9 +257,9 @@ public class Privacy extends IQ {
* collection of privacy items.
*/
// CHECKSTYLE:OFF
public Map<String, List<PrivacyItem>> getItemLists() {
return itemLists;
}
public Map<String, List<PrivacyItem>> getItemLists() {
return itemLists;
}
// CHECKSTYLE:ON
/**
@ -268,9 +268,9 @@ public class Privacy extends IQ {
* @return the decline status of the list.
*/
// CHECKSTYLE:OFF
public boolean isDeclineActiveList() {
return declineActiveList;
}
public boolean isDeclineActiveList() {
return declineActiveList;
}
// CHECKSYTLE:ON
/**
@ -279,9 +279,9 @@ public class Privacy extends IQ {
* @param declineActiveList indicates if the receiver declines the use of an active list.
*/
// CHECKSTYLE:OFF
public void setDeclineActiveList(boolean declineActiveList) {
this.declineActiveList = declineActiveList;
}
public void setDeclineActiveList(boolean declineActiveList) {
this.declineActiveList = declineActiveList;
}
// CHECKSTYLE:ON
/**
@ -290,9 +290,9 @@ public class Privacy extends IQ {
* @return the decline status of the list.
*/
// CHECKSTYLE:OFF
public boolean isDeclineDefaultList() {
return declineDefaultList;
}
public boolean isDeclineDefaultList() {
return declineDefaultList;
}
// CHECKSTYLE:ON
/**
@ -301,18 +301,18 @@ public class Privacy extends IQ {
* @param declineDefaultList indicates if the receiver declines the use of a default list.
*/
// CHECKSTYLE:OFF
public void setDeclineDefaultList(boolean declineDefaultList) {
this.declineDefaultList = declineDefaultList;
}
public void setDeclineDefaultList(boolean declineDefaultList) {
this.declineDefaultList = declineDefaultList;
}
/**
/**
* Returns all the list names the user has defined to group restrictions.
*
* @return a Set with Strings containing every list names.
*/
public Set<String> getPrivacyListNames() {
return this.itemLists.keySet();
}
public Set<String> getPrivacyListNames() {
return this.itemLists.keySet();
}
// CHECKSTYLE:ON
@Override
@ -322,40 +322,40 @@ public class Privacy extends IQ {
// Add the active tag
if (this.isDeclineActiveList()) {
buf.append("<active/>");
buf.append("<active/>");
} else {
if (this.getActiveName() != null) {
if (this.getActiveName() != null) {
buf.append("<active name=\"").escape(getActiveName()).append("\"/>");
}
}
// Add the default tag
if (this.isDeclineDefaultList()) {
buf.append("<default/>");
buf.append("<default/>");
} else {
if (this.getDefaultName() != null) {
if (this.getDefaultName() != null) {
buf.append("<default name=\"").escape(getDefaultName()).append("\"/>");
}
}
}
// Add the list with their privacy items
for (Map.Entry<String, List<PrivacyItem>> entry : this.getItemLists().entrySet()) {
String listName = entry.getKey();
List<PrivacyItem> items = entry.getValue();
// Begin the list tag
if (items.isEmpty()) {
// Begin the list tag
if (items.isEmpty()) {
buf.append("<list name=\"").escape(listName).append("\"/>");
} else {
} else {
buf.append("<list name=\"").escape(listName).append("\">");
}
for (PrivacyItem item : items) {
// Append the item xml representation
buf.append(item.toXML());
}
// Close the list tag
if (!items.isEmpty()) {
buf.append("</list>");
}
}
}
for (PrivacyItem item : items) {
// Append the item xml representation
buf.append(item.toXML());
}
// Close the list tag
if (!items.isEmpty()) {
buf.append("</list>");
}
}
// CHECKSTYLE:ON
return buf;
}

View file

@ -47,20 +47,20 @@ public class PrivacyProvider extends IQProvider<Privacy> {
if (eventType == XmlPullParser.START_TAG) {
// CHECKSTYLE:OFF
if (parser.getName().equals("active")) {
String activeName = parser.getAttributeValue("", "name");
if (activeName == null) {
privacy.setDeclineActiveList(true);
} else {
privacy.setActiveName(activeName);
}
String activeName = parser.getAttributeValue("", "name");
if (activeName == null) {
privacy.setDeclineActiveList(true);
} else {
privacy.setActiveName(activeName);
}
}
else if (parser.getName().equals("default")) {
String defaultName = parser.getAttributeValue("", "name");
if (defaultName == null) {
privacy.setDeclineDefaultList(true);
} else {
privacy.setDefaultName(defaultName);
}
String defaultName = parser.getAttributeValue("", "name");
if (defaultName == null) {
privacy.setDeclineDefaultList(true);
} else {
privacy.setDefaultName(defaultName);
}
}
// CHECKSTYLE:ON
else if (parser.getName().equals("list")) {
@ -75,10 +75,10 @@ public class PrivacyProvider extends IQProvider<Privacy> {
}
return privacy;
}
}
// Parse the list complex type
private static void parseList(XmlPullParser parser, Privacy privacy) throws XmlPullParserException, IOException, SmackException {
// Parse the list complex type
private static void parseList(XmlPullParser parser, Privacy privacy) throws XmlPullParserException, IOException, SmackException {
boolean done = false;
String listName = parser.getAttributeValue("", "name");
ArrayList<PrivacyItem> items = new ArrayList<PrivacyItem>();
@ -87,7 +87,7 @@ public class PrivacyProvider extends IQProvider<Privacy> {
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("item")) {
// CHECKSTYLE:OFF
items.add(parseItem(parser));
items.add(parseItem(parser));
// CHECKSTYLE:ON
}
}
@ -100,10 +100,10 @@ public class PrivacyProvider extends IQProvider<Privacy> {
privacy.setPrivacyList(listName, items);
// CHECKSTYLE:OFF
}
}
// Parse the list complex type
private static PrivacyItem parseItem(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException {
// Parse the list complex type
private static PrivacyItem parseItem(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException {
// CHECKSTYLE:ON
// Retrieves the required attributes
String actionValue = parser.getAttributeValue("", "action");
@ -142,7 +142,7 @@ public class PrivacyProvider extends IQProvider<Privacy> {
parseItemChildElements(parser, item);
return item;
// CHECKSTYLE:OFF
}
}
// CHECKSTYLE:ON
private static void parseItemChildElements(XmlPullParser parser, PrivacyItem privacyItem) throws XmlPullParserException, IOException {