mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 14:22:05 +01:00
Merge remote-tracking branch 'my/master'
This commit is contained in:
commit
b558a128c3
30 changed files with 203 additions and 136 deletions
|
@ -104,5 +104,18 @@
|
||||||
<property name="checkEmptyJavadoc" value="true"/>
|
<property name="checkEmptyJavadoc" value="true"/>
|
||||||
<property name="checkHtml" value="false"/>
|
<property name="checkHtml" value="false"/>
|
||||||
</module>
|
</module>
|
||||||
|
<module name="ParenPad">
|
||||||
|
</module>
|
||||||
|
<module name="NoWhitespaceAfter">
|
||||||
|
<property name="tokens" value="INC
|
||||||
|
, DEC
|
||||||
|
, UNARY_MINUS
|
||||||
|
, UNARY_PLUS
|
||||||
|
, BNOT, LNOT
|
||||||
|
, DOT
|
||||||
|
, ARRAY_DECLARATOR
|
||||||
|
, INDEX_OP
|
||||||
|
"/>
|
||||||
|
</module>
|
||||||
</module>
|
</module>
|
||||||
</module>
|
</module>
|
||||||
|
|
|
@ -248,11 +248,13 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
*/
|
*/
|
||||||
private final ExecutorService cachedExecutorService = Executors.newCachedThreadPool(
|
private final ExecutorService cachedExecutorService = Executors.newCachedThreadPool(
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
|
// CHECKSTYLE:OFF
|
||||||
new SmackExecutorThreadFactory( // threadFactory
|
new SmackExecutorThreadFactory( // threadFactory
|
||||||
this,
|
this,
|
||||||
"Cached Executor"
|
"Cached Executor"
|
||||||
)
|
)
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
// CHECKSTYLE:ON
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -149,7 +149,7 @@ public final class SmackConfiguration {
|
||||||
* @param mech the SASL mechanism to be added
|
* @param mech the SASL mechanism to be added
|
||||||
*/
|
*/
|
||||||
public static void addSaslMech(String mech) {
|
public static void addSaslMech(String mech) {
|
||||||
if(! defaultMechs.contains(mech) ) {
|
if(!defaultMechs.contains(mech)) {
|
||||||
defaultMechs.add(mech);
|
defaultMechs.add(mech);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,11 @@
|
||||||
|
|
||||||
package org.jivesoftware.smack;
|
package org.jivesoftware.smack;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.Nonza;
|
||||||
import org.jivesoftware.smack.packet.Stanza;
|
import org.jivesoftware.smack.packet.Stanza;
|
||||||
import org.jivesoftware.smack.packet.StreamError;
|
import org.jivesoftware.smack.packet.StreamError;
|
||||||
import org.jivesoftware.smack.packet.XMPPError;
|
import org.jivesoftware.smack.packet.XMPPError;
|
||||||
|
import org.jxmpp.jid.Jid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A generic exception that is thrown when an error occurs performing an
|
* A generic exception that is thrown when an error occurs performing an
|
||||||
|
@ -72,48 +74,28 @@ public abstract class XMPPException extends Exception {
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 212790389529249604L;
|
private static final long serialVersionUID = 212790389529249604L;
|
||||||
private final XMPPError error;
|
private final XMPPError error;
|
||||||
|
private final Stanza stanza;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new XMPPErrorException with the given builder.
|
||||||
|
*
|
||||||
|
* @param xmppErrorBuilder
|
||||||
|
* @deprecated Use {@link #XMPPErrorException(Stanza, XMPPError)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public XMPPErrorException(XMPPError.Builder xmppErrorBuilder) {
|
public XMPPErrorException(XMPPError.Builder xmppErrorBuilder) {
|
||||||
this(xmppErrorBuilder.build());
|
this(null, xmppErrorBuilder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new XMPPException with the XMPPError that was the root case of the exception.
|
* Creates a new XMPPErrorException with the XMPPError that was the root case of the exception.
|
||||||
*
|
*
|
||||||
* @param error the root cause of the exception.
|
* @param error the root cause of the exception.
|
||||||
*/
|
*/
|
||||||
public XMPPErrorException(XMPPError error) {
|
public XMPPErrorException(Stanza stanza, XMPPError error) {
|
||||||
super();
|
super();
|
||||||
this.error = error;
|
this.error = error;
|
||||||
}
|
this.stanza = stanza;
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new XMPPException with a description of the exception, an XMPPError, and the
|
|
||||||
* Throwable that was the root cause of the exception.
|
|
||||||
*
|
|
||||||
* @param message a description of the exception.
|
|
||||||
* @param error the root cause of the exception.
|
|
||||||
* @param wrappedThrowable the root cause of the exception.
|
|
||||||
* @deprecated use {@link #XMPPException.XMPPErrorException(XMPPError)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public XMPPErrorException(String message, XMPPError error, Throwable wrappedThrowable) {
|
|
||||||
super(message, wrappedThrowable);
|
|
||||||
this.error = error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new XMPPException with a description of the exception and the XMPPException
|
|
||||||
* that was the root cause of the exception.
|
|
||||||
*
|
|
||||||
* @param message a description of the exception.
|
|
||||||
* @param error the root cause of the exception.
|
|
||||||
* @deprecated use {@link #XMPPException.XMPPErrorException(XMPPError)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public XMPPErrorException(String message, XMPPError error) {
|
|
||||||
super(message);
|
|
||||||
this.error = error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,23 +110,53 @@ public abstract class XMPPException extends Exception {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
String superMessage = super.getMessage();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (superMessage != null) {
|
|
||||||
return superMessage;
|
if (stanza != null) {
|
||||||
}
|
Jid from = stanza.getFrom();
|
||||||
else {
|
if (from != null) {
|
||||||
return error.toString();
|
sb.append("XMPP error reply received from " + from + ": ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sb.append(error);
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ifHasErrorThenThrow(Stanza packet) throws XMPPErrorException {
|
public static void ifHasErrorThenThrow(Stanza packet) throws XMPPErrorException {
|
||||||
XMPPError xmppError = packet.getError();
|
XMPPError xmppError = packet.getError();
|
||||||
if (xmppError != null) {
|
if (xmppError != null) {
|
||||||
throw new XMPPErrorException(xmppError);
|
throw new XMPPErrorException(packet, xmppError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class FailedNonzaException extends XMPPException {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final XMPPError.Condition condition;
|
||||||
|
|
||||||
|
private final Nonza nonza;
|
||||||
|
|
||||||
|
public FailedNonzaException(Nonza nonza, XMPPError.Condition condition) {
|
||||||
|
this.condition = condition;
|
||||||
|
this.nonza = nonza;
|
||||||
|
}
|
||||||
|
|
||||||
|
public XMPPError.Condition getCondition() {
|
||||||
|
return condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Nonza getNonza() {
|
||||||
|
return nonza;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class StreamErrorException extends XMPPException {
|
public static class StreamErrorException extends XMPPException {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2015 Florian Schmaus
|
* Copyright © 2015-2016 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -34,6 +34,7 @@ public class UnparsedIQ extends IQ {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
||||||
throw new UnsupportedOperationException();
|
xml.escape(content);
|
||||||
|
return xml;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class ProxyInfo
|
||||||
private ProxyType proxyType;
|
private ProxyType proxyType;
|
||||||
private final ProxySocketConnection proxySocketConnection;
|
private final ProxySocketConnection proxySocketConnection;
|
||||||
|
|
||||||
public ProxyInfo( ProxyType pType, String pHost, int pPort, String pUser,
|
public ProxyInfo(ProxyType pType, String pHost, int pPort, String pUser,
|
||||||
String pPass)
|
String pPass)
|
||||||
{
|
{
|
||||||
this.proxyType = pType;
|
this.proxyType = pType;
|
||||||
|
|
|
@ -983,9 +983,9 @@ public class PacketParserUtils {
|
||||||
private static String getLanguageAttribute(XmlPullParser parser) {
|
private static String getLanguageAttribute(XmlPullParser parser) {
|
||||||
// CHECKSTYLE:OFF
|
// CHECKSTYLE:OFF
|
||||||
for (int i = 0; i < parser.getAttributeCount(); i++) {
|
for (int i = 0; i < parser.getAttributeCount(); i++) {
|
||||||
// CHECKSTYLE:ON
|
|
||||||
String attributeName = parser.getAttributeName(i);
|
String attributeName = parser.getAttributeName(i);
|
||||||
if ( "xml:lang".equals(attributeName) ||
|
if ( "xml:lang".equals(attributeName) ||
|
||||||
|
// CHECKSTYLE:ON
|
||||||
("lang".equals(attributeName) &&
|
("lang".equals(attributeName) &&
|
||||||
"xml".equals(parser.getAttributePrefix(i)))) {
|
"xml".equals(parser.getAttributePrefix(i)))) {
|
||||||
// CHECKSTYLE:OFF
|
// CHECKSTYLE:OFF
|
||||||
|
|
|
@ -249,7 +249,7 @@ public class StringUtils {
|
||||||
*/
|
*/
|
||||||
public static String encodeHex(byte[] bytes) {
|
public static String encodeHex(byte[] bytes) {
|
||||||
char[] hexChars = new char[bytes.length * 2];
|
char[] hexChars = new char[bytes.length * 2];
|
||||||
for ( int j = 0; j < bytes.length; j++ ) {
|
for (int j = 0; j < bytes.length; j++) {
|
||||||
int v = bytes[j] & 0xFF;
|
int v = bytes[j] & 0xFF;
|
||||||
hexChars[j * 2] = HEX_CHARS[v >>> 4];
|
hexChars[j * 2] = HEX_CHARS[v >>> 4];
|
||||||
hexChars[j * 2 + 1] = HEX_CHARS[v & 0x0F];
|
hexChars[j * 2 + 1] = HEX_CHARS[v & 0x0F];
|
||||||
|
|
|
@ -83,7 +83,7 @@ public final class Thing {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (toStringCache == null) {
|
if (toStringCache == null) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append( "Thing " + nodeInfo + " [");
|
sb.append("Thing " + nodeInfo + " [");
|
||||||
Iterator<Tag> it = metaTags.values().iterator();
|
Iterator<Tag> it = metaTags.values().iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Tag tag = it.next();
|
Tag tag = it.next();
|
||||||
|
|
|
@ -169,7 +169,7 @@ public final class BlockingCommandManager extends Manager {
|
||||||
|
|
||||||
BlockListIQ blockListIQ = new BlockListIQ();
|
BlockListIQ blockListIQ = new BlockListIQ();
|
||||||
BlockListIQ blockListIQResult = connection().createPacketCollectorAndSend(blockListIQ).nextResultOrThrow();
|
BlockListIQ blockListIQResult = connection().createPacketCollectorAndSend(blockListIQ).nextResultOrThrow();
|
||||||
blockListCached = blockListIQResult.getJids();
|
blockListCached = blockListIQResult.getBlockedJidsCopy();
|
||||||
|
|
||||||
return Collections.unmodifiableList(blockListCached);
|
return Collections.unmodifiableList(blockListCached);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.blocking.element;
|
package org.jivesoftware.smackx.blocking.element;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -52,9 +53,10 @@ public class BlockListIQ extends IQ {
|
||||||
public BlockListIQ(List<Jid> jids) {
|
public BlockListIQ(List<Jid> jids) {
|
||||||
super(ELEMENT, NAMESPACE);
|
super(ELEMENT, NAMESPACE);
|
||||||
if (jids == null) {
|
if (jids == null) {
|
||||||
jids = Collections.emptyList();
|
this.jids = Collections.emptyList();
|
||||||
|
} else {
|
||||||
|
this.jids = Collections.unmodifiableList(jids);
|
||||||
}
|
}
|
||||||
this.jids = jids;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,14 +67,23 @@ public class BlockListIQ extends IQ {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the JIDs.
|
* Get the JIDs as unmodifiable list.
|
||||||
*
|
*
|
||||||
* @return the JIDs
|
* @return the blocked JIDs
|
||||||
*/
|
*/
|
||||||
public List<Jid> getJids() {
|
public List<Jid> getBlockedJids() {
|
||||||
return jids;
|
return jids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a copy of the blocked list JIDs. This copy is modifiable.
|
||||||
|
*
|
||||||
|
* @return the blocked JIDs
|
||||||
|
*/
|
||||||
|
public List<Jid> getBlockedJidsCopy() {
|
||||||
|
return new ArrayList<>(getBlockedJids());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
||||||
if (jids.isEmpty()) {
|
if (jids.isEmpty()) {
|
||||||
|
|
|
@ -280,7 +280,7 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
|
||||||
XMPPError.Builder error = XMPPError.from(XMPPError.Condition.item_not_found, errorMessage);
|
XMPPError.Builder error = XMPPError.from(XMPPError.Condition.item_not_found, errorMessage);
|
||||||
IQ errorIQ = IQ.createErrorResponse(this.bytestreamRequest, error);
|
IQ errorIQ = IQ.createErrorResponse(this.bytestreamRequest, error);
|
||||||
this.manager.getConnection().sendStanza(errorIQ);
|
this.manager.getConnection().sendStanza(errorIQ);
|
||||||
throw new XMPPErrorException(error);
|
throw new XMPPErrorException(errorIQ, error.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -615,6 +615,7 @@ public final class AdHocCommandManager extends Manager {
|
||||||
* @return the command instance to execute.
|
* @return the command instance to execute.
|
||||||
* @throws XMPPErrorException if there is problem creating the new instance.
|
* @throws XMPPErrorException if there is problem creating the new instance.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
private LocalCommand newInstanceOfCmd(String commandNode, String sessionID) throws XMPPErrorException
|
private LocalCommand newInstanceOfCmd(String commandNode, String sessionID) throws XMPPErrorException
|
||||||
{
|
{
|
||||||
AdHocCommandInfo commandInfo = commands.get(commandNode);
|
AdHocCommandInfo commandInfo = commands.get(commandNode);
|
||||||
|
|
|
@ -95,8 +95,14 @@ public class AdHocCommandDataProvider extends IQProvider<AdHocCommandData> {
|
||||||
adHocCommandData.setForm(dataFormProvider.parse(parser));
|
adHocCommandData.setForm(dataFormProvider.parse(parser));
|
||||||
}
|
}
|
||||||
else if (parser.getName().equals("note")) {
|
else if (parser.getName().equals("note")) {
|
||||||
AdHocCommandNote.Type type = AdHocCommandNote.Type.valueOf(
|
String typeString = parser.getAttributeValue("", "type");
|
||||||
parser.getAttributeValue("", "type"));
|
AdHocCommandNote.Type type;
|
||||||
|
if (typeString != null) {
|
||||||
|
type = AdHocCommandNote.Type.valueOf(typeString);
|
||||||
|
} else {
|
||||||
|
// Type is optional and 'info' if not present.
|
||||||
|
type = AdHocCommandNote.Type.info;
|
||||||
|
}
|
||||||
String value = parser.nextText();
|
String value = parser.nextText();
|
||||||
adHocCommandData.addNote(new AdHocCommandNote(type, value));
|
adHocCommandData.addNote(new AdHocCommandNote(type, value));
|
||||||
}
|
}
|
||||||
|
|
|
@ -327,7 +327,7 @@ public final class FileTransferNegotiator extends Manager {
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new XMPPErrorException(iqResponse.getError());
|
throw new XMPPErrorException(iqResponse, iqResponse.getError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -36,6 +36,6 @@ public class ValidationConsistencyException extends IllegalArgumentException {
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
public ValidationConsistencyException(String message) {
|
public ValidationConsistencyException(String message) {
|
||||||
super( message);
|
super(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,13 +47,13 @@ public class GetBlockingListTest {
|
||||||
public void checkBlockListIQ() throws Exception {
|
public void checkBlockListIQ() throws Exception {
|
||||||
IQ iq = (IQ) PacketParserUtils.parseStanza(blockListIQExample);
|
IQ iq = (IQ) PacketParserUtils.parseStanza(blockListIQExample);
|
||||||
BlockListIQ blockListIQ = (BlockListIQ) iq;
|
BlockListIQ blockListIQ = (BlockListIQ) iq;
|
||||||
Assert.assertEquals(2, blockListIQ.getJids().size());
|
Assert.assertEquals(2, blockListIQ.getBlockedJids().size());
|
||||||
Assert.assertEquals(JidCreate.from("romeo@montague.net"), blockListIQ.getJids().get(0));
|
Assert.assertEquals(JidCreate.from("romeo@montague.net"), blockListIQ.getBlockedJids().get(0));
|
||||||
Assert.assertEquals(JidCreate.from("iago@shakespeare.lit"), blockListIQ.getJids().get(1));
|
Assert.assertEquals(JidCreate.from("iago@shakespeare.lit"), blockListIQ.getBlockedJids().get(1));
|
||||||
|
|
||||||
IQ iq2 = (IQ) PacketParserUtils.parseStanza(emptyBlockListIQExample);
|
IQ iq2 = (IQ) PacketParserUtils.parseStanza(emptyBlockListIQExample);
|
||||||
BlockListIQ emptyBlockListIQ = (BlockListIQ) iq2;
|
BlockListIQ emptyBlockListIQ = (BlockListIQ) iq2;
|
||||||
Assert.assertEquals(0, emptyBlockListIQ.getJids().size());
|
Assert.assertEquals(0, emptyBlockListIQ.getBlockedJids().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class DataFormTest {
|
||||||
FormField field = new FormField("testField1");
|
FormField field = new FormField("testField1");
|
||||||
df.addField(field);
|
df.addField(field);
|
||||||
|
|
||||||
assertNotNull( df.toXML());
|
assertNotNull(df.toXML());
|
||||||
String output = df.toXML().toString();
|
String output = df.toXML().toString();
|
||||||
assertEquals(TEST_OUTPUT_1, output);
|
assertEquals(TEST_OUTPUT_1, output);
|
||||||
|
|
||||||
|
@ -65,10 +65,10 @@ public class DataFormTest {
|
||||||
|
|
||||||
assertNotNull(df);
|
assertNotNull(df);
|
||||||
assertNotNull(df.getFields());
|
assertNotNull(df.getFields());
|
||||||
assertEquals(1 , df.getFields().size() );
|
assertEquals(1 , df.getFields().size());
|
||||||
assertEquals(1 , df.getInstructions().size());
|
assertEquals(1 , df.getInstructions().size());
|
||||||
|
|
||||||
assertNotNull( df.toXML());
|
assertNotNull(df.toXML());
|
||||||
output = df.toXML().toString();
|
output = df.toXML().toString();
|
||||||
assertEquals(TEST_OUTPUT_1, output);
|
assertEquals(TEST_OUTPUT_1, output);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public class DataFormTest {
|
||||||
df.addExtensionElement(layout);
|
df.addExtensionElement(layout);
|
||||||
|
|
||||||
|
|
||||||
assertNotNull( df.toXML());
|
assertNotNull(df.toXML());
|
||||||
String output = df.toXML().toString();
|
String output = df.toXML().toString();
|
||||||
assertEquals(TEST_OUTPUT_2, output);
|
assertEquals(TEST_OUTPUT_2, output);
|
||||||
|
|
||||||
|
@ -103,14 +103,14 @@ public class DataFormTest {
|
||||||
|
|
||||||
assertNotNull(df);
|
assertNotNull(df);
|
||||||
assertNotNull(df.getExtensionElements());
|
assertNotNull(df.getExtensionElements());
|
||||||
assertEquals(1 , df.getExtensionElements().size() );
|
assertEquals(1 , df.getExtensionElements().size());
|
||||||
Element element = df.getExtensionElements().get(0);
|
Element element = df.getExtensionElements().get(0);
|
||||||
assertNotNull(element);
|
assertNotNull(element);
|
||||||
layout = (DataLayout) element;
|
layout = (DataLayout) element;
|
||||||
|
|
||||||
assertEquals(3 , layout.getPageLayout().size());
|
assertEquals(3 , layout.getPageLayout().size());
|
||||||
|
|
||||||
assertNotNull( df.toXML());
|
assertNotNull(df.toXML());
|
||||||
output = df.toXML().toString();
|
output = df.toXML().toString();
|
||||||
assertEquals(TEST_OUTPUT_2, output);
|
assertEquals(TEST_OUTPUT_2, output);
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ public class DataFormTest {
|
||||||
ValidateElement dv = new RangeValidateElement("xs:integer","1111", "9999");
|
ValidateElement dv = new RangeValidateElement("xs:integer","1111", "9999");
|
||||||
field.setValidateElement(dv);
|
field.setValidateElement(dv);
|
||||||
|
|
||||||
assertNotNull( df.toXML());
|
assertNotNull(df.toXML());
|
||||||
String output = df.toXML().toString();
|
String output = df.toXML().toString();
|
||||||
assertEquals(TEST_OUTPUT_3, output);
|
assertEquals(TEST_OUTPUT_3, output);
|
||||||
|
|
||||||
|
@ -137,14 +137,14 @@ public class DataFormTest {
|
||||||
|
|
||||||
assertNotNull(df);
|
assertNotNull(df);
|
||||||
assertNotNull(df.getFields());
|
assertNotNull(df.getFields());
|
||||||
assertEquals(1 , df.getFields().size() );
|
assertEquals(1 , df.getFields().size());
|
||||||
Element element = df.getFields().get(0).getValidateElement();
|
Element element = df.getFields().get(0).getValidateElement();
|
||||||
assertNotNull(element);
|
assertNotNull(element);
|
||||||
dv = (ValidateElement) element;
|
dv = (ValidateElement) element;
|
||||||
|
|
||||||
assertEquals("xs:integer" , dv.getDatatype());
|
assertEquals("xs:integer" , dv.getDatatype());
|
||||||
|
|
||||||
assertNotNull( df.toXML());
|
assertNotNull(df.toXML());
|
||||||
output = df.toXML().toString();
|
output = df.toXML().toString();
|
||||||
assertEquals(TEST_OUTPUT_3, output);
|
assertEquals(TEST_OUTPUT_3, output);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,9 +76,9 @@ public class DataLayoutTest {
|
||||||
Section section = new Section("section Label");
|
Section section = new Section("section Label");
|
||||||
section.getSectionLayout().add(new Text("SectionText"));
|
section.getSectionLayout().add(new Text("SectionText"));
|
||||||
layout.getPageLayout().add(section);
|
layout.getPageLayout().add(section);
|
||||||
layout.getPageLayout().add(new Text( "PageText"));
|
layout.getPageLayout().add(new Text("PageText"));
|
||||||
|
|
||||||
assertNotNull( layout.toXML());
|
assertNotNull(layout.toXML());
|
||||||
String output = layout.toXML().toString();
|
String output = layout.toXML().toString();
|
||||||
assertEquals(TEST_OUTPUT_2, output);
|
assertEquals(TEST_OUTPUT_2, output);
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ public class DataLayoutTest {
|
||||||
assertEquals(3 , layout.getPageLayout().size());
|
assertEquals(3 , layout.getPageLayout().size());
|
||||||
assertEquals("Label", layout.getLabel());
|
assertEquals("Label", layout.getLabel());
|
||||||
|
|
||||||
assertNotNull( layout.toXML());
|
assertNotNull(layout.toXML());
|
||||||
output = layout.toXML().toString();
|
output = layout.toXML().toString();
|
||||||
assertEquals(TEST_OUTPUT_2, output);
|
assertEquals(TEST_OUTPUT_2, output);
|
||||||
}
|
}
|
||||||
|
@ -101,18 +101,18 @@ public class DataLayoutTest {
|
||||||
Fieldref reffield = new Fieldref("testField1");
|
Fieldref reffield = new Fieldref("testField1");
|
||||||
layout.getPageLayout().add(reffield);
|
layout.getPageLayout().add(reffield);
|
||||||
Section section = new Section("section Label - & \u00E9 \u00E1 ");
|
Section section = new Section("section Label - & \u00E9 \u00E1 ");
|
||||||
section.getSectionLayout().add(new Text( "SectionText - & \u00E9 \u00E1 "));
|
section.getSectionLayout().add(new Text("SectionText - & \u00E9 \u00E1 "));
|
||||||
layout.getPageLayout().add(section);
|
layout.getPageLayout().add(section);
|
||||||
layout.getPageLayout().add(new Text( "PageText - & \u00E9 \u00E1 "));
|
layout.getPageLayout().add(new Text("PageText - & \u00E9 \u00E1 "));
|
||||||
|
|
||||||
section = new Section("<html>Number of Persons by<br/> Nationality and Status</html>");
|
section = new Section("<html>Number of Persons by<br/> Nationality and Status</html>");
|
||||||
section.getSectionLayout().add(new Reportedref());
|
section.getSectionLayout().add(new Reportedref());
|
||||||
layout.getPageLayout().add(section);
|
layout.getPageLayout().add(section);
|
||||||
|
|
||||||
layout.getPageLayout().add(new Text( "<html><font color='red'><em>DO NOT DELAY</em></font><br/>supply further information</html>"));
|
layout.getPageLayout().add(new Text("<html><font color='red'><em>DO NOT DELAY</em></font><br/>supply further information</html>"));
|
||||||
|
|
||||||
|
|
||||||
assertNotNull( layout.toXML());
|
assertNotNull(layout.toXML());
|
||||||
String output = layout.toXML().toString();
|
String output = layout.toXML().toString();
|
||||||
assertEquals(TEST_OUTPUT_SPECIAL, output);
|
assertEquals(TEST_OUTPUT_SPECIAL, output);
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ public class DataLayoutTest {
|
||||||
assertEquals("<html><font color='red'><em>DO NOT DELAY</em></font><br/>supply further information</html>", text.getText());
|
assertEquals("<html><font color='red'><em>DO NOT DELAY</em></font><br/>supply further information</html>", text.getText());
|
||||||
|
|
||||||
|
|
||||||
assertNotNull( layout.toXML());
|
assertNotNull(layout.toXML());
|
||||||
output = layout.toXML().toString();
|
output = layout.toXML().toString();
|
||||||
assertEquals(TEST_OUTPUT_SPECIAL, output);
|
assertEquals(TEST_OUTPUT_SPECIAL, output);
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ public class DataLayoutTest {
|
||||||
parser.next();
|
parser.next();
|
||||||
|
|
||||||
DataForm form = pr.parse(parser);
|
DataForm form = pr.parse(parser);
|
||||||
assertNotNull( form);
|
assertNotNull(form);
|
||||||
assertEquals(1 , form.getExtensionElements().size());
|
assertEquals(1 , form.getExtensionElements().size());
|
||||||
|
|
||||||
DataLayout layout = (DataLayout) form.getExtensionElements().get(0);
|
DataLayout layout = (DataLayout) form.getExtensionElements().get(0);
|
||||||
|
@ -163,7 +163,7 @@ public class DataLayoutTest {
|
||||||
assertEquals("<html><font color='red'><em>DO NOT DELAY</em></font><br/>supply further information</html>", text.getText());
|
assertEquals("<html><font color='red'><em>DO NOT DELAY</em></font><br/>supply further information</html>", text.getText());
|
||||||
|
|
||||||
|
|
||||||
assertNotNull( layout.toXML());
|
assertNotNull(layout.toXML());
|
||||||
String output = layout.toXML().toString();
|
String output = layout.toXML().toString();
|
||||||
assertEquals(TEST_OUTPUT_SPECIAL, output);
|
assertEquals(TEST_OUTPUT_SPECIAL, output);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class DataValidationTest {
|
||||||
|
|
||||||
ValidateElement dv = new BasicValidateElement(null);
|
ValidateElement dv = new BasicValidateElement(null);
|
||||||
|
|
||||||
assertNotNull( dv.toXML());
|
assertNotNull(dv.toXML());
|
||||||
String output = dv.toXML().toString();
|
String output = dv.toXML().toString();
|
||||||
assertEquals(TEST_OUTPUT_MIN, output);
|
assertEquals(TEST_OUTPUT_MIN, output);
|
||||||
|
|
||||||
|
@ -58,9 +58,9 @@ public class DataValidationTest {
|
||||||
|
|
||||||
assertNotNull(dv);
|
assertNotNull(dv);
|
||||||
assertEquals("xs:string", dv.getDatatype());
|
assertEquals("xs:string", dv.getDatatype());
|
||||||
assertTrue( dv instanceof BasicValidateElement);
|
assertTrue(dv instanceof BasicValidateElement);
|
||||||
|
|
||||||
assertNotNull( dv.toXML());
|
assertNotNull(dv.toXML());
|
||||||
output = dv.toXML().toString();
|
output = dv.toXML().toString();
|
||||||
assertEquals(TEST_OUTPUT_MIN, output);
|
assertEquals(TEST_OUTPUT_MIN, output);
|
||||||
}
|
}
|
||||||
|
@ -71,9 +71,9 @@ public class DataValidationTest {
|
||||||
ValidateElement dv = new RangeValidateElement("xs:string", "min-val", "max-val");
|
ValidateElement dv = new RangeValidateElement("xs:string", "min-val", "max-val");
|
||||||
|
|
||||||
ListRange listRange = new ListRange(111L, 999L);
|
ListRange listRange = new ListRange(111L, 999L);
|
||||||
dv.setListRange(listRange );
|
dv.setListRange(listRange);
|
||||||
|
|
||||||
assertNotNull( dv.toXML());
|
assertNotNull(dv.toXML());
|
||||||
String output = dv.toXML().toString();
|
String output = dv.toXML().toString();
|
||||||
assertEquals(TEST_OUTPUT_RANGE, output);
|
assertEquals(TEST_OUTPUT_RANGE, output);
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ public class DataValidationTest {
|
||||||
|
|
||||||
assertNotNull(dv);
|
assertNotNull(dv);
|
||||||
assertEquals("xs:string", dv.getDatatype());
|
assertEquals("xs:string", dv.getDatatype());
|
||||||
assertTrue(dv instanceof RangeValidateElement );
|
assertTrue(dv instanceof RangeValidateElement);
|
||||||
RangeValidateElement rdv = (RangeValidateElement) dv;
|
RangeValidateElement rdv = (RangeValidateElement) dv;
|
||||||
assertEquals("min-val", rdv.getMin());
|
assertEquals("min-val", rdv.getMin());
|
||||||
assertEquals("max-val", rdv.getMax());
|
assertEquals("max-val", rdv.getMax());
|
||||||
|
@ -92,7 +92,7 @@ public class DataValidationTest {
|
||||||
assertEquals(999, rdv.getListRange().getMax().intValue());
|
assertEquals(999, rdv.getListRange().getMax().intValue());
|
||||||
|
|
||||||
|
|
||||||
assertNotNull( dv.toXML());
|
assertNotNull(dv.toXML());
|
||||||
output = dv.toXML().toString();
|
output = dv.toXML().toString();
|
||||||
assertEquals(TEST_OUTPUT_RANGE, output);
|
assertEquals(TEST_OUTPUT_RANGE, output);
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ public class DataValidationTest {
|
||||||
|
|
||||||
ValidateElement dv = new RangeValidateElement(null, null, null);
|
ValidateElement dv = new RangeValidateElement(null, null, null);
|
||||||
|
|
||||||
assertNotNull( dv.toXML());
|
assertNotNull(dv.toXML());
|
||||||
String output = dv.toXML().toString();
|
String output = dv.toXML().toString();
|
||||||
assertEquals(TEST_OUTPUT_RANGE2, output);
|
assertEquals(TEST_OUTPUT_RANGE2, output);
|
||||||
|
|
||||||
|
@ -112,12 +112,12 @@ public class DataValidationTest {
|
||||||
|
|
||||||
assertNotNull(dv);
|
assertNotNull(dv);
|
||||||
assertEquals("xs:string", dv.getDatatype());
|
assertEquals("xs:string", dv.getDatatype());
|
||||||
assertTrue(dv instanceof RangeValidateElement );
|
assertTrue(dv instanceof RangeValidateElement);
|
||||||
RangeValidateElement rdv = (RangeValidateElement) dv;
|
RangeValidateElement rdv = (RangeValidateElement) dv;
|
||||||
assertEquals(null, rdv.getMin());
|
assertEquals(null, rdv.getMin());
|
||||||
assertEquals(null, rdv.getMax());
|
assertEquals(null, rdv.getMax());
|
||||||
|
|
||||||
assertNotNull( rdv.toXML());
|
assertNotNull(rdv.toXML());
|
||||||
output = rdv.toXML().toString();
|
output = rdv.toXML().toString();
|
||||||
assertEquals(TEST_OUTPUT_RANGE2, output);
|
assertEquals(TEST_OUTPUT_RANGE2, output);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.Stanza;
|
import org.jivesoftware.smack.packet.Stanza;
|
||||||
import org.jivesoftware.smack.packet.XMPPError;
|
|
||||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
import org.jxmpp.jid.DomainBareJid;
|
import org.jxmpp.jid.DomainBareJid;
|
||||||
import org.jxmpp.jid.EntityFullJid;
|
import org.jxmpp.jid.EntityFullJid;
|
||||||
|
@ -113,8 +112,7 @@ public class ConnectionUtils {
|
||||||
public Stanza answer(InvocationOnMock invocation) throws Throwable {
|
public Stanza answer(InvocationOnMock invocation) throws Throwable {
|
||||||
Stanza packet = protocol.getResponses().poll();
|
Stanza packet = protocol.getResponses().poll();
|
||||||
if (packet == null) return packet;
|
if (packet == null) return packet;
|
||||||
XMPPError xmppError = packet.getError();
|
XMPPErrorException.ifHasErrorThenThrow(packet);
|
||||||
if (xmppError != null) throw new XMPPErrorException(xmppError);
|
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -346,37 +346,62 @@ public class RosterPacket extends IQ {
|
||||||
* have a subscription to the user's presence; this is the default value, so if the
|
* have a subscription to the user's presence; this is the default value, so if the
|
||||||
* subscription attribute is not included then the state is to be understood as "none".
|
* subscription attribute is not included then the state is to be understood as "none".
|
||||||
*/
|
*/
|
||||||
none,
|
none('⊥'),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The user has a subscription to the contact's presence, but the contact does not have a
|
* The user has a subscription to the contact's presence, but the contact does not have a
|
||||||
* subscription to the user's presence.
|
* subscription to the user's presence.
|
||||||
*/
|
*/
|
||||||
to,
|
to('←'),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The contact has a subscription to the user's presence, but the user does not have a
|
* The contact has a subscription to the user's presence, but the user does not have a
|
||||||
* subscription to the contact's presence.
|
* subscription to the contact's presence.
|
||||||
*/
|
*/
|
||||||
from,
|
from('→'),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The user and the contact have subscriptions to each other's presence (also called a
|
* The user and the contact have subscriptions to each other's presence (also called a
|
||||||
* "mutual subscription").
|
* "mutual subscription").
|
||||||
*/
|
*/
|
||||||
both,
|
both('↔'),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The user wishes to stop receiving presence updates from the subscriber.
|
* The user wishes to stop receiving presence updates from the subscriber.
|
||||||
*/
|
*/
|
||||||
remove,
|
remove('⚡'),
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
private static final char ME = '●';
|
||||||
|
|
||||||
|
private final String symbol;
|
||||||
|
|
||||||
|
private ItemType(char secondSymbolChar) {
|
||||||
|
StringBuilder sb = new StringBuilder(2);
|
||||||
|
sb.append(ME).append(secondSymbolChar);
|
||||||
|
symbol = sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
public static ItemType fromString(String string) {
|
public static ItemType fromString(String string) {
|
||||||
if (StringUtils.isNullOrEmpty(string)) {
|
if (StringUtils.isNullOrEmpty(string)) {
|
||||||
return none;
|
return none;
|
||||||
}
|
}
|
||||||
return ItemType.valueOf(string.toLowerCase(Locale.US));
|
return ItemType.valueOf(string.toLowerCase(Locale.US));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a String containing symbols representing the item type. The first symbol in the
|
||||||
|
* string is a big dot, representing the local entity. The second symbol represents the
|
||||||
|
* established subscription relation and is typically an arrow. The head(s) of the arrow
|
||||||
|
* point in the direction presence messages are sent. For example, if there is only a head
|
||||||
|
* pointing to the big dot, then the local user will receive presence information from the
|
||||||
|
* remote entity.
|
||||||
|
*
|
||||||
|
* @return the symbolic representation of this item type.
|
||||||
|
*/
|
||||||
|
public String asSymbol() {
|
||||||
|
return symbol;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.igniterealtime.smack.inttest.SmackIntegrationTestFramework.TestRunRes
|
||||||
import org.jivesoftware.smack.SmackException;
|
import org.jivesoftware.smack.SmackException;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||||
|
import org.jivesoftware.smack.packet.Message;
|
||||||
import org.jivesoftware.smack.packet.XMPPError;
|
import org.jivesoftware.smack.packet.XMPPError;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
@ -97,8 +98,9 @@ public class SmackIntegrationTestFrameworkUnitTest {
|
||||||
|
|
||||||
@SmackIntegrationTest
|
@SmackIntegrationTest
|
||||||
public void throwRuntimeExceptionTest() throws XMPPErrorException {
|
public void throwRuntimeExceptionTest() throws XMPPErrorException {
|
||||||
throw new XMPPException.XMPPErrorException(
|
Message message = new Message();
|
||||||
XMPPError.from(XMPPError.Condition.bad_request, DESCRIPTIVE_TEXT));
|
throw new XMPPException.XMPPErrorException(message,
|
||||||
|
XMPPError.from(XMPPError.Condition.bad_request, DESCRIPTIVE_TEXT).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import java.util.logging.Logger;
|
||||||
* @author rob@iharder.net
|
* @author rob@iharder.net
|
||||||
* @version 2.2.1
|
* @version 2.2.1
|
||||||
*/
|
*/
|
||||||
|
// CHECKSTYLE:OFF
|
||||||
public final class Base64
|
public final class Base64
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = Logger.getLogger(Base64.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(Base64.class.getName());
|
||||||
|
@ -1682,4 +1683,4 @@ public final class Base64
|
||||||
|
|
||||||
|
|
||||||
} // end class Base64
|
} // end class Base64
|
||||||
|
// CHECKSTYLE:ON
|
||||||
|
|
|
@ -30,19 +30,19 @@ import java.awt.image.ColorModel;
|
||||||
public abstract class AbstractBufferedImageOp implements BufferedImageOp, Cloneable {
|
public abstract class AbstractBufferedImageOp implements BufferedImageOp, Cloneable {
|
||||||
|
|
||||||
public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel dstCM) {
|
public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel dstCM) {
|
||||||
if ( dstCM == null )
|
if (dstCM == null)
|
||||||
dstCM = src.getColorModel();
|
dstCM = src.getColorModel();
|
||||||
return new BufferedImage(dstCM, dstCM.createCompatibleWritableRaster(src.getWidth(), src.getHeight()), dstCM.isAlphaPremultiplied(), null);
|
return new BufferedImage(dstCM, dstCM.createCompatibleWritableRaster(src.getWidth(), src.getHeight()), dstCM.isAlphaPremultiplied(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rectangle2D getBounds2D( BufferedImage src ) {
|
public Rectangle2D getBounds2D(BufferedImage src) {
|
||||||
return new Rectangle(0, 0, src.getWidth(), src.getHeight());
|
return new Rectangle(0, 0, src.getWidth(), src.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point2D getPoint2D( Point2D srcPt, Point2D dstPt ) {
|
public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) {
|
||||||
if ( dstPt == null )
|
if (dstPt == null)
|
||||||
dstPt = new Point2D.Double();
|
dstPt = new Point2D.Double();
|
||||||
dstPt.setLocation( srcPt.getX(), srcPt.getY() );
|
dstPt.setLocation(srcPt.getX(), srcPt.getY());
|
||||||
return dstPt;
|
return dstPt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,11 +62,11 @@ public abstract class AbstractBufferedImageOp implements BufferedImageOp, Clonea
|
||||||
* @return the pixels
|
* @return the pixels
|
||||||
* @see #setRGB
|
* @see #setRGB
|
||||||
*/
|
*/
|
||||||
public int[] getRGB( BufferedImage image, int x, int y, int width, int height, int[] pixels ) {
|
public int[] getRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels) {
|
||||||
int type = image.getType();
|
int type = image.getType();
|
||||||
if ( type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB )
|
if (type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB)
|
||||||
return (int [])image.getRaster().getDataElements( x, y, width, height, pixels );
|
return (int [])image.getRaster().getDataElements(x, y, width, height, pixels);
|
||||||
return image.getRGB( x, y, width, height, pixels, 0, width );
|
return image.getRGB(x, y, width, height, pixels, 0, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,19 +80,19 @@ public abstract class AbstractBufferedImageOp implements BufferedImageOp, Clonea
|
||||||
* @param pixels the array of pixels to set
|
* @param pixels the array of pixels to set
|
||||||
* @see #getRGB
|
* @see #getRGB
|
||||||
*/
|
*/
|
||||||
public void setRGB( BufferedImage image, int x, int y, int width, int height, int[] pixels ) {
|
public void setRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels) {
|
||||||
int type = image.getType();
|
int type = image.getType();
|
||||||
if ( type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB )
|
if (type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB)
|
||||||
image.getRaster().setDataElements( x, y, width, height, pixels );
|
image.getRaster().setDataElements(x, y, width, height, pixels);
|
||||||
else
|
else
|
||||||
image.setRGB( x, y, width, height, pixels, 0, width );
|
image.setRGB(x, y, width, height, pixels, 0, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
try {
|
try {
|
||||||
return super.clone();
|
return super.clone();
|
||||||
}
|
}
|
||||||
catch ( CloneNotSupportedException e ) {
|
catch (CloneNotSupportedException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,7 +163,7 @@ public class QuantizeFilter extends WholeImageFilter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int[] filterPixels( int width, int height, int[] inPixels, Rectangle transformedSpace ) {
|
protected int[] filterPixels(int width, int height, int[] inPixels, Rectangle transformedSpace) {
|
||||||
int[] outPixels = new int[width*height];
|
int[] outPixels = new int[width*height];
|
||||||
|
|
||||||
quantize(inPixels, outPixels, width, height, numColors, dither, serpentine);
|
quantize(inPixels, outPixels, width, height, numColors, dither, serpentine);
|
||||||
|
|
|
@ -43,7 +43,7 @@ public abstract class WholeImageFilter extends AbstractBufferedImageOp {
|
||||||
public WholeImageFilter() {
|
public WholeImageFilter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public BufferedImage filter( BufferedImage src, BufferedImage dst ) {
|
public BufferedImage filter(BufferedImage src, BufferedImage dst) {
|
||||||
int width = src.getWidth();
|
int width = src.getWidth();
|
||||||
int height = src.getHeight();
|
int height = src.getHeight();
|
||||||
int type = src.getType();
|
int type = src.getType();
|
||||||
|
@ -53,15 +53,15 @@ public abstract class WholeImageFilter extends AbstractBufferedImageOp {
|
||||||
transformedSpace = new Rectangle(0, 0, width, height);
|
transformedSpace = new Rectangle(0, 0, width, height);
|
||||||
transformSpace(transformedSpace);
|
transformSpace(transformedSpace);
|
||||||
|
|
||||||
if ( dst == null ) {
|
if (dst == null) {
|
||||||
ColorModel dstCM = src.getColorModel();
|
ColorModel dstCM = src.getColorModel();
|
||||||
dst = new BufferedImage(dstCM, dstCM.createCompatibleWritableRaster(transformedSpace.width, transformedSpace.height), dstCM.isAlphaPremultiplied(), null);
|
dst = new BufferedImage(dstCM, dstCM.createCompatibleWritableRaster(transformedSpace.width, transformedSpace.height), dstCM.isAlphaPremultiplied(), null);
|
||||||
}
|
}
|
||||||
WritableRaster dstRaster = dst.getRaster();
|
WritableRaster dstRaster = dst.getRaster();
|
||||||
|
|
||||||
int[] inPixels = getRGB( src, 0, 0, width, height, null );
|
int[] inPixels = getRGB(src, 0, 0, width, height, null);
|
||||||
inPixels = filterPixels( width, height, inPixels, transformedSpace );
|
inPixels = filterPixels(width, height, inPixels, transformedSpace);
|
||||||
setRGB( dst, 0, 0, transformedSpace.width, transformedSpace.height, inPixels );
|
setRGB(dst, 0, 0, transformedSpace.width, transformedSpace.height, inPixels);
|
||||||
|
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,6 @@ public abstract class WholeImageFilter extends AbstractBufferedImageOp {
|
||||||
* @param transformedSpace the output bounds
|
* @param transformedSpace the output bounds
|
||||||
* @return the output pixels
|
* @return the output pixels
|
||||||
*/
|
*/
|
||||||
protected abstract int[] filterPixels( int width, int height, int[] inPixels, Rectangle transformedSpace );
|
protected abstract int[] filterPixels(int width, int height, int[] inPixels, Rectangle transformedSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@ public final class QueueDetails implements ExtensionElement {
|
||||||
|
|
||||||
eventType = parser.next();
|
eventType = parser.next();
|
||||||
while ((eventType != XmlPullParser.END_TAG)
|
while ((eventType != XmlPullParser.END_TAG)
|
||||||
|| (! "user".equals(parser.getName())))
|
|| (!"user".equals(parser.getName())))
|
||||||
{
|
{
|
||||||
if ("position".equals(parser.getName())) {
|
if ("position".equals(parser.getName())) {
|
||||||
position = Integer.parseInt(parser.nextText());
|
position = Integer.parseInt(parser.nextText());
|
||||||
|
@ -180,7 +180,7 @@ public final class QueueDetails implements ExtensionElement {
|
||||||
throw new SmackException(e);
|
throw new SmackException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( parser.getName().equals( "waitTime" ) ) {
|
else if(parser.getName().equals("waitTime")) {
|
||||||
Date wait;
|
Date wait;
|
||||||
try {
|
try {
|
||||||
wait = dateFormat.parse(parser.nextText());
|
wait = dateFormat.parse(parser.nextText());
|
||||||
|
|
|
@ -469,7 +469,7 @@ public class Workgroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fireInvitationEvent(WorkgroupInvitation invitation) {
|
private void fireInvitationEvent(WorkgroupInvitation invitation) {
|
||||||
for (WorkgroupInvitationListener listener : invitationListeners ){
|
for (WorkgroupInvitationListener listener : invitationListeners) {
|
||||||
// CHECKSTYLE:OFF
|
// CHECKSTYLE:OFF
|
||||||
listener.invitationReceived(invitation);
|
listener.invitationReceived(invitation);
|
||||||
// CHECKSTYLE:ON
|
// CHECKSTYLE:ON
|
||||||
|
|
|
@ -31,10 +31,10 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||||
import org.jivesoftware.smack.SmackException.ConnectionException;
|
import org.jivesoftware.smack.SmackException.ConnectionException;
|
||||||
import org.jivesoftware.smack.SmackException.SecurityRequiredByServerException;
|
import org.jivesoftware.smack.SmackException.SecurityRequiredByServerException;
|
||||||
import org.jivesoftware.smack.SynchronizationPoint;
|
import org.jivesoftware.smack.SynchronizationPoint;
|
||||||
|
import org.jivesoftware.smack.XMPPException.FailedNonzaException;
|
||||||
import org.jivesoftware.smack.XMPPException.StreamErrorException;
|
import org.jivesoftware.smack.XMPPException.StreamErrorException;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
|
||||||
import org.jivesoftware.smack.compress.packet.Compressed;
|
import org.jivesoftware.smack.compress.packet.Compressed;
|
||||||
import org.jivesoftware.smack.compression.XMPPInputOutputStream;
|
import org.jivesoftware.smack.compression.XMPPInputOutputStream;
|
||||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||||
|
@ -67,7 +67,6 @@ import org.jivesoftware.smack.sm.packet.StreamManagement.StreamManagementFeature
|
||||||
import org.jivesoftware.smack.sm.predicates.Predicate;
|
import org.jivesoftware.smack.sm.predicates.Predicate;
|
||||||
import org.jivesoftware.smack.sm.provider.ParseStreamManagement;
|
import org.jivesoftware.smack.sm.provider.ParseStreamManagement;
|
||||||
import org.jivesoftware.smack.packet.Nonza;
|
import org.jivesoftware.smack.packet.Nonza;
|
||||||
import org.jivesoftware.smack.packet.XMPPError;
|
|
||||||
import org.jivesoftware.smack.proxy.ProxyInfo;
|
import org.jivesoftware.smack.proxy.ProxyInfo;
|
||||||
import org.jivesoftware.smack.util.ArrayBlockingQueueWithShutdown;
|
import org.jivesoftware.smack.util.ArrayBlockingQueueWithShutdown;
|
||||||
import org.jivesoftware.smack.util.Async;
|
import org.jivesoftware.smack.util.Async;
|
||||||
|
@ -221,10 +220,10 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
*/
|
*/
|
||||||
private String smSessionId;
|
private String smSessionId;
|
||||||
|
|
||||||
private final SynchronizationPoint<XMPPException> smResumedSyncPoint = new SynchronizationPoint<XMPPException>(
|
private final SynchronizationPoint<FailedNonzaException> smResumedSyncPoint = new SynchronizationPoint<>(
|
||||||
this, "stream resumed element");
|
this, "stream resumed element");
|
||||||
|
|
||||||
private final SynchronizationPoint<XMPPException> smEnabledSyncPoint = new SynchronizationPoint<XMPPException>(
|
private final SynchronizationPoint<SmackException> smEnabledSyncPoint = new SynchronizationPoint<>(
|
||||||
this, "stream enabled element");
|
this, "stream enabled element");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1096,10 +1095,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
if (enabled.isResumeSet()) {
|
if (enabled.isResumeSet()) {
|
||||||
smSessionId = enabled.getId();
|
smSessionId = enabled.getId();
|
||||||
if (StringUtils.isNullOrEmpty(smSessionId)) {
|
if (StringUtils.isNullOrEmpty(smSessionId)) {
|
||||||
XMPPError.Builder builder = XMPPError.getBuilder(XMPPError.Condition.bad_request);
|
SmackException xmppException = new SmackException("Stream Management 'enabled' element with resume attribute but without session id received");
|
||||||
builder.setDescriptiveEnText("Stream Management 'enabled' element with resume attribute but without session id received");
|
|
||||||
XMPPErrorException xmppException = new XMPPErrorException(
|
|
||||||
builder);
|
|
||||||
smEnabledSyncPoint.reportFailure(xmppException);
|
smEnabledSyncPoint.reportFailure(xmppException);
|
||||||
throw xmppException;
|
throw xmppException;
|
||||||
}
|
}
|
||||||
|
@ -1115,8 +1111,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
break;
|
break;
|
||||||
case Failed.ELEMENT:
|
case Failed.ELEMENT:
|
||||||
Failed failed = ParseStreamManagement.failed(parser);
|
Failed failed = ParseStreamManagement.failed(parser);
|
||||||
XMPPError.Builder xmppError = XMPPError.getBuilder(failed.getXMPPErrorCondition());
|
FailedNonzaException xmppException = new FailedNonzaException(failed, failed.getXMPPErrorCondition());
|
||||||
XMPPException xmppException = new XMPPErrorException(xmppError);
|
|
||||||
// If only XEP-198 would specify different failure elements for the SM
|
// If only XEP-198 would specify different failure elements for the SM
|
||||||
// enable and SM resume failure case. But this is not the case, so we
|
// enable and SM resume failure case. But this is not the case, so we
|
||||||
// need to determine if this is a 'Failed' response for either 'Enable'
|
// need to determine if this is a 'Failed' response for either 'Enable'
|
||||||
|
@ -1128,7 +1123,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
if (!smEnabledSyncPoint.requestSent()) {
|
if (!smEnabledSyncPoint.requestSent()) {
|
||||||
throw new IllegalStateException("Failed element received but SM was not previously enabled");
|
throw new IllegalStateException("Failed element received but SM was not previously enabled");
|
||||||
}
|
}
|
||||||
smEnabledSyncPoint.reportFailure(xmppException);
|
smEnabledSyncPoint.reportFailure(new SmackException(xmppException));
|
||||||
// Report success for last lastFeaturesReceived so that in case a
|
// Report success for last lastFeaturesReceived so that in case a
|
||||||
// failed resumption, we can continue with normal resource binding.
|
// failed resumption, we can continue with normal resource binding.
|
||||||
// See text of XEP-198 5. below Example 11.
|
// See text of XEP-198 5. below Example 11.
|
||||||
|
|
Loading…
Reference in a new issue