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: ConnectionDescriptor.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
.lib
.connections
.socket
;
34 * Helper class for <code>socketAcceptor</code> and
35 * <code>socketConnector</code>.
37 * <p>FIXME: Once those classes have been moved from <code>jurt</code> to
38 * <code>javaunohelper</code>, they should use
39 * <code>com.sun.star.lib.uno.helper.UnoUrl</code> either instead of this class
40 * or underneath this class.</p>
42 final class ConnectionDescriptor
{
43 public ConnectionDescriptor(String description
)
44 throws com
.sun
.star
.lang
.IllegalArgumentException
{
45 for (int i
= description
.indexOf(','); i
>= 0;) {
46 int j
= description
.indexOf(',', i
+ 1);
47 int k
= j
< 0 ? description
.length() : j
;
48 int l
= description
.indexOf('=', i
+ 1);
49 if (l
< 0 || l
>= k
) {
50 throw new com
.sun
.star
.lang
.IllegalArgumentException(
51 "parameter lacks '='");
53 String key
= description
.substring(i
+ 1, l
);
54 String value
= description
.substring(l
+ 1, k
);
55 if (key
.equalsIgnoreCase("host")) {
57 } else if (key
.equalsIgnoreCase("port")) {
59 port
= Integer
.valueOf(value
).intValue();
60 } catch (NumberFormatException e
) {
61 throw new com
.sun
.star
.lang
.IllegalArgumentException(
64 if (port
< 0 || port
> 65535) {
65 throw new com
.sun
.star
.lang
.IllegalArgumentException(
66 "port parameter must have value between 0 and 65535,"
69 } else if (key
.equalsIgnoreCase("backlog")) {
71 backlog
= Integer
.valueOf(value
).intValue();
72 } catch (NumberFormatException e
) {
73 throw new com
.sun
.star
.lang
.IllegalArgumentException(
76 } else if (key
.equalsIgnoreCase("tcpnodelay")) {
77 if (value
.equals("0")) {
78 tcpNoDelay
= Boolean
.FALSE
;
79 } else if (value
.equals("1")) {
80 tcpNoDelay
= Boolean
.TRUE
;
82 throw new com
.sun
.star
.lang
.IllegalArgumentException(
83 "tcpnodelay parameter must have 0/1 value");
90 public String
getHost() {
94 public int getPort() {
98 public int getBacklog() {
102 public Boolean
getTcpNoDelay() {
106 private String host
= null;
107 private int port
= 6001;
108 private int backlog
= 50;
109 private Boolean tcpNoDelay
= null;