1 /*
2 * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
3 * @LastModified: Oct 2017
4 */
5 /*
6 * Licensed to the Apache Software Foundation (ASF) under one or more
7 * contributor license agreements. See the NOTICE file distributed with
8 * this work for additional information regarding copyright ownership.
9 * The ASF licenses this file to You under the Apache License, Version 2.0
10 * (the "License"); you may not use this file except in compliance with
11 * the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22 package com.sun.org.apache.xalan.internal.xsltc.trax;
23
1501
1502 byte[] bytes = new byte[auxlength];
1503
1504 try {
1505 readFromInputStream(bytes, auxinput, auxlength);
1506 auxinput.close();
1507 }
1508 catch (IOException e) {
1509 continue;
1510 }
1511
1512 bytecodes.add(bytes);
1513 }
1514 }
1515
1516 // Convert the ArrayList of byte[] to byte[][].
1517 final int count = bytecodes.size();
1518 if ( count > 0) {
1519 final byte[][] result = new byte[count][1];
1520 for (int i = 0; i < count; i++) {
1521 result[i] = (byte[])bytecodes.get(i);
1522 }
1523
1524 return result;
1525 }
1526 else
1527 return null;
1528 }
1529
1530 /**
1531 * Load the translet classes from the jar file and return the bytecode.
1532 *
1533 * @param source The xsl source
1534 * @param fullClassName The full name of the translet
1535 * @return The bytecode array
1536 */
1537 private byte[][] getBytecodesFromJar(Source source, String fullClassName)
1538 {
1539 String xslFileName = getStylesheetFileName(source);
1540 File xslFile = null;
1541 if (xslFileName != null)
1595 {
1596 try {
1597 InputStream input = jarFile.getInputStream(entry);
1598 int size = (int)entry.getSize();
1599 byte[] bytes = new byte[size];
1600 readFromInputStream(bytes, input, size);
1601 input.close();
1602 bytecodes.add(bytes);
1603 }
1604 catch (IOException e) {
1605 return null;
1606 }
1607 }
1608 }
1609
1610 // Convert the ArrayList of byte[] to byte[][].
1611 final int count = bytecodes.size();
1612 if (count > 0) {
1613 final byte[][] result = new byte[count][1];
1614 for (int i = 0; i < count; i++) {
1615 result[i] = (byte[])bytecodes.get(i);
1616 }
1617
1618 return result;
1619 }
1620 else
1621 return null;
1622 }
1623
1624 /**
1625 * Read a given number of bytes from the InputStream into a byte array.
1626 *
1627 * @param bytes The byte array to store the input content.
1628 * @param input The input stream.
1629 * @param size The number of bytes to read.
1630 */
1631 private void readFromInputStream(byte[] bytes, InputStream input, int size)
1632 throws IOException
1633 {
1634 int n = 0;
1635 int offset = 0;
|
1 /*
2 * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
3 * @LastModified: Nov 2017
4 */
5 /*
6 * Licensed to the Apache Software Foundation (ASF) under one or more
7 * contributor license agreements. See the NOTICE file distributed with
8 * this work for additional information regarding copyright ownership.
9 * The ASF licenses this file to You under the Apache License, Version 2.0
10 * (the "License"); you may not use this file except in compliance with
11 * the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22 package com.sun.org.apache.xalan.internal.xsltc.trax;
23
1501
1502 byte[] bytes = new byte[auxlength];
1503
1504 try {
1505 readFromInputStream(bytes, auxinput, auxlength);
1506 auxinput.close();
1507 }
1508 catch (IOException e) {
1509 continue;
1510 }
1511
1512 bytecodes.add(bytes);
1513 }
1514 }
1515
1516 // Convert the ArrayList of byte[] to byte[][].
1517 final int count = bytecodes.size();
1518 if ( count > 0) {
1519 final byte[][] result = new byte[count][1];
1520 for (int i = 0; i < count; i++) {
1521 result[i] = bytecodes.get(i);
1522 }
1523
1524 return result;
1525 }
1526 else
1527 return null;
1528 }
1529
1530 /**
1531 * Load the translet classes from the jar file and return the bytecode.
1532 *
1533 * @param source The xsl source
1534 * @param fullClassName The full name of the translet
1535 * @return The bytecode array
1536 */
1537 private byte[][] getBytecodesFromJar(Source source, String fullClassName)
1538 {
1539 String xslFileName = getStylesheetFileName(source);
1540 File xslFile = null;
1541 if (xslFileName != null)
1595 {
1596 try {
1597 InputStream input = jarFile.getInputStream(entry);
1598 int size = (int)entry.getSize();
1599 byte[] bytes = new byte[size];
1600 readFromInputStream(bytes, input, size);
1601 input.close();
1602 bytecodes.add(bytes);
1603 }
1604 catch (IOException e) {
1605 return null;
1606 }
1607 }
1608 }
1609
1610 // Convert the ArrayList of byte[] to byte[][].
1611 final int count = bytecodes.size();
1612 if (count > 0) {
1613 final byte[][] result = new byte[count][1];
1614 for (int i = 0; i < count; i++) {
1615 result[i] = bytecodes.get(i);
1616 }
1617
1618 return result;
1619 }
1620 else
1621 return null;
1622 }
1623
1624 /**
1625 * Read a given number of bytes from the InputStream into a byte array.
1626 *
1627 * @param bytes The byte array to store the input content.
1628 * @param input The input stream.
1629 * @param size The number of bytes to read.
1630 */
1631 private void readFromInputStream(byte[] bytes, InputStream input, int size)
1632 throws IOException
1633 {
1634 int n = 0;
1635 int offset = 0;
|