From 7ebdcae90302a4aeabda2defa92f0656876fd294 Mon Sep 17 00:00:00 2001 From: PseudoKnight Date: Sun, 14 Jan 2024 12:55:05 -0800 Subject: [PATCH] Add unsupported method overrides to CByteArray --- .../core/constructs/CByteArray.java | 89 ++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/laytonsmith/core/constructs/CByteArray.java b/src/main/java/com/laytonsmith/core/constructs/CByteArray.java index 073ac3def..20d7b6337 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CByteArray.java +++ b/src/main/java/com/laytonsmith/core/constructs/CByteArray.java @@ -7,6 +7,7 @@ import com.laytonsmith.core.MSVersion; import com.laytonsmith.core.exceptions.CRE.CRERangeException; import com.laytonsmith.core.exceptions.CRE.CREReadOnlyException; +import com.laytonsmith.core.exceptions.CRE.CREUnsupportedOperationException; import com.laytonsmith.core.exceptions.ConfigRuntimeException; import com.laytonsmith.core.natives.interfaces.ArrayAccess; import com.laytonsmith.core.natives.interfaces.Mixed; @@ -14,6 +15,7 @@ import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.nio.ByteOrder; +import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.SortedMap; @@ -492,9 +494,49 @@ public boolean isAssociative() { return false; } + @Override + protected List getArray() { + throw new CREUnsupportedOperationException("Getting backing array from a byte array is not supported.", getTarget()); + } + + @Override + public List asList() { + throw new CREUnsupportedOperationException("Getting a list from a byte array is not supported.", getTarget()); + } + + @Override + protected SortedMap getAssociativeArray() { + throw new CREUnsupportedOperationException("Getting an associative array from a byte array is not supported.", getTarget()); + } + + @Override + public boolean inAssociativeMode() { + return false; + } + + @Override + public void reverse(Target t) { + throw new CREUnsupportedOperationException("Reversing a byte array is not supported.", t); + } + + @Override + public void push(Mixed c, Integer index, Target t) throws IllegalArgumentException, IndexOutOfBoundsException { + throw new CREUnsupportedOperationException("Modifying a byte array using array_push() is not supported.", t); + } + @Override public Set keySet() { - throw new UnsupportedOperationException("Not supported."); + throw new CREUnsupportedOperationException("Getting a key set from a byte array is not supported.", getTarget()); + } + + @Override + public Set stringKeySet() { + throw new CREUnsupportedOperationException("Getting a string key set from a byte array is not supported.", getTarget()); + } + + @Override + public void set(Mixed index, Mixed c, Target t) throws ConfigRuntimeException { + throw new CREUnsupportedOperationException("Modifying a byte array using array_set() is not supported.", t); } @Override @@ -513,6 +555,51 @@ public Mixed get(Mixed index, Target t) throws ConfigRuntimeException { return new CInt(b, t); } + @Override + public boolean containsKey(String c) { + throw new CREUnsupportedOperationException("Checking for a key in a byte array is not supported.", getTarget()); + } + + @Override + public boolean contains(Mixed c) { + throw new CREUnsupportedOperationException("Checking for a value in a byte array is not supported.", c.getTarget()); + } + + @Override + public CArray indexesOf(Mixed value) { + throw new CREUnsupportedOperationException("Getting indexes of a byte array is not supported.", value.getTarget()); + } + + @Override + public Mixed remove(Mixed construct) { + throw new CREUnsupportedOperationException("Removing a value from a byte array is not supported.", construct.getTarget()); + } + + @Override + public void removeValues(Mixed construct) { + throw new CREUnsupportedOperationException("Removing values from a byte array is not supported.", construct.getTarget()); + } + + @Override + public Iterator iterator() { + throw new CREUnsupportedOperationException("Iterating a byte array is not supported.", getTarget()); + } + + @Override + public void sort(final ArraySortType sort) { + throw new CREUnsupportedOperationException("Sorting a byte array is not supported.", getTarget()); + } + + @Override + public void clear() { + throw new CREUnsupportedOperationException("Clearing a byte array is not supported.", getTarget()); + } + + @Override + public void ensureCapacity(int capacity) { + throw new CREUnsupportedOperationException("Ensuring capacity in a byte array is not supported.", getTarget()); + } + @Override public String docs() { return "A byte_array represents low level byte data.";