repo stringclasses 1k values | file_url stringlengths 96 373 | file_path stringlengths 11 294 | content stringlengths 0 32.8k | language stringclasses 1 value | license stringclasses 6 values | commit_sha stringclasses 1k values | retrieved_at stringdate 2026-01-04 14:45:56 2026-01-04 18:30:23 | truncated bool 2 classes |
|---|---|---|---|---|---|---|---|---|
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/insn/cst/Constant.java | src/main/java/org/spongepowered/despector/ast/insn/cst/Constant.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.insn.cst;
import org.spongepowered.despector.ast.insn.Instruction;
/**
* An abstract instruction for constants.
*/
public abstract class Constant implements Instruction {
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/insn/cst/TypeConstant.java | src/main/java/org/spongepowered/despector/ast/insn/cst/TypeConstant.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.insn.cst;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.generic.ClassTypeSignature;
import org.spongepowered.despector.ast.generic.TypeSignature;
import org.spongepowered.despector.ast.insn.InstructionVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* A constant type value.
*/
public class TypeConstant extends Constant {
private ClassTypeSignature cst;
public TypeConstant(ClassTypeSignature cst) {
this.cst = checkNotNull(cst, "type");
}
/**
* Gets the constant value.
*/
public ClassTypeSignature getConstant() {
return this.cst;
}
/**
* Sets the constant value.
*/
public void setConstant(ClassTypeSignature type) {
this.cst = checkNotNull(type, "type");
}
@Override
public TypeSignature inferType() {
return ClassTypeSignature.of(this.cst.getDescriptor());
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof InstructionVisitor) {
((InstructionVisitor) visitor).visitTypeConstant(this);
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(2);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_TYPE_CONSTANT);
pack.writeString("cst").writeString(this.cst.getDescriptor());
pack.endMap();
}
@Override
public String toString() {
return this.cst.getClassName() + ".class";
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof TypeConstant)) {
return false;
}
TypeConstant insn = (TypeConstant) obj;
return this.cst.equals(insn.cst);
}
@Override
public int hashCode() {
return this.cst.hashCode();
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/insn/cst/package-info.java | src/main/java/org/spongepowered/despector/ast/insn/cst/package-info.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.despector.util.NonnullByDefault
package org.spongepowered.despector.ast.insn.cst;
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/insn/cst/IntConstant.java | src/main/java/org/spongepowered/despector/ast/insn/cst/IntConstant.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.insn.cst;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.generic.ClassTypeSignature;
import org.spongepowered.despector.ast.generic.TypeSignature;
import org.spongepowered.despector.ast.insn.InstructionVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* A constant int value.
*/
public class IntConstant extends Constant {
private int cst;
private IntFormat format = IntFormat.DECIMAL;
public IntConstant(int val) {
this.cst = val;
}
/**
* Gets the constant value.
*/
public int getConstant() {
return this.cst;
}
/**
* Sets the constant value.
*/
public void setConstant(int cst) {
this.cst = cst;
}
public IntFormat getFormat() {
return this.format;
}
public void setFormat(IntFormat format) {
this.format = checkNotNull(format, "format");
}
@Override
public TypeSignature inferType() {
return ClassTypeSignature.INT;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof InstructionVisitor) {
((InstructionVisitor) visitor).visitIntConstant(this);
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(2);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_INT_CONSTANT);
pack.writeString("cst").writeInt(this.cst);
pack.endMap();
}
@Override
public String toString() {
return String.valueOf(this.cst);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof IntConstant)) {
return false;
}
IntConstant cast = (IntConstant) obj;
return this.cst == cast.cst;
}
@Override
public int hashCode() {
return this.cst;
}
/**
* The format for an integer constant when emitted.
*/
public static enum IntFormat {
BINARY,
OCTAL,
DECIMAL,
HEXADECIMAL
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/insn/cst/FloatConstant.java | src/main/java/org/spongepowered/despector/ast/insn/cst/FloatConstant.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.insn.cst;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.generic.ClassTypeSignature;
import org.spongepowered.despector.ast.generic.TypeSignature;
import org.spongepowered.despector.ast.insn.InstructionVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* A constant float value.
*/
public class FloatConstant extends Constant {
private float cst;
public FloatConstant(float val) {
this.cst = val;
}
/**
* Gets the constant value.
*/
public float getConstant() {
return this.cst;
}
/**
* Sets the constant value.
*/
public void setConstant(float cst) {
this.cst = cst;
}
@Override
public TypeSignature inferType() {
return ClassTypeSignature.FLOAT;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof InstructionVisitor) {
((InstructionVisitor) visitor).visitFloatConstant(this);
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(2);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_FLOAT_CONSTANT);
pack.writeString("cst").writeFloat(this.cst);
pack.endMap();
}
@Override
public String toString() {
return String.valueOf(this.cst);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof FloatConstant)) {
return false;
}
FloatConstant cast = (FloatConstant) obj;
return this.cst == cast.cst;
}
@Override
public int hashCode() {
return Float.floatToIntBits(this.cst);
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/insn/cst/DoubleConstant.java | src/main/java/org/spongepowered/despector/ast/insn/cst/DoubleConstant.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.insn.cst;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.generic.ClassTypeSignature;
import org.spongepowered.despector.ast.generic.TypeSignature;
import org.spongepowered.despector.ast.insn.InstructionVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* A constant double value.
*/
public class DoubleConstant extends Constant {
private double cst;
public DoubleConstant(double val) {
this.cst = val;
}
/**
* Gets the constant value.
*/
public double getConstant() {
return this.cst;
}
/**
* Sets the constant value.
*/
public void setConstant(double cst) {
this.cst = cst;
}
@Override
public TypeSignature inferType() {
return ClassTypeSignature.DOUBLE;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof InstructionVisitor) {
((InstructionVisitor) visitor).visitDoubleConstant(this);
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(2);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_DOUBLE_CONSTANT);
pack.writeString("cst").writeDouble(this.cst);
pack.endMap();
}
@Override
public String toString() {
return String.valueOf(this.cst);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof DoubleConstant)) {
return false;
}
DoubleConstant cast = (DoubleConstant) obj;
return this.cst == cast.cst;
}
@Override
public int hashCode() {
long bits = Double.doubleToLongBits(this.cst);
return (int) ((bits >>> 32) ^ bits);
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/insn/cst/StringConstant.java | src/main/java/org/spongepowered/despector/ast/insn/cst/StringConstant.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.insn.cst;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.generic.ClassTypeSignature;
import org.spongepowered.despector.ast.generic.TypeSignature;
import org.spongepowered.despector.ast.insn.InstructionVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* A constant String value.
*/
public class StringConstant extends Constant {
private String cst;
public StringConstant(String cst) {
this.cst = checkNotNull(cst, "cst");
}
/**
* Gets the constant value.
*/
public String getConstant() {
return this.cst;
}
/**
* Sets the constant value.
*/
public void setConstant(String cst) {
this.cst = checkNotNull(cst, "cst");
}
@Override
public TypeSignature inferType() {
return ClassTypeSignature.STRING;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof InstructionVisitor) {
((InstructionVisitor) visitor).visitStringConstant(this);
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(2);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_STRING_CONSTANT);
pack.writeString("cst").writeString(this.cst);
pack.endMap();
}
@Override
public String toString() {
return "\"" + this.cst + "\"";
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof StringConstant)) {
return false;
}
StringConstant insn = (StringConstant) obj;
return this.cst.equals(insn.cst);
}
@Override
public int hashCode() {
return this.cst.hashCode();
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/insn/cst/NullConstant.java | src/main/java/org/spongepowered/despector/ast/insn/cst/NullConstant.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.insn.cst;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.generic.ClassTypeSignature;
import org.spongepowered.despector.ast.generic.TypeSignature;
import org.spongepowered.despector.ast.insn.InstructionVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* A constant null value.
*/
public final class NullConstant extends Constant {
public static final NullConstant NULL = new NullConstant();
private NullConstant() {
}
@Override
public TypeSignature inferType() {
return ClassTypeSignature.OBJECT;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof InstructionVisitor) {
((InstructionVisitor) visitor).visitNullConstant(this);
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(1);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_NULL_CONSTANT);
pack.endMap();
}
@Override
public String toString() {
return "null";
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof NullConstant)) {
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/insn/cst/LongConstant.java | src/main/java/org/spongepowered/despector/ast/insn/cst/LongConstant.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.insn.cst;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.generic.ClassTypeSignature;
import org.spongepowered.despector.ast.generic.TypeSignature;
import org.spongepowered.despector.ast.insn.InstructionVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* A constant long value.
*/
public class LongConstant extends Constant {
private long cst;
public LongConstant(long val) {
this.cst = val;
}
/**
* Gets the constant value.
*/
public long getConstant() {
return this.cst;
}
/**
* Sets the constant value.
*/
public void setConstant(long cst) {
this.cst = cst;
}
@Override
public TypeSignature inferType() {
return ClassTypeSignature.LONG;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof InstructionVisitor) {
((InstructionVisitor) visitor).visitLongConstant(this);
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(2);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_LONG_CONSTANT);
pack.writeString("cst").writeInt(this.cst);
pack.endMap();
}
@Override
public String toString() {
return String.valueOf(this.cst);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof LongConstant)) {
return false;
}
LongConstant cast = (LongConstant) obj;
return this.cst == cast.cst;
}
@Override
public int hashCode() {
return (int) ((this.cst >>> 32) ^ this.cst);
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/insn/condition/AndCondition.java | src/main/java/org/spongepowered/despector/ast/insn/condition/AndCondition.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.insn.condition;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Lists;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
import java.util.List;
/**
* A condition for the and of several other conditions.
*/
public class AndCondition extends Condition {
private final List<Condition> args;
public AndCondition(Condition... args) {
this.args = Lists.newArrayList(checkNotNull(args, "args"));
checkArgument(this.args.size() >= 2, "Not enough operands");
}
public AndCondition(Iterable<Condition> args) {
this.args = Lists.newArrayList(checkNotNull(args, "args"));
checkArgument(this.args.size() >= 2, "Not enough operands");
}
/**
* Gets the operands of this condition.
*/
public List<Condition> getOperands() {
return this.args;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof ConditionVisitor) {
((ConditionVisitor) visitor).visitAndCondition(this);
for (Condition c : this.args) {
c.accept(visitor);
}
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(2);
pack.writeString("id").writeInt(AstSerializer.CONDITION_ID_AND);
pack.writeString("args").startArray(this.args.size());
for (Condition arg : this.args) {
arg.writeTo(pack);
}
pack.endArray();
pack.endMap();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < this.args.size(); i++) {
Condition arg = this.args.get(i);
if (arg instanceof OrCondition) {
sb.append("(");
sb.append(this.args.get(i));
sb.append(')');
} else {
sb.append(this.args.get(i));
}
if (i < this.args.size() - 1) {
sb.append(" && ");
}
}
return sb.toString();
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof AndCondition)) {
return false;
}
AndCondition and = (AndCondition) o;
if (and.getOperands().size() != this.args.size()) {
return false;
}
for (int i = 0; i < this.args.size(); i++) {
if (!this.args.get(i).equals(and.getOperands().get(i))) {
return false;
}
}
return true;
}
@Override
public int hashCode() {
int h = 1;
for (Condition cond : this.args) {
h = h * 37 + cond.hashCode();
}
return h;
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/insn/condition/BooleanCondition.java | src/main/java/org/spongepowered/despector/ast/insn/condition/BooleanCondition.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.insn.condition;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.insn.Instruction;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* A condition based off of a simple boolean value.
*/
public class BooleanCondition extends Condition {
private Instruction value;
private boolean inverse;
public BooleanCondition(Instruction value, boolean inverse) {
this.value = checkNotNull(value, "value");
this.inverse = inverse;
}
/**
* Gets the instruction for the value of this condition.
*/
public Instruction getConditionValue() {
return this.value;
}
/**
* Sets the instruction for the value of this condition.
*/
public void setConditionValue(Instruction insn) {
this.value = checkNotNull(insn, "value");
}
/**
* Gets if this condition is marked as inverted.
*/
public boolean isInverse() {
return this.inverse;
}
/**
* Sets if this condition is marked as inverted.
*/
public void setInverse(boolean state) {
this.inverse = state;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof ConditionVisitor) {
((ConditionVisitor) visitor).visitBooleanCondition(this);
}
this.value.accept(visitor);
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(3);
pack.writeString("id").writeInt(AstSerializer.CONDITION_ID_BOOL);
pack.writeString("val");
this.value.writeTo(pack);
pack.writeString("inverse").writeBool(this.inverse);
pack.endMap();
}
@Override
public String toString() {
return (this.inverse ? "!" : "") + this.value;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof BooleanCondition)) {
return false;
}
BooleanCondition and = (BooleanCondition) o;
return this.value.equals(and.value) && this.inverse == and.inverse;
}
@Override
public int hashCode() {
int h = 1;
h = h * 37 + this.value.hashCode();
h = h * 37 + (this.inverse ? 0 : 1);
return h;
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/insn/condition/CompareCondition.java | src/main/java/org/spongepowered/despector/ast/insn/condition/CompareCondition.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.insn.condition;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.insn.Instruction;
import org.spongepowered.despector.decompiler.ir.Insn;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* A condition which compares two object or numerical values.
*/
public class CompareCondition extends Condition {
/**
* Gets the compare operator for the given conditional jump operator.
*/
public static CompareOperator fromOpcode(int op) {
switch (op) {
case Insn.IFEQ:
case Insn.IF_CMPEQ:
return CompareOperator.EQUAL;
case Insn.IFNE:
case Insn.IF_CMPNE:
return CompareOperator.NOT_EQUAL;
case Insn.IF_CMPGE:
return CompareOperator.GREATER_EQUAL;
case Insn.IF_CMPGT:
return CompareOperator.GREATER;
case Insn.IF_CMPLE:
return CompareOperator.LESS_EQUAL;
case Insn.IF_CMPLT:
return CompareOperator.LESS;
default:
throw new UnsupportedOperationException("Not a conditional jump opcode: " + op);
}
}
/**
* Represents a specific comparison operator.
*/
public static enum CompareOperator {
EQUAL(" == "),
NOT_EQUAL(" != "),
LESS_EQUAL(" <= "),
GREATER_EQUAL(" >= "),
LESS(" < "),
GREATER(" > ");
static {
EQUAL.inverse = NOT_EQUAL;
NOT_EQUAL.inverse = EQUAL;
LESS_EQUAL.inverse = GREATER;
GREATER_EQUAL.inverse = LESS;
LESS.inverse = GREATER_EQUAL;
GREATER.inverse = LESS_EQUAL;
}
private final String str;
private CompareOperator inverse;
CompareOperator(String str) {
this.str = checkNotNull(str, "str");
}
/**
* Gets the operator as its string representation.
*/
public String asString() {
return this.str;
}
/**
* Gets the operator which is the inverse of this operator.
*/
public CompareOperator inverse() {
return this.inverse;
}
}
private Instruction left;
private Instruction right;
private CompareOperator op;
public CompareCondition(Instruction left, Instruction right, CompareOperator op) {
this.left = checkNotNull(left, "left");
this.right = checkNotNull(right, "right");
this.op = checkNotNull(op, "op");
}
/**
* Gets the left operand of the comparison.
*/
public Instruction getLeft() {
return this.left;
}
/**
* Sets the left operand of the comparison.
*/
public void setLeft(Instruction left) {
this.left = checkNotNull(left, "left");
}
/**
* Gets the right operand of the comparison.
*/
public Instruction getRight() {
return this.right;
}
/**
* Sets the right operand of the comparison.
*/
public void setRight(Instruction right) {
this.right = checkNotNull(right, "right");
}
/**
* Gets the comparison operator.
*/
public CompareOperator getOperator() {
return this.op;
}
/**
* Sets the comparison operator.
*/
public void setOperator(CompareOperator op) {
this.op = checkNotNull(op, "op");
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof ConditionVisitor) {
((ConditionVisitor) visitor).visitCompareCondition(this);
}
this.left.accept(visitor);
this.right.accept(visitor);
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(4);
pack.writeString("id").writeInt(AstSerializer.CONDITION_ID_COMPARE);
pack.writeString("left");
this.left.writeTo(pack);
pack.writeString("right");
this.right.writeTo(pack);
pack.writeString("op").writeInt(this.op.ordinal());
pack.endMap();
}
@Override
public String toString() {
return this.left + this.op.asString() + this.right;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof CompareCondition)) {
return false;
}
CompareCondition and = (CompareCondition) o;
return and.right.equals(this.right) && and.left.equals(this.left) && this.op == and.op;
}
@Override
public int hashCode() {
int h = 1;
h = h * 37 + this.right.hashCode();
h = h * 37 + this.left.hashCode();
h = h * 37 + this.op.hashCode();
return h;
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/insn/condition/package-info.java | src/main/java/org/spongepowered/despector/ast/insn/condition/package-info.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.despector.util.NonnullByDefault
package org.spongepowered.despector.ast.insn.condition;
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/insn/condition/Condition.java | src/main/java/org/spongepowered/despector/ast/insn/condition/Condition.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.insn.condition;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* A boolean condition of arbitrary complexity.
*/
public abstract class Condition {
/**
* Passes itself and any child nodes to the given visitor.
*/
public abstract void accept(AstVisitor visitor);
@Override
public abstract String toString();
@Override
public abstract boolean equals(Object o);
@Override
public abstract int hashCode();
public abstract void writeTo(MessagePacker pack) throws IOException;
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/insn/condition/InverseCondition.java | src/main/java/org/spongepowered/despector/ast/insn/condition/InverseCondition.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.insn.condition;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* A condition based off of a simple boolean value.
*/
public class InverseCondition extends Condition {
private Condition value;
public InverseCondition(Condition value) {
this.value = checkNotNull(value, "value");
}
/**
* Gets the condition value being inverted.
*/
public Condition getConditionValue() {
return this.value;
}
/**
* Sets the condition value being inverted.
*/
public void setConditionValue(Condition val) {
this.value = checkNotNull(val, "value");
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof ConditionVisitor) {
((ConditionVisitor) visitor).visitInverseCondition(this);
this.value.accept(visitor);
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(2);
pack.writeString("id").writeInt(AstSerializer.CONDITION_ID_INVERSE);
pack.writeString("val");
this.value.writeTo(pack);
pack.endMap();
}
@Override
public String toString() {
return "!" + this.value;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof InverseCondition)) {
return false;
}
InverseCondition and = (InverseCondition) o;
return this.value.equals(and.value);
}
@Override
public int hashCode() {
int h = 1;
h = h * 37 + this.value.hashCode();
return h;
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/insn/condition/OrCondition.java | src/main/java/org/spongepowered/despector/ast/insn/condition/OrCondition.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.insn.condition;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Lists;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
import java.util.List;
/**
* A condition for the or of several other conditions.
*/
public class OrCondition extends Condition {
private final List<Condition> args;
public OrCondition(Condition... args) {
this.args = Lists.newArrayList(checkNotNull(args, "args"));
checkArgument(this.args.size() >= 1, "Not enough operands");
}
public OrCondition(List<Condition> args) {
this.args = checkNotNull(args, "args");
checkArgument(this.args.size() >= 1, "Not enough operands");
}
/**
* Gets the operands of this condition.
*/
public List<Condition> getOperands() {
return this.args;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof ConditionVisitor) {
((ConditionVisitor) visitor).visitOrCondition(this);
for (Condition c : this.args) {
c.accept(visitor);
}
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(2);
pack.writeString("id").writeInt(AstSerializer.CONDITION_ID_OR);
pack.writeString("args").startArray(this.args.size());
for (Condition arg : this.args) {
arg.writeTo(pack);
}
pack.endArray();
pack.endMap();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < this.args.size(); i++) {
sb.append(this.args.get(i));
if (i < this.args.size() - 1) {
sb.append(" || ");
}
}
return sb.toString();
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof OrCondition)) {
return false;
}
OrCondition and = (OrCondition) o;
if (and.getOperands().size() != this.args.size()) {
return false;
}
for (int i = 0; i < this.args.size(); i++) {
if (!this.args.get(i).equals(and.getOperands().get(i))) {
return false;
}
}
return true;
}
@Override
public int hashCode() {
int h = 1;
for (Condition arg : this.args) {
h = h * 37 + arg.hashCode();
}
return h;
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/insn/condition/ConditionVisitor.java | src/main/java/org/spongepowered/despector/ast/insn/condition/ConditionVisitor.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.insn.condition;
import org.spongepowered.despector.ast.AstVisitor;
public interface ConditionVisitor extends AstVisitor {
void visitAndCondition(AndCondition andCondition);
void visitBooleanCondition(BooleanCondition booleanCondition);
void visitCompareCondition(CompareCondition compareCondition);
void visitInverseCondition(InverseCondition inverseCondition);
void visitOrCondition(OrCondition orCondition);
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/Statement.java | src/main/java/org/spongepowered/despector/ast/stmt/Statement.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* Abstract type for a statement.
*/
public interface Statement {
/**
* Accepts the given visitor.
*/
void accept(AstVisitor visitor);
void writeTo(MessagePacker pack) throws IOException;
@Override
String toString();
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/package-info.java | src/main/java/org/spongepowered/despector/ast/stmt/package-info.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.despector.util.NonnullByDefault
package org.spongepowered.despector.ast.stmt;
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/StatementBlock.java | src/main/java/org/spongepowered/despector/ast/stmt/StatementBlock.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Lists;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.insn.InstructionVisitor;
import java.util.Iterator;
import java.util.List;
/**
* A block of statements.
*/
public class StatementBlock implements Iterable<Statement> {
/**
* The type of a block.
*/
public static enum Type {
BLOCK,
IF,
WHILE,
METHOD,
SWITCH,
TRY,
CATCH,
FINALLY
}
private Type type;
final List<Statement> statements;
public StatementBlock(Type type) {
this.type = checkNotNull(type, "type");
this.statements = Lists.newArrayList();
}
public StatementBlock(StatementBlock block) {
this.type = block.type;
this.statements = Lists.newArrayList(block.statements);
}
/**
* Gets the type of this statement block.
*/
public Type getType() {
return this.type;
}
/**
* Sets the type of this statement block.
*/
public void setType(Type t) {
this.type = checkNotNull(t, "type");
}
/**
* Sets the locals of this block.
*/
public List<Statement> getStatements() {
return this.statements;
}
/**
* Gets the number of statements in this block.
*/
public int getStatementCount() {
return this.statements.size();
}
public int size() {
return this.statements.size();
}
/**
* Gets the given statement in this block.
*/
public Statement getStatement(int i) {
return this.statements.get(i);
}
public Statement get(int i) {
return this.statements.get(i);
}
/**
* Appends the given statement to the end of this block.
*/
public void append(Statement insn) {
this.statements.add(checkNotNull(insn, "insn"));
}
/**
* Pops the last statement off this block and returns it.
*/
public Statement popStatement() {
Statement last = this.statements.get(this.statements.size() - 1);
this.statements.remove(this.statements.size() - 1);
return last;
}
/**
* Accepts the given visitor to each statement in this block.
*/
public void accept(AstVisitor visitor) {
if (visitor instanceof InstructionVisitor || visitor instanceof StatementVisitor) {
for (Statement stmt : this.statements) {
stmt.accept(visitor);
}
}
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for (Statement insn : this.statements) {
sb.append(insn.toString()).append("\n");
}
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof StatementBlock)) {
return false;
}
StatementBlock insn = (StatementBlock) obj;
if (this.type != insn.type) {
return false;
}
if (this.statements.size() != insn.statements.size()) {
return false;
}
for (int i = 0; i < this.statements.size(); i++) {
if (!this.statements.get(i).equals(insn.statements.get(i))) {
return false;
}
}
return true;
}
@Override
public int hashCode() {
int h = 1;
h = h * 37 + this.type.hashCode();
for (Statement stmt : this.statements) {
h = h * 37 + stmt.hashCode();
}
return h;
}
@Override
public Iterator<Statement> iterator() {
return new Itr();
}
class Itr implements Iterator<Statement> {
private int index;
@Override
public boolean hasNext() {
return StatementBlock.this.statements.size() > this.index;
}
@Override
public Statement next() {
return StatementBlock.this.statements.get(this.index++);
}
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/StatementVisitor.java | src/main/java/org/spongepowered/despector/ast/stmt/StatementVisitor.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.stmt.assign.ArrayAssignment;
import org.spongepowered.despector.ast.stmt.assign.InstanceFieldAssignment;
import org.spongepowered.despector.ast.stmt.assign.LocalAssignment;
import org.spongepowered.despector.ast.stmt.assign.StaticFieldAssignment;
import org.spongepowered.despector.ast.stmt.branch.Break;
import org.spongepowered.despector.ast.stmt.branch.DoWhile;
import org.spongepowered.despector.ast.stmt.branch.For;
import org.spongepowered.despector.ast.stmt.branch.ForEach;
import org.spongepowered.despector.ast.stmt.branch.If;
import org.spongepowered.despector.ast.stmt.branch.If.Elif;
import org.spongepowered.despector.ast.stmt.branch.If.Else;
import org.spongepowered.despector.ast.stmt.branch.Switch;
import org.spongepowered.despector.ast.stmt.branch.TryCatch;
import org.spongepowered.despector.ast.stmt.branch.TryCatch.CatchBlock;
import org.spongepowered.despector.ast.stmt.branch.While;
import org.spongepowered.despector.ast.stmt.invoke.InvokeStatement;
import org.spongepowered.despector.ast.stmt.misc.Comment;
import org.spongepowered.despector.ast.stmt.misc.Increment;
import org.spongepowered.despector.ast.stmt.misc.Return;
import org.spongepowered.despector.ast.stmt.misc.Throw;
public interface StatementVisitor extends AstVisitor {
void visitArrayAssignment(ArrayAssignment stmt);
void visitBreak(Break stmt);
void visitCatchBlock(CatchBlock stmt);
void visitComment(Comment stmt);
void visitDoWhile(DoWhile stmt);
void visitElif(Elif stmt);
void visitElse(Else stmt);
void visitFor(For stmt);
void visitForEach(ForEach stmt);
void visitIf(If stmt);
void visitIncrement(Increment stmt);
void visitInstanceFieldAssignment(InstanceFieldAssignment stmt);
void visitInvoke(InvokeStatement stmt);
void visitLocalAssignment(LocalAssignment stmt);
void visitReturn(Return stmt);
void visitStaticFieldAssignment(StaticFieldAssignment stmt);
void visitSwitch(Switch tableSwitch);
void visitSwitchCase(Switch.Case case1);
void visitThrow(Throw throwException);
void visitTryCatch(TryCatch tryBlock);
void visitWhile(While whileLoop);
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/misc/Comment.java | src/main/java/org/spongepowered/despector/ast/stmt/misc/Comment.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.misc;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.stmt.Statement;
import org.spongepowered.despector.ast.stmt.StatementVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* A comment statement.
*/
public class Comment implements Statement {
private final List<String> comment_text = new ArrayList<>();
public Comment(String text) {
for (String line : text.split("\n")) {
this.comment_text.add(line);
}
}
public Comment(List<String> texts) {
for (String text : texts) {
for (String line : text.split("\n")) {
this.comment_text.add(line);
}
}
}
public List<String> getCommentText() {
return this.comment_text;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof StatementVisitor) {
((StatementVisitor) visitor).visitComment(this);
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(2);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_COMMENT);
pack.writeString("comment").startArray(this.comment_text.size());
for (String line : this.comment_text) {
pack.writeString(line);
}
pack.endArray();
pack.endMap();
}
@Override
public String toString() {
if (this.comment_text.isEmpty()) {
return "";
}
if (this.comment_text.size() == 1) {
return "// " + this.comment_text.get(0);
}
StringBuilder str = new StringBuilder();
str.append("/*\n");
for (String line : this.comment_text) {
str.append(" * ").append(line).append("\n");
}
str.append(" */");
return str.toString();
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/misc/package-info.java | src/main/java/org/spongepowered/despector/ast/stmt/misc/package-info.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.despector.util.NonnullByDefault
package org.spongepowered.despector.ast.stmt.misc;
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/misc/Return.java | src/main/java/org/spongepowered/despector/ast/stmt/misc/Return.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.misc;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.insn.Instruction;
import org.spongepowered.despector.ast.stmt.Statement;
import org.spongepowered.despector.ast.stmt.StatementVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
import java.util.Optional;
import javax.annotation.Nullable;
/**
* A return statement which returns a value.
*/
public class Return implements Statement {
@Nullable
private Instruction value;
public Return() {
this.value = null;
}
public Return(@Nullable Instruction val) {
this.value = val;
}
/**
* Gets the value being returned, if present.
*/
public Optional<Instruction> getValue() {
return Optional.ofNullable(this.value);
}
/**
* Sets the value being returned, may be null.
*/
public void setValue(@Nullable Instruction insn) {
this.value = insn;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof StatementVisitor) {
((StatementVisitor) visitor).visitReturn(this);
}
if (this.value != null) {
this.value.accept(visitor);
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(2);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_RETURN);
pack.writeString("value");
if (this.value != null) {
this.value.writeTo(pack);
} else {
pack.writeNil();
}
pack.endMap();
}
@Override
public String toString() {
if (this.value == null) {
return "return;";
}
return "return " + this.value + ";";
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof Return)) {
return false;
}
Return insn = (Return) obj;
return this.value.equals(insn.value);
}
@Override
public int hashCode() {
return this.value.hashCode();
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/misc/Increment.java | src/main/java/org/spongepowered/despector/ast/stmt/misc/Increment.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.misc;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.Locals.LocalInstance;
import org.spongepowered.despector.ast.insn.InstructionVisitor;
import org.spongepowered.despector.ast.stmt.Statement;
import org.spongepowered.despector.ast.stmt.StatementVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* An increment statement. Example {@code var += increment_value;}.
*/
public class Increment implements Statement {
private LocalInstance local;
private int val;
public Increment(LocalInstance local, int val) {
this.local = checkNotNull(local, "local");
this.val = val;
}
/**
* Gets the local being incremented.
*/
public LocalInstance getLocal() {
return this.local;
}
/**
* Sets the local being incremented.
*/
public void setLocal(LocalInstance local) {
this.local = checkNotNull(local, "local");
}
/**
* Gets the value that the local is incremented by.
*/
public int getIncrementValue() {
return this.val;
}
/**
* Sets the value that the local is incremented by.
*/
public void setIncrementValue(int val) {
this.val = val;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof StatementVisitor) {
((StatementVisitor) visitor).visitIncrement(this);
}
if (visitor instanceof InstructionVisitor) {
((InstructionVisitor) visitor).visitLocalInstance(this.local);
}
}
@Override
public String toString() {
return this.local + " += " + this.val + ";";
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(3);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_INCREMENT);
pack.writeString("local");
this.local.writeToSimple(pack);
pack.writeString("increment").writeInt(this.val);
pack.endMap();
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof Increment)) {
return false;
}
Increment insn = (Increment) obj;
return this.local.equals(insn.local) && this.val == insn.val;
}
@Override
public int hashCode() {
int h = 1;
h = h * 37 + this.local.hashCode();
h = h * 37 + this.val;
return h;
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/misc/Throw.java | src/main/java/org/spongepowered/despector/ast/stmt/misc/Throw.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.misc;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.insn.Instruction;
import org.spongepowered.despector.ast.stmt.Statement;
import org.spongepowered.despector.ast.stmt.StatementVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* A statement throwing an exception type.
*/
public class Throw implements Statement {
private Instruction ex;
public Throw(Instruction arg) {
this.ex = checkNotNull(arg, "ex");
}
/**
* Gets the exception object being thrown.
*/
public Instruction getException() {
return this.ex;
}
/**
* Sets the exception object being thrown.
*/
public void setException(Instruction ex) {
this.ex = checkNotNull(ex, "ex");
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof StatementVisitor) {
((StatementVisitor) visitor).visitThrow(this);
}
this.ex.accept(visitor);
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(2);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_THROW);
pack.writeString("ex");
this.ex.writeTo(pack);
pack.endMap();
}
@Override
public String toString() {
return "throw " + this.ex + ";";
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof Throw)) {
return false;
}
Throw insn = (Throw) obj;
return this.ex.equals(insn.ex);
}
@Override
public int hashCode() {
return this.ex.hashCode();
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/branch/If.java | src/main/java/org/spongepowered/despector/ast/stmt/branch/If.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.branch;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.insn.condition.Condition;
import org.spongepowered.despector.ast.stmt.Statement;
import org.spongepowered.despector.ast.stmt.StatementBlock;
import org.spongepowered.despector.ast.stmt.StatementVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
/**
* An if block, possibly with attached else if and else blocks.
*/
public class If implements Statement {
private Condition condition;
private StatementBlock block;
private final List<Elif> elif_blocks = new ArrayList<>();
@Nullable
private Else else_block;
public If(Condition condition, StatementBlock insn) {
this.condition = checkNotNull(condition, "condition");
this.block = checkNotNull(insn, "block");
}
/**
* Gets the condition.
*/
public Condition getCondition() {
return this.condition;
}
/**
* Sets the condition.
*/
public void setCondition(Condition condition) {
this.condition = checkNotNull(condition, "condition");
}
/**
* Gets the body of the if statement.
*/
public StatementBlock getBody() {
return this.block;
}
/**
* Sets the body of the if statement.
*/
public void setBody(StatementBlock block) {
this.block = checkNotNull(block, "block");
}
/**
* Gets any else-if blocks attached to this if statement.
*/
public List<Elif> getElifBlocks() {
return this.elif_blocks;
}
/**
* Adds the given else-if block to this if statement.
*/
public void addElifBlock(Elif e) {
this.elif_blocks.add(checkNotNull(e, "elif"));
}
/**
* Gets the else block of this if statement, may be null.
*/
@Nullable
public Else getElseBlock() {
return this.else_block;
}
/**
* Sets the else block of this if statement, may be null.
*/
public void setElseBlock(@Nullable Else else_block) {
this.else_block = else_block;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof StatementVisitor) {
((StatementVisitor) visitor).visitIf(this);
}
this.condition.accept(visitor);
for (Statement stmt : this.block.getStatements()) {
stmt.accept(visitor);
}
for (Elif elif : this.elif_blocks) {
elif.accept(visitor);
}
if (this.else_block != null) {
this.else_block.accept(visitor);
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(5);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_IF);
pack.writeString("condition");
this.condition.writeTo(pack);
pack.writeString("body");
pack.startArray(this.block.getStatementCount());
for (Statement stmt : this.block.getStatements()) {
stmt.writeTo(pack);
}
pack.endArray();
pack.writeString("elif").startArray(this.elif_blocks.size());
for (Elif elif : this.elif_blocks) {
pack.startMap(2);
pack.writeString("condition");
elif.getCondition().writeTo(pack);
pack.writeString("body");
pack.startArray(elif.getBody().getStatementCount());
for (Statement stmt : elif.getBody().getStatements()) {
stmt.writeTo(pack);
}
pack.endArray();
pack.endMap();
}
pack.endArray();
pack.writeString("else");
if (this.else_block != null) {
pack.startArray(this.else_block.getBody().getStatementCount());
for (Statement stmt : this.else_block.getBody().getStatements()) {
stmt.writeTo(pack);
}
pack.endArray();
} else {
pack.writeNil();
}
pack.endMap();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("if (");
sb.append(this.condition).append(") {\n");
for (Statement insn : this.block.getStatements()) {
sb.append(" ").append(insn).append("\n");
}
sb.append("}");
if (this.else_block != null) {
sb.append(" ").append(this.else_block);
}
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof If)) {
return false;
}
If insn = (If) obj;
if (this.else_block != null) {
if (!this.else_block.equals(insn.else_block)) {
return false;
}
} else if (insn.else_block != null) {
return false;
}
if (!this.elif_blocks.equals(insn.elif_blocks)) {
return false;
}
return this.condition.equals(insn.condition) && this.block.equals(insn.block);
}
@Override
public int hashCode() {
int h = 1;
h = h * 37 + this.condition.hashCode();
h = h * 37 + this.block.hashCode();
h = h * 37 + (this.else_block == null ? 0 : this.else_block.hashCode());
for (Elif elif : this.elif_blocks) {
h = h * 37 + elif.hashCode();
}
return h;
}
/**
* An else-if block attached to an if statement.
*/
public class Elif {
private StatementBlock block;
private Condition condition;
public Elif(Condition cond, StatementBlock block) {
this.condition = checkNotNull(cond, "condition");
this.block = checkNotNull(block, "block");
If.this.addElifBlock(this);
}
/**
* Gets the condition of this block.
*/
public Condition getCondition() {
return this.condition;
}
/**
* Sets the condition of this block.
*/
public void setCondition(Condition cond) {
this.condition = checkNotNull(cond, "condition");
}
/**
* Gets the body of this block.
*/
public StatementBlock getBody() {
return this.block;
}
/**
* Sets the body of this block.
*/
public void setBody(StatementBlock block) {
this.block = checkNotNull(block, "block");
}
public void accept(AstVisitor visitor) {
if (visitor instanceof StatementVisitor) {
((StatementVisitor) visitor).visitElif(this);
}
for (Statement stmt : this.block.getStatements()) {
stmt.accept(visitor);
}
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("else if(");
sb.append(this.condition.toString());
sb.append(") {\n");
for (Statement insn : this.block.getStatements()) {
sb.append(" ").append(insn).append("\n");
}
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof Elif)) {
return false;
}
Elif insn = (Elif) obj;
return this.condition.equals(insn.condition) && this.block.equals(insn.block);
}
@Override
public int hashCode() {
int h = 1;
h = h * 37 + this.condition.hashCode();
h = h * 37 + this.block.hashCode();
return h;
}
}
/**
* The else block of an if statement.
*/
public class Else {
private StatementBlock block;
public Else(StatementBlock block) {
this.block = checkNotNull(block, "block");
If.this.setElseBlock(this);
}
/**
* Gets the body of this block.
*/
public StatementBlock getBody() {
return this.block;
}
/**
* Sets the body of this block.
*/
public void setBody(StatementBlock block) {
this.block = checkNotNull(block, "block");
}
public void accept(AstVisitor visitor) {
if (visitor instanceof StatementVisitor) {
((StatementVisitor) visitor).visitElse(this);
}
for (Statement stmt : this.block.getStatements()) {
stmt.accept(visitor);
}
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("else {\n");
for (Statement insn : this.block.getStatements()) {
sb.append(" ").append(insn).append("\n");
}
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof Else)) {
return false;
}
Else insn = (Else) obj;
return this.block.equals(insn.block);
}
@Override
public int hashCode() {
return this.block.hashCode();
}
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/branch/Break.java | src/main/java/org/spongepowered/despector/ast/stmt/branch/Break.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.branch;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.stmt.Statement;
import org.spongepowered.despector.ast.stmt.StatementVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
import java.util.List;
import javax.annotation.Nullable;
/**
* A statement breaking control flow out of a surrounding loop.
*/
public class Break implements Statement {
@Nullable
private Breakable loop;
private Type type;
private boolean nested;
public Break(@Nullable Breakable loop, Type type, boolean nested) {
this.loop = loop;
this.type = checkNotNull(type, "type");
this.nested = nested;
}
/**
* Gets the loop being broken.
*/
@Nullable
public Breakable getLoop() {
return this.loop;
}
/**
* Sets the loop being broken.
*/
public void setLoop(Breakable loop) {
this.loop = loop;
}
/**
* Gets whether this is a break or a continue statement.
*/
public Type getType() {
return this.type;
}
/**
* Sets whether this is a break or a continue statement.
*/
public void setType(Type type) {
this.type = type;
}
/**
* Gets if this break is breaking a loop other than the immediate
* surrounding loop and will therefore require a label on the outer loop.
*/
public boolean isNested() {
return this.nested;
}
/**
* Sets if this break is breaking a loop other than the immediate
* surrounding loop and will therefore require a label on the outer loop.
*/
public void setNested(boolean state) {
this.nested = state;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof StatementVisitor) {
((StatementVisitor) visitor).visitBreak(this);
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(4);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_BREAK);
pack.writeString("type").writeInt(this.type.ordinal());
pack.writeString("nested").writeBool(this.nested);
pack.writeString("break_id").writeInt(((Object) this).hashCode());
pack.endMap();
}
/**
* A marker interface for a statement which may be broken.
*/
public static interface Breakable {
/**
* Gets all control flow breaks for this statement.
*/
List<Break> getBreaks();
}
/**
* The type of the break statement.
*/
public static enum Type {
BREAK("break"),
CONTINUE("continue");
private final String keyword;
Type(String keyword) {
this.keyword = keyword;
}
/**
* Gets the java keyword for this type.
*/
public String getKeyword() {
return this.keyword;
}
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/branch/package-info.java | src/main/java/org/spongepowered/despector/ast/stmt/branch/package-info.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.despector.util.NonnullByDefault
package org.spongepowered.despector.ast.stmt.branch;
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/branch/While.java | src/main/java/org/spongepowered/despector/ast/stmt/branch/While.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.branch;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.insn.condition.Condition;
import org.spongepowered.despector.ast.stmt.Statement;
import org.spongepowered.despector.ast.stmt.StatementBlock;
import org.spongepowered.despector.ast.stmt.StatementVisitor;
import org.spongepowered.despector.ast.stmt.branch.Break.Breakable;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* A while loop.
*/
public class While implements Statement, Breakable {
private Condition condition;
private StatementBlock body;
private List<Break> breaks = new ArrayList<>();
public While(Condition condition, StatementBlock body) {
this.condition = checkNotNull(condition, "condition");
this.body = checkNotNull(body, "body");
}
/**
* Gets the condition of the loop.
*/
public Condition getCondition() {
return this.condition;
}
/**
* Sets the condition of the loop.
*/
public void setCondition(Condition condition) {
this.condition = checkNotNull(condition, "condition");
}
/**
* Gets the body of the loop.
*/
public StatementBlock getBody() {
return this.body;
}
/**
* Sets the body of the loop.
*/
public void setBody(StatementBlock block) {
this.body = checkNotNull(block, "body");
}
@Override
public List<Break> getBreaks() {
return this.breaks;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof StatementVisitor) {
((StatementVisitor) visitor).visitWhile(this);
}
this.condition.accept(visitor);
for (Statement stmt : this.body.getStatements()) {
stmt.accept(visitor);
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(4);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_WHILE);
pack.writeString("condition");
this.condition.writeTo(pack);
pack.writeString("breakpoints").startArray(this.breaks.size());
for (Break br : this.breaks) {
pack.writeInt(((Object) br).hashCode());
}
pack.endArray();
pack.writeString("body");
pack.startArray(this.body.getStatementCount());
for (Statement stmt : this.body.getStatements()) {
stmt.writeTo(pack);
}
pack.endArray();
pack.endMap();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("while (");
sb.append(this.condition);
sb.append(") {\n");
for (Statement insn : this.body.getStatements()) {
sb.append(" ").append(insn).append("\n");
}
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof While)) {
return false;
}
While insn = (While) obj;
return this.condition.equals(insn.condition) && this.body.equals(insn.body);
}
@Override
public int hashCode() {
int h = 1;
h = h * 37 + this.condition.hashCode();
h = h * 37 + this.body.hashCode();
return h;
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/branch/For.java | src/main/java/org/spongepowered/despector/ast/stmt/branch/For.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.branch;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.insn.condition.Condition;
import org.spongepowered.despector.ast.stmt.Statement;
import org.spongepowered.despector.ast.stmt.StatementBlock;
import org.spongepowered.despector.ast.stmt.StatementVisitor;
import org.spongepowered.despector.ast.stmt.branch.Break.Breakable;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
/**
* A for loop.
*/
public class For implements Statement, Breakable {
private Statement init;
private Condition condition;
private Statement incr;
private StatementBlock body;
private List<Break> breaks = new ArrayList<>();
public For(@Nullable Statement init, Condition condition, @Nullable Statement incr, StatementBlock body) {
this.init = init;
this.condition = checkNotNull(condition, "condition");
this.incr = incr;
this.body = checkNotNull(body, "body");
}
/**
* Gets the initialization statement, may be null.
*/
@Nullable
public Statement getInit() {
return this.init;
}
/**
* Sets the initialization statement, may be null.
*/
public void setInit(@Nullable Statement init) {
this.init = init;
}
/**
* Gets the loop condition.
*/
public Condition getCondition() {
return this.condition;
}
/**
* Sets the loop condition.
*/
public void setCondition(Condition condition) {
this.condition = checkNotNull(condition, "condition");
}
/**
* Gets the incrementing statement, may be null.
*/
@Nullable
public Statement getIncr() {
return this.incr;
}
/**
* Sets the incrementing statement, may be null.
*/
public void setIncr(@Nullable Statement incr) {
this.incr = incr;
}
/**
* Gets the loop body.
*/
public StatementBlock getBody() {
return this.body;
}
/**
* Sets the loop body.
*/
public void setBody(StatementBlock block) {
this.body = checkNotNull(block, "block");
}
@Override
public List<Break> getBreaks() {
return this.breaks;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof StatementVisitor) {
((StatementVisitor) visitor).visitFor(this);
}
if (this.init != null) {
this.init.accept(visitor);
}
this.condition.accept(visitor);
if (this.incr != null) {
this.incr.accept(visitor);
}
for (Statement stmt : this.body.getStatements()) {
stmt.accept(visitor);
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(6);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_FOR);
pack.writeString("init");
if (this.init != null) {
this.init.writeTo(pack);
} else {
pack.writeNil();
}
pack.writeString("condition");
this.condition.writeTo(pack);
pack.writeString("incr");
if (this.incr != null) {
this.incr.writeTo(pack);
} else {
pack.writeNil();
}
pack.writeString("breakpoints").startArray(this.breaks.size());
for (Break br : this.breaks) {
pack.writeInt(((Object) br).hashCode());
}
pack.endArray();
pack.writeString("body");
pack.startArray(this.body.getStatementCount());
for (Statement stmt : this.body.getStatements()) {
stmt.writeTo(pack);
}
pack.endArray();
pack.endMap();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("for (");
if (this.init != null) {
sb.append(this.init);
}
sb.append(";");
sb.append(this.condition);
sb.append(";");
if (this.incr != null) {
sb.append(this.incr);
}
sb.append(") {\n");
for (Statement insn : this.body.getStatements()) {
sb.append(" ").append(insn).append("\n");
}
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof For)) {
return false;
}
For insn = (For) obj;
if (this.init != null) {
if (!this.init.equals(insn.init)) {
return false;
}
} else if (insn.init != null) {
return false;
}
if (this.incr != null) {
if (!this.incr.equals(insn.incr)) {
return false;
}
} else if (insn.incr != null) {
return false;
}
return this.condition.equals(insn.condition) && this.body.equals(insn.body);
}
@Override
public int hashCode() {
int h = 1;
h = h * 37 + (this.init == null ? 0 : this.init.hashCode());
h = h * 37 + (this.incr == null ? 0 : this.incr.hashCode());
h = h * 37 + this.condition.hashCode();
h = h * 37 + this.body.hashCode();
return h;
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/branch/DoWhile.java | src/main/java/org/spongepowered/despector/ast/stmt/branch/DoWhile.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.branch;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.insn.condition.Condition;
import org.spongepowered.despector.ast.stmt.Statement;
import org.spongepowered.despector.ast.stmt.StatementBlock;
import org.spongepowered.despector.ast.stmt.StatementVisitor;
import org.spongepowered.despector.ast.stmt.branch.Break.Breakable;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* A do-while loop.
*/
public class DoWhile implements Statement, Breakable {
private Condition condition;
private StatementBlock body;
private List<Break> breaks = new ArrayList<>();
public DoWhile(Condition condition, StatementBlock body) {
this.condition = checkNotNull(condition, "condition");
this.body = checkNotNull(body, "body");
}
/**
* Gets the loop condition.
*/
public Condition getCondition() {
return this.condition;
}
/**
* Sets the loop condition.
*/
public void setCondition(Condition condition) {
this.condition = checkNotNull(condition, "condition");
}
/**
* Gets the loop body.
*/
public StatementBlock getBody() {
return this.body;
}
/**
* Sets the loop body.
*/
public void setBody(StatementBlock block) {
this.body = checkNotNull(block, "block");
}
@Override
public List<Break> getBreaks() {
return this.breaks;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof StatementVisitor) {
((StatementVisitor) visitor).visitDoWhile(this);
}
this.condition.accept(visitor);
for (Statement stmt : this.body.getStatements()) {
stmt.accept(visitor);
}
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("do {\n");
for (Statement insn : this.body.getStatements()) {
sb.append(" ").append(insn).append("\n");
}
sb.append("} while (");
sb.append(this.condition);
sb.append(");");
return sb.toString();
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(4);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_DO_WHILE);
pack.writeString("condition");
this.condition.writeTo(pack);
pack.writeString("breakpoints").startArray(this.breaks.size());
for (Break br : this.breaks) {
pack.writeInt(((Object) br).hashCode());
}
pack.endArray();
pack.writeString("body");
pack.startArray(this.body.getStatementCount());
for (Statement stmt : this.body.getStatements()) {
stmt.writeTo(pack);
}
pack.endArray();
pack.endMap();
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof DoWhile)) {
return false;
}
DoWhile insn = (DoWhile) obj;
return this.condition.equals(insn.condition) && this.body.equals(insn.body);
}
@Override
public int hashCode() {
int h = 1;
h = h * 37 + this.condition.hashCode();
h = h * 37 + this.body.hashCode();
return h;
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/branch/TryCatch.java | src/main/java/org/spongepowered/despector/ast/stmt/branch/TryCatch.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.branch;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Lists;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.Locals.LocalInstance;
import org.spongepowered.despector.ast.stmt.Statement;
import org.spongepowered.despector.ast.stmt.StatementBlock;
import org.spongepowered.despector.ast.stmt.StatementVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
import java.util.List;
import javax.annotation.Nullable;
/**
* A try-catch block.
*/
public class TryCatch implements Statement {
private StatementBlock block;
final List<CatchBlock> catch_blocks = Lists.newArrayList();
public TryCatch(StatementBlock block) {
this.block = checkNotNull(block, "block");
}
/**
* Gets the body of the try block.
*/
public StatementBlock getTryBlock() {
return this.block;
}
/**
* Sets the body of the try block.
*/
public void setBlock(StatementBlock block) {
this.block = checkNotNull(block, "block");
}
/**
* Gets all attached catch blocks.
*/
public List<CatchBlock> getCatchBlocks() {
return this.catch_blocks;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof StatementVisitor) {
((StatementVisitor) visitor).visitTryCatch(this);
}
for (Statement stmt : this.block.getStatements()) {
stmt.accept(visitor);
}
for (CatchBlock catch_block : this.catch_blocks) {
catch_block.accept(visitor);
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(3);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_TRY_CATCH);
pack.writeString("body");
pack.startArray(this.block.getStatementCount());
for (Statement stmt : this.block.getStatements()) {
stmt.writeTo(pack);
}
pack.endArray();
pack.writeString("catch").startArray(this.catch_blocks.size());
for (CatchBlock cat : this.catch_blocks) {
pack.startMap(3);
pack.writeString("exceptions").startArray(cat.getExceptions().size());
for (String ex : cat.getExceptions()) {
pack.writeString(ex);
}
pack.endArray();
pack.writeString("block");
pack.startArray(cat.getBlock().getStatementCount());
for (Statement stmt : cat.getBlock().getStatements()) {
stmt.writeTo(pack);
}
pack.endArray();
if (cat.getExceptionLocal() != null) {
pack.writeString("local");
cat.getExceptionLocal().writeToSimple(pack);
} else {
pack.writeString("dummy_name").writeString(cat.getDummyName());
}
pack.endMap();
}
pack.endArray();
pack.endMap();
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof TryCatch)) {
return false;
}
TryCatch insn = (TryCatch) obj;
return this.block.equals(insn.block) && this.catch_blocks.equals(insn.catch_blocks);
}
@Override
public int hashCode() {
int h = 1;
h = h * 37 + this.block.hashCode();
for (CatchBlock cat : this.catch_blocks) {
h = h * 37 + cat.hashCode();
}
return h;
}
/**
* A catch block.
*/
public class CatchBlock {
private final List<String> exceptions;
private StatementBlock block;
private LocalInstance exception_local;
private String dummy_name;
public CatchBlock(LocalInstance exception_local, List<String> ex, StatementBlock block) {
this.exception_local = checkNotNull(exception_local, "local");
this.dummy_name = null;
this.exceptions = ex;
this.block = block;
TryCatch.this.catch_blocks.add(this);
}
public CatchBlock(String dummy_name, List<String> ex, StatementBlock block) {
this.exception_local = null;
this.dummy_name = checkNotNull(dummy_name, "name");
this.exceptions = ex;
this.block = block;
TryCatch.this.catch_blocks.add(this);
}
/**
* Gets the local that the exception is placed into.
*/
@Nullable
public LocalInstance getExceptionLocal() {
return this.exception_local;
}
/**
* Sets the local that the exception is placed into.
*/
public void setExceptionLocal(@Nullable LocalInstance local) {
if (local == null && this.dummy_name == null) {
throw new IllegalStateException("Cannot have both a null exception local and dummy name in catch block.");
}
this.exception_local = local;
}
/**
* Gets the dummy name for this variable. This name is ignored if the
* {@link #getExceptionLocal()} is not null.
*/
public String getDummyName() {
if (this.exception_local != null) {
return this.exception_local.getName();
}
return this.dummy_name;
}
/**
* Sets the dummy name for this variable. This name is ignored if the
* {@link #getExceptionLocal()} is not null.
*/
public void setDummyName(String name) {
if (name == null && this.exception_local == null) {
throw new IllegalStateException("Cannot have both a null exception local and dummy name in catch block.");
}
this.dummy_name = name;
}
/**
* Gets all exceptions that this catch block is catching.
*/
public List<String> getExceptions() {
return this.exceptions;
}
/**
* Gets the body of this catch block.
*/
public StatementBlock getBlock() {
return this.block;
}
/**
* Sets the body of this catch block.
*/
public void setBlock(StatementBlock block) {
this.block = checkNotNull(block, "block");
}
/**
* Accepts the given visitor.
*/
public void accept(AstVisitor visitor) {
if (visitor instanceof StatementVisitor) {
((StatementVisitor) visitor).visitCatchBlock(this);
}
for (Statement stmt : this.block.getStatements()) {
stmt.accept(visitor);
}
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof CatchBlock)) {
return false;
}
CatchBlock insn = (CatchBlock) obj;
return this.exception_local.equals(insn.exception_local) && this.exceptions.equals(insn.exceptions) && this.block.equals(insn.block)
&& this.dummy_name.equals(insn.dummy_name);
}
@Override
public int hashCode() {
int h = 1;
h = h * 37 + this.exception_local.hashCode();
h = h * 37 + this.exceptions.hashCode();
h = h * 37 + this.block.hashCode();
h = h * 37 + this.dummy_name.hashCode();
return h;
}
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/branch/ForEach.java | src/main/java/org/spongepowered/despector/ast/stmt/branch/ForEach.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.branch;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.Locals.LocalInstance;
import org.spongepowered.despector.ast.insn.Instruction;
import org.spongepowered.despector.ast.insn.InstructionVisitor;
import org.spongepowered.despector.ast.stmt.Statement;
import org.spongepowered.despector.ast.stmt.StatementBlock;
import org.spongepowered.despector.ast.stmt.StatementVisitor;
import org.spongepowered.despector.ast.stmt.branch.Break.Breakable;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* A for loop.
*/
public class ForEach implements Statement, Breakable {
private Instruction collection;
private LocalInstance val;
private StatementBlock body;
private List<Break> breaks = new ArrayList<>();
public ForEach(Instruction collection, LocalInstance val, StatementBlock body) {
this.collection = checkNotNull(collection, "collection");
this.val = checkNotNull(val, "val");
this.body = checkNotNull(body, "body");
}
/**
* Gets the collection being iterated over.
*/
public Instruction getCollectionValue() {
return this.collection;
}
/**
* Sets the collection being iterated over.
*/
public void setCollectionValue(Instruction collection) {
this.collection = checkNotNull(collection, "collection");
}
/**
* Gets the local that the current loop value is set to.
*/
public LocalInstance getValueAssignment() {
return this.val;
}
/**
* Sets the local that the current loop value is set to.
*/
public void setValueAssignment(LocalInstance val) {
this.val = checkNotNull(val, "val");
}
/**
* Gets the loop body.
*/
public StatementBlock getBody() {
return this.body;
}
/**
* Sets the loop body.
*/
public void setBody(StatementBlock block) {
this.body = checkNotNull(block, "block");
}
@Override
public List<Break> getBreaks() {
return this.breaks;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof StatementVisitor) {
((StatementVisitor) visitor).visitForEach(this);
}
if (visitor instanceof InstructionVisitor) {
((InstructionVisitor) visitor).visitLocalInstance(this.val);
}
this.collection.accept(visitor);
for (Statement stmt : this.body.getStatements()) {
stmt.accept(visitor);
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(5);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_FOREACH);
pack.writeString("local");
this.val.writeToSimple(pack);
pack.writeString("collection");
this.collection.writeTo(pack);
pack.writeString("breakpoints").startArray(this.breaks.size());
for (Break br : this.breaks) {
pack.writeInt(((Object) br).hashCode());
}
pack.endArray();
pack.writeString("body");
pack.startArray(this.body.getStatementCount());
for (Statement stmt : this.body.getStatements()) {
stmt.writeTo(pack);
}
pack.endArray();
pack.endMap();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("for (");
sb.append(this.val.getTypeName());
sb.append(" ").append(this.val.getName());
sb.append(": ");
sb.append(this.collection);
sb.append(") {\n");
for (Statement insn : this.body.getStatements()) {
sb.append(" ").append(insn).append("\n");
}
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof ForEach)) {
return false;
}
ForEach insn = (ForEach) obj;
return this.collection.equals(insn.collection) && this.body.equals(insn.body) && this.val.equals(insn.val);
}
@Override
public int hashCode() {
int h = 1;
h = h * 37 + this.collection.hashCode();
h = h * 37 + this.body.hashCode();
h = h * 37 + this.val.hashCode();
return h;
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/branch/Switch.java | src/main/java/org/spongepowered/despector/ast/stmt/branch/Switch.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.branch;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Lists;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.insn.Instruction;
import org.spongepowered.despector.ast.stmt.Statement;
import org.spongepowered.despector.ast.stmt.StatementBlock;
import org.spongepowered.despector.ast.stmt.StatementVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
import java.util.List;
/**
* A switch statement.
*/
public class Switch implements Statement {
private Instruction variable;
final List<Case> cases = Lists.newArrayList();
public Switch(Instruction var) {
this.variable = checkNotNull(var, "var");
}
/**
* Gets the variable that the switch is acting upon.
*/
public Instruction getSwitchVar() {
return this.variable;
}
/**
* Sets the variable that the switch is acting upon.
*/
public void setSwitchVar(Instruction var) {
this.variable = checkNotNull(var, "var");
}
/**
* Gets all cases of this switch.
*/
public List<Case> getCases() {
return this.cases;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof StatementVisitor) {
((StatementVisitor) visitor).visitSwitch(this);
}
this.variable.accept(visitor);
for (Case cs : this.cases) {
cs.accept(visitor);
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(3);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_SWITCH);
pack.writeString("var");
this.variable.writeTo(pack);
pack.writeString("cases").startArray(this.cases.size());
for (Case cs : this.cases) {
pack.startMap(4);
pack.writeString("body");
pack.startArray(cs.getBody().getStatementCount());
for (Statement stmt : cs.getBody().getStatements()) {
stmt.writeTo(pack);
}
pack.endArray();
pack.writeString("breaks").writeBool(cs.doesBreak());
pack.writeString("default").writeBool(cs.isDefault());
pack.writeString("indices").startArray(cs.getIndices().size());
for (Integer index : cs.getIndices()) {
pack.writeInt(index);
}
pack.endArray();
pack.endMap();
}
pack.endArray();
pack.endMap();
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof Switch)) {
return false;
}
Switch insn = (Switch) obj;
return this.variable.equals(insn.variable) && this.cases.equals(insn.cases);
}
@Override
public int hashCode() {
int h = 1;
h = h * 37 + this.variable.hashCode();
for (Case cs : this.cases) {
h = h * 37 + cs.hashCode();
}
return h;
}
/**
* A switch case.
*/
public class Case {
private StatementBlock body;
private boolean breaks;
private boolean is_default;
private final List<Integer> indices;
public Case(StatementBlock block, boolean br, boolean def, List<Integer> indices) {
this.body = checkNotNull(block, "block");
this.breaks = br;
this.is_default = def;
this.indices = indices == null ? Lists.newArrayList() : indices;
Switch.this.cases.add(this);
}
/**
* Gets the body of this case.
*/
public StatementBlock getBody() {
return this.body;
}
/**
* Sets the body of this case.
*/
public void setBody(StatementBlock block) {
this.body = checkNotNull(block, "block");
}
/**
* Gets if this case breaks at the end.
*/
public boolean doesBreak() {
return this.breaks;
}
/**
* Sets if this case breaks at the end.
*/
public void setBreak(boolean state) {
this.breaks = state;
}
/**
* Gets if this is the default case.
*/
public boolean isDefault() {
return this.is_default;
}
/**
* Sets if this is the default case.
*/
public void setDefault(boolean state) {
this.is_default = state;
}
/**
* Gets the indices targeting this case.
*/
public List<Integer> getIndices() {
return this.indices;
}
/**
* Accepts the given visitor.
*/
public void accept(AstVisitor visitor) {
if (visitor instanceof StatementVisitor) {
((StatementVisitor) visitor).visitSwitchCase(this);
}
for (Statement stmt : this.body.getStatements()) {
stmt.accept(visitor);
}
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof Case)) {
return false;
}
Case insn = (Case) obj;
return this.body.equals(insn.body) && this.breaks == insn.breaks && this.is_default == insn.is_default
&& this.indices.equals(insn.indices);
}
@Override
public int hashCode() {
int h = 1;
h = h * 37 + this.body.hashCode();
h = h * 37 + this.indices.hashCode();
h = h * 37 + (this.breaks ? 1 : 0);
h = h * 37 + (this.is_default ? 1 : 0);
return h;
}
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/invoke/InstanceMethodInvoke.java | src/main/java/org/spongepowered/despector/ast/stmt/invoke/InstanceMethodInvoke.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.invoke;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.insn.Instruction;
import org.spongepowered.despector.ast.insn.InstructionVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* A statement calling an instance method.
*/
public class InstanceMethodInvoke extends MethodInvoke {
private Type type;
private Instruction callee;
public InstanceMethodInvoke(Type type, String name, String desc, String owner, Instruction[] args, Instruction call) {
super(name, desc, owner, args);
this.type = checkNotNull(type, "type");
this.callee = checkNotNull(call, "callee");
}
public Type getType() {
return this.type;
}
/**
* Gets the object that the method is onvoked on.
*/
public Instruction getCallee() {
return this.callee;
}
/**
* Sets the object that the method is onvoked on.
*/
public void setCallee(Instruction callee) {
this.callee = checkNotNull(callee, "callee");
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof InstructionVisitor) {
((InstructionVisitor) visitor).visitInstanceMethodInvoke(this);
}
this.callee.accept(visitor);
super.accept(visitor);
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(7);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_INSTANCE_INVOKE);
pack.writeString("type").writeInt(this.type.ordinal());
pack.writeString("name").writeString(this.method_name);
pack.writeString("owner").writeString(this.method_owner);
pack.writeString("desc").writeString(this.method_desc);
pack.writeString("params").startArray(this.params.length);
for (Instruction insn : this.params) {
insn.writeTo(pack);
}
pack.endArray();
pack.writeString("callee");
this.callee.writeTo(pack);
pack.endMap();
}
@Override
public String toString() {
StringBuilder params = new StringBuilder();
for (int i = 0; i < this.params.length; i++) {
params.append(this.params[i]);
if (i < this.params.length - 1) {
params.append(", ");
}
}
return this.callee + "." + this.method_name + "(" + params + ");";
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!super.equals(obj)) {
return false;
}
InstanceMethodInvoke insn = (InstanceMethodInvoke) obj;
return this.callee.equals(insn.callee);
}
@Override
public int hashCode() {
int h = super.hashCode();
h = h * 37 + this.callee.hashCode();
return h;
}
public static enum Type {
VIRTUAL,
SPECIAL,
INTERFACE,
STATIC,
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/invoke/MethodInvoke.java | src/main/java/org/spongepowered/despector/ast/stmt/invoke/MethodInvoke.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.invoke;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.generic.ClassTypeSignature;
import org.spongepowered.despector.ast.generic.TypeSignature;
import org.spongepowered.despector.ast.insn.Instruction;
import org.spongepowered.despector.ast.insn.InstructionVisitor;
import org.spongepowered.despector.util.TypeHelper;
/**
* An abstract statement for making method invocations.
*/
public abstract class MethodInvoke implements Instruction {
protected String method_name;
protected String method_desc;
protected String method_owner;
protected Instruction[] params;
public MethodInvoke(String name, String desc, String owner, Instruction[] args) {
this.method_name = checkNotNull(name, "name");
this.method_desc = checkNotNull(desc, "desc");
this.method_owner = checkNotNull(owner, "owner");
checkNotNull(args, "args");
checkArgument(TypeHelper.paramCount(this.method_desc) == args.length);
this.params = args;
}
/**
* Gets the name of the method being invoked.
*/
public String getMethodName() {
return this.method_name;
}
/**
* Sets the name of the method being invoked.
*/
public void setMethodName(String name) {
this.method_name = checkNotNull(name, "name");
}
/**
* Gets the description of the method being invoked.
*/
public String getMethodDescription() {
return this.method_desc;
}
/**
* Gets the return type of the method being invoked.
*/
public String getReturnType() {
return TypeHelper.getRet(this.method_desc);
}
/**
* Sets the description of the method being invoked.
*/
public void setMethodDescription(String desc) {
this.method_desc = checkNotNull(desc, "desc");
}
/**
* Gets the type description of the owner of the method being invoked.
*/
public String getOwner() {
return this.method_owner;
}
/**
* Gets the internal name of the owner of the method being invoked.
*/
public String getOwnerName() {
return TypeHelper.descToType(this.method_owner);
}
/**
* Sets the type description of the owner of the method being invoked.
*/
public void setOwner(String type) {
this.method_owner = checkNotNull(type, "owner");
}
/**
* Gets the parameters of this method call.
*/
public Instruction[] getParameters() {
return this.params;
}
/**
* Sets the parameters of this method call.
*/
public void setParameters(Instruction... args) {
checkNotNull(args, "args");
checkArgument(TypeHelper.paramCount(this.method_desc) == args.length);
this.params = args;
}
@Override
public TypeSignature inferType() {
return ClassTypeSignature.of(getReturnType());
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof InstructionVisitor) {
for (Instruction insn : this.params) {
insn.accept(visitor);
}
}
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (o == null || !getClass().equals(o.getClass())) {
return false;
}
MethodInvoke invoke = (MethodInvoke) o;
if (this.params.length != invoke.params.length) {
return false;
}
for (int i = 0; i < this.params.length; i++) {
if (!this.params[i].equals(invoke.params[i])) {
return false;
}
}
return this.method_desc.equals(invoke.method_desc) && this.method_name.equals(invoke.method_name)
&& this.method_owner.equals(invoke.method_owner);
}
@Override
public int hashCode() {
int h = 1;
h = h * 37 + this.method_desc.hashCode();
h = h * 37 + this.method_name.hashCode();
h = h * 37 + this.method_owner.hashCode();
for (Instruction insn : this.params) {
h = h * 37 + insn.hashCode();
}
return h;
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/invoke/InvokeStatement.java | src/main/java/org/spongepowered/despector/ast/stmt/invoke/InvokeStatement.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.invoke;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.insn.Instruction;
import org.spongepowered.despector.ast.stmt.Statement;
import org.spongepowered.despector.ast.stmt.StatementVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* A statement wrapping an instruction. Typically used for method invokes that
* have no return value and therefore are called as instructions rather than as
* part of another statement.
*/
public class InvokeStatement implements Statement {
private Instruction inner;
public InvokeStatement(Instruction inner) {
this.inner = checkNotNull(inner, "instruction");
}
/**
* Gets the instruction being invoked in this statement.
*/
public Instruction getInstruction() {
return this.inner;
}
/**
* Sets the instruction being invoked in this statement.
*/
public void setInstruction(Instruction insn) {
this.inner = checkNotNull(insn, "instruction");
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof StatementVisitor) {
((StatementVisitor) visitor).visitInvoke(this);
}
this.inner.accept(visitor);
}
@Override
public String toString() {
return this.inner.toString();
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(2);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_INVOKE);
pack.writeString("inner");
this.inner.writeTo(pack);
pack.endMap();
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/invoke/StaticMethodInvoke.java | src/main/java/org/spongepowered/despector/ast/stmt/invoke/StaticMethodInvoke.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.invoke;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.insn.Instruction;
import org.spongepowered.despector.ast.insn.InstructionVisitor;
import org.spongepowered.despector.util.TypeHelper;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* A statement calling a static method.
*/
public class StaticMethodInvoke extends MethodInvoke {
public StaticMethodInvoke(String name, String desc, String owner, Instruction[] args) {
super(name, desc, owner, args);
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof InstructionVisitor) {
((InstructionVisitor) visitor).visitStaticMethodInvoke(this);
}
super.accept(visitor);
}
@Override
public String toString() {
StringBuilder params = new StringBuilder();
for (int i = 0; i < this.params.length; i++) {
params.append(this.params[i]);
if (i < this.params.length - 1) {
params.append(", ");
}
}
return TypeHelper.descToType(this.method_owner) + "." + this.method_name + "(" + params + ");";
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(5);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_STATIC_INVOKE);
pack.writeString("name").writeString(this.method_name);
pack.writeString("owner").writeString(this.method_owner);
pack.writeString("desc").writeString(this.method_desc);
pack.writeString("params").startArray(this.params.length);
for (Instruction insn : this.params) {
insn.writeTo(pack);
}
pack.endArray();
pack.endMap();
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/invoke/package-info.java | src/main/java/org/spongepowered/despector/ast/stmt/invoke/package-info.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.despector.util.NonnullByDefault
package org.spongepowered.despector.ast.stmt.invoke;
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/invoke/MethodReference.java | src/main/java/org/spongepowered/despector/ast/stmt/invoke/MethodReference.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.invoke;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.generic.TypeSignature;
import org.spongepowered.despector.ast.insn.Instruction;
import org.spongepowered.despector.ast.insn.InstructionVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* A dynamic method invoke instruction.
*/
public class MethodReference implements Instruction {
private Instruction owner_val;
private TypeSignature type;
private String name;
private String lambda_owner;
private String lambda_method;
private String lambda_desc;
public MethodReference(Instruction owner_val, String owner, String method, String desc, TypeSignature type, String name) {
this.owner_val = checkNotNull(owner_val, "owner_val");
this.lambda_owner = checkNotNull(owner, "owner");
this.lambda_method = checkNotNull(method, "method");
this.lambda_desc = checkNotNull(desc, "desc");
this.type = checkNotNull(type, "type");
this.name = checkNotNull(name, "name");
}
public Instruction getOwnerVal() {
return this.owner_val;
}
/**
* Gets the owner of the lambda.
*/
public String getLambdaOwner() {
return this.lambda_owner;
}
/**
* Gets the lambda method.
*/
public String getLambdaMethod() {
return this.lambda_method;
}
/**
* Gets the lambda description.
*/
public String getLambdaDescription() {
return this.lambda_desc;
}
/**
* Gets the lambda return type.
*/
public TypeSignature getType() {
return this.type;
}
/**
* Gets the lambda name.
*/
public String getName() {
return this.name;
}
@Override
public TypeSignature inferType() {
return this.type;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof InstructionVisitor) {
((InstructionVisitor) visitor).visitMethodReference(this);
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(7);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_METHOD_REF);
pack.writeString("type");
this.type.writeTo(pack);
pack.writeString("name").writeString(this.name);
pack.writeString("owner").writeString(this.lambda_owner);
pack.writeString("method").writeString(this.lambda_method);
pack.writeString("desc").writeString(this.lambda_desc);
pack.writeString("owner_val");
this.owner_val.writeTo(pack);
pack.endMap();
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/invoke/Lambda.java | src/main/java/org/spongepowered/despector/ast/stmt/invoke/Lambda.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.invoke;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.generic.TypeSignature;
import org.spongepowered.despector.ast.insn.Instruction;
import org.spongepowered.despector.ast.insn.InstructionVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* A dynamic method invoke instruction.
*/
public class Lambda implements Instruction {
private TypeSignature type;
private String name;
private String lambda_owner;
private String lambda_method;
private String lambda_desc;
public Lambda(String owner, String method, String desc, TypeSignature type, String name) {
this.lambda_owner = checkNotNull(owner, "owner");
this.lambda_method = checkNotNull(method, "method");
this.lambda_desc = checkNotNull(desc, "desc");
this.type = checkNotNull(type, "type");
this.name = checkNotNull(name, "name");
}
/**
* Gets the owner of the lambda.
*/
public String getLambdaOwner() {
return this.lambda_owner;
}
/**
* Gets the lambda method.
*/
public String getLambdaMethod() {
return this.lambda_method;
}
/**
* Gets the lambda description.
*/
public String getLambdaDescription() {
return this.lambda_desc;
}
/**
* Gets the lambda return type.
*/
public TypeSignature getType() {
return this.type;
}
/**
* Gets the lambda name.
*/
public String getName() {
return this.name;
}
@Override
public TypeSignature inferType() {
return this.type;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof InstructionVisitor) {
((InstructionVisitor) visitor).visitDynamicInvoke(this);
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(6);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_DYNAMIC_INVOKE);
pack.writeString("type");
this.type.writeTo(pack);
pack.writeString("name").writeString(this.name);
pack.writeString("owner").writeString(this.lambda_owner);
pack.writeString("method").writeString(this.lambda_method);
pack.writeString("desc").writeString(this.lambda_desc);
pack.endMap();
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/invoke/New.java | src/main/java/org/spongepowered/despector/ast/stmt/invoke/New.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.invoke;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.generic.TypeSignature;
import org.spongepowered.despector.ast.insn.Instruction;
import org.spongepowered.despector.ast.insn.InstructionVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
import java.util.Arrays;
/**
* A statement instantiating a new instance of a type.
*/
public class New implements Instruction {
private TypeSignature type;
private String ctor;
private Instruction[] params;
public New(TypeSignature type, String ctor_desc, Instruction[] args) {
this.type = checkNotNull(type, "type");
this.ctor = checkNotNull(ctor_desc, "ctor");
this.params = checkNotNull(args, "args");
}
/**
* Gets the description of the constructor being called.
*/
public String getCtorDescription() {
return this.ctor;
}
/**
* Sets the description of the constructor being called.
*/
public void setCtorDescription(String desc) {
this.ctor = checkNotNull(desc, "ctor_desc");
}
/**
* Gets the type description of the type being instanciated.
*/
public TypeSignature getType() {
return this.type;
}
/**
* Sets the type description of the type being instanciated.
*/
public void setType(TypeSignature type) {
this.type = checkNotNull(type, "type");
}
/**
* Gets the parameters of the constructor.
*/
public Instruction[] getParameters() {
return this.params;
}
/**
* Sets the parameters of the constructor.
*/
public void setParameters(Instruction... args) {
this.params = checkNotNull(args, "args");
}
@Override
public TypeSignature inferType() {
return this.type;
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof InstructionVisitor) {
((InstructionVisitor) visitor).visitNew(this);
for (Instruction insn : this.params) {
insn.accept(visitor);
}
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(4);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_NEW);
pack.writeString("type");
this.type.writeTo(pack);
pack.writeString("ctor").writeString(this.ctor);
pack.writeString("params").startArray(this.params.length);
for (Instruction insn : this.params) {
insn.writeTo(pack);
}
pack.endArray();
pack.endMap();
}
@Override
public String toString() {
StringBuilder params = new StringBuilder();
for (int i = 0; i < this.params.length; i++) {
params.append(this.params[i]);
if (i < this.params.length - 1) {
params.append(", ");
}
}
return "new " + this.type.getName() + "(" + params + ");";
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof New)) {
return false;
}
New insn = (New) obj;
return this.type.equals(insn.type) && this.ctor.equals(insn.ctor) && Arrays.equals(this.params, insn.params);
}
@Override
public int hashCode() {
int h = 1;
h = h * 37 + this.type.hashCode();
h = h * 37 + this.ctor.hashCode();
for (Instruction insn : this.params) {
h = h * 37 + insn.hashCode();
}
return h;
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/assign/StaticFieldAssignment.java | src/main/java/org/spongepowered/despector/ast/stmt/assign/StaticFieldAssignment.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.assign;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.generic.TypeSignature;
import org.spongepowered.despector.ast.insn.Instruction;
import org.spongepowered.despector.ast.stmt.StatementVisitor;
import org.spongepowered.despector.util.TypeHelper;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* An assignment to a static field.
*/
public class StaticFieldAssignment extends FieldAssignment {
public StaticFieldAssignment(String field, TypeSignature type_desc, String owner, Instruction val) {
super(field, type_desc, owner, val);
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof StatementVisitor) {
((StatementVisitor) visitor).visitStaticFieldAssignment(this);
}
this.val.accept(visitor);
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(5);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_STATIC_FIELD_ASSIGN);
pack.writeString("name").writeString(this.field_name);
pack.writeString("type");
this.type_desc.writeTo(pack);
pack.writeString("owner").writeString(this.owner_type);
pack.writeString("val");
this.val.writeTo(pack);
pack.endMap();
}
@Override
public String toString() {
return TypeHelper.descToTypeName(this.owner_type) + "." + this.field_name + " = " + this.val + ";";
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!super.equals(obj)) {
return false;
}
StaticFieldAssignment insn = (StaticFieldAssignment) obj;
return this.val.equals(insn.val);
}
@Override
public int hashCode() {
int h = super.hashCode();
h = h * 37 + this.val.hashCode();
return h;
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/assign/LocalAssignment.java | src/main/java/org/spongepowered/despector/ast/stmt/assign/LocalAssignment.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.assign;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.Locals.LocalInstance;
import org.spongepowered.despector.ast.insn.Instruction;
import org.spongepowered.despector.ast.insn.InstructionVisitor;
import org.spongepowered.despector.ast.stmt.StatementVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* An assignment statement for assigning a value to a local.
*/
public class LocalAssignment extends Assignment {
private LocalInstance local;
public LocalAssignment(LocalInstance local, Instruction val) {
super(val);
this.local = checkNotNull(local, "local");
}
/**
* Gets the local to which the value is being assigned.
*/
public LocalInstance getLocal() {
return this.local;
}
/**
* Sets the local to which the value is being assigned.
*/
public void setLocal(LocalInstance local) {
this.local = checkNotNull(local, "local");
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof StatementVisitor) {
((StatementVisitor) visitor).visitLocalAssignment(this);
}
if (visitor instanceof InstructionVisitor) {
((InstructionVisitor) visitor).visitLocalInstance(this.local);
this.val.accept(visitor);
}
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(3);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_LOCAL_ASSIGN);
pack.writeString("local");
this.local.writeToSimple(pack);
pack.writeString("val");
this.val.writeTo(pack);
pack.endMap();
}
@Override
public String toString() {
return this.local + " = " + this.val + ";";
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof LocalAssignment)) {
return false;
}
LocalAssignment insn = (LocalAssignment) obj;
return this.val.equals(insn.val) && this.local.equals(insn.local);
}
@Override
public int hashCode() {
int h = 1;
h = h * 37 + this.val.hashCode();
h = h * 37 + this.local.hashCode();
return h;
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/assign/package-info.java | src/main/java/org/spongepowered/despector/ast/stmt/assign/package-info.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.despector.util.NonnullByDefault
package org.spongepowered.despector.ast.stmt.assign;
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/assign/ArrayAssignment.java | src/main/java/org/spongepowered/despector/ast/stmt/assign/ArrayAssignment.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.assign;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.insn.Instruction;
import org.spongepowered.despector.ast.stmt.StatementVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* An array assignment statement.
*
* <p>Example: {@code var[i] = val;}</p>
*/
public class ArrayAssignment extends Assignment {
private Instruction array;
private Instruction index;
public ArrayAssignment(Instruction array, Instruction index, Instruction val) {
super(val);
this.index = checkNotNull(index, "index");
this.array = checkNotNull(array, "array");
}
/**
* Gets the instruction providing the array object.
*/
public Instruction getArray() {
return this.array;
}
/**
* Sets the instruction providing the array object.
*/
public void setArray(Instruction array) {
this.array = checkNotNull(array, "array");
}
/**
* Gets the instruction providing the array index.
*/
public Instruction getIndex() {
return this.index;
}
/**
* Sets the instruction providing the array index.
*/
public void setIndex(Instruction index) {
this.index = checkNotNull(index, "index");
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof StatementVisitor) {
((StatementVisitor) visitor).visitArrayAssignment(this);
}
this.array.accept(visitor);
this.index.accept(visitor);
this.val.accept(visitor);
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(4);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_ARRAY_ASSIGN);
pack.writeString("array");
this.array.writeTo(pack);
pack.writeString("index");
this.index.writeTo(pack);
pack.writeString("val");
this.val.writeTo(pack);
pack.endMap();
}
@Override
public String toString() {
return this.array + "[" + this.index + "] = " + this.val + ";";
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof ArrayAssignment)) {
return false;
}
ArrayAssignment insn = (ArrayAssignment) obj;
return this.val.equals(insn.val) && this.array.equals(insn.array) && this.index.equals(insn.index);
}
@Override
public int hashCode() {
int h = 1;
h = h * 37 + this.val.hashCode();
h = h * 37 + this.array.hashCode();
h = h * 37 + this.index.hashCode();
return h;
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/assign/Assignment.java | src/main/java/org/spongepowered/despector/ast/stmt/assign/Assignment.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.assign;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.insn.Instruction;
import org.spongepowered.despector.ast.stmt.Statement;
/**
* An abstract statement for assignments.
*/
public abstract class Assignment implements Statement {
protected Instruction val;
protected Assignment(Instruction val) {
this.val = checkNotNull(val, "value");
}
/**
* Gets the value being assigned.
*/
public Instruction getValue() {
return this.val;
}
/**
* Sets the value being assigned.
*/
public void setValue(Instruction insn) {
this.val = checkNotNull(insn, "value");
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/assign/InstanceFieldAssignment.java | src/main/java/org/spongepowered/despector/ast/stmt/assign/InstanceFieldAssignment.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.assign;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.AstVisitor;
import org.spongepowered.despector.ast.generic.TypeSignature;
import org.spongepowered.despector.ast.insn.Instruction;
import org.spongepowered.despector.ast.stmt.StatementVisitor;
import org.spongepowered.despector.util.serialization.AstSerializer;
import org.spongepowered.despector.util.serialization.MessagePacker;
import java.io.IOException;
/**
* An assignment to an instance field.
*/
public class InstanceFieldAssignment extends FieldAssignment {
private Instruction owner;
public InstanceFieldAssignment(String field_name, TypeSignature type_desc, String owner_type, Instruction owner, Instruction val) {
super(field_name, type_desc, owner_type, val);
this.owner = checkNotNull(owner, "owner");
}
/**
* Gets the object on which the field is being set.
*/
public Instruction getOwner() {
return this.owner;
}
/**
* Sets the object on which the field is being set.
*/
public void setOwner(Instruction owner) {
this.owner = checkNotNull(owner, "owner");
}
@Override
public void accept(AstVisitor visitor) {
if (visitor instanceof StatementVisitor) {
((StatementVisitor) visitor).visitInstanceFieldAssignment(this);
}
this.owner.accept(visitor);
this.val.accept(visitor);
}
@Override
public void writeTo(MessagePacker pack) throws IOException {
pack.startMap(6);
pack.writeString("id").writeInt(AstSerializer.STATEMENT_ID_INSTANCE_FIELD_ASSIGN);
pack.writeString("name").writeString(this.field_name);
pack.writeString("type");
this.type_desc.writeTo(pack);
pack.writeString("owner").writeString(this.owner_type);
pack.writeString("owner_val");
this.owner.writeTo(pack);
pack.writeString("val");
this.val.writeTo(pack);
pack.endMap();
}
@Override
public String toString() {
return this.owner + "." + this.field_name + " = " + this.val + ";";
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!super.equals(obj)) {
return false;
}
InstanceFieldAssignment insn = (InstanceFieldAssignment) obj;
return this.val.equals(insn.val) && this.owner.equals(insn.owner);
}
@Override
public int hashCode() {
int h = super.hashCode();
h = h * 37 + this.val.hashCode();
h = h * 37 + this.owner.hashCode();
return h;
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
Despector/Despector | https://github.com/Despector/Despector/blob/e60cfaaf7a0688bc83f8b00c392521d0b162afba/src/main/java/org/spongepowered/despector/ast/stmt/assign/FieldAssignment.java | src/main/java/org/spongepowered/despector/ast/stmt/assign/FieldAssignment.java | /*
* The MIT License (MIT)
*
* Copyright (c) Despector <https://despector.voxelgenesis.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.despector.ast.stmt.assign;
import static com.google.common.base.Preconditions.checkNotNull;
import org.spongepowered.despector.ast.generic.TypeSignature;
import org.spongepowered.despector.ast.insn.Instruction;
import org.spongepowered.despector.util.TypeHelper;
/**
* An assignment to an instance or static field.
*/
public abstract class FieldAssignment extends Assignment {
protected String field_name;
protected TypeSignature type_desc;
protected String owner_type;
protected boolean initializer = false;
public FieldAssignment(String field, TypeSignature type_desc, String owner, Instruction val) {
super(val);
this.field_name = checkNotNull(field, "field");
this.type_desc = checkNotNull(type_desc, "field_desc");
this.owner_type = checkNotNull(owner, "owner");
}
/**
* Gets the field name.
*/
public String getFieldName() {
return this.field_name;
}
/**
* Sets the field name.
*/
public void setFieldName(String name) {
this.field_name = checkNotNull(name, "name");
}
/**
* Gets the field's type description.
*/
public TypeSignature getFieldDescription() {
return this.type_desc;
}
/**
* Sets the field's type description.
*/
public void setFieldDescription(TypeSignature desc) {
this.type_desc = checkNotNull(desc, "desc");
}
/**
* Gets the field owner's type description.
*/
public String getOwnerType() {
return this.owner_type;
}
/**
* Gets the field owner's type internal name.
*/
public String getOwnerName() {
return TypeHelper.descToType(this.owner_type);
}
/**
* Sets the field owner's type description.
*/
public void setOwner(String owner) {
this.owner_type = checkNotNull(owner, "owner");
}
/**
* Gets if this field assignment is an initializer and therefore should be
* ignored when encountered in a method.
*/
public boolean isInitializer() {
return this.initializer;
}
/**
* Sets if this field assignment is an initializer.
*
* @see #isInitializer()
*/
public void setInitializer(boolean state) {
this.initializer = state;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (o == null || !o.getClass().equals(getClass())) {
return false;
}
FieldAssignment assign = (FieldAssignment) o;
return this.field_name.equals(assign.field_name) && this.owner_type.equals(assign.owner_type) && this.type_desc.equals(assign.type_desc);
}
@Override
public int hashCode() {
int h = 1;
h = h * 37 + this.field_name.hashCode();
h = h * 37 + this.owner_type.hashCode();
h = h * 37 + this.type_desc.hashCode();
return h;
}
}
| java | MIT | e60cfaaf7a0688bc83f8b00c392521d0b162afba | 2026-01-05T02:42:07.381192Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/test/java/org/jeewx/api/mp/aes/WXBizMsgCryptTest.java | src/test/java/org/jeewx/api/mp/aes/WXBizMsgCryptTest.java | package org.jeewx.api.mp.aes;
import static org.junit.Assert.*;
import java.io.IOException;
import java.io.StringReader;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
public class WXBizMsgCryptTest {
String appId = "??";
String encodingAesKey = "??";
String token = "pamtest";
String timestamp = "1409304348";
String nonce = "xxxxxx";
String replyMsg = "我是中文abcd123";
String xmlFormat = "<xml><ToUserName><![CDATA[toUser]]></ToUserName><Encrypt><![CDATA[%1$s]]></Encrypt></xml>";
String afterAesEncrypt = "jn1L23DB+6ELqJ+6bruv21Y6MD7KeIfP82D6gU39rmkgczbWwt5+3bnyg5K55bgVtVzd832WzZGMhkP72vVOfg==";
String randomStr = "aaaabbbbccccdddd";
String replyMsg2 = "<xml><ToUserName><![CDATA[oia2Tj我是中文jewbmiOUlr6X-1crbLOvLw]]></ToUserName><FromUserName><![CDATA[gh_7f083739789a]]></FromUserName><CreateTime>1407743423</CreateTime><MsgType><![CDATA[video]]></MsgType><Video><MediaId><![CDATA[eYJ1MbwPRJtOvIEabaxHs7TX2D-HV71s79GUxqdUkjm6Gs2Ed1KF3ulAOA9H1xG0]]></MediaId><Title><![CDATA[testCallBackReplyVideo]]></Title><Description><![CDATA[testCallBackReplyVideo]]></Description></Video></xml>";
String afterAesEncrypt2 = "jn1L23DB+6ELqJ+6bruv23M2GmYfkv0xBh2h+XTBOKVKcgDFHle6gqcZ1cZrk3e1qjPQ1F4RsLWzQRG9udbKWesxlkupqcEcW7ZQweImX9+wLMa0GaUzpkycA8+IamDBxn5loLgZpnS7fVAbExOkK5DYHBmv5tptA9tklE/fTIILHR8HLXa5nQvFb3tYPKAlHF3rtTeayNf0QuM+UW/wM9enGIDIJHF7CLHiDNAYxr+r+OrJCmPQyTy8cVWlu9iSvOHPT/77bZqJucQHQ04sq7KZI27OcqpQNSto2OdHCoTccjggX5Z9Mma0nMJBU+jLKJ38YB1fBIz+vBzsYjrTmFQ44YfeEuZ+xRTQwr92vhA9OxchWVINGC50qE/6lmkwWTwGX9wtQpsJKhP+oS7rvTY8+VdzETdfakjkwQ5/Xka042OlUb1/slTwo4RscuQ+RdxSGvDahxAJ6+EAjLt9d8igHngxIbf6YyqqROxuxqIeIch3CssH/LqRs+iAcILvApYZckqmA7FNERspKA5f8GoJ9sv8xmGvZ9Yrf57cExWtnX8aCMMaBropU/1k+hKP5LVdzbWCG0hGwx/dQudYR/eXp3P0XxjlFiy+9DMlaFExWUZQDajPkdPrEeOwofJb";
@BeforeClass
public static void setUpBeforeClass() throws Exception {
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
}
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test
public void testNormal() throws ParserConfigurationException, SAXException, IOException {
try {
WXBizMsgCrypt pc = new WXBizMsgCrypt(token, encodingAesKey, appId);
String afterEncrpt = pc.encryptMsg(replyMsg, timestamp, nonce);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
StringReader sr = new StringReader(afterEncrpt);
InputSource is = new InputSource(sr);
Document document = db.parse(is);
Element root = document.getDocumentElement();
NodeList nodelist1 = root.getElementsByTagName("Encrypt");
NodeList nodelist2 = root.getElementsByTagName("MsgSignature");
String encrypt = nodelist1.item(0).getTextContent();
String msgSignature = nodelist2.item(0).getTextContent();
String fromXML = String.format(xmlFormat, encrypt);
// 第三方收到公众号平台发送的消息
String afterDecrpt = pc.decryptMsg(msgSignature, timestamp, nonce, fromXML);
assertEquals(replyMsg, afterDecrpt);
} catch (AesException e) {
fail("正常流程,怎么就抛出异常了??????");
}
}
@Test
public void testAesEncrypt() {
try {
WXBizMsgCrypt pc = new WXBizMsgCrypt(token, encodingAesKey, appId);
assertEquals(afterAesEncrypt, pc.encrypt(randomStr, replyMsg));
} catch (AesException e) {
e.printStackTrace();
fail("no异常");
}
}
@Test
public void testAesEncrypt2() {
try {
WXBizMsgCrypt pc = new WXBizMsgCrypt(token, encodingAesKey, appId);
assertEquals(afterAesEncrypt2, pc.encrypt(randomStr, replyMsg2));
} catch (AesException e) {
e.printStackTrace();
fail("no异常");
}
}
@Test
public void testIllegalAesKey() {
try {
new WXBizMsgCrypt(token, "abcde", appId);
} catch (AesException e) {
assertEquals(AesException.IllegalAesKey, e.getCode());
return;
}
fail("错误流程不抛出异常???");
}
@Test
public void testValidateSignatureError() throws ParserConfigurationException, SAXException,
IOException {
try {
WXBizMsgCrypt pc = new WXBizMsgCrypt(token, encodingAesKey, appId);
String afterEncrpt = pc.encryptMsg(replyMsg, timestamp, nonce);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
StringReader sr = new StringReader(afterEncrpt);
InputSource is = new InputSource(sr);
Document document = db.parse(is);
Element root = document.getDocumentElement();
NodeList nodelist1 = root.getElementsByTagName("Encrypt");
String encrypt = nodelist1.item(0).getTextContent();
String fromXML = String.format(xmlFormat, encrypt);
pc.decryptMsg("12345", timestamp, nonce, fromXML); // 这里签名错误
} catch (AesException e) {
assertEquals(AesException.ValidateSignatureError, e.getCode());
return;
}
fail("错误流程不抛出异常???");
}
@Test
public void testVerifyUrl() throws AesException {
WXBizMsgCrypt wxcpt = new WXBizMsgCrypt("QDG6eK", "??", "??");
String verifyMsgSig = "5c45ff5e21c57e6ad56bac8758b79b1d9ac89fd3";
String timeStamp = "1409659589";
String nonce = "263014780";
String echoStr = "P9nAzCzyDtyTWESHep1vC5X9xho/qYX3Zpb4yKa9SKld1DsH3Iyt3tP3zNdtp+4RPcs8TgAE7OaBO+FZXvnaqQ==";
wxcpt.verifyUrl(verifyMsgSig, timeStamp, nonce, echoStr);
// 只要不抛出异常就好
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/test/java/org/jeewx/api/wxsendmsg/test/JwSendMessageAPITest.java | src/test/java/org/jeewx/api/wxsendmsg/test/JwSendMessageAPITest.java | package org.jeewx.api.wxsendmsg.test;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.List;
import org.jeewx.api.core.common.AccessToken;
import org.jeewx.api.core.exception.WexinReqException;
import org.jeewx.api.core.req.model.user.Group;
import org.jeewx.api.wxsendmsg.JwSendMessageAPI;
import org.jeewx.api.wxsendmsg.model.SendMessageReport;
import org.jeewx.api.wxsendmsg.model.SendMessageResponse;
import org.jeewx.api.wxsendmsg.model.WxArticle;
import org.jeewx.api.wxsendmsg.model.WxMedia;
import org.jeewx.api.wxuser.user.model.Wxuser;
import org.junit.Before;
import org.junit.Test;
public class JwSendMessageAPITest {
private static String newAccessToken = null;
private static String touser = null;
JwSendMessageAPI service = null;
/**
* 测试获取token
*/
// @Ignore
@Before
public void getToken() throws WexinReqException {
service = new JwSendMessageAPI();
touser = "oA1Vct-_r1rAd5mcL3lEZKgcvGZY";
String appid = "??";
String appscret = "??";
AccessToken token = new AccessToken(appid, appscret);
String strtoken = token.getNewAccessToken();
newAccessToken = strtoken;
System.out.println(strtoken);
}
@Test
public void testMessagePrivateStringStringString() {
// 文本预览
try {
String r = service.messagePrivate(newAccessToken, touser, "我要预览啊");
System.out.println(r);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Test
public void testMessagePrivateStringStringListOfWxArticle() {
try {
List<WxArticle> wxArticles = new ArrayList<WxArticle>();
for (int i = 0; i < 4; i++) {
WxArticle article = new WxArticle();
article.setAuthor("author" + i);
article.setContent("Content" + i);
article.setDigest("Digest" + i);
article.setShow_cover_pic("1");
article.setTitle("title" + i);
article.setFileName("showqrcode.jpg");
article.setFilePath("F:\\img\\");
wxArticles.add(article);
}
service.messagePrivate(newAccessToken, touser, wxArticles);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testMessagePrivateStringStringWxMedia() {
// 多媒体文件预览
WxMedia media = new WxMedia();
media.setType("image");
media.setFileName("showqrcode.jpg");
media.setFilePath("F:\\img\\");
try {
service.messagePrivate(newAccessToken, touser, media);
} catch (WexinReqException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@SuppressWarnings("static-access")
@Test
public void testSendMessageToGroupOrAllWithText() {
// 按组群发微信文本
// 获取分组
/*
* String url =
* "https://api.weixin.qq.com/cgi-bin/groups/get?access_token=ACCESS_TOKEN"
* ; String requestUrl = url.replace("ACCESS_TOKEN", newAccessToken);
* JSONObject result = WxstoreUtils.httpRequest(requestUrl, "GET",
* null); System.out.println(result);
*/
// {"groups":[{"id":0,"count":44,"name":"未分组"},{"id":1,"count":0,"name":"黑名单"},{"id":2,"count":0,"name":"星标组"},{"id":100,"count":0,"name":"分组1"},{"id":101,"count":0,"name":"www"},{"id":102,"count":0,"name":"测试1"},{"id":103,"count":2,"name":"我的发送组"},{"id":104,"count":0,"name":"测试1"}]}
// POST数据例子:{"openid":"oDF3iYx0ro3_7jD4HFRDfrjdCM58","to_groupid":108}
// 移动用户至分组
/*
* String url =
* "https://api.weixin.qq.com/cgi-bin/groups/members/update?access_token=ACCESS_TOKEN"
* ; String requestUrl = url.replace("ACCESS_TOKEN", newAccessToken);
* JSONObject openid =new JSONObject(); openid.put("openid", touser);
* openid.put("to_groupid", "101"); JSONObject result =
* WxstoreUtils.httpRequest(requestUrl, "POST", openid.toString());
* System.out.println(result);
*/
try {
Group group = new Group();
group.setId("101");
SendMessageResponse response = service.sendMessageToGroupOrAllWithText(newAccessToken, false, group, "我的文本预览。。。");
System.out.println(response);
} catch (WexinReqException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Test
public void testSendMessageToGroupOrAllWithArticles() {
// 图文按组发送
try {
List<WxArticle> wxArticles = new ArrayList<WxArticle>();
for (int i = 0; i < 4; i++) {
WxArticle article = new WxArticle();
article.setAuthor("author" + i);
article.setContent("Content" + i);
article.setDigest("Digest" + i);
article.setShow_cover_pic("1");
article.setTitle("title" + i);
article.setFileName("showqrcode.jpg");
article.setFilePath("F:\\img\\");
wxArticles.add(article);
}
Group group = new Group();
group.setId("101");
service.sendMessageToGroupOrAllWithArticles(newAccessToken, false, group, wxArticles);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testSendMessageToGroupOrAllWithMedia() {
// 多媒体文件按组发送
WxMedia media = new WxMedia();
media.setType("image");
media.setFileName("showqrcode.jpg");
media.setFilePath("F:\\img\\");
try {
Group group = new Group();
group.setId("101");
service.sendMessageToGroupOrAllWithMedia(newAccessToken, false, group, media);
} catch (WexinReqException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Test
public void testSendMessageToOpenidsWithText() {
// 文本信息安人发送
try {
Wxuser user = new Wxuser();
user.setOpenid(touser);
Wxuser[] wxusers = new Wxuser[1];
wxusers[0]=user;
SendMessageResponse response = service.sendMessageToOpenidsWithText(newAccessToken, wxusers, "我的文本预览。。。");
System.out.println(response);
} catch (WexinReqException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Test
public void testSendMessageToOpenidsWithArticles() {
// 图文按人发送
try {
List<WxArticle> wxArticles = new ArrayList<WxArticle>();
for (int i = 0; i < 4; i++) {
WxArticle article = new WxArticle();
article.setAuthor("author" + i);
article.setContent("Content" + i);
article.setDigest("Digest" + i);
article.setShow_cover_pic("1");
article.setTitle("title" + i);
article.setFileName("showqrcode.jpg");
article.setFilePath("F:\\img\\");
wxArticles.add(article);
}
Wxuser user = new Wxuser();
user.setOpenid(touser);
Wxuser[] wxusers = new Wxuser[1];
wxusers[0]=user;
service.sendMessageToOpenidsWithArticles(newAccessToken,wxusers, wxArticles);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testSendMessageToOpenidsWithMedia() {
// 多媒体文件按人发送
WxMedia media = new WxMedia();
media.setType("image");
media.setFileName("showqrcode.jpg");
media.setFilePath("F:\\img\\");
try {
Wxuser user = new Wxuser();
user.setOpenid(touser);
Wxuser[] wxusers = new Wxuser[1];
wxusers[0]=user;
service.sendMessageToOpenidsWithMedia(newAccessToken,wxusers, media);
} catch (WexinReqException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@SuppressWarnings("static-access")
@Test
public void testDeleteSendMessage() {
try {
String response = service.deleteSendMessage(newAccessToken, "2350922727");
System.out.println(response);
} catch (WexinReqException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@SuppressWarnings("static-access")
@Test
public void testGetSendMessageStatus() {
try {
boolean response = service.getSendMessageStatus(newAccessToken, "2350922727");
System.out.println(response);
} catch (WexinReqException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@SuppressWarnings("static-access")
@Test
public void testGetReportBySendMessageReturnString() {
String a = ""
+ "<xml>"
+ "<ToUserName><![CDATA[gh_3e8adccde292]]></ToUserName>"
+ "<FromUserName><![CDATA[oR5Gjjl_eiZoUpGozMo7dbBJ362A]]></FromUserName>"
+ "<CreateTime>1394524295</CreateTime>"
+ "<MsgType><![CDATA[event]]></MsgType>"
+ "<Event><![CDATA[MASSSENDJOBFINISH]]></Event>"
+ "<MsgID>1988</MsgID>"
+ "<Status><![CDATA[sendsuccess]]></Status>"
+ "<TotalCount>100</TotalCount>"
+ "<FilterCount>80</FilterCount>"
+ "<SentCount>75</SentCount>"
+ "<ErrorCount>5</ErrorCount>"
+ "</xml>";
try {
SendMessageReport response = service.getReportBySendMessageReturnString(a);
System.out.println(response);
} catch (WexinReqException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/test/java/org/jeewx/api/wxsendmsg/test/MessageTest.java | src/test/java/org/jeewx/api/wxsendmsg/test/MessageTest.java | package org.jeewx.api.wxsendmsg.test;
import java.util.ArrayList;
import java.util.List;
import org.jeewx.api.core.common.AccessToken;
import org.jeewx.api.core.exception.WexinReqException;
import org.jeewx.api.wxsendmsg.JwSendMessageAPI;
import org.jeewx.api.wxsendmsg.model.WxArticle;
import org.jeewx.api.wxsendmsg.model.WxArticlesResponse;
import org.jeewx.api.wxsendmsg.model.WxMediaResponse;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
/**
* 请使用认证的服务号测试
*
* @author LIAIJUN
*
*/
public class MessageTest {
private static String newAccessToken = null;
private static String touser = null;
/**
* 测试获取token
*/
// @Ignore
@Before
public void getToken() throws WexinReqException {
touser = "oA1Vct-_r1rAd5mcL3lEZKgcvGZY";
String appId = "??";
String appSecret = "??";
AccessToken token = new AccessToken(appId, appSecret);
String strtoken = token.getNewAccessToken();
newAccessToken = strtoken;
System.out.println(strtoken);
}
// 文本预览
@Test
public void testmessagePrivateUsedText() {
JwSendMessageAPI service = new JwSendMessageAPI();
try {
String r = service.messagePrivate(newAccessToken, touser, "我要预览啊");
System.out.println(r);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// 上传资源
// @Ignore
@Test
public void testuploadmedia() {
JwSendMessageAPI service = new JwSendMessageAPI();
try {
WxMediaResponse r = service.uploadMediaFile(newAccessToken, "F:\\img\\", "showqrcode.jpg", "image");
System.out.println(r);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// 上传素材
@Ignore
@Test
public void testuploadnews() {
JwSendMessageAPI service = new JwSendMessageAPI();
try {
List<WxArticle> wxArticles = new ArrayList<WxArticle>();
for (int i = 0; i < 4; i++) {
WxArticle article = new WxArticle();
article.setAuthor("author" + i);
article.setContent("Content" + i);
article.setDigest("Digest" + i);
article.setShow_cover_pic("1");
article.setTitle("title" + i);
article.setFileName("showqrcode.jpg");
article.setFilePath("F:\\img\\");
wxArticles.add(article);
}
WxArticlesResponse result = service.uploadArticles(newAccessToken, wxArticles);
System.out.println(result);
} catch (Exception e) {
e.printStackTrace();
}
}
// 图文消息预览
@Test
public void testmessagePrivateUsedNews() {
JwSendMessageAPI service = new JwSendMessageAPI();
try {
List<WxArticle> wxArticles = new ArrayList<WxArticle>();
for (int i = 0; i < 4; i++) {
WxArticle article = new WxArticle();
article.setAuthor("author" + i);
article.setContent("Content" + i);
article.setDigest("Digest" + i);
article.setShow_cover_pic("1");
article.setTitle("title" + i);
article.setFileName("showqrcode.jpg");
article.setFilePath("F:\\img\\");
wxArticles.add(article);
}
service.messagePrivate(newAccessToken, touser, wxArticles);
} catch (Exception e) {
e.printStackTrace();
}
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/test/java/org/jeewx/api/prtest/WeChatAccountTest2.java | src/test/java/org/jeewx/api/prtest/WeChatAccountTest2.java | package org.jeewx.api.prtest;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jeecg.dingtalk.api.base.JdtBaseAPI;
import com.jeecg.dingtalk.api.user.vo.User;
import com.jeecg.qywx.api.menu.vo.Menu;
import org.jeewx.api.ai.JwAIApi;
import org.jeewx.api.ai.model.Voice;
import org.jeewx.api.core.common.AccessToken;
import org.jeewx.api.core.common.JSONHelper;
import org.jeewx.api.core.exception.WexinReqException;
import org.jeewx.api.core.req.model.WeixinReqParam;
import org.jeewx.api.core.req.model.menu.PersonalizedMenu;
import org.jeewx.api.core.req.model.menu.WeixinButton;
import org.jeewx.api.core.req.model.menu.WeixinMenuMatchrule;
import org.jeewx.api.core.req.model.menu.config.CustomWeixinButtonConfig;
import org.jeewx.api.core.req.model.message.IndustryTemplateMessageSend;
import org.jeewx.api.core.req.model.message.TemplateData;
import org.jeewx.api.core.req.model.message.TemplateMessage;
import org.jeewx.api.core.req.model.user.Group;
import org.jeewx.api.core.req.model.user.GroupCreate;
import org.jeewx.api.core.util.WeiXinReqUtil;
import org.jeewx.api.wxaccount.JwAccountAPI;
import org.jeewx.api.wxaccount.model.WxQrcode;
import org.jeewx.api.wxbase.wxmedia.JwMediaAPI;
import org.jeewx.api.wxbase.wxmedia.model.*;
import org.jeewx.api.wxbase.wxserviceip.JwServiceIpAPI;
import org.jeewx.api.wxmenu.JwMenuAPI;
import org.jeewx.api.wxmenu.JwPersonalizedMenuAPI;
import org.jeewx.api.wxsendmsg.JwSendMessageAPI;
import org.jeewx.api.wxsendmsg.JwTemplateMessageAPI;
import org.jeewx.api.wxsendmsg.model.WxArticle;
import org.jeewx.api.wxsendmsg.model.WxArticlesResponse;
import org.jeewx.api.wxsendmsg.model.WxMediaResponse;
import org.jeewx.api.wxuser.group.JwGroupAPI;
import org.jeewx.api.wxuser.tag.JwTagAPI;
import org.jeewx.api.wxuser.tag.model.WxTag;
import org.jeewx.api.wxuser.tag.model.WxTagUser;
import org.jeewx.api.wxuser.user.JwUserAPI;
import org.jeewx.api.wxuser.user.model.Wxuser;
import org.junit.Test;
import org.slf4j.LoggerFactory;
import java.util.*;
/**
* @Description: 公众号测试
* 测试用例 敲敲云公众号
*
* @author: wangshuai
* @date: 2024/9/11 上午10:45
*/
public class WeChatAccountTest2 {
private static final org.slf4j.Logger log = LoggerFactory.getLogger(WeChatAccountTest2.class);
private static String appid = "??";
private static String appscret = "??";
//============= 发送模板消息 ===========================================
/**
* 添加模板消息 (此接口已经废弃)
*/
@Test
public void addTemplateMessageSend(){
try {
String s = JwTemplateMessageAPI.addTemplate(getAccessToken(), "4m3vrpiSA-CPyL9YqHw2jKDlZSX6Sz65SoMKvA9BV1s");
log.info("~~~~~~~~~~添加模板消息~~~~~~~~~~"+s);
} catch (WexinReqException e) {
throw new RuntimeException(e);
}
}
/**
* 发送模板消息
*/
@Test
public void sendTemplateMessageSend(){
IndustryTemplateMessageSend industryTemplateMessageSend = new IndustryTemplateMessageSend();
industryTemplateMessageSend.setAccess_token(getAccessToken());
industryTemplateMessageSend.setTemplate_id("4m3vrpiSA-CPyL9YqHw2jKDlZSX6Sz65SoMKvA9BV1s");
industryTemplateMessageSend.setTouser("oKMOd6TU0cOqlQalYtGCPD5jWfY8");
industryTemplateMessageSend.setUrl("www.baidu.com");
industryTemplateMessageSend.setTopcolor("#ffAADD");
TemplateMessage data = new TemplateMessage();
TemplateData first = new TemplateData();
first.setColor("#173177");
first.setValue("恭喜你购买成2323功!");
TemplateData keynote1= new TemplateData();
keynote1.setColor("#173177");
keynote1.setValue("巧克22力");
TemplateData keynote2= new TemplateData();
keynote2.setColor("39.8元");
keynote2.setValue("恭喜你购买成功!");
TemplateData keynote3= new TemplateData();
keynote3.setColor("#173177");
keynote3.setValue("2014年9月16日");
TemplateData remark= new TemplateData();
remark.setColor("#173177");
remark.setValue("欢迎再次购买!");
data.setFirst(first);
data.setKeynote1(keynote1);
data.setKeynote2(keynote2);
data.setKeynote3(keynote3);
data.setRemark(remark);
industryTemplateMessageSend.setData(data);
try {
String s = JwTemplateMessageAPI.sendTemplateMsg(industryTemplateMessageSend);
log.info("~~~~~~~~~~发送模板消息~~~~~~~~~~"+s);
} catch (WexinReqException e) {
throw new RuntimeException(e);
}
}
@Test
public void getToken(){
System.out.println(getAccessToken());
}
public String getAccessToken() {
return new AccessToken(appid, appscret).getNewAccessToken();
}
/**
* 创建二维码
*/
@Test
public void createQrcode(){
try {
WxQrcode qrScene = JwAccountAPI.createQrcode(getAccessToken(), "", "QR_SCENE", "1800");
log.info("~~~~~~~~~~创建二维码~~~~~~~~~~" + qrScene.getUrl());
} catch (WexinReqException e) {
throw new RuntimeException(e);
}
}
//=============================== 智能语音翻译 ==========================
@Test
public void tranVoiceText(){
String file = "C:\\Users\\Administrator\\Desktop\\image\\1.mp3";
String accessToken = getAccessToken();
String voice_id = "ceshi1230981fr4";
String lang = "zh_CN";
Voice voice = new Voice(accessToken, "mp3",voice_id, lang, file);
String voiceContent = JwAIApi.translateVoice(voice);
log.info("~~~~~翻译语音~~~~~"+voiceContent);
}
@Test
public void tranText(){
String accessToken = getAccessToken();
String lfrom = "zh_CN",lto = "en_US";
String text = "我是中国人啊";
String s = JwAIApi.translateText(accessToken, lfrom, lto, text);
log.info("~~~~~翻译文本~~~~~"+s);
}
@Test
public void getServiceIpList(){
try {
List<String> serviceIpList = JwServiceIpAPI.getServiceIpList(getAccessToken());
log.info("ip集合:::" + JSONObject.toJSONString(serviceIpList));
} catch (WexinReqException e) {
throw new RuntimeException(e);
}
}
//=============================== 素材 =================================
/**
* 获取素材数量
*/
@Test
public void getMediaCount(){
try {
WxCountResponse mediaCount = JwMediaAPI.getMediaCount(getAccessToken());
log.info("~~~~~~~~~~~~获取素材数量~~~~~~~~~~~"+JSONObject.toJSONString(mediaCount));
} catch (WexinReqException e) {
throw new RuntimeException(e);
}
}
/**
* 上传临时素材
*/
@Test
public void uploadMedia(){
try {
WxMediaResponse wxMediaResponse = JwSendMessageAPI.uploadMediaFile(getAccessToken(), "C://Users/Administrator/Desktop/image/", "logo.png", "image");
log.info("~~~~~~~~~~~~临时素材返回结果~~~~~~~~~~~"+JSONObject.toJSONString(wxMediaResponse));
} catch (WexinReqException e) {
throw new RuntimeException(e);
}
}
/**
* 下载素材
*/
@Test
public void downMedia(){
try {
WxDwonload wxDwonload = JwMediaAPI.downMedia(getAccessToken(), "Vdok_lDhoEEqi49K73_ul98p8mvRf6ijiR6OLGRSQYlKaydksfKUJ4ILL439b43E", "C://Users/Administrator/Desktop/image/");
log.info("~~~~~~~~~~~~临时素材下载结果~~~~~~~~~~~"+JSONObject.toJSONString(wxDwonload));
} catch (WexinReqException e) {
throw new RuntimeException(e);
}
}
/**
* 获取着指定素材
*/
@Test
public void getArticlesByMaterial(){
try {
//图片
//WxNewsArticle wxNewsArticle = JwMediaAPI.getArticlesByMaterialNews(getAccessToken(), "69fCQC8lI3S1aU3solmpeB5hnqXu3r5OlQCHeUiE-0j2dnG6jALBLhpQIT6g1FQk");
//视频
WxNewsArticle wxNewsArticle = JwMediaAPI.getArticlesByMaterialNews(getAccessToken(), "69fCQC8lI3S1aU3solmpeJ8UacWsBRjyuztecwynv7UnH8-K14g67LmuSvoirB2l");
//语音
//WxNewsArticle wxNewsArticle = JwMediaAPI.getArticlesByMaterialNews(getAccessToken(), "69fCQC8lI3S1aU3solmpeOF4BnQlr-B0pSjPxnooPpxuFfAMgB4HlzuIxQzm4t4x");
log.info("~~~~~~~~~~~~获取指定素材~~~~~~~~~~~"+JSONObject.toJSONString(wxNewsArticle));
} catch (WexinReqException e) {
throw new RuntimeException(e);
}
}
/**
* 获取素材列表
*/
@Test
public void queryArticlesByMaterialNews(){
try {
WxNews image = JwMediaAPI.queryArticlesByMaterialNews(getAccessToken(), "video", 0, 10);
log.info("~~~~~~~~~~~~获取素材列表~~~~~~~~~~~"+JSONObject.toJSONString(image));
} catch (WexinReqException e) {
throw new RuntimeException(e);
}
}
/**
* 新增永久素材图片
*/
@Test
public void uploadImages() throws WexinReqException {
List<WxArticle> wxArticles = new ArrayList<>();
WxArticle wxArticle = new WxArticle();
wxArticle.setFileName("敲敲云");
wxArticle.setFilePath("C:\\Users\\Administrator\\Desktop\\image\\jeecg.jpg");
wxArticles.add(wxArticle);
WxArticlesResponse wxArticlesResponse = JwMediaAPI.uploadArticlesByMaterialNews(getAccessToken(), wxArticles,"image");
log.info("~~~~~~~~~~~~上传永久素材图片~~~~~~~~~~~"+JSONObject.toJSONString(wxArticlesResponse));
}
/**
* 新增永久素材视频
*/
@Test
public void uploadVideo() throws WexinReqException {
List<WxArticle> wxArticles = new ArrayList<>();
WxArticle wxArticle = new WxArticle();
wxArticle.setTitle("测试");
wxArticle.setFilePath("C:\\Users\\Administrator\\Desktop\\image\\1.mp4");
wxArticle.setContent("测试");
wxArticles.add(wxArticle);
WxArticlesResponse wxArticlesResponse = JwMediaAPI.uploadArticlesByMaterialNews(getAccessToken(), wxArticles,"video");
log.info("~~~~~~~~~~~~上传永久素材视频~~~~~~~~~~~"+JSONObject.toJSONString(wxArticlesResponse));
}
/**
* 新增永久素材语音
*/
@Test
public void uploadVoice() throws WexinReqException {
List<WxArticle> wxArticles = new ArrayList<>();
WxArticle wxArticle = new WxArticle();
wxArticle.setTitle("测试");
wxArticle.setFilePath("C:\\Users\\Administrator\\Desktop\\image\\1.mp3");
wxArticle.setContent("测试");
wxArticles.add(wxArticle);
WxArticlesResponse wxArticlesResponse = JwMediaAPI.uploadArticlesByMaterialNews(getAccessToken(), wxArticles,"voice");
log.info("~~~~~~~~~~~~上传永久素材语音~~~~~~~~~~~"+JSONObject.toJSONString(wxArticlesResponse));
}
/**
* 删除永久素材
*/
@Test
public void deleteArticlesByMaterialNews(){
try {
log.info("~~~~~~~~~~~~删除永久素材~~~~~~~~~~~");
JwMediaAPI.deleteArticlesByMaterialNews(getAccessToken(), "69fCQC8lI3S1aU3solmpeCVf32ajWHDG0E-5faBWG51V-_F8sl7IPacA1iiTuYMV");
} catch (WexinReqException e) {
throw new RuntimeException(e);
}
}
//=========================微信转换参数工具类=================================
@Test
public void WeiXinToParam(){
WeixinReqParam reqParam = new WeixinReqParam();
Map weixinReqParam = WeiXinReqUtil.getWeixinReqParam(reqParam);
log.info("~~~~~~~~~~转成map~~~~~~~~~~~~~~"+JSONObject.toJSONString(weixinReqParam));
String str = WeiXinReqUtil.getWeixinParamJson(reqParam);
log.info("~~~~~~~~~~str~~~~~~~~~~~~~~"+str);
}
//=========================JSON 转换工具类=================================
@Test
public void toJson(){
Map<String,Object> map = new HashMap<>();
map.put("name","张三");
log.info(JSONHelper.bean2json(map));
List<String> list = new ArrayList<>();
list.add("list集合1");
list.add("list集合2");
log.info("list转json:"+JSONHelper.toJSONString(list));
log.info("map转json:"+JSONHelper.toJSONString(map));
log.info("map转JSONObject:"+JSONHelper.toJSONObject(map));
List<User> menuList = new ArrayList<>();
User user = new User();
user.setName("李四");
menuList.add(user);
log.info("将对象转换为List<Map<String,Object>>:"+JSONHelper.toList(menuList));
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = new JSONObject();
jsonObject.put("name","张三");
jsonArray.add(jsonObject);
log.info("将JSON对象转换为传入类型的对象:"+JSONHelper.toList(jsonArray,User.class));
log.info("将对象转换为传入类型的List:"+JSONHelper.toList(menuList,User.class));
log.info("将JSONObject转换为传入类型的List:"+JSONHelper.toBean(jsonObject,User.class));
log.info("将map转换为传入类型的List:"+JSONHelper.toBean(map,User.class));
}
/**
* 将JSON文本反序列化为主从关系的实体
*/
@Test
public void jsonToEntity(){
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = new JSONObject();
jsonObject.put("name","张三");
jsonObject.put("mobile","17610623333");
jsonArray.add(jsonObject);
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("name",jsonArray);
String user = jsonObject1.toJSONString();
User name = JSONHelper.toBean(user, User.class, "name", User.class);
log.info(JSONHelper.toJSONString(name));
JSONArray jsonArrayTwo = new JSONArray();
JSONObject jsonObjectTwoa = new JSONObject();
jsonObjectTwoa.put("name","张三");
jsonArrayTwo.add(jsonObjectTwoa);
JSONArray jsonArrayTwo1 = new JSONArray();
JSONObject jsonObjectTwoa1 = new JSONObject();
jsonObjectTwoa1.put("mobile","17777777777");
jsonArrayTwo1.add(jsonObjectTwoa1);
JSONObject jsonObjectTwo = new JSONObject();
jsonObjectTwo.put("name",jsonArrayTwo);
jsonObjectTwo.put("mobile",jsonArrayTwo1);
String userTwo = jsonObjectTwo.toJSONString();
User bean = JSONHelper.toBean(userTwo, User.class, "name", User.class, "mobile", User.class);
log.info(JSONHelper.toJSONString(bean));
}
@Test
public void jsonToEntity1(){
JSONObject jsonObject = new JSONObject();
jsonObject.put("name","张三");
jsonObject.put("mobile","17610623333");
String user = jsonObject.toJSONString();
HashMap<String, Class> detailClass = new HashMap<>();
detailClass.put("user",User.class);
User bean = JSONHelper.toBean(user, User.class, detailClass);
log.info(JSONHelper.toJSONString(detailClass));
log.info(JSONHelper.toJSONString(bean));
}
public String getAccessTokenCx() {
return JdtBaseAPI.getAccessToken("??","??").getAccessToken();
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/test/java/org/jeewx/api/prtest/WeChatAccountTest.java | src/test/java/org/jeewx/api/prtest/WeChatAccountTest.java | package org.jeewx.api.prtest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jeecg.dingtalk.api.base.JdtBaseAPI;
import org.jeewx.api.core.common.AccessToken;
import org.jeewx.api.core.exception.WexinReqException;
import org.jeewx.api.core.req.model.menu.PersonalizedMenu;
import org.jeewx.api.core.req.model.menu.WeixinButton;
import org.jeewx.api.core.req.model.menu.WeixinMenuMatchrule;
import org.jeewx.api.core.req.model.menu.config.CustomWeixinButtonConfig;
import org.jeewx.api.core.req.model.user.Group;
import org.jeewx.api.core.req.model.user.GroupCreate;
import org.jeewx.api.wxbase.wxtoken.JwTokenAPI;
import org.jeewx.api.wxmenu.JwMenuAPI;
import org.jeewx.api.wxmenu.JwPersonalizedMenuAPI;
import org.jeewx.api.wxuser.group.JwGroupAPI;
import org.jeewx.api.wxuser.tag.JwTagAPI;
import org.jeewx.api.wxuser.tag.model.WxTag;
import org.jeewx.api.wxuser.tag.model.WxTagUser;
import org.jeewx.api.wxuser.user.JwUserAPI;
import org.jeewx.api.wxuser.user.model.Wxuser;
import org.junit.Test;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
/**
* @Description: 公众号测试
* 测试用例 敲敲云公众号
* @author: wangshuai
* @date: 2024/9/11 上午10:45
*/
public class WeChatAccountTest {
private static final org.slf4j.Logger log = LoggerFactory.getLogger(WeChatAccountTest.class);
private static String appid = "??";
private static String appscret = "??";
//============= 获取粉丝 ===========================================
/**
* 获取粉丝
*
* @throws WexinReqException
*/
@Test
public void getUserInfo() throws WexinReqException {
String accessToken = this.getAccessToken();
Wxuser wxusers = JwUserAPI.getWxuser(accessToken, "oKMOd6TU0cOqlQalYtGCPD5jWfY8");
log.info("~~~~~~~获取粉丝~~~~~~~~~"+JSONObject.toJSONString(wxusers));
log.info(accessToken);
}
/**
* 获取所有粉丝(一个一个获取,特别慢)
*
* @throws WexinReqException
*/
@Test
public void getAllUserInfo() throws WexinReqException {
String accessToken = this.getAccessToken();
List<Wxuser> allWxuser = JwUserAPI.getAllWxuser(accessToken, null);
log.info("~~~~~~~获取粉丝列表~~~~~~~~~"+JSONObject.toJSONString(allWxuser));
log.info(accessToken);
}
//============= 用户分组 ===========================================
/**
* 获取所有分组信息
*
* @throws WexinReqException
*/
@Test
public void getAllGroup() throws WexinReqException {
List<Group> allGroup = JwGroupAPI.getAllGroup(this.getAccessToken());
System.out.println("~~~~~~~获取所有的分组信息~~~~~~~" + JSONObject.toJSONString(allGroup));
}
/**
* 添加分组
* @throws WexinReqException
*/
@Test
public void addGroup() throws WexinReqException {
GroupCreate group = JwGroupAPI.createGroup(this.getAccessToken(), "2024分组测试");
System.out.println("~~~~~~~获取所有的分组信息~~~~~~~" + JSONObject.toJSONString(group));
}
/**
* 更新分组
* @throws WexinReqException
*/
@Test
public void updateGroup() throws WexinReqException {
String s = JwGroupAPI.updateGroup(this.getAccessToken(), "100", "2024分组测试-更新");
System.out.println("~~~~~~~更新分组信息~~~~~~~" + s);
}
/**
* 删除分组
* @throws WexinReqException
*/
@Test
public void deleteGroup() throws WexinReqException {
String s = JwGroupAPI.groupDelete(this.getAccessToken(), "100");
System.out.println("~~~~~~~删除分组信息~~~~~~~" + s);
}
//============= 标签 ===========================================
/**
* 创建标签
*
* @throws WexinReqException
*/
@Test
public void createTag() throws WexinReqException {
JSONObject object = JwTagAPI.createTag(this.getAccessToken(), "测试标签");
System.out.println("~~~~~~~新增标签~~~~~~~" + object.toJSONString());
}
/**
* 获取标签
* @throws WexinReqException
*/
@Test
public void getTag() {
List<WxTag> tags = JwTagAPI.getTags(this.getAccessToken());
System.out.println("~~~~~~~标签列表~~~~~~~" + JSONObject.toJSONString(tags));
}
/**
* 获取标签
* @throws WexinReqException
*/
@Test
public void updateTag(){
JSONObject jsonObject = JwTagAPI.updateTag(this.getAccessToken(), 102, "20240911标签页");
System.out.println("~~~~~~~更新标签~~~~~~~" + jsonObject.toJSONString());
}
/**
* 根据标签页的id获取用户
*/
@Test
public void getTagUser() {
WxTagUser tagUser = JwTagAPI.getTagUser(this.getAccessToken(), 2,"");
System.out.println("~~~~~~~根据标签页的id获取用户~~~~~~~" + JSONObject.toJSONString(tagUser));
}
/**
* 批量设置标签
*/
@Test
public void batchtagging() {
List<String> list = new ArrayList<>();
list.add("oKMOd6TU0cOqlQalYtGCPD5jWfY8");
JSONObject batchtagging = JwTagAPI.batchtagging(this.getAccessToken(), list, 102);
System.out.println("~~~~~~~批量设置标签~~~~~~~" + JSONObject.toJSONString(batchtagging));
}
/**
* 批量取消标签
*/
@Test
public void batchuntagging() {
List<String> list = new ArrayList<>();
list.add("oKMOd6TU0cOqlQalYtGCPD5jWfY8");
JSONObject batchtagging = JwTagAPI.batchuntagging(this.getAccessToken(), list, 102);
System.out.println("~~~~~~~批量设置标签~~~~~~~" + JSONObject.toJSONString(batchtagging));
}
/**
* 获取用户身上的标签列表
*/
@Test
public void getidlist() {
List<Integer> list = JwTagAPI.getidlist(this.getAccessToken(), "oKMOd6TU0cOqlQalYtGCPD5jWfY8");
System.out.println("~~~~~~~批量设置标签~~~~~~~" + JSONObject.toJSONString(list));
}
//============= 菜单接口 ===========================================
/**
* 获取全部菜单
*
* @throws WexinReqException
*/
@Test
public void getAllMenu() throws WexinReqException {
List<WeixinButton> allMenu = JwMenuAPI.getAllMenu(getAccessToken());
log.info("~~~~~~~~~~~菜单列表~~~~~~~~~~~"+ JSONObject.toJSONString(allMenu));
}
/**
* 获取自定义菜单配置
*
* @throws WexinReqException
*/
@Test
public void getAllMenuConfigure() throws WexinReqException {
CustomWeixinButtonConfig allMenuConfigure = JwMenuAPI.getAllMenuConfigure(getAccessToken());
log.info("~~~~~~~~~~~自定义菜单配置~~~~~~~~~~~"+ JSONObject.toJSONString(allMenuConfigure));
}
/**
* 添加菜单 注意:此步骤会创建一个影响其他菜单
*
* @throws WexinReqException
*/
@Test
public void createMenu() throws WexinReqException {
List<WeixinButton> list = new LinkedList<>();
List<WeixinButton> subList = new LinkedList<>();
WeixinButton subButton = new WeixinButton();
subButton.setName("JimuReport积木报表");
subButton.setType("view");
subButton.setUrl("http://jimureport.com");
subButton.setKey("jimureport");
WeixinButton subButton1 = new WeixinButton();
subButton1.setName("JEECG低代码平台");
subButton1.setType("view");
subButton1.setUrl("http://boot3.jeecg.com/");
subButton1.setKey("JeecgBoot");
subList.add(subButton);
subList.add(subButton1);
WeixinButton weixinButton2 = new WeixinButton();
weixinButton2.setName("APP版本");
weixinButton2.setType("view");
weixinButton2.setUrl("https://jeecgos.oss-cn-beijing.aliyuncs.com/app/jeecg20240903.apk");
weixinButton2.setKey("app");
list.add(weixinButton2);
WeixinButton weixinButton1 = new WeixinButton();
weixinButton1.setName("敲敲云官网");
weixinButton1.setType("view");
weixinButton1.setUrl("https://app.qiaoqiaoyun.com/");
weixinButton1.setKey("qiaoqiaoyun");
list.add(weixinButton1);
WeixinButton weixinButton = new WeixinButton();
weixinButton.setName("更多功能");
weixinButton.setSub_button(subList);
list.add(weixinButton);
String menu = JwMenuAPI.createMenu(getAccessToken(), list);
log.info("~~~~~~~~~~~添加菜单~~~~~~~~~~~" + menu);
}
/**
* 创建个性化菜单 sex已被废弃 目前只能用标签
*/
@Test
public void PersonalizedMenu(){
WeixinMenuMatchrule matchrule = new WeixinMenuMatchrule();
matchrule.setGroup_id("2");
List<WeixinButton> testsUb = new ArrayList<WeixinButton>();
WeixinButton w = new WeixinButton();
w.setName("测试菜单");
w.setType("click");
w.setKey("V1001_TODAY_MUSIC");
testsUb.add(w);
PersonalizedMenu menu = new PersonalizedMenu();
menu.setButton(testsUb);
menu.setMatchrule(matchrule);
//个性化菜单创建
String s = JwPersonalizedMenuAPI.createMenu(getAccessToken(),menu);
log.info("个性化菜单创建结果"+ JSONObject.toJSONString(s));
//个性化菜单匹配
List<WeixinButton> s3 = JwPersonalizedMenuAPI.testMatchrule(getAccessToken(),"oKMOd6TU0cOqlQalYtGCPD5jWfY8");
log.info("个性化菜单匹配结果"+ JSONObject.toJSONString(s3));
//删除个性化菜单
// String deleteMenu = JwPersonalizedMenuAPI.deleteMenu(getAccessToken(), Integer.valueOf(s));
// log.info("个性化菜单删除结果"+ deleteMenu);
}
public String getAccessToken() {
return new AccessToken(appid, appscret).getNewAccessToken();
}
public String getAccessTokenCx() {
return JdtBaseAPI.getAccessToken("??","??").getAccessToken();
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/test/java/org/jeewx/api/prtest/DingDingTest.java | src/test/java/org/jeewx/api/prtest/DingDingTest.java | package org.jeewx.api.prtest;
import com.alibaba.fastjson.JSONObject;
import com.jeecg.dingtalk.api.base.JdtBaseAPI;
import com.jeecg.dingtalk.api.core.response.Response;
import com.jeecg.dingtalk.api.core.vo.AccessToken;
import com.jeecg.dingtalk.api.core.vo.PageResult;
import com.jeecg.dingtalk.api.department.JdtDepartmentAPI;
import com.jeecg.dingtalk.api.department.vo.Department;
import com.jeecg.dingtalk.api.message.JdtMessageAPI;
import com.jeecg.dingtalk.api.message.vo.Message;
import com.jeecg.dingtalk.api.message.vo.TextMessage;
import com.jeecg.dingtalk.api.user.JdtUserAPI;
import com.jeecg.dingtalk.api.user.body.GetUserListBody;
import com.jeecg.dingtalk.api.user.vo.User;
import org.junit.Test;
import org.slf4j.LoggerFactory;
/**
* @Description: 钉钉第三方测试类
*
* @author: wangshuai
* @date: 2024/9/11 上午10:45
*/
public class DingDingTest {
private static final org.slf4j.Logger log = LoggerFactory.getLogger(DingDingTest.class);
/**
* 获取部门下的用户
*/
@Test
public void getUserList() {
String accessToken = this.getAccessToken();
log.info("accessToken====="+accessToken);
Response<Department> department = JdtDepartmentAPI.getDepartmentById(1, accessToken);
//获取部门信息
if(department.isSuccess()){
Department departmentResult = department.getResult();
log.info("~~~~~~~~~~~~部门id~~~~~~~~~~~~~~"+ departmentResult.getDept_id());
log.info("~~~~~~~~~~~~部门名称~~~~~~~~~~~~~~"+ departmentResult.getName());
log.info("获取部门下的用户");
GetUserListBody getUserListBody = new GetUserListBody(departmentResult.getDept_id(), 0, 100);
Response<PageResult<User>> response = JdtUserAPI.getUserListByDeptId(getUserListBody, accessToken);
if(response.isSuccess()){
PageResult<User> result = response.getResult();
log.info("~~~~~~~~~~~用户列表~~~~~~~~~~"+ JSONObject.toJSONString(result.getList()));
}
}
}
/**
* 发送模板消息 到钉钉
*/
@Test
public void sendMessageToDing() {
String accessToken = this.getAccessToken();
Message<TextMessage> textMessage = new Message<>("2820902354", new TextMessage("测试钉钉消息"));
textMessage.setTo_all_user(true);
Response<String> response = JdtMessageAPI.sendTextMessage(textMessage, accessToken);
if(response.isSuccess()){
log.info("钉钉消息发送状态:" + response.getResult());
}
}
public String getAccessToken() {
AccessToken accessToken = JdtBaseAPI.getAccessToken("dingdbgpfnv56wtdpli9", "??");
return accessToken.getAccessToken();
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/test/java/org/jeewx/api/prtest/QywxTest.java | src/test/java/org/jeewx/api/prtest/QywxTest.java | package org.jeewx.api.prtest;
import com.alibaba.fastjson.JSONObject;
import com.jeecg.qywx.api.base.JwAccessTokenAPI;
import com.jeecg.qywx.api.core.common.AccessToken;
import com.jeecg.qywx.api.core.util.WXUpload;
import com.jeecg.qywx.api.department.JwDepartmentAPI;
import com.jeecg.qywx.api.department.vo.Department;
import com.jeecg.qywx.api.message.JwMessageAPI;
import com.jeecg.qywx.api.message.vo.Text;
import com.jeecg.qywx.api.message.vo.TextEntity;
import com.jeecg.qywx.api.user.JwUserAPI;
import com.jeecg.qywx.api.user.vo.User;
import org.apache.commons.collections.CollectionUtils;
import org.junit.Test;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.nio.file.Files;
import java.util.Collections;
import java.util.List;
/**
* @Description: 企业微信第三方测试类
*
* @author: wangshuai
* @date: 2024/9/11 上午10:45
*/
public class QywxTest {
private static final org.slf4j.Logger log = LoggerFactory.getLogger(QywxTest.class);
/**
* 获取部门下的用户
*/
@Test
public void getUserList() {
String accessToken = this.getAccessToken();
log.info("accessToken====="+accessToken);
List<Department> allDepartment = JwDepartmentAPI.getAllDepartment(accessToken);
//获取部门信息
if(!CollectionUtils.isEmpty(allDepartment)){
log.info("allDepartment====="+ JSONObject.toJSONString(allDepartment));
log.info("~~~~~~~~~~~~其中一个部门id~~~~~~~~~~~~~~"+ allDepartment.get(0).getId());
log.info("~~~~~~~~~~~~其中一个部门名称~~~~~~~~~~~~~~"+ allDepartment.get(0).getName());
log.info("获取部门下的用户");
List<User> usersByDepartid = JwUserAPI.getUsersByDepartid(allDepartment.get(0).getId(), "1", null, accessToken);
if(!CollectionUtils.isEmpty(usersByDepartid)){
log.info("~~~~~~~~~~~用户列表~~~~~~~~~~"+ JSONObject.toJSONString(usersByDepartid));
}
}
}
/**
* 发送模板消息 到企业微信
*/
@Test
public void sendMessageToQywx() {
String accessToken = this.getAccessToken();
Text text = new Text();
text.setMsgtype("text");
text.setTouser("@all");
TextEntity entity = new TextEntity();
entity.setContent("测试企业微信消息");
text.setText(entity);
text.setAgentid(Integer.parseInt("1000009"));
JSONObject jsonObject = JwMessageAPI.sendTextMessage(text, accessToken);
log.info("=========返回系统消息====="+jsonObject);
}
/**
* 复制文件到指定目录
*/
@Test
public void writeFile() {
try (FileInputStream fileInputStream = new FileInputStream("D://images/gdbt.jpg");
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = fileInputStream.read(buffer)) != -1) {
byteArrayOutputStream.write(buffer, 0, bytesRead);
}
byte[] byteArray = byteArrayOutputStream.toByteArray();
WXUpload.writeFile(byteArray,"D://images","2.jpg",false);
} catch (IOException e) {
e.printStackTrace();
}
}
public String getAccessToken() {
AccessToken accessToken = JwAccessTokenAPI.getAccessToken("??", "??");
return accessToken.getAccesstoken();
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/test/java/org/jeewx/api/prtest/WeChatAccountTest3.java | src/test/java/org/jeewx/api/prtest/WeChatAccountTest3.java | package org.jeewx.api.prtest;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jeecg.dingtalk.api.base.JdtBaseAPI;
import com.jeecg.dingtalk.api.user.vo.User;
import org.jeewx.api.ai.JwAIApi;
import org.jeewx.api.ai.model.Voice;
import org.jeewx.api.core.common.AccessToken;
import org.jeewx.api.core.common.JSONHelper;
import org.jeewx.api.core.exception.WexinReqException;
import org.jeewx.api.core.req.model.WeixinReqParam;
import org.jeewx.api.core.req.model.interfacesummary.InterfaceSummaryParam;
import org.jeewx.api.core.req.model.message.IndustryTemplateMessageSend;
import org.jeewx.api.core.req.model.message.TemplateData;
import org.jeewx.api.core.req.model.message.TemplateMessage;
import org.jeewx.api.core.util.WeiXinReqUtil;
import org.jeewx.api.custservice.multicustservice.JwMultiCustomerAPI;
import org.jeewx.api.custservice.multicustservice.model.ChatRecord;
import org.jeewx.api.extend.CustomJsonConfig;
import org.jeewx.api.report.datastatistics.graphicanalysis.JwGraphicAnalysisAPI;
import org.jeewx.api.report.datastatistics.graphicanalysis.model.GraphicAnalysisRtnInfo;
import org.jeewx.api.report.datastatistics.interfacesummary.JwInterfaceSummary;
import org.jeewx.api.report.datastatistics.useranalysis.JwUserAnalysisAPI;
import org.jeewx.api.report.datastatistics.useranalysis.model.UserAnalysisRtnInfo;
import org.jeewx.api.report.interfacesummary.JwInterfaceSummaryAPI;
import org.jeewx.api.report.interfacesummary.model.InterfaceSummary;
import org.jeewx.api.report.interfacesummary.model.InterfaceSummaryHour;
import org.jeewx.api.wxaccount.JwAccountAPI;
import org.jeewx.api.wxaccount.model.WxQrcode;
import org.jeewx.api.wxbase.wxmedia.JwMediaAPI;
import org.jeewx.api.wxbase.wxmedia.model.WxCountResponse;
import org.jeewx.api.wxbase.wxmedia.model.WxDwonload;
import org.jeewx.api.wxbase.wxmedia.model.WxNews;
import org.jeewx.api.wxbase.wxmedia.model.WxNewsArticle;
import org.jeewx.api.wxbase.wxserviceip.JwServiceIpAPI;
import org.jeewx.api.wxsendmsg.JwSendMessageAPI;
import org.jeewx.api.wxsendmsg.JwTemplateMessageAPI;
import org.jeewx.api.wxsendmsg.model.WxArticle;
import org.jeewx.api.wxsendmsg.model.WxArticlesResponse;
import org.jeewx.api.wxsendmsg.model.WxMediaResponse;
import org.junit.Test;
import org.slf4j.LoggerFactory;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Description: 公众号测试
* 测试用例 敲敲云公众号
*
* @author: wangshuai
* @date: 2024/9/11 上午10:45
*/
public class WeChatAccountTest3 {
private static final org.slf4j.Logger log = LoggerFactory.getLogger(WeChatAccountTest3.class);
private static String appid = "??";
private static String appscret = "??";
private static String openId = "oKMOd6TU0cOqlQalYtGCPD5jWfY8";
@Test
public void getToken(){
System.out.println(getAccessToken());
}
//============= 过滤不需要转换的属性 ===========================================
@Test
public void filterTr(){
CustomJsonConfig customJsonConfig = new CustomJsonConfig();
}
//=================== 客服 ==================
@Test
public void kefu(){
JwMultiCustomerAPI api = new JwMultiCustomerAPI();
boolean a = api.isOnlineCustServiceAvailable(getAccessToken(), "kf2001@qiaoqiaoyun1");
log.info("~~~~~判断指定客服是否在线可用~~~~~"+a);
String servcieMessage = api.getMultiCustServcieMessage(openId, appid);
log.info("~~~~~获取转发多客服的响应消息~~~~~"+servcieMessage);
String specCustServcie = api.getSpecCustServcie(getAccessToken(), openId, appid, "kf2001@qiaoqiaoyun1");
log.info("~~~~~获取指定客服的响应消息~~~~~"+specCustServcie);
List<ChatRecord> custServiceRecordList = api.getCustServiceRecordList(getAccessToken(), openId, 1726134970276L, 1726134963000L, 10, 0);
log.info("~~~~~获取客服消息~~~~~"+JSONObject.toJSONString(custServiceRecordList));
}
//====================获取报表信息====================================
/**
* 获取接口分析分时数据
*/
@Test
public void getInterfaceSummaryHour(){
JwInterfaceSummaryAPI s = new JwInterfaceSummaryAPI();
InterfaceSummaryParam param=new InterfaceSummaryParam();
param.setBegin_date("2024-09-11");
param.setEnd_date("2024-09-11");
//小时
List<InterfaceSummaryHour> list = s.getInterfaceSummaryHour(getAccessToken(),param);
log.info("~~~~~~~~~~获取接口分析分时数据~~~~~~~~~~~~"+JSONObject.toJSONString(list));
//全天
List<InterfaceSummary> interfaceSummary = s.getInterfaceSummary(getAccessToken(), param);
log.info("~~~~~~~~~~获取接口分析数据~~~~~~~~~~~~"+JSONObject.toJSONString(interfaceSummary));
}
/**
* 用户分析数据接口
*/
@Test
public void getUserCumulate() throws WexinReqException {
JwUserAnalysisAPI jua = new JwUserAnalysisAPI();
List<UserAnalysisRtnInfo> userAnalysisList = jua.getUserSummary(getAccessToken(), "2024-09-08", "2024-09-11");
log.info("~~~~~~~~~~获取用户增减数据~~~~~~~~~~~~"+JSONObject.toJSONString(userAnalysisList));
List<UserAnalysisRtnInfo> userCumulate = jua.getUserCumulate(getAccessToken(), "2024-09-08", "2024-09-11");
log.info("~~~~~~~~~~获取累计用户数据~~~~~~~~~~~~"+JSONObject.toJSONString(userCumulate));
}
/**
* 图文分析数据接口
*/
@Test
public void getinterfacesummary() throws WexinReqException, UnsupportedEncodingException {
JwGraphicAnalysisAPI jua = new JwGraphicAnalysisAPI();
List<GraphicAnalysisRtnInfo> articleSummary = jua.getArticleSummary(getAccessToken(), "2024-09-10", "2024-09-10");
log.info("~~~~~~~~~~获取图文群发每日数据~~~~~~~~~~~~"+JSONObject.toJSONString(articleSummary));
}
/**
* 获取文章阅读数量
*/
@Test
public void getArticleTotal() throws WexinReqException, UnsupportedEncodingException {
JwGraphicAnalysisAPI jua = new JwGraphicAnalysisAPI();
List<GraphicAnalysisRtnInfo> articleSummary = jua.getArticleTotal(getAccessToken(), "2024-09-10", "2024-09-10");
log.info("~~~~~~~~~~获取文章数量~~~~~~~~~~~~"+JSONObject.toJSONString(articleSummary));
}
/**
* 获取用户阅读
*/
@Test
public void getUserRead() throws WexinReqException, UnsupportedEncodingException {
JwGraphicAnalysisAPI jua = new JwGraphicAnalysisAPI();
List<GraphicAnalysisRtnInfo> articleSummary = jua.getUserRead(getAccessToken(), "2024-09-10", "2024-09-10");
log.info("~~~~~~~~~~获取用户阅读~~~~~~~~~~~~"+JSONObject.toJSONString(articleSummary));
}
/**
* 获取用户小时阅读
*/
@Test
public void getUserReadHour() throws WexinReqException, UnsupportedEncodingException {
JwGraphicAnalysisAPI jua = new JwGraphicAnalysisAPI();
List<GraphicAnalysisRtnInfo> articleSummary = jua.getUserReadHour(getAccessToken(), "2024-09-10", "2024-09-10");
log.info("~~~~~~~~~~获取用户小时~~~~~~~~~~~~"+JSONObject.toJSONString(articleSummary));
}
/**
* 获取用户分享
*/
@Test
public void getUserShare() throws WexinReqException, UnsupportedEncodingException {
JwGraphicAnalysisAPI jua = new JwGraphicAnalysisAPI();
List<GraphicAnalysisRtnInfo> articleSummary = jua.getUserShare(getAccessToken(), "2024-09-10", "2024-09-10");
log.info("~~~~~~~~~~获取用户分享~~~~~~~~~~~~"+JSONObject.toJSONString(articleSummary));
}
/**
* 获取用户小时分享
*/
@Test
public void getUserShareHour() throws WexinReqException, UnsupportedEncodingException {
JwGraphicAnalysisAPI jua = new JwGraphicAnalysisAPI();
List<GraphicAnalysisRtnInfo> articleSummary = jua.getUserShareHour(getAccessToken(), "2024-09-10", "2024-09-10");
log.info("~~~~~~~~~~获取用户小时分享~~~~~~~~~~~~"+JSONObject.toJSONString(articleSummary));
}
public String getAccessToken() {
return new AccessToken(appid, appscret).getNewAccessToken();
}
public String getAccessTokenCx() {
return JdtBaseAPI.getAccessToken("??","??").getAccessToken();
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/JwLableAPI.java | src/main/java/com/jeecg/alipay/api/base/JwLableAPI.java | package com.jeecg.alipay.api.base;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException;
import com.alipay.api.request.AlipayMobilePublicLabelAddRequest;
import com.alipay.api.request.AlipayMobilePublicLabelDeleteRequest;
import com.alipay.api.request.AlipayMobilePublicLabelQueryRequest;
import com.alipay.api.request.AlipayMobilePublicLabelUpdateRequest;
import com.alipay.api.request.AlipayMobilePublicLabelUserAddRequest;
import com.alipay.api.request.AlipayMobilePublicLabelUserDeleteRequest;
import com.alipay.api.request.AlipayMobilePublicLabelUserQueryRequest;
import com.alipay.api.request.AlipayMobilePublicMessageLabelSendRequest;
import com.alipay.api.response.AlipayMobilePublicLabelAddResponse;
import com.alipay.api.response.AlipayMobilePublicLabelDeleteResponse;
import com.alipay.api.response.AlipayMobilePublicLabelQueryResponse;
import com.alipay.api.response.AlipayMobilePublicLabelUpdateResponse;
import com.alipay.api.response.AlipayMobilePublicLabelUserAddResponse;
import com.alipay.api.response.AlipayMobilePublicLabelUserDeleteResponse;
import com.alipay.api.response.AlipayMobilePublicLabelUserQueryResponse;
import com.alipay.api.response.AlipayMobilePublicMessageLabelSendResponse;
import com.jeecg.alipay.api.base.vo.LableGroupVo.LableGroup;
import com.jeecg.alipay.api.base.vo.LableUserAddVo.UserAddLable;
import com.jeecg.alipay.api.base.vo.LableVo.LableId;
import com.jeecg.alipay.api.base.vo.LableVo.UpDateLable;
import com.jeecg.alipay.api.core.AlipayClientFactory;
import com.jeecg.alipay.api.core.AlipayConfig;
/**
* 支付服务窗标签API
*
* @author zhangdaihao
*
*/
public class JwLableAPI {
/**
* 创建标签
*
* @param appAuthToken
* @param name
* 标签名不能重复
* @return
* @throws AlipayApiException
*/
public static AlipayMobilePublicLabelAddResponse lableadd(String appAuthToken, String name,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicLabelAddRequest request = new AlipayMobilePublicLabelAddRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
JSONObject json = new JSONObject();
json.put("name", name);
request.setBizContent(json.toJSONString());
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
/**
* 查询标签
*
* @param appAuthToken
* @return
* @throws AlipayApiException
*/
public static AlipayMobilePublicLabelQueryResponse lablequery(String appAuthToken,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicLabelQueryRequest request = new AlipayMobilePublicLabelQueryRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
/**
* 修改标签
*
* @param appAuthToken
* @param model
* @return
* @throws AlipayApiException
*/
public static AlipayMobilePublicLabelUpdateResponse lableupdate(String appAuthToken, UpDateLable model,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicLabelUpdateRequest request = new AlipayMobilePublicLabelUpdateRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
String json = JSONObject.toJSONString(model);
request.setBizContent(json);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
/**
* 删除标签
*
* @param appAuthToken
* @param model
* @return
* @throws AlipayApiException
*/
public static AlipayMobilePublicLabelDeleteResponse labledel(String appAuthToken, LableId model,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicLabelDeleteRequest request = new AlipayMobilePublicLabelDeleteRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
String json = JSONObject.toJSONString(model);
request.setBizContent(json);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
/**
* 用户增加标签
*
* @param appAuthToken
* @param model
* @return
* @throws AlipayApiException
*/
public static AlipayMobilePublicLabelUserAddResponse lableUserAdd(String appAuthToken, UserAddLable model,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicLabelUserAddRequest request = new AlipayMobilePublicLabelUserAddRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
String json = JSONObject.toJSONString(model);
request.setBizContent(json);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
// /**
// * 添加用户标签 (新版API)
// * @param appAuthToken
// * @param model
// * @param config
// * @return
// * @throws AlipayApiException
// */
// public static AlipayOpenPublicLabelUserCreateResponse labelUserAddNew(String appAuthToken, UserAddLable model,AlipayConfig config) throws AlipayApiException {
// AlipayOpenPublicLabelUserCreateRequest request = new AlipayOpenPublicLabelUserCreateRequest();
// String json = JSONObject.toJSONString(model);
// System.out.println("添加用户标签:"+json);
//
// request.setBizContent(json);
// return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
// }
/**
* 查询用户标签
*
* @param appAuthToken
* @param model
* @return
* @throws AlipayApiException
*/
public static AlipayMobilePublicLabelUserQueryResponse lableUserQuery(String appAuthToken, UserAddLable model,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicLabelUserQueryRequest request = new AlipayMobilePublicLabelUserQueryRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
String json = JSONObject.toJSONString(model);
request.setBizContent(json);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
/**
* 删除用户标签
*
* @param appAuthToken
* @param model
* @return
* @throws AlipayApiException
*/
public static AlipayMobilePublicLabelUserDeleteResponse lableUserDel(String appAuthToken, UserAddLable model,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicLabelUserDeleteRequest request = new AlipayMobilePublicLabelUserDeleteRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
String json = JSONObject.toJSONString(model);
request.setBizContent(json);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
/**
* 根据标签组发
*
* @param appAuthToken
* @param model
* @return
* @throws AlipayApiException
*/
public static AlipayMobilePublicMessageLabelSendResponse sendMsg(String appAuthToken, LableGroup model,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicMessageLabelSendRequest request = new AlipayMobilePublicMessageLabelSendRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
String json = JSONObject.toJSONString(model);
request.setBizContent(json);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/JwServiceWindowAPI.java | src/main/java/com/jeecg/alipay/api/base/JwServiceWindowAPI.java | package com.jeecg.alipay.api.base;
import com.alipay.api.AlipayApiException;
import com.alipay.api.request.AlipayMobilePublicInfoModifyRequest;
import com.alipay.api.request.AlipayMobilePublicInfoQueryRequest;
import com.alipay.api.response.AlipayMobilePublicInfoModifyResponse;
import com.alipay.api.response.AlipayMobilePublicInfoQueryResponse;
import com.jeecg.alipay.api.base.vo.ServicWindowsVo.ServiceWindowsContent;
import com.jeecg.alipay.api.core.AlipayClientFactory;
import com.jeecg.alipay.api.core.AlipayConfig;
/**
* 服务窗基础信息
*
* @author zhangdaihao
*
*/
public class JwServiceWindowAPI {
/**
* 服务窗基础信息查询方法
*
* @param appAuthToken
* @return
* @throws AlipayApiException
*/
public static AlipayMobilePublicInfoQueryResponse infoQuery(String appAuthToken,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicInfoQueryRequest request = new AlipayMobilePublicInfoQueryRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
/**
* 服务窗基础信息修改方法
*
* @param appAuthToken
* @param serviceWindowsContent
* @return
* @throws AlipayApiException
*/
public static AlipayMobilePublicInfoModifyResponse queryAdvertise(String appAuthToken, ServiceWindowsContent serviceWindowsContent,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicInfoModifyRequest request = new AlipayMobilePublicInfoModifyRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
request.setAppName(serviceWindowsContent.getAppName());
request.setLogoUrl(serviceWindowsContent.getLogoUrl());
request.setPublicGreeting(serviceWindowsContent.getPublicGreeting());
request.setLicenseUrl(serviceWindowsContent.getLicenseUrl());
request.setShopPic1(serviceWindowsContent.getShopPic1());
request.setShopPic2(serviceWindowsContent.getShopPic2());
request.setShopPic3(serviceWindowsContent.getShopPic3());
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/ShortLink.java | src/main/java/com/jeecg/alipay/api/base/ShortLink.java | package com.jeecg.alipay.api.base;
public class ShortLink {
private String sceneId; // 短链接对应的场景ID,该ID由商户自己定义
private String remark; // 对于场景ID的描述,商户自己定义
public String getSceneId() {
return sceneId;
}
public void setSceneId(String sceneId) {
this.sceneId = sceneId;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/JwMenuAPI.java | src/main/java/com/jeecg/alipay/api/base/JwMenuAPI.java | package com.jeecg.alipay.api.base;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException;
import com.alipay.api.request.AlipayMobilePublicMenuAddRequest;
import com.alipay.api.request.AlipayMobilePublicMenuGetRequest;
import com.alipay.api.request.AlipayMobilePublicMenuUpdateRequest;
import com.alipay.api.response.AlipayMobilePublicMenuAddResponse;
import com.alipay.api.response.AlipayMobilePublicMenuGetResponse;
import com.alipay.api.response.AlipayMobilePublicMenuUpdateResponse;
import com.jeecg.alipay.api.base.vo.menuVo.BizContent;
import com.jeecg.alipay.api.core.AlipayClientFactory;
import com.jeecg.alipay.api.core.AlipayConfig;
/**
* 支付服务窗菜单API
*
* @author zhangdaihao
*
*/
public class JwMenuAPI {
/**
* 添加菜单方法
*
* @param appAuthToken
* @param bizContent
* @return
* @throws AlipayApiException
*/
public static AlipayMobilePublicMenuAddResponse menuAdd(String appAuthToken, BizContent model,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicMenuAddRequest request = new AlipayMobilePublicMenuAddRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
String json = JSONObject.toJSONString(model);
request.setBizContent(json);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
/**
* 更新菜单方法
*
* @param appAuthToken
* @param bizContent
* @return
* @throws AlipayApiException
*/
public static AlipayMobilePublicMenuUpdateResponse menuUpdate(String appAuthToken, BizContent model,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicMenuUpdateRequest request = new AlipayMobilePublicMenuUpdateRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
String json = JSONObject.toJSONString(model);
//update-begin-author:zhangjiaqiang Date:20161011 for:TASK #1422 【支付窗】3. 菜单同步,没有二级菜单,同步不成功
json = json.replace(",\"subButton\":[]", "");
//update-end-author:zhangjiaqiang Date:20161011 for:TASK #1422 【支付窗】3. 菜单同步,没有二级菜单,同步不成功
request.setBizContent(json);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
/**
* 查询菜单方法
*
* @param appAuthToken
* @return
* @throws AlipayApiException
*/
public static AlipayMobilePublicMenuGetResponse menuGet(String appAuthToken,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicMenuGetRequest request = new AlipayMobilePublicMenuGetRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/JwSendMessageAPI.java | src/main/java/com/jeecg/alipay/api/base/JwSendMessageAPI.java | package com.jeecg.alipay.api.base;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alipay.api.AlipayApiException;
import com.alipay.api.domain.AlipayOpenPublicMessageSingleSendModel;
import com.alipay.api.request.AlipayMobilePublicMessageCustomSendRequest;
import com.alipay.api.request.AlipayMobilePublicMessageSingleSendRequest;
import com.alipay.api.request.AlipayMobilePublicMessageTotalSendRequest;
import com.alipay.api.request.AlipayOpenPublicMessageSingleSendRequest;
import com.alipay.api.request.AlipayOpenPublicTemplateMessageGetRequest;
import com.alipay.api.response.AlipayMobilePublicMessageCustomSendResponse;
import com.alipay.api.response.AlipayMobilePublicMessageSingleSendResponse;
import com.alipay.api.response.AlipayMobilePublicMessageTotalSendResponse;
import com.alipay.api.response.AlipayOpenPublicMessageSingleSendResponse;
import com.alipay.api.response.AlipayOpenPublicTemplateMessageGetResponse;
import com.jeecg.alipay.api.base.vo.SendMessageImageTextMoreVo.SendMessageImageTextMore;
import com.jeecg.alipay.api.base.vo.SendMessageImageTextOneVo.SendMessageImageText;
import com.jeecg.alipay.api.base.vo.SendMessageModelVo.SendMessageImageModel;
import com.jeecg.alipay.api.base.vo.SendMessageTextMoreVo.SendMessageTextMore;
import com.jeecg.alipay.api.base.vo.SendMessageTextOneVo.SendMessage;
import com.jeecg.alipay.api.core.AlipayClientFactory;
import com.jeecg.alipay.api.core.AlipayConfig;
/**
* 支付服务窗发送消息API
*
* @author zhangdaihao
*
*/
public class JwSendMessageAPI {
/**
* 异步单发消息(文本)
*
* @param appAuthToken
* 商户授权后获取的app_auth_token
* @param model
* @return
* @throws AlipayApiException
*/
public static AlipayMobilePublicMessageCustomSendResponse messageCustomSend(String appAuthToken, String content,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicMessageCustomSendRequest request = new AlipayMobilePublicMessageCustomSendRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
request.setBizContent(content);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
/**
* 异步单发消息(文本)
*
* @param appAuthToken
* 商户授权后获取的app_auth_token
* @param model
* @return
* @throws AlipayApiException
*/
@Deprecated
public static AlipayMobilePublicMessageCustomSendResponse messageCustomSendText(String appAuthToken, SendMessage model,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicMessageCustomSendRequest request = new AlipayMobilePublicMessageCustomSendRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
String json = "";
json = JSONObject.toJSONString(model);
request.setBizContent(json);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
/**
* 异步单发消息(图文消息,支持6条)
*
* @param appAuthToken
* 商户授权后获取的app_auth_token
* @param model
* @return
* @throws AlipayApiException
*/
@Deprecated
public static AlipayMobilePublicMessageCustomSendResponse messageCustomSendImageText(String appAuthToken, SendMessageImageText model,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicMessageCustomSendRequest request = new AlipayMobilePublicMessageCustomSendRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
String json = "";
json = JSONObject.toJSONString(model);
request.setBizContent(json);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
/**
* 群发消息(文本)
*
* @param appAuthToken
* 商户授权后获取的app_auth_token
* @param model
* @return
* @throws AlipayApiException
*/
public static AlipayMobilePublicMessageTotalSendResponse messageTotalSend(String appAuthToken, String content,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicMessageTotalSendRequest request = new AlipayMobilePublicMessageTotalSendRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
request.setBizContent(content);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
/**
* 群发消息(文本)
*
* @param appAuthToken
* 商户授权后获取的app_auth_token
* @param model
* @return
* @throws AlipayApiException
*/
@Deprecated
public static AlipayMobilePublicMessageTotalSendResponse messageTotalSendText(String appAuthToken, SendMessageTextMore model,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicMessageTotalSendRequest request = new AlipayMobilePublicMessageTotalSendRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
String json = "";
json = JSONObject.toJSONString(model);
request.setBizContent(json);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
/**
* 群发消息(图文)
*
* @param appAuthToken
* 商户授权后获取的app_auth_token
* @param model
* @return
* @throws AlipayApiException
*/
@Deprecated
public static AlipayMobilePublicMessageTotalSendResponse messageTotalSendImageText(String appAuthToken, SendMessageImageTextMore model,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicMessageTotalSendRequest request = new AlipayMobilePublicMessageTotalSendRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
String json = "";
json = JSONObject.toJSONString(model);
request.setBizContent(json);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
/**
* 单发模板消息
*
* @param appAuthToken
* 商户授权后获取的app_auth_token
* @param model
* @return
* @throws AlipayApiException
*/
public static AlipayMobilePublicMessageSingleSendResponse messageSingleSend(String appAuthToken, SendMessageImageModel model,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicMessageSingleSendRequest request = new AlipayMobilePublicMessageSingleSendRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
String json = "";
//update-begin--author:zhangjiaqiang Date:20161028 for:#1486 【支付窗】模板消息接口、推广二维码研究
json = JSONObject.toJSONString(model,SerializerFeature.WriteMapNullValue);
//update-end--author:zhangjiaqiang Date:20161028 for:#1486 【支付窗】模板消息接口、推广二维码研究
request.setBizContent(json);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
//update-begin--author:zhangjiaqiang Date:20161028 for:#1486 【支付窗】模板消息接口、推广二维码研究
/**
* 单发模板消息(新版API)
* @param model
* @param config
* @return
* @throws AlipayApiException
*/
public static AlipayOpenPublicMessageSingleSendResponse messageSingleSendNew(AlipayOpenPublicMessageSingleSendModel model,AlipayConfig config) throws AlipayApiException{
AlipayOpenPublicMessageSingleSendRequest request = new AlipayOpenPublicMessageSingleSendRequest();
String json = JSONObject.toJSONString(model);
request.setBizContent(json);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
/**
* 获取模板详情
* @param templateId
* @param config
* @return
* @throws AlipayApiException
*/
public static AlipayOpenPublicTemplateMessageGetResponse templateMessageGet(String templateId,AlipayConfig config) throws AlipayApiException{
AlipayOpenPublicTemplateMessageGetRequest request = new AlipayOpenPublicTemplateMessageGetRequest();
JSONObject json = new JSONObject();
json.put("template_id", templateId);
request.setBizContent(json.toJSONString());
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
//update-end--author:zhangjiaqiang Date:20161028 for:#1486 【支付窗】模板消息接口、推广二维码研究
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/JwGetUserInforMationAPI.java | src/main/java/com/jeecg/alipay/api/base/JwGetUserInforMationAPI.java | package com.jeecg.alipay.api.base;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException;
import com.alipay.api.request.AlipayMobilePublicFollowListRequest;
import com.alipay.api.request.AlipayMobilePublicGisGetRequest;
import com.alipay.api.response.AlipayMobilePublicFollowListResponse;
import com.alipay.api.response.AlipayMobilePublicGisGetResponse;
import com.jeecg.alipay.api.base.vo.GetUserInfoMateonVo.GetAddress;
import com.jeecg.alipay.api.base.vo.GetUserInfoMateonVo.GetUserInfoMateon;
import com.jeecg.alipay.api.core.AlipayClientFactory;
import com.jeecg.alipay.api.core.AlipayConfig;
/**
* 关注用户
*
* @author zhangdaihao
*
*/
public class JwGetUserInforMationAPI {
/**
* 获取关注者列表
*
* @param appAuthToken
* @param model
* @return
* @throws AlipayApiException
*/
public static AlipayMobilePublicFollowListResponse followlistQuery(String appAuthToken, GetUserInfoMateon model,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicFollowListRequest request = new AlipayMobilePublicFollowListRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
String json = JSONObject.toJSONString(model);
request.setBizContent(json);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
/**
* 获取用户地理位置
*
* @param appAuthToken
* @param model
* @return
* @throws AlipayApiException
*/
public static AlipayMobilePublicGisGetResponse gisget(String appAuthToken, GetAddress model,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicGisGetRequest request = new AlipayMobilePublicGisGetRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
String json = JSONObject.toJSONString(model);
request.setBizContent(json);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/JWPromotionalSupportAPI.java | src/main/java/com/jeecg/alipay/api/base/JWPromotionalSupportAPI.java | package com.jeecg.alipay.api.base;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException;
import com.alipay.api.request.AlipayMobilePublicQrcodeCreateRequest;
import com.alipay.api.request.AlipayMobilePublicShortlinkCreateRequest;
import com.alipay.api.response.AlipayMobilePublicQrcodeCreateResponse;
import com.alipay.api.response.AlipayMobilePublicShortlinkCreateResponse;
import com.jeecg.alipay.api.base.vo.PromotionalSupportVo.PromotionalSupport;
import com.jeecg.alipay.api.core.AlipayClientFactory;
import com.jeecg.alipay.api.core.AlipayConfig;
/**
* 推广二维码
*
* @author zhangdaihao
*
*/
public class JWPromotionalSupportAPI {
/**
* 带参推广二维码
*
* @param appAuthToken
* @param model
* @return
* @throws AlipayApiException
*/
public static AlipayMobilePublicQrcodeCreateResponse qrcodeCreate(String appAuthToken, PromotionalSupport model,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicQrcodeCreateRequest request = new AlipayMobilePublicQrcodeCreateRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
String json = JSONObject.toJSONString(model);
request.setBizContent(json);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
/**
* 推广短链接
*
* @param appAuthToken
* @param model
* @return
* @throws AlipayApiException
*/
public static AlipayMobilePublicShortlinkCreateResponse shortlinkCreate(String appAuthToken, ShortLink model,AlipayConfig config) throws AlipayApiException {
AlipayMobilePublicShortlinkCreateRequest request = new AlipayMobilePublicShortlinkCreateRequest();
request.putOtherTextParam("app_auth_token", appAuthToken);
String json = JSONObject.toJSONString(model);
request.setBizContent(json);
return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/SendMessageModelVo/SendMessageImageModel.java | src/main/java/com/jeecg/alipay/api/base/vo/SendMessageModelVo/SendMessageImageModel.java | package com.jeecg.alipay.api.base.vo.SendMessageModelVo;
public class SendMessageImageModel {
private String toUserId; //消息接收用户的userid
//update-begin--author:zhangjiaqiang Date:20161028 for:#1486 【支付窗】模板消息接口、推广二维码研究
private TempLate template;//消息模板相关参数,其中包括templateId模板ID和context模板上下文
//update-end--author:zhangjiaqiang Date:20161028 for:#1486 【支付窗】模板消息接口、推广二维码研究
public String getToUserId() {
return toUserId;
}
public void setToUserId(String toUserId) {
this.toUserId = toUserId;
}
//update-begin--author:zhangjiaqiang Date:20161028 for:#1486 【支付窗】模板消息接口、推广二维码研究
public TempLate getTemplate() {
return template;
}
public void setTemplate(TempLate template) {
this.template = template;
}
//update-end--author:zhangjiaqiang Date:20161028 for:#1486 【支付窗】模板消息接口、推广二维码研究
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/SendMessageModelVo/TempLate.java | src/main/java/com/jeecg/alipay/api/base/vo/SendMessageModelVo/TempLate.java | package com.jeecg.alipay.api.base.vo.SendMessageModelVo;
public class TempLate {
private String templateId;//消息模板ID
private ConText context;//消息模板上下文,即模板中定义的参数及参数值
public String getTemplateId() {
return templateId;
}
public void setTemplateId(String templateId) {
this.templateId = templateId;
}
public ConText getContext() {
return context;
}
public void setContext(ConText context) {
this.context = context;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/SendMessageModelVo/ConText.java | src/main/java/com/jeecg/alipay/api/base/vo/SendMessageModelVo/ConText.java | package com.jeecg.alipay.api.base.vo.SendMessageModelVo;
public class ConText {
private String headColor; //顶部色条的色值
private String url; //点击消息后承接页的地址
private String actionName; //底部链接描述文字,如“查看详情”
private KeyWord keyword1; //模板中占位符的值及文字颜色,value和color都为必填项,color为当前文字颜色
private KeyWord keyword2; //模板中占位符的值及文字颜色,value和color都为必填项,color为当前文字颜色
private KeyWord keyword3;//模板中占位符的值及文字颜色,value和color都为必填项,color为当前文字颜色
private KeyWord keyword4;//模板中占位符的值及文字颜色,value和color都为必填项,color为当前文字颜色
private KeyWord keyword5;//模板中占位符的值及文字颜色,value和color都为必填项,color为当前文字颜色
private KeyWord keyword6;//模板中占位符的值及文字颜色,value和color都为必填项,color为当前文字颜色
private KeyWord first; //模板中占位符的值及文字颜色,value和color都为必填项,color为当前文字颜色
private KeyWord remark;//模板中占位符的值及文字颜色,value和color都为必填项,color为当前文字颜色
public String getHeadColor() {
return headColor;
}
public void setHeadColor(String headColor) {
this.headColor = headColor;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getActionName() {
return actionName;
}
public void setActionName(String actionName) {
this.actionName = actionName;
}
public KeyWord getKeyword1() {
return keyword1;
}
public void setKeyword1(KeyWord keyword1) {
this.keyword1 = keyword1;
}
public KeyWord getKeyword2() {
return keyword2;
}
public void setKeyword2(KeyWord keyword2) {
this.keyword2 = keyword2;
}
public KeyWord getFirst() {
return first;
}
public void setFirst(KeyWord first) {
this.first = first;
}
public KeyWord getRemark() {
return remark;
}
public void setRemark(KeyWord remark) {
this.remark = remark;
}
public KeyWord getKeyword3() {
return keyword3;
}
public void setKeyword3(KeyWord keyword3) {
this.keyword3 = keyword3;
}
public KeyWord getKeyword4() {
return keyword4;
}
public void setKeyword4(KeyWord keyword4) {
this.keyword4 = keyword4;
}
public KeyWord getKeyword5() {
return keyword5;
}
public void setKeyword5(KeyWord keyword5) {
this.keyword5 = keyword5;
}
public KeyWord getKeyword6() {
return keyword6;
}
public void setKeyword6(KeyWord keyword6) {
this.keyword6 = keyword6;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/SendMessageModelVo/KeyWord.java | src/main/java/com/jeecg/alipay/api/base/vo/SendMessageModelVo/KeyWord.java | package com.jeecg.alipay.api.base.vo.SendMessageModelVo;
public class KeyWord {
private String color;
private String value;
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/ServicWindowsVo/ServiceWindowsContent.java | src/main/java/com/jeecg/alipay/api/base/vo/ServicWindowsVo/ServiceWindowsContent.java | package com.jeecg.alipay.api.base.vo.ServicWindowsVo;
public class ServiceWindowsContent {
private String appName; //服务窗名称
private String logoUrl; //服务窗头像,请使用照片上传接口上传图片获得image_url
private String publicGreeting; //欢迎语
private String licenseUrl; //营业执照,请使用照片上传接口上传图片获得image_url
private String shopPic1; //第一张门店照片 请使用照片上传接口上传图片获得image_url
private String shopPic2; //第二张门店照片 请使用照片上传接口上传图片获得image_url
private String shopPic3; //第三张门店照片 请使用照片上传接口上传图片获得image_url
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public String getLogoUrl() {
return logoUrl;
}
public void setLogoUrl(String logoUrl) {
this.logoUrl = logoUrl;
}
public String getPublicGreeting() {
return publicGreeting;
}
public void setPublicGreeting(String publicGreeting) {
this.publicGreeting = publicGreeting;
}
public String getLicenseUrl() {
return licenseUrl;
}
public void setLicenseUrl(String licenseUrl) {
this.licenseUrl = licenseUrl;
}
public String getShopPic1() {
return shopPic1;
}
public void setShopPic1(String shopPic1) {
this.shopPic1 = shopPic1;
}
public String getShopPic2() {
return shopPic2;
}
public void setShopPic2(String shopPic2) {
this.shopPic2 = shopPic2;
}
public String getShopPic3() {
return shopPic3;
}
public void setShopPic3(String shopPic3) {
this.shopPic3 = shopPic3;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/SendMessageTextMoreVo/ConTextMore.java | src/main/java/com/jeecg/alipay/api/base/vo/SendMessageTextMoreVo/ConTextMore.java | package com.jeecg.alipay.api.base.vo.SendMessageTextMoreVo;
public class ConTextMore {
private String content; //文本消息内容
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/SendMessageTextMoreVo/SendMessageTextMore.java | src/main/java/com/jeecg/alipay/api/base/vo/SendMessageTextMoreVo/SendMessageTextMore.java | package com.jeecg.alipay.api.base.vo.SendMessageTextMoreVo;
public class SendMessageTextMore {
private String msgType; //消息类型,text
private ConTextMore text;
public String getMsgType() {
return msgType;
}
public void setMsgType(String msgType) {
this.msgType = msgType;
}
public ConTextMore getText() {
return text;
}
public void setText(ConTextMore text) {
this.text = text;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/LableVo/LableId.java | src/main/java/com/jeecg/alipay/api/base/vo/LableVo/LableId.java | package com.jeecg.alipay.api.base.vo.LableVo;
public class LableId {
private String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/LableVo/UpDateLable.java | src/main/java/com/jeecg/alipay/api/base/vo/LableVo/UpDateLable.java | package com.jeecg.alipay.api.base.vo.LableVo;
public class UpDateLable {
private String id;//标签Id
private String name;//修改后的标签名
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/GetUserInfoMateonVo/GetUserInfoMateon.java | src/main/java/com/jeecg/alipay/api/base/vo/GetUserInfoMateonVo/GetUserInfoMateon.java | package com.jeecg.alipay.api.base.vo.GetUserInfoMateonVo;
public class GetUserInfoMateon {
private String nextUserId;
public String getNextUserId() {
return nextUserId;
}
public void setNextUserId(String nextUserId) {
this.nextUserId = nextUserId;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/GetUserInfoMateonVo/GetAddress.java | src/main/java/com/jeecg/alipay/api/base/vo/GetUserInfoMateonVo/GetAddress.java | package com.jeecg.alipay.api.base.vo.GetUserInfoMateonVo;
public class GetAddress {
private String userId;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/LableUserAddVo/UserAddLable.java | src/main/java/com/jeecg/alipay/api/base/vo/LableUserAddVo/UserAddLable.java | package com.jeecg.alipay.api.base.vo.LableUserAddVo;
public class UserAddLable {
private String userId;
private Long labelId;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public Long getLabelId() {
return labelId;
}
public void setLabelId(Long labelId) {
this.labelId = labelId;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/PromotionalSupportVo/Scene.java | src/main/java/com/jeecg/alipay/api/base/vo/PromotionalSupportVo/Scene.java | package com.jeecg.alipay.api.base.vo.PromotionalSupportVo;
public class Scene {
private String sceneId;
public String getSceneId() {
return sceneId;
}
public void setSceneId(String sceneId) {
this.sceneId = sceneId;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/PromotionalSupportVo/PromotionalSupport.java | src/main/java/com/jeecg/alipay/api/base/vo/PromotionalSupportVo/PromotionalSupport.java | package com.jeecg.alipay.api.base.vo.PromotionalSupportVo;
public class PromotionalSupport {
private CodeInfo codeInfo; //开发者自定义信息
private String codeType; //二维码类型,目前只支持两种类型:TEMP:临时的(默认);PERM:永久的
private String expireSecond; // 临时码过期时间,以秒为单位,最大不超过1800秒;永久码置空
private String showLogo; //二维码中间是否显示服务窗logo,Y:显示;N:不显示(默认)
public CodeInfo getCodeInfo() {
return codeInfo;
}
public void setCodeInfo(CodeInfo codeInfo) {
this.codeInfo = codeInfo;
}
public String getCodeType() {
return codeType;
}
public void setCodeType(String codeType) {
this.codeType = codeType;
}
public String getExpireSecond() {
return expireSecond;
}
public void setExpireSecond(String expireSecond) {
this.expireSecond = expireSecond;
}
public String getShowLogo() {
return showLogo;
}
public void setShowLogo(String showLogo) {
this.showLogo = showLogo;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/PromotionalSupportVo/CodeInfo.java | src/main/java/com/jeecg/alipay/api/base/vo/PromotionalSupportVo/CodeInfo.java | package com.jeecg.alipay.api.base.vo.PromotionalSupportVo;
public class CodeInfo {
private Scene scene; //场景Id,最长32位,英文字母、数字以及下划线,开发者自定义
//update-begin--author:zhangjiaqiang Date:20161028 for:#1486 【支付窗】模板消息接口、推广二维码研究
private String gotoUrl;//跳转URL,扫码关注服务窗后会直接跳转到此URL
//update-end--author:zhangjiaqiang Date:20161028 for:#1486 【支付窗】模板消息接口、推广二维码研究
public Scene getScene() {
return scene;
}
public void setScene(Scene scene) {
this.scene = scene;
}
//update-begin--author:zhangjiaqiang Date:20161028 for:#1486 【支付窗】模板消息接口、推广二维码研究
public String getGotoUrl() {
return gotoUrl;
}
public void setGotoUrl(String gotoUrl) {
this.gotoUrl = gotoUrl;
}
//update-end--author:zhangjiaqiang Date:20161028 for:#1486 【支付窗】模板消息接口、推广二维码研究
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/SendMessageImageTextMoreVo/SendMessageImageTextMore.java | src/main/java/com/jeecg/alipay/api/base/vo/SendMessageImageTextMoreVo/SendMessageImageTextMore.java | package com.jeecg.alipay.api.base.vo.SendMessageImageTextMoreVo;
import java.util.List;
import com.jeecg.alipay.api.base.vo.SendMessageImageTextOneVo.Articles;
public class SendMessageImageTextMore {
private String msgType;//消息类型,image
private List<Articles> articles;
public String getMsgType() {
return msgType;
}
public void setMsgType(String msgType) {
this.msgType = msgType;
}
public List<Articles> getArticles() {
return articles;
}
public void setArticles(List<Articles> articles) {
this.articles = articles;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/LableGroupVo/Context.java | src/main/java/com/jeecg/alipay/api/base/vo/LableGroupVo/Context.java | package com.jeecg.alipay.api.base.vo.LableGroupVo;
import java.util.List;
public class Context {
private List<ContextList> list ;
public List<ContextList> getList() {
return list;
}
public void setList(List<ContextList> list) {
this.list = list;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/LableGroupVo/Filter.java | src/main/java/com/jeecg/alipay/api/base/vo/LableGroupVo/Filter.java | package com.jeecg.alipay.api.base.vo.LableGroupVo;
public class Filter {
private String template;
private Context context;
public String getTemplate() {
return template;
}
public void setTemplate(String template) {
this.template = template;
}
public Context getContext() {
return context;
}
public void setContext(Context context) {
this.context = context;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/LableGroupVo/LableGroup.java | src/main/java/com/jeecg/alipay/api/base/vo/LableGroupVo/LableGroup.java | package com.jeecg.alipay.api.base.vo.LableGroupVo;
public class LableGroup {
private Material material;
private Filter filter;
public Material getMaterial() {
return material;
}
public void setMaterial(Material material) {
this.material = material;
}
public Filter getFilter() {
return filter;
}
public void setFilter(Filter filter) {
this.filter = filter;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/LableGroupVo/Articles.java | src/main/java/com/jeecg/alipay/api/base/vo/LableGroupVo/Articles.java | package com.jeecg.alipay.api.base.vo.LableGroupVo;
public class Articles {
private String title;
private String actionName;
private String imageUrl;
private String desc;
private String url;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getActionName() {
return actionName;
}
public void setActionName(String actionName) {
this.actionName = actionName;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/LableGroupVo/Material.java | src/main/java/com/jeecg/alipay/api/base/vo/LableGroupVo/Material.java | package com.jeecg.alipay.api.base.vo.LableGroupVo;
public class Material {
private String msgType;
private String creatTime;
private Articles articles;
public String getMsgType() {
return msgType;
}
public void setMsgType(String msgType) {
this.msgType = msgType;
}
public String getCreatTime() {
return creatTime;
}
public void setCreatTime(String creatTime) {
this.creatTime = creatTime;
}
public Articles getArticles() {
return articles;
}
public void setArticles(Articles articles) {
this.articles = articles;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/LableGroupVo/ContextList.java | src/main/java/com/jeecg/alipay/api/base/vo/LableGroupVo/ContextList.java | package com.jeecg.alipay.api.base.vo.LableGroupVo;
public class ContextList {
private String columnName;
private String op;
private String values;
public String getColumnName() {
return columnName;
}
public void setColumnName(String columnName) {
this.columnName = columnName;
}
public String getOp() {
return op;
}
public void setOp(String op) {
this.op = op;
}
public String getValues() {
return values;
}
public void setValues(String values) {
this.values = values;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/SendMessageTextOneVo/SendMessage.java | src/main/java/com/jeecg/alipay/api/base/vo/SendMessageTextOneVo/SendMessage.java | package com.jeecg.alipay.api.base.vo.SendMessageTextOneVo;
public class SendMessage {
private String toUserId; //消息接收用户的userid
private String msgType; //消息类型,text
private ConTent text;
public String getToUserId() {
return toUserId;
}
public void setToUserId(String toUserId) {
this.toUserId = toUserId;
}
public String getMsgType() {
return msgType;
}
public void setMsgType(String msgType) {
this.msgType = msgType;
}
public ConTent getText() {
return text;
}
public void setText(ConTent text) {
this.text = text;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/SendMessageTextOneVo/ConTent.java | src/main/java/com/jeecg/alipay/api/base/vo/SendMessageTextOneVo/ConTent.java | package com.jeecg.alipay.api.base.vo.SendMessageTextOneVo;
public class ConTent {
private String content; //文本消息内容
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/SendMessageImageTextOneVo/SendMessageImageText.java | src/main/java/com/jeecg/alipay/api/base/vo/SendMessageImageTextOneVo/SendMessageImageText.java | package com.jeecg.alipay.api.base.vo.SendMessageImageTextOneVo;
import java.util.List;
public class SendMessageImageText {
private String toUserId; //消息接收用户的userid
private String msgType; //消息类型,image-text
private List<Articles> articles; //图文消息子消息项集合,单条消息最多6个子项,否则会发送失败
public String getToUserId() {
return toUserId;
}
public void setToUserId(String toUserId) {
this.toUserId = toUserId;
}
public String getMsgType() {
return msgType;
}
public void setMsgType(String msgType) {
this.msgType = msgType;
}
public List<Articles> getArticles() {
return articles;
}
public void setArticles(List<Articles> articles) {
this.articles = articles;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/SendMessageImageTextOneVo/Articles.java | src/main/java/com/jeecg/alipay/api/base/vo/SendMessageImageTextOneVo/Articles.java | package com.jeecg.alipay.api.base.vo.SendMessageImageTextOneVo;
public class Articles {
private String actionName; //链接文字
private String desc; //图文消息内容
private String imageUrl; // 图片链接,对于多条图文消息的第一条消息,该字段不能为空
private String title; // 图文消息标题
private String url; // 点击图文消息跳转的链接
public String getActionName() {
return actionName;
}
public void setActionName(String actionName) {
this.actionName = actionName;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/menuVo/SubButton.java | src/main/java/com/jeecg/alipay/api/base/vo/menuVo/SubButton.java | package com.jeecg.alipay.api.base.vo.menuVo;
public class SubButton {
private String actionParam;
private String actionType;
private String name;
public void setActionParam(String actionParam){
this.actionParam = actionParam;
}
public String getActionParam(){
return this.actionParam;
}
public void setActionType(String actionType){
this.actionType = actionType;
}
public String getActionType(){
return this.actionType;
}
public void setName(String name){
this.name = name;
}
public String getName(){
return this.name;
}
} | java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/menuVo/Button.java | src/main/java/com/jeecg/alipay/api/base/vo/menuVo/Button.java | package com.jeecg.alipay.api.base.vo.menuVo;
public class Button {
private String actionParam;
private String actionType;
private String name;
private SubButton[] subButton;
public void setActionParam(String actionParam) {
this.actionParam = actionParam;
}
public String getActionParam() {
return this.actionParam;
}
public void setActionType(String actionType) {
this.actionType = actionType;
}
public String getActionType() {
return this.actionType;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public SubButton[] getSubButton() {
return subButton;
}
public void setSubButton(SubButton[] subButton) {
this.subButton = subButton;
}
} | java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/base/vo/menuVo/BizContent.java | src/main/java/com/jeecg/alipay/api/base/vo/menuVo/BizContent.java | package com.jeecg.alipay.api.base.vo.menuVo;
import java.util.List;
public class BizContent {
private List<Button> button;
public List<Button> getButton() {
return button;
}
public void setButton(List<Button> button) {
this.button = button;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/core/AlipayClientFactory.java | src/main/java/com/jeecg/alipay/api/core/AlipayClientFactory.java | package com.jeecg.alipay.api.core;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
public class AlipayClientFactory {
public static AlipayClient getAlipayClientInstance(AlipayConfig config) {
AlipayClient client = new DefaultAlipayClient(AlipayConfig.URL, config.getAppid(), config.getRsaPrivateKey(),
AlipayConfig.FORMAT, AlipayConfig.CHARSET, config.getAlipayPublicKey());
return client;
}
} | java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/core/Config.java | src/main/java/com/jeecg/alipay/api/core/Config.java | package com.jeecg.alipay.api.core;
public class Config {
// 开发者应用私钥。java配置PKCS8格式,PHP/.Net语言配置rsa_private_key.pem文件中原始私钥。
/* 详见密钥生成 */
public static final String RSA_RRIVATE_KEY = "???";
// // 接口请求网关。当面付支付、查询、退款、撤销接口中为固定值
public static final String URL = "https://openapi.alipay.com/gateway.do";
// 商户应用APPID,只要您的应用中包含当面付接口且是开通状态,就可以用此应用对应的appid。
/* 开发者可登录开放平台-管理中心-对应应用中查看 */
public static final String APPID = " ??";
// 编码字符集。默认 utf-8
public static final String CHARSET = "utf-8";
// 返回格式。默认json
public static final String FORMAT = "json";
// 支付宝公钥,用于获取同步返回信息后进行验证,验证是否是支付宝发送的信息。
/* 开发者登录开放平台-管理中心-进入应用后查看 */
public static final String ALIPAY_PUBLIC_KEY = "???";
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/core/AlipayConfig.java | src/main/java/com/jeecg/alipay/api/core/AlipayConfig.java | package com.jeecg.alipay.api.core;
public class AlipayConfig {
// 开发者应用私钥。java配置PKCS8格式,PHP/.Net语言配置rsa_private_key.pem文件中原始私钥。
private String appid;
/* 详见密钥生成 */
private String rsaPrivateKey = "";
// 接口请求网关。当面付支付、查询、退款、撤销接口中为固定值
public static final String URL = "https://openapi.alipay.com/gateway.do";
// 商户应用APPID,只要您的应用中包含当面付接口且是开通状态,就可以用此应用对应的appid。
// 编码字符集。默认 utf-8
public static final String CHARSET = "utf-8";
// 返回格式。默认json
public static final String FORMAT = "json";
// 支付宝公钥,用于获取同步返回信息后进行验证,验证是否是支付宝发送的信息。
/* 开发者登录开放平台-管理中心-进入应用后查看 */
private String alipayPublicKey = "";
private String publicKey = "";
public AlipayConfig(String appid, String rsaPrivateKey, String alipayPublicKey, String publicKey) {
this.appid = appid;
this.rsaPrivateKey = rsaPrivateKey;
this.alipayPublicKey = alipayPublicKey;
this.publicKey = publicKey;
}
public String getAppid() {
return appid;
}
public void setAppid(String appid) {
this.appid = appid;
}
public String getRsaPrivateKey() {
return rsaPrivateKey;
}
public void setRsaPrivateKey(String rsaPrivateKey) {
this.rsaPrivateKey = rsaPrivateKey;
}
public String getAlipayPublicKey() {
return alipayPublicKey;
}
public void setAlipayPublicKey(String alipayPublicKey) {
this.alipayPublicKey = alipayPublicKey;
}
public String getPublicKey() {
return publicKey;
}
public void setPublicKey(String publicKey) {
this.publicKey = publicKey;
}
// public static void init(String appid, String rsaPrivateKey, String alipayPublicKey, String publicKey) {
// appid = appid;
// rsaPrivateKey = rsaPrivateKey;
// alipayPublicKey = alipayPublicKey;
// }
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/alipay/api/core/util/HttpUtil.java | src/main/java/com/jeecg/alipay/api/core/util/HttpUtil.java | package com.jeecg.alipay.api.core.util;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONObject;
/**
* @author zhoujf
*
*/
public class HttpUtil {
private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
/**
* http get请求
* @param url
* @return
*/
public static JSONObject sendGet(String url) {
JSONObject jsonObject = null;
jsonObject = httpRequest(url,"GET",null);
return jsonObject;
}
/**
* http post请求
* @param url
* @return
*/
public static JSONObject sendPost(String url) {
JSONObject jsonObject = null;
jsonObject = httpRequest(url,"POST",null);
return jsonObject;
}
/**
* http post请求
* @param url
* @param output json串
* @return
*/
public static JSONObject sendPost(String url,String output) {
JSONObject jsonObject = null;
jsonObject = httpRequest(url,"POST",output);
return jsonObject;
}
/**
* 发起https请求并获取结果
*
* @param requestUrl 请求地址
* @param requestMethod 请求方式(GET、POST)
* @param outputStr 提交的数据
* @return JSONObject(通过JSONObject.get(key)的方式获取json对象的属性值)
*/
private static JSONObject httpRequest(String request , String requestMethod , String output){
JSONObject jsonObject = null;
StringBuffer buffer = new StringBuffer();
InputStream inputStream = null;
InputStreamReader inputStreamReader = null;
BufferedReader reader = null;
try {
logger.debug("[HTTP]", "http请求request:{},method:{},output{}", new Object[]{request,requestMethod,output});
//建立连接
URL url = new URL(request);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setConnectTimeout(3000);
connection.setReadTimeout(30000);
connection.setUseCaches(false);
connection.setRequestMethod(requestMethod);
if(output!=null){
OutputStream out = connection.getOutputStream();
out.write(output.getBytes("UTF-8"));
out.close();
}
//流处理
inputStream = connection.getInputStream();
inputStreamReader = new InputStreamReader(inputStream,"UTF-8");
reader = new BufferedReader(inputStreamReader);
String line;
while((line=reader.readLine())!=null){
buffer.append(line);
}
//关闭连接、释放资源
reader.close();
inputStreamReader.close();
inputStream.close();
inputStream = null;
connection.disconnect();
jsonObject = JSONObject.parseObject(buffer.toString());
} catch (Exception e) {
logger.error("[HTTP]", "http请求error:{}", new Object[]{e.getMessage()});
}finally {
// 使用finally块来关闭输出流、输入流
try {
if (reader != null) {
reader.close();
}
if(inputStreamReader!=null){
inputStreamReader.close();
}
if(inputStream!=null){
inputStream.close();
}
} catch (Exception ex) {
ex.printStackTrace();
logger.error("[HTTP]", "http请求error:{}", new Object[]{ex.getMessage()});
}
}
return jsonObject;
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/qywx/api/base/JwAccessTokenAPI.java | src/main/java/com/jeecg/qywx/api/base/JwAccessTokenAPI.java | package com.jeecg.qywx.api.base;
import com.alibaba.fastjson.JSONObject;
import com.jeecg.qywx.api.core.common.AccessToken;
import com.jeecg.qywx.api.core.util.HttpUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 企业微信--access token信息
*
* @author zhoujf
*
*/
public class JwAccessTokenAPI {
private static final Logger logger = LoggerFactory.getLogger(JwAccessTokenAPI.class);
//获取access_token的接口地址(GET)
public final static String access_token_url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=CorpID&corpsecret=SECRET";
/**
* 获取access_token
*
* @param CorpID 企业Id
* @param SECRET 管理组的凭证密钥,每个secret代表了对应用、通讯录、接口的不同权限;不同的管理组拥有不同的secret
* @return
*/
public static AccessToken getAccessToken(String corpID, String secret) {
AccessToken accessToken = null;
String requestUrl = access_token_url.replace("CorpID", corpID).replace("SECRET", secret);
JSONObject jsonObject = HttpUtil.sendGet(requestUrl);
// 如果请求成功
if (null != jsonObject) {
try {
accessToken = new AccessToken();
accessToken.setAccesstoken(jsonObject.getString("access_token"));
accessToken.setExpiresIn(jsonObject.getIntValue("expires_in"));
logger.info("[ACCESSTOKEN]", "获取ACCESSTOKEN成功:{}", new Object[]{accessToken});
} catch (Exception e) {
accessToken = null;
// 获取token失败
int errcode = jsonObject.getIntValue("errcode");
String errmsg = jsonObject.getString("errmsg");
logger.info("[ACCESSTOKEN]", "获取ACCESSTOKEN失败 errcode:{} errmsg:{}", new Object[]{errcode,errmsg});
}
}
return accessToken;
}
public static void main(String[] args){
try {
AccessToken s = JwAccessTokenAPI.getAccessToken(JwParamesAPI.corpId,JwParamesAPI.secret);
System.out.println(s);
} catch (Exception e) {
e.printStackTrace();
}
}
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
jeecgboot/weixin4j | https://github.com/jeecgboot/weixin4j/blob/9a0a503cc99e24c77de671890fae15ee3235669f/src/main/java/com/jeecg/qywx/api/base/JwParamesAPI.java | src/main/java/com/jeecg/qywx/api/base/JwParamesAPI.java | package com.jeecg.qywx.api.base;
/**
* @author zhoujf
* @date 2016-04-05
* 参数API类
*/
public class JwParamesAPI {
// token
public static String token = "jeewx";
// 随机戳
public static String encodingAESKey = "b2rxXq7GMymOskwpkMnwKPctb6ySWnmDQVIu7q0lKOW";
//你的企业号ID
public static String corpId = "wx967db4406788c64c";
// 管理组的凭证密钥,每个secret代表了对应用、通讯录、接口的不同权限;不同的管理组拥有不同的secret
public static String secret = "kIeWcG7xN-15Sy-VYymr6ZHeYsDRx28RCj7pfWwXEQQ0GHXdD518C1qxnO2kBjhb";
//应用id
public static String agentid = "4";
// OAuth2 回调地址
public static String REDIRECT_URI = "";
}
| java | Apache-2.0 | 9a0a503cc99e24c77de671890fae15ee3235669f | 2026-01-05T02:41:50.789942Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.