Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d51c2a0b
authored
Oct 23, 2014
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Logging
1 parent
65723777
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
16 deletions
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/reader/ReaderNameContainer.java
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/reader/ReaderNameContainer.java
View file @
d51c2a0
...
...
@@ -25,6 +25,9 @@ import java.util.List;
import
javax.enterprise.context.SessionScoped
;
import
javax.inject.Named
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
@Named
@SessionScoped
public
class
ReaderNameContainer
implements
Serializable
{
...
...
@@ -32,48 +35,53 @@ public class ReaderNameContainer implements Serializable {
private
static
final
long
serialVersionUID
=
571747919767505523L
;
//private Integer readerId;
// handling first user when using via getReaderId and setReaderId;
private
final
List
<
Integer
>
readers
=
new
ArrayList
<
Integer
>();;
private
boolean
autopoll
=
false
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ReaderNameContainer
.
class
);
/**
*
use this function when using readers in "only one reader" -mode
* use this function when using readers in "only one reader" -mode
*
* @return first selected reader, or null if no reader selected
*/
public
Integer
getReaderId
()
{
if
(
getReaders
().
size
()
==
0
)
if
(
getReaders
().
size
()
==
0
)
return
null
;
return
readers
.
get
(
0
);
}
/**
* Use this function when using readers in "only one reader" -mode
* @param readerId to set, or null to clear all readers
*
* @param readerId
* to set, or null to clear all readers
*/
public
void
setReaderId
(
Integer
readerId
)
{
if
(
readerId
==
null
)
if
(
readerId
==
null
)
clearReaders
();
if
(
getReaders
().
size
()
==
0
)
{
if
(
getReaders
().
isEmpty
()
)
{
getReaders
().
add
(
readerId
);
}
else
{
getReaders
().
set
(
0
,
readerId
);
Integer
replacedItem
=
getReaders
().
set
(
0
,
readerId
);
logger
.
warn
(
"Replaced item {} wit {}"
,
readerId
,
replacedItem
);
}
}
public
void
addReader
(
Integer
readerId
)
{
if
(!
getReaders
().
contains
(
readerId
))
{
if
(!
getReaders
().
contains
(
readerId
))
{
getReaders
().
add
(
readerId
);
}
}
public
List
<
Integer
>
getReaders
()
{
return
readers
;
}
...
...
@@ -84,7 +92,7 @@ public class ReaderNameContainer implements Serializable {
public
void
setAutopoll
(
boolean
autopoll
)
{
this
.
autopoll
=
autopoll
;
}
public
void
clearReaders
()
{
readers
.
clear
();
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment