2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package com
.sun
.star
.lib
.connections
.socket
;
22 * Helper class for <code>socketAcceptor</code> and <code>socketConnector</code>.
24 * <p>FIXME: Once those classes have been moved from <code>jurt</code> to
25 * <code>javaunohelper</code>, they should use
26 * <code>com.sun.star.lib.uno.helper.UnoUrl</code> either instead of this class
27 * or underneath this class.</p>
29 final class ConnectionDescriptor
{
30 public ConnectionDescriptor(String description
)
31 throws com
.sun
.star
.lang
.IllegalArgumentException
{
32 for (int i
= description
.indexOf(','); i
>= 0;) {
33 int j
= description
.indexOf(',', i
+ 1);
34 int k
= j
< 0 ? description
.length() : j
;
35 int l
= description
.indexOf('=', i
+ 1);
36 if (l
< 0 || l
>= k
) {
37 throw new com
.sun
.star
.lang
.IllegalArgumentException(
38 "parameter lacks '='");
40 String key
= description
.substring(i
+ 1, l
);
41 String value
= description
.substring(l
+ 1, k
);
42 if (key
.equalsIgnoreCase("host")) {
44 } else if (key
.equalsIgnoreCase("port")) {
46 port
= Integer
.parseInt(value
);
47 } catch (NumberFormatException e
) {
48 throw new com
.sun
.star
.lang
.IllegalArgumentException(e
);
50 if (port
< 0 || port
> 65535) {
51 throw new com
.sun
.star
.lang
.IllegalArgumentException(
52 "port parameter must have value between 0 and 65535,"
55 } else if (key
.equalsIgnoreCase("backlog")) {
57 backlog
= Integer
.parseInt(value
);
58 } catch (NumberFormatException e
) {
59 throw new com
.sun
.star
.lang
.IllegalArgumentException(e
);
61 } else if (key
.equalsIgnoreCase("tcpnodelay")) {
62 if (value
.equals("0")) {
63 tcpNoDelay
= Boolean
.FALSE
;
64 } else if (value
.equals("1")) {
65 tcpNoDelay
= Boolean
.TRUE
;
67 throw new com
.sun
.star
.lang
.IllegalArgumentException(
68 "tcpnodelay parameter must have 0/1 value");
75 public String
getHost() {
79 public int getPort() {
83 public int getBacklog() {
87 public Boolean
getTcpNoDelay() {
91 private String host
= null;
92 private int port
= 6001;
93 private int backlog
= 50;
94 private Boolean tcpNoDelay
= null;