These three convert functions are here to perform
any type conversion that may be required between
Java and OpenCL.

@param _typeDesc
String in the Java JNI notation, [I, etc
@return Suitably converted string, "char*", etc
966677
@Override public String convertType(String _typeDesc, boolean useClassModel, boolean isLocal) {
      if (_typeDesc.equals("Z") || _typeDesc.equals("boolean")) {
         return (cvtBooleanToChar);
      } else if (_typeDesc.equals("[Z") || _typeDesc.equals("boolean[]")) {
         return isLocal ? (cvtBooleanArrayToChar) : (cvtBooleanArrayToCharStar);
      } else if (_typeDesc.equals("B") || _typeDesc.equals("byte")) {
         return (cvtByteToChar);
      } else if (_typeDesc.equals("[B") || _typeDesc.equals("byte[]")) {
         return isLocal ? (cvtByteArrayToChar) : (cvtByteArrayToCharStar);
      } else if (_typeDesc.equals("C") || _typeDesc.equals("char")) {
         return (cvtCharToShort);
      } else if (_typeDesc.equals("[C") || _typeDesc.equals("char[]")) {
         return isLocal ? (cvtCharArrayToShort) : (cvtCharArrayToShortStar);
      } else if (_typeDesc.equals("[I") || _typeDesc.equals("int[]")) {
         return isLocal ? (cvtIntArrayToInt) : (cvtIntArrayToIntStar);
      } else if (_typeDesc.equals("[F") || _typeDesc.equals("float[]")) {
         return isLocal ? (cvtFloatArrayToFloat) : (cvtFloatArrayToFloatStar);
      } else if (_typeDesc.equals("[D") || _typeDesc.equals("double[]")) {
         return isLocal ? (cvtDoubleArrayToDouble) : (cvtDoubleArrayToDoubleStar);
      } else if (_typeDesc.equals("[J") || _typeDesc.equals("long[]")) {
         return isLocal ? (cvtLongArrayToLong) : (cvtLongArrayToLongStar);
      } else if (_typeDesc.equals("[S") || _typeDesc.equals("short[]")) {
         return isLocal ? (cvtShortArrayToShort) : (cvtShortArrayToShortStar);
      } else if ("[Ljava/util/concurrent/atomic/AtomicInteger;".equals(_typeDesc) ||
    		  "[Ljava.util.concurrent.atomic.AtomicInteger;".equals(_typeDesc)) {
    	 return (cvtIntArrayToIntStar);
      }
      // if we get this far, we haven't matched anything yet
      if (useClassModel) {
         return (ClassModel.convert(_typeDesc, "", true));
      } else {
         return _typeDesc;
      }
   }
228932
@Override
    public INDArray convertDataEx(DataTypeEx typeSrc, INDArray source, DataTypeEx typeDst) {
        if (source.isView())
            throw new UnsupportedOperationException("Impossible to compress View. Consider using dup() before. ");

        DataBuffer buffer = convertDataEx(typeSrc, source.data(), typeDst);
        source.setData(buffer);

        if (buffer instanceof CompressedDataBuffer)
            source.markAsCompressed(true);
        else
            source.markAsCompressed(false);

        return source;
    }
34768
public final int toCodePoints(char[] src, int srcOff, int srcLen, int[] dest, int destOff) {
    if (srcLen < 0) {
      throw new IllegalArgumentException("srcLen must be >= 0");
    }
    int codePointCount = 0;
    for (int i = 0; i < srcLen; ) {
      final int cp = codePointAt(src, srcOff + i, srcOff + srcLen);
      final int charCount = Character.charCount(cp);
      dest[destOff + codePointCount++] = cp;
      i += charCount;
    }
    return codePointCount;
  }
960229
def type_name(self, t, generate=True):
        
        # no Test case for these
        # elif isinstance(t, typedesc.Argument):
        # elif isinstance(t, typedesc.CvQualifiedType):
        # elif isinstance(t, typedesc.Variable):
        #   return "%s" % self.type_name(t.typ, generate)
        # elif isinstance(t, typedesc.Enumeration):
        #   return t.name

        if isinstance(t, typedesc.FundamentalType):
            return self.FundamentalType(t)
        elif isinstance(t, typedesc.ArrayType):
            return "%s * %s" % (self.type_name(t.typ, generate), t.size)
        elif isinstance(t, typedesc.PointerType):
            self.enable_pointer_type()
            return "POINTER_T(%s)" % (self.type_name(t.typ, generate))
        elif isinstance(t, typedesc.FunctionType):
            args = [
                self.type_name(
                    x,
                    generate) for x in [
                    t.returns] +
                list(
                    t.iterArgTypes())]
            if "__stdcall__" in t.attributes:
                return "ctypes.WINFUNCTYPE(%s)" % ", ".join(args)
            else:
                return "ctypes.CFUNCTYPE(%s)" % ", ".join(args)
        # elif isinstance(t, typedesc.Structure):
        # elif isinstance(t, typedesc.Typedef):
        # elif isinstance(t, typedesc.Union):
        return t.name
690910
public static String esc(String in) {
		if (in == null) {
			return null;
		}
		StringBuffer val = new StringBuffer(in);
		esc(val);
		return val.toString();
	}
931519
def _convert_type_to_char(self, type_char):
        
        typecode = type_char
        if type(type_char) is int:
            typecode = chr(type_char)

        if typecode in self.TYPECODES_LIST:
            return ord(typecode)
        elif len(typecode) > 1:
            if typecode[0] == "L":
                return ord(self.TYPE_OBJECT)
            elif typecode[0] == "[":
                return ord(self.TYPE_ARRAY)

        raise RuntimeError(
            "Typecode {0} ({1}) isn't supported.".format(type_char, typecode)
        )
338270
private String escapeSpecialChars(final String s) {
        char c;
        final StringBuffer so = new StringBuffer();

        final int len = s.length();
        for (int i = 0; i < len; i++) {
            c = s.charAt(i);

            /*
             * note that some of these escape sequences are unique to Erlang,
             * which is why the corresponding 'case' values use octal. The
             * resulting string is, of course, in Erlang format.
             */

            switch (c) {
            // some special escape sequences
            case '\b':
                so.append("\\b");
                break;

            case 0177:
                so.append("\\d");
                break;

            case 033:
                so.append("\\e");
                break;

            case '\f':
                so.append("\\f");
                break;

            case '\n':
                so.append("\\n");
                break;

            case '\r':
                so.append("\\r");
                break;

            case '\t':
                so.append("\\t");
                break;

            case 013:
                so.append("\\v");
                break;

            case '\\':
                so.append("\\\\");
                break;

            case '\'':
                so.append("\\'");
                break;

            case '\"':
                so.append("\\\"");
                break;

            default:
                // some other character classes
                if (c < 027) {
                    // control chars show as "\^@", "\^A" etc
                    so.append("\\^" + (char) ('A' - 1 + c));
                } else if (c > 126) {
                    // 8-bit chars show as \345 \344 \366 etc
                    so.append("\\" + Integer.toOctalString(c));
                } else {
                    // character is printable without modification!
                    so.append(c);
                }
            }
        }
        return new String(so);
    }
427330
static SQLTransform getLanguageTransform(TypeName type) {
		String typeName = type.toString();

		if (Integer.class.getCanonicalName().equals(typeName)) {
			return new IntegerSQLTransform(true);
		}
		if (Boolean.class.getCanonicalName().equals(typeName)) {
			return new BooleanSQLTransform(true);
		}
		if (Long.class.getCanonicalName().equals(typeName)) {
			return new LongSQLTransform(true);
		}
		if (Double.class.getCanonicalName().equals(typeName)) {
			return new DoubleSQLTransform(true);
		}
		if (Float.class.getCanonicalName().equals(typeName)) {
			return new FloatSQLTransform(true);
		}
		if (Short.class.getCanonicalName().equals(typeName)) {
			return new ShortSQLTransform(true);
		}
		if (Byte.class.getCanonicalName().equals(typeName)) {
			return new ByteSQLTransform(true);
		}
		if (Character.class.getCanonicalName().equals(typeName)) {
			return new CharacterSQLTransform(true);
		}
		if (String.class.getCanonicalName().equals(typeName)) {
			return new StringSQLTransform();
		}
		return null;
	}
1308
public static MethodDesc forDescriptor(String desc) 
        throws IllegalArgumentException
    {
        try {
            int cursor = 0;
            char c;

            if ((c = desc.charAt(cursor++)) != '(') {
                throw invalidDescriptor(desc);
            }

            StringBuffer buf = new StringBuffer();
            List<TypeDesc> list = new ArrayList<TypeDesc>();

            while ((c = desc.charAt(cursor++)) != ')') {
                switch (c) {
                case 'V':
                case 'I':
                case 'C':
                case 'Z':
                case 'D':
                case 'F':
                case 'J':
                case 'B':
                case 'S':
                    buf.append(c);
                    break;
                case '[':
                    buf.append(c);
                    continue;
                case 'L':
                    while (true) {
                        buf.append(c);
                        if (c == ';') {
                            break;
                        }
                        c = desc.charAt(cursor++);
                    }
                    break;
                default:
                    throw invalidDescriptor(desc);
                }

                list.add(TypeDesc.forDescriptor(buf.toString()));
                buf.setLength(0);
            }

            TypeDesc ret = TypeDesc.forDescriptor(desc.substring(cursor));

            TypeDesc[] tds = list.toArray(new TypeDesc[list.size()]);

            return intern(new MethodDesc(desc, ret, tds));
        } catch (NullPointerException e) {
            throw invalidDescriptor(desc);
        } catch (IndexOutOfBoundsException e) {
            throw invalidDescriptor(desc);
        }
    }
188918
public static boolean isPrimitiveDesc(String desc) {
        if (desc.length() > 1) return false;
        char c = desc.charAt(0);
        return c == 'Z'
               || c == 'B'
               || c == 'C'
               || c == 'D'
               || c == 'F'
               || c == 'I'
               || c == 'J'
               || c == 'S';
    }
11545
public static byte schemaToColumnType(String s) {
        switch (s.toLowerCase()) {
            case "boolean":
            case "smallint":
            case "tinyint":
            case "bigint":  // FIXME: make sure this is fixed by Tomas.
            case "int":
            case "float":
            case "double":
            case "decimal":
                return Vec.T_NUM;
            case "timestamp":
            case "date":
                return Vec.T_TIME;
            case "enum":
                return Vec.T_CAT;
            case "string":
            case "varchar":
//      case "binary":  // Removed binary column type support for now
            case "char":
                return Vec.T_STR;
            default:
                throw new IllegalArgumentException("Unsupported Orc schema type: " + s);
        }
    }
974105
@Override
    protected String getVoltColumnTypeName(String columnTypeName) {
        String equivalentTypeName = m_PostgreSQLTypeNames.get(columnTypeName);
        return (equivalentTypeName == null) ? columnTypeName.toUpperCase() : equivalentTypeName;
    }
1216396
public static String tokenTypeDesc(int type)
    {
        switch (type) {
        case START_ELEMENT:
            return "START_ELEMENT";
        case END_ELEMENT:
            return "END_ELEMENT";
        case START_DOCUMENT:
            return "START_DOCUMENT";
        case END_DOCUMENT:
            return "END_DOCUMENT";

        case CHARACTERS:
            return "CHARACTERS";
        case CDATA:
            return "CDATA";
        case SPACE:
            return "SPACE";

        case COMMENT:
            return "COMMENT";
        case PROCESSING_INSTRUCTION:
            return "PROCESSING_INSTRUCTION";
        case DTD:
            return "DTD";
        case ENTITY_REFERENCE:
            return "ENTITY_REFERENCE";
        }
        return "["+type+"]";
    }
1361533
private InputSource getCMLType(String type) {
        try {
            InputStream ins = this.getClass().getClassLoader()
                    .getResourceAsStream("org/openscience/cdk/io/cml/data/" + type);
            return new InputSource(new BufferedReader(new InputStreamReader(ins)));
        } catch (Exception e) {
            logger.error("Error while trying to read CML DTD (" + type + "): ", e.getMessage());
            logger.debug(e);
            return null;
        }
    }
476876
public List<String> updateType(TypesDef typeDef) throws AtlasServiceException {
        return updateType(TypesSerialization.toJson(typeDef));
    }
1319905
public static TypeDesc forDescriptor(String desc)
        throws IllegalArgumentException
    {
        // TODO: Figure out how to cache these. Using a plain IdentityMap poses
        // a problem. The back reference to the key causes a memory leak.

        TypeDesc td;
        int cursor = 0;
        int dim = 0;
        try {
            char c;
            while ((c = desc.charAt(cursor++)) == '[') {
                dim++;
            }

            switch (c) {
            case 'V':
                td = VOID;
                break;
            case 'Z':
                td = BOOLEAN;
                break;
            case 'C':
                td = CHAR;
                break;
            case 'B':
                td = BYTE;
                break;
            case 'S':
                td = SHORT;
                break;
            case 'I':
                td = INT;
                break;
            case 'J':
                td = LONG;
                break;
            case 'F':
                td = FLOAT;
                break;
            case 'D':
                td = DOUBLE;
                break;
            case 'L':
                if (dim > 0) {
                    desc = desc.substring(dim);
                    cursor = 1;
                }
                StringBuffer name = new StringBuffer(desc.length() - 2);
                while ((c = desc.charAt(cursor++)) != ';') {
                    if (c == '/') {
                        c = '.';
                    }
                    name.append(c);
                }
                td = intern(new ObjectType(desc, name.toString()));
                break;
            default:
                throw invalidDescriptor(desc);
            }
        }
        catch (NullPointerException e) {
            throw invalidDescriptor(desc);
        }
        catch (IndexOutOfBoundsException e) {
            throw invalidDescriptor(desc);
        }

        if (cursor != desc.length()) {
            throw invalidDescriptor(desc);
        }

        while (--dim >= 0) {
            td = td.toArrayType();
        }

        return td;
    }
785508
public final void mDESC() throws RecognitionException {
		try {
			int _type = DESC;
			int _channel = DEFAULT_TOKEN_CHANNEL;
			// druidG.g:636:6: ( ( 'DESC' | 'desc' ) )
			// druidG.g:636:8: ( 'DESC' | 'desc' )
			{
			// druidG.g:636:8: ( 'DESC' | 'desc' )
			int alt25=2;
			int LA25_0 = input.LA(1);
			if ( (LA25_0=='D') ) {
				alt25=1;
			}
			else if ( (LA25_0=='d') ) {
				alt25=2;
			}

			else {
				NoViableAltException nvae =
					new NoViableAltException("", 25, 0, input);
				throw nvae;
			}

			switch (alt25) {
				case 1 :
					// druidG.g:636:9: 'DESC'
					{
					match("DESC"); 

					}
					break;
				case 2 :
					// druidG.g:636:18: 'desc'
					{
					match("desc"); 

					}
					break;

			}

			}

			state.type = _type;
			state.channel = _channel;
		}
		finally {
			// do for sure before leaving
		}
	}