Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of

package microsoft.exchange.webservices.data;

import java.lang.reflect.Array;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -190,32 +190,28 @@ protected Object ConvertToValueOrDefault(String stringValue) throws ServiceXmlDe
/**
* Validates array value.
*
* @param value
* the value
* @throws microsoft.exchange.webservices.data.ArgumentException
* the argument exception
* @param value the value
* @throws microsoft.exchange.webservices.data.ArgumentException the argument exception
*/
private void validateValueAsArray(Object value) throws ArgumentException {

Array array = null;
if(value instanceof Array)
private void validateValueAsArray(Object value) throws ArgumentException
{
ArrayList arrayList = null;
if (value == null)
{
array = (Array) value;
throw new ArgumentException(String.format(Strings.ArrayIsNull));
}

if (array == null) {
throw new ArgumentException(String.format(
Strings.IncompatibleTypeForArray, value.getClass(), this
.getType()));

} else if (getDim(array) != 1) {
throw new ArgumentException(Strings.ArrayMustHaveSingleDimension);
} else if (Array.getLength(array) == 0) {
throw new ArgumentException(Strings.ArrayMustHaveAtLeastOneElement);
} else if (array.getClass().getComponentType() != this.getType()) {
throw new ArgumentException(String.format(
Strings.IncompatibleTypeForArray, value.getClass(), this
.getType()));
else if (value instanceof ArrayList)
{
arrayList = (ArrayList) value;
if (arrayList.isEmpty())
{
throw new ArgumentException(Strings.ArrayMustHaveAtLeastOneElement);
}
else if (arrayList.get(0).getClass() != this.getType())
{
throw new ArgumentException(String.format(Strings.IncompatibleTypeForArray, value.getClass(),
this.getType()));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public abstract class Strings {
public static String CannotSaveNotNewUserConfiguration = "Calling Save isn't allowed because this user configuration isn't new. To apply local changes to this user configuration, call Update instead.";
public static String ArrayMustHaveAtLeastOneElement = "The Array value must have at least one element.";
public static String ArrayMustHaveSingleDimension = "The array value must have a single dimension.";
public static String ArrayIsNull = "The array value cannot be null.";
public static String IncompatibleTypeForArray = "Type %s can't be used as an array of type %s.";
public static String ValueCannotBeConverted = "The value '%s' couldn't be converted to type %s.";
public static String ValueOfTypeCannotBeConverted = "The value '%s' of type %s can't be converted to a value of type %s.";
Expand Down