if (offset < 0 || offset > JavaDOMGlobals::javaMaxInt || count < 0 || count > JavaDOMGlobals::javaMaxInt) { JavaDOMGlobals::ThrowException(env, "", NS_ERROR_DOM_INDEX_SIZE_ERR, JavaDOMGlobals::EXCEPTION_DOM); return NULL; }
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_CharacterDataImpl_substringData  (JNIEnv *env, jobject jthis, jint offset, jint count){  nsIDOMCharacterData* data = (nsIDOMCharacterData*)     env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);  if (!data) {    JavaDOMGlobals::ThrowException(env,        "CharacterData.substringData: NULL pointer");    return NULL;  }  nsString ret;  nsresult rv = data->SubstringData((PRUint32) offset, (PRUint32) count, ret);  if (NS_FAILED(rv)) {    JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;    if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&        (NS_ERROR_GET_CODE(rv) == NS_ERROR_DOM_INDEX_SIZE_ERR ||         NS_ERROR_GET_CODE(rv) == NS_ERROR_DOM_DOMSTRING_SIZE_ERR)) {      exceptionType = JavaDOMGlobals::EXCEPTION_DOM;    }    JavaDOMGlobals::ThrowException(env,      "CharacterData.substringData: failed", rv, exceptionType);    return NULL;  }  jstring jret = env->NewString(ret.GetUnicode(), ret.Length());  if (!jret) {    JavaDOMGlobals::ThrowException(env,       "CharacterData.substringData: NewString failed");  }  return jret;}