mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-25 07:25:34 +00:00
TreeItems documentation
This commit is contained in:
@@ -20,23 +20,42 @@ import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
|
||||
import com.jpexs.decompiler.flash.abc.ClassPath;
|
||||
|
||||
/**
|
||||
*
|
||||
* ActionScript 3 class TreeItem.
|
||||
* @author JPEXS
|
||||
*/
|
||||
public abstract class AS3ClassTreeItem implements TreeItem {
|
||||
|
||||
/**
|
||||
* Name
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Class path
|
||||
*/
|
||||
private final ClassPath path;
|
||||
|
||||
/**
|
||||
* Namespace suffix
|
||||
*/
|
||||
private final String namespaceSuffix;
|
||||
|
||||
/**
|
||||
* Constructs AS3ClassTreeItem.
|
||||
* @param name Name
|
||||
* @param namespaceSuffix Namespace suffix
|
||||
* @param path Class path
|
||||
*/
|
||||
public AS3ClassTreeItem(String name, String namespaceSuffix, ClassPath path) {
|
||||
this.name = name;
|
||||
this.path = path;
|
||||
this.namespaceSuffix = namespaceSuffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets name with namespace suffix.
|
||||
* @return
|
||||
*/
|
||||
public String getNameWithNamespaceSuffix() {
|
||||
String ret = name;
|
||||
if (namespaceSuffix != null) {
|
||||
@@ -45,6 +64,10 @@ public abstract class AS3ClassTreeItem implements TreeItem {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets name with namespace suffix but printable.
|
||||
* @return
|
||||
*/
|
||||
public String getPrintableNameWithNamespaceSuffix() {
|
||||
String ret = IdentifiersDeobfuscation.printIdentifier(true, name);
|
||||
if (namespaceSuffix != null) {
|
||||
@@ -53,10 +76,18 @@ public abstract class AS3ClassTreeItem implements TreeItem {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets class path as string.
|
||||
* @return
|
||||
*/
|
||||
public String getPath() {
|
||||
return path.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* ToString.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getPrintableNameWithNamespaceSuffix();
|
||||
|
||||
@@ -21,19 +21,38 @@ import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* A folder TreeItem - container for items.
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class FolderItem implements TreeItem {
|
||||
|
||||
/**
|
||||
* SWF.
|
||||
*/
|
||||
public SWF swf;
|
||||
|
||||
/**
|
||||
* ToString name.
|
||||
*/
|
||||
private final String str;
|
||||
|
||||
/**
|
||||
* Name.
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Sub items.
|
||||
*/
|
||||
public final List<TreeItem> subItems;
|
||||
|
||||
/**
|
||||
* Constructs FolderItem
|
||||
* @param str ToString name
|
||||
* @param name Name
|
||||
* @param swf SWF
|
||||
* @param subItems Sub items
|
||||
*/
|
||||
public FolderItem(String str, String name, SWF swf, List<TreeItem> subItems) {
|
||||
this.swf = swf;
|
||||
this.str = str;
|
||||
@@ -41,20 +60,36 @@ public class FolderItem implements TreeItem {
|
||||
this.subItems = subItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets name.
|
||||
* @return
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets openable.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Openable getOpenable() {
|
||||
return swf;
|
||||
}
|
||||
|
||||
/**
|
||||
* ToString.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets modified flag.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
if (subItems == null) {
|
||||
|
||||
@@ -19,30 +19,48 @@ package com.jpexs.decompiler.flash.treeitems;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
|
||||
/**
|
||||
*
|
||||
* SWF header TreeItem
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class HeaderItem implements TreeItem {
|
||||
|
||||
/**
|
||||
* SWF
|
||||
*/
|
||||
private final SWF swf;
|
||||
|
||||
/**
|
||||
* Name for toString
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
|
||||
public HeaderItem(SWF swf, String name) {
|
||||
this.swf = swf;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets openable.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Openable getOpenable() {
|
||||
return swf;
|
||||
}
|
||||
|
||||
/**
|
||||
* ToString.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets modified flag.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return swf.isHeaderModified();
|
||||
|
||||
@@ -28,28 +28,53 @@ import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
/**
|
||||
*
|
||||
* List of openable items.
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class OpenableList implements List<Openable>, SWFContainerItem {
|
||||
|
||||
/**
|
||||
* Name.
|
||||
*/
|
||||
public String name;
|
||||
|
||||
/**
|
||||
* Bundle.
|
||||
* Can be null.
|
||||
*/
|
||||
public Bundle bundle;
|
||||
|
||||
/**
|
||||
* Source info.
|
||||
*/
|
||||
public OpenableSourceInfo sourceInfo;
|
||||
|
||||
/**
|
||||
* Items of the list.
|
||||
*/
|
||||
public List<Openable> items = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Checks whether it is bundle.
|
||||
* @return
|
||||
*/
|
||||
public boolean isBundle() {
|
||||
return bundle != null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets openable.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Openable getOpenable() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* ToString.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
if (isBundle()) {
|
||||
@@ -59,66 +84,127 @@ public class OpenableList implements List<Openable>, SWFContainerItem {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterator.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Iterator<Openable> iterator() {
|
||||
return items.iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets item count.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
return items.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether items are empty.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return items.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether list contains specific openable.
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
return items.contains(o);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts to array.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return items.toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts to array.
|
||||
* @param <T>
|
||||
* @param ts
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public <T> T[] toArray(T[] ts) {
|
||||
return items.toArray(ts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains all.
|
||||
* @param clctn
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> clctn) {
|
||||
return items.containsAll(clctn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all.
|
||||
* @param clctn
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> clctn) {
|
||||
return items.removeAll(clctn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retains all.
|
||||
* @param clctn
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> clctn) {
|
||||
return items.retainAll(clctn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears list.
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
items.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all items.
|
||||
* @param clctn
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends Openable> clctn) {
|
||||
return items.addAll(clctn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all items at index.
|
||||
* @param i
|
||||
* @param clctn
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean addAll(int i, Collection<? extends Openable> clctn) {
|
||||
return items.addAll(i, clctn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets item at index.
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Openable get(int i) {
|
||||
if (i < 0 || i >= items.size()) {
|
||||
@@ -127,56 +213,111 @@ public class OpenableList implements List<Openable>, SWFContainerItem {
|
||||
return items.get(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets item at index.
|
||||
* @param i
|
||||
* @param e
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Openable set(int i, Openable e) {
|
||||
return items.set(i, e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds item.
|
||||
* @param e
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean add(Openable e) {
|
||||
return items.add(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds item at index.
|
||||
* @param i
|
||||
* @param e
|
||||
*/
|
||||
@Override
|
||||
public void add(int i, Openable e) {
|
||||
items.add(i, e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes item.
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
return items.remove(o);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes item at index.
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Openable remove(int i) {
|
||||
return items.remove(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Index of item.
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int indexOf(Object o) {
|
||||
return items.indexOf(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Last index of item.
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int lastIndexOf(Object o) {
|
||||
return items.lastIndexOf(o);
|
||||
}
|
||||
|
||||
/**
|
||||
* List iterator.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ListIterator<Openable> listIterator() {
|
||||
return items.listIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* List iterator.
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ListIterator<Openable> listIterator(int i) {
|
||||
return items.listIterator(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sublist.
|
||||
* @param i
|
||||
* @param i1
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Openable> subList(int i, int i1) {
|
||||
return items.subList(i, i1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets modified flag.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
for (Openable s : items) {
|
||||
@@ -187,6 +328,10 @@ public class OpenableList implements List<Openable>, SWFContainerItem {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets modified flag.
|
||||
* It marks all items inside as modified.
|
||||
*/
|
||||
public void setModified() {
|
||||
for (Openable openable : this) {
|
||||
if (openable instanceof SWF) {
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2024 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.flash.treeitems;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface ScriptContainer {
|
||||
|
||||
public Map<String, TreeItem> getInnerScripts();
|
||||
}
|
||||
Reference in New Issue
Block a user