Skip to content

Commit

Permalink
Add unsupported method overrides to CByteArray
Browse files Browse the repository at this point in the history
  • Loading branch information
PseudoKnight committed Jan 14, 2024
1 parent 518178d commit 7ebdcae
Showing 1 changed file with 88 additions and 1 deletion.
89 changes: 88 additions & 1 deletion src/main/java/com/laytonsmith/core/constructs/CByteArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
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;
import com.laytonsmith.core.objects.ObjectModifier;
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;
Expand Down Expand Up @@ -492,9 +494,49 @@ public boolean isAssociative() {
return false;
}

@Override
protected List<Mixed> getArray() {
throw new CREUnsupportedOperationException("Getting backing array from a byte array is not supported.", getTarget());
}

@Override
public List<Mixed> asList() {
throw new CREUnsupportedOperationException("Getting a list from a byte array is not supported.", getTarget());
}

@Override
protected SortedMap<String, Mixed> 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<Mixed> keySet() {
throw new UnsupportedOperationException("Not supported.");
throw new CREUnsupportedOperationException("Getting a key set from a byte array is not supported.", getTarget());
}

@Override
public Set<String> 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
Expand All @@ -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<Mixed> 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.";
Expand Down

0 comments on commit 7ebdcae

Please sign in to comment.