1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 package com
.sun
.star
.comp
.helper
;
30 import java
.net
.MalformedURLException
;
32 import java
.net
.URLClassLoader
;
35 * UnoInfo offers functionality to obtain the UNO jar files.
37 public final class UnoInfo
{
47 * @return the URL base
49 private static String
getBase() {
51 final String JUHJAR
= "/juh.jar";
55 URLClassLoader cl
= (URLClassLoader
) UnoInfo
.class.getClassLoader();
56 URL
[] urls
= cl
.getURLs();
57 for ( int i
= 0; i
< urls
.length
; i
++ ) {
58 String url
= urls
[i
].toString();
59 if ( url
.endsWith( JUHJAR
) )
61 int index
= url
.lastIndexOf( JUHJAR
);
63 base
= url
.substring( 0, index
+ 1 );
73 * Gets a list of URLs for the given jar files.
75 * @return the list of URLs
77 private static URL
[] getURLs( String
[] jarFileNames
) {
79 URL
[] jars
= new URL
[jarFileNames
.length
];
80 String base
= getBase();
81 for ( int i
= 0; i
< jarFileNames
.length
; i
++ ) {
83 jars
[i
] = new URL( base
+ jarFileNames
[i
] );
84 } catch ( MalformedURLException e
) {
93 * Gets the UNO jar files.
95 * @return the UNO jar files
97 public static URL
[] getJars() {
99 String
[] jarFileNames
= new String
[] {
104 return getURLs( jarFileNames
);
108 * Gets the extra UNO types.
110 * @return the extra UNO types
112 public static URL
[] getExtraTypes() {