1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package org.openoffice.xmerge.converter.xml.sxw.wordsmith;
25 
26 /**
27  *  WordSmith utility class.
28  *
29  *  @author   David Proulx
30  */
31 class util {
32 
33     /**
34      *  Convert 2 bytes to an integer.
35      *
36      *  @param  data   <code>byte</code> data to convert.
37      *  @param  index  Index to convert.
38      *
39      *  @return  Converted integer.
40      */
intFrom2bytes(byte[] data, int index)41     static int intFrom2bytes(byte[] data, int index) {
42         return (((data[index] & 0xFF) << 8)
43                 | (data[index+1] & 0xFF));
44 
45     }
46 
47 
48     /**
49      *  Convert 4 bytes to an integer.
50      *
51      *  @param  data   <code>byte</code> data to convert.
52      *  @param  index  Index to convert.
53      *
54      *  @return  Converted integer.
55      */
intFrom4bytes(byte[] data, int index)56     static int intFrom4bytes(byte[] data, int index) {
57         return (((data[index] & 0xFF) << 24)
58 		  | ((data[index + 1] & 0xFF) << 16)
59 		  | ((data[index + 2] & 0xFF) << 8)
60                 | (data[index+3] & 0xFF));
61 
62     }
63 }
64 
65