mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-26 14:37:28 +00:00
Better multi packs handling (Alchemy) - direct editing allowed
Better package/class splitting for obfuscated names
This commit is contained in:
106
libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/DottedChain.java
Normal file
106
libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/DottedChain.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.graph;
|
||||
|
||||
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class DottedChain {
|
||||
|
||||
public List<String> parts = new ArrayList<>();
|
||||
|
||||
public DottedChain(List<String> parts) {
|
||||
this.parts = new ArrayList<>(parts);
|
||||
}
|
||||
|
||||
public DottedChain(String... parts) {
|
||||
for (int i = 0; i < parts.length; i++) {
|
||||
this.parts.add(parts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public String getLast() {
|
||||
if (parts.isEmpty()) {
|
||||
return "";
|
||||
} else {
|
||||
return parts.get(parts.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public DottedChain getWithoutLast() {
|
||||
List<String> nparts = new ArrayList<>(parts);
|
||||
if (!nparts.isEmpty()) {
|
||||
nparts.remove(nparts.size() - 1);
|
||||
}
|
||||
return new DottedChain(nparts);
|
||||
}
|
||||
|
||||
public String toPrintableString() {
|
||||
String ret = "";
|
||||
for (int i = 0; i < parts.size(); i++) {
|
||||
if (i > 0) {
|
||||
ret += ".";
|
||||
}
|
||||
ret += IdentifiersDeobfuscation.printIdentifier(true, parts.get(0));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String ret = "";
|
||||
for (int i = 0; i < parts.size(); i++) {
|
||||
if (i > 0) {
|
||||
ret += ".";
|
||||
}
|
||||
ret += parts.get(i);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 3;
|
||||
hash = 89 * hash + Objects.hashCode(this.parts);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof String) {
|
||||
obj = new DottedChain(((String) obj).split("\\."));
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final DottedChain other = (DottedChain) obj;
|
||||
if (!Objects.equals(this.parts, other.parts)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user