PageRenderTime 47ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/src/main/java/org/dynjs/runtime/builtins/EncodeUriComponent.java

https://github.com/akiellor/dynjs
Java | 48 lines | 24 code | 9 blank | 15 comment | 0 complexity | 5059d0c9359a76cb7a906aef75847899 MD5 | raw file
Possible License(s): Apache-2.0
  1. /*
  2. * Copyright 2013 JBoss Inc
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.dynjs.runtime.builtins;
  17. import org.dynjs.runtime.AbstractNonConstructorFunction;
  18. import org.dynjs.runtime.ExecutionContext;
  19. import org.dynjs.runtime.GlobalObject;
  20. import org.dynjs.runtime.Types;
  21. public class EncodeUriComponent extends AbstractNonConstructorFunction {
  22. public EncodeUriComponent(GlobalObject globalObject) {
  23. super(globalObject, "uriComponent");
  24. }
  25. @Override
  26. public Object call(ExecutionContext context, Object self, Object... args) {
  27. String uriComponent = Types.toString( context, args[0] );
  28. String result = URLCodec.encode(context, uriComponent, URLCodec.URI_UNESCAPED_SET );
  29. return result;
  30. }
  31. @Override
  32. public void setFileName() {
  33. this.filename = "org/dynjs/runtime/builtins/EncodeUriComponent.java";
  34. }
  35. @Override
  36. public void setupDebugContext() {
  37. this.debugContext = "<native function: encodeURIComponent>";
  38. }
  39. }