Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    /**
     * Decode a string as a glyph position adjustments array, where the string
     * shall adhere to the syntax specified by {@link #encodePositionAdjustments}.
     * @param value the encoded value
     * @return the position adjustments array
     */
    public static int[][] decodePositionAdjustments(String value) {
        int[][] dp = null;
        if (value != null) {
            String[] sa = value.split("\\s");
            if (sa != null) {
                if (sa.length > 0) {
                    int na = Integer.parseInt(sa[0]);
                    dp = new int[na][4];
                    for (int i = 1, n = sa.length, k = 0; i < n; i++) {
                        String s = sa[i];
                        if (s.charAt(0) == 'Z') {
                            int nz = Integer.parseInt(s.substring(1));
                            k += nz;
                        } else {
                            dp[k / 4][k % 4] = Integer.parseInt(s);
                            k += 1;
                        }
                    }
                }
            }
        }
        return dp;
    }
}