}
private void handlePropertyPath(final EdmProperty property) throws UriSyntaxException, UriNotMatchingException,
EdmException {
uriResult.addProperty(property);
final EdmType type = property.getType();
if (pathSegments.isEmpty()) {
if (type.getKind() == EdmTypeKind.SIMPLE) {
if (uriResult.getPropertyPath().size() == 1) {
uriResult.setUriType(UriType.URI5);
} else {
uriResult.setUriType(UriType.URI4);
}
} else if (type.getKind() == EdmTypeKind.COMPLEX) {
uriResult.setUriType(UriType.URI3);
} else {
throw new UriSyntaxException(UriSyntaxException.INVALIDPROPERTYTYPE.addContent(type.getKind()));
}
uriResult.setTargetType(type);
} else {
currentPathSegment = percentDecode(pathSegments.remove(0));
switch (type.getKind()) {
case SIMPLE:
if ("$value".equals(currentPathSegment)) {
ensureLastSegment();
uriResult.setValue(true);
if (uriResult.getPropertyPath().size() == 1) {
uriResult.setUriType(UriType.URI5);
} else {
uriResult.setUriType(UriType.URI4);
}
} else {
throw new UriSyntaxException(UriSyntaxException.INVALIDSEGMENT.addContent(currentPathSegment));
}
uriResult.setTargetType(type);
break;
case COMPLEX:
final EdmProperty nextProperty = (EdmProperty) ((EdmComplexType) type).getProperty(currentPathSegment);
if (nextProperty == null) {
throw new UriNotMatchingException(UriNotMatchingException.PROPERTYNOTFOUND.addContent(currentPathSegment));
}
handlePropertyPath(nextProperty);
break;
default:
throw new UriSyntaxException(UriSyntaxException.INVALIDPROPERTYTYPE.addContent(type.getKind()));
}
}
}