1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: UnoInfo.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package com
.sun
.star
.comp
.helper
;
33 import java
.net
.MalformedURLException
;
35 import java
.net
.URLClassLoader
;
38 * UnoInfo offers functionality to obtain the UNO jar files.
40 public final class UnoInfo
{
50 * @return the URL base
52 private static String
getBase() {
54 final String JUHJAR
= "/juh.jar";
58 URLClassLoader cl
= (URLClassLoader
) UnoInfo
.class.getClassLoader();
59 URL
[] urls
= cl
.getURLs();
60 for ( int i
= 0; i
< urls
.length
; i
++ ) {
61 String url
= urls
[i
].toString();
62 if ( url
.endsWith( JUHJAR
) )
64 int index
= url
.lastIndexOf( JUHJAR
);
66 base
= url
.substring( 0, index
+ 1 );
76 * Gets a list of URLs for the given jar files.
78 * @return the list of URLs
80 private static URL
[] getURLs( String
[] jarFileNames
) {
82 URL
[] jars
= new URL
[jarFileNames
.length
];
83 String base
= getBase();
84 for ( int i
= 0; i
< jarFileNames
.length
; i
++ ) {
86 jars
[i
] = new URL( base
+ jarFileNames
[i
] );
87 } catch ( MalformedURLException e
) {
96 * Gets the UNO jar files.
98 * @return the UNO jar files
100 public static URL
[] getJars() {
102 String
[] jarFileNames
= new String
[] {
107 return getURLs( jarFileNames
);
111 * Gets the extra UNO types.
113 * @return the extra UNO types
115 public static URL
[] getExtraTypes() {