From 1331a7d73bb10dee2749b1667aad484c0acda983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Tue, 6 Aug 2024 04:07:38 +0200 Subject: [PATCH] TreeItems documentation --- .../flash/treeitems/AS3ClassTreeItem.java | 33 +++- .../flash/treeitems/FolderItem.java | 37 ++++- .../flash/treeitems/HeaderItem.java | 22 ++- .../flash/treeitems/OpenableList.java | 149 +++++++++++++++++- .../flash/treeitems/ScriptContainer.java | 28 ---- 5 files changed, 235 insertions(+), 34 deletions(-) delete mode 100644 libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/ScriptContainer.java diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/AS3ClassTreeItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/AS3ClassTreeItem.java index 44b6f2f0c..1b2926b5c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/AS3ClassTreeItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/AS3ClassTreeItem.java @@ -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(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/FolderItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/FolderItem.java index be5ef3e3a..955f12be5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/FolderItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/FolderItem.java @@ -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 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 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) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/HeaderItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/HeaderItem.java index d3950bc25..d2752b795 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/HeaderItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/HeaderItem.java @@ -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(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/OpenableList.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/OpenableList.java index 2c7a1d795..0703c8d4b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/OpenableList.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/OpenableList.java @@ -28,28 +28,53 @@ import java.util.List; import java.util.ListIterator; /** - * + * List of openable items. * @author JPEXS */ public class OpenableList implements List, SWFContainerItem { + /** + * Name. + */ public String name; + /** + * Bundle. + * Can be null. + */ public Bundle bundle; + /** + * Source info. + */ public OpenableSourceInfo sourceInfo; + /** + * Items of the list. + */ public List 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, SWFContainerItem { } } + /** + * Iterator. + * @return + */ @Override public Iterator 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 + * @param ts + * @return + */ @Override public 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 clctn) { return items.addAll(clctn); } + /** + * Adds all items at index. + * @param i + * @param clctn + * @return + */ @Override public boolean addAll(int i, Collection 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, 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 listIterator() { return items.listIterator(); } + /** + * List iterator. + * @param i + * @return + */ @Override public ListIterator listIterator(int i) { return items.listIterator(i); } + /** + * Sublist. + * @param i + * @param i1 + * @return + */ @Override public List 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, SWFContainerItem { return false; } + /** + * Sets modified flag. + * It marks all items inside as modified. + */ public void setModified() { for (Openable openable : this) { if (openable instanceof SWF) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/ScriptContainer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/ScriptContainer.java deleted file mode 100644 index a8106d695..000000000 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/ScriptContainer.java +++ /dev/null @@ -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 getInnerScripts(); -}